win-chart 2.10.5 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,4 +19,4 @@ var Zi={},qi={};var Ki,$i=function(){function e(e,t,n){var r=this;this._sleepAft
19
19
  * LICENSE file in the root directory of this source tree.
20
20
  */"production"===process.env.NODE_ENV?fU.exports=function(){if(pU)return gU;pU=1;var t=e,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,l={},u=null,c=null;for(s in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,s)&&!a.hasOwnProperty(s)&&(l[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===l[s]&&(l[s]=t[s]);return{$$typeof:n,type:e,key:u,ref:c,props:l,_owner:o.current}}return gU.Fragment=r,gU.jsx=s,gU.jsxs=s,gU}():fU.exports=(mU||(mU=1,"production"!==process.env.NODE_ENV&&function(){var t,n=e,r=Symbol.for("react.element"),i=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),m=Symbol.iterator,v=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];!function(e,t,n){var r=v.ReactDebugCurrentFrame.getStackAddendum();""!==r&&(t+="%s",n=n.concat([r]));var i=n.map((function(e){return String(e)}));i.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,i)}("error",e,n)}function _(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case o:return"Fragment";case i:return"Portal";case s:return"Profiler";case a:return"StrictMode";case h:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case u:return _(e)+".Consumer";case l:return _(e._context)+".Provider";case c:return function(e,t,n){var r=e.displayName;if(r)return r;var i=t.displayName||t.name||"";return""!==i?n+"("+i+")":n}(e,e.render,"ForwardRef");case p:var t=e.displayName||null;return null!==t?t:x(e.type)||"Memo";case f:var n=e,r=n._payload,g=n._init;try{return x(g(r))}catch(e){return null}}return null}t=Symbol.for("react.module.reference");var b,w,S,T,M,C,D,A=Object.assign,I=0;function E(){}E.__reactDisabledLog=!0;var L,N=v.ReactCurrentDispatcher;function P(e,t,n){if(void 0===L)try{throw Error()}catch(e){var r=e.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return"\n"+L+e}var O,R=!1,k="function"==typeof WeakMap?WeakMap:Map;function z(e,t){if(!e||R)return"";var n,r=O.get(e);if(void 0!==r)return r;R=!0;var i,o=Error.prepareStackTrace;Error.prepareStackTrace=void 0,i=N.current,N.current=null,function(){if(0===I){b=console.log,w=console.info,S=console.warn,T=console.error,M=console.group,C=console.groupCollapsed,D=console.groupEnd;var e={configurable:!0,enumerable:!0,value:E,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(e){n=e}Reflect.construct(e,[],a)}else{try{a.call()}catch(e){n=e}e.call(a.prototype)}}else{try{throw Error()}catch(e){n=e}e()}}catch(t){if(t&&n&&"string"==typeof t.stack){for(var s=t.stack.split("\n"),l=n.stack.split("\n"),u=s.length-1,c=l.length-1;u>=1&&c>=0&&s[u]!==l[c];)c--;for(;u>=1&&c>=0;u--,c--)if(s[u]!==l[c]){if(1!==u||1!==c)do{if(u--,--c<0||s[u]!==l[c]){var h="\n"+s[u].replace(" at new "," at ");return e.displayName&&h.includes("<anonymous>")&&(h=h.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,h),h}}while(u>=1&&c>=0);break}}}finally{R=!1,N.current=i,function(){if(0==--I){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:b}),info:A({},e,{value:w}),warn:A({},e,{value:S}),error:A({},e,{value:T}),group:A({},e,{value:M}),groupCollapsed:A({},e,{value:C}),groupEnd:A({},e,{value:D})})}I<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=o}var d=e?e.displayName||e.name:"",p=d?P(d):"";return"function"==typeof e&&O.set(e,p),p}function V(e,t,n){if(null==e)return"";if("function"==typeof e)return z(e,!(!(r=e.prototype)||!r.isReactComponent));var r;if("string"==typeof e)return P(e);switch(e){case h:return P("Suspense");case d:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return z(e.render,!1);case p:return V(e.type,t,n);case f:var i=e,o=i._payload,a=i._init;try{return V(a(o),t,n)}catch(e){}}return""}O=new k;var B=Object.prototype.hasOwnProperty,F={},G=v.ReactDebugCurrentFrame;function H(e){if(e){var t=e._owner,n=V(e.type,e._source,t?t.type:null);G.setExtraStackFrame(n)}else G.setExtraStackFrame(null)}var U=Array.isArray;function W(e){return U(e)}function j(e){return""+e}function X(e){if(function(e){try{return j(e),!1}catch(e){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),j(e)}var Y,Z,q,K=v.ReactCurrentOwner,$={key:!0,ref:!0,__self:!0,__source:!0};function J(e,t,n,i,o){var a,s={},l=null,u=null;for(a in void 0!==n&&(X(n),l=""+n),function(e){if(B.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(X(t.key),l=""+t.key),function(e){if(B.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(u=t.ref,function(e,t){if("string"==typeof e.ref&&K.current&&t&&K.current.stateNode!==t){var n=x(K.current.type);q[n]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',x(K.current.type),e.ref),q[n]=!0)}}(t,o)),t)B.call(t,a)&&!$.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps){var c=e.defaultProps;for(a in c)void 0===s[a]&&(s[a]=c[a])}if(l||u){var h="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var n=function(){Y||(Y=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(s,h),u&&function(e,t){var n=function(){Z||(Z=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(s,h)}return function(e,t,n,i,o,a,s){var l={$$typeof:r,type:e,key:t,ref:n,props:s,_owner:a,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,u,o,i,K.current,s)}q={};var Q,ee=v.ReactCurrentOwner,te=v.ReactDebugCurrentFrame;function ne(e){if(e){var t=e._owner,n=V(e.type,e._source,t?t.type:null);te.setExtraStackFrame(n)}else te.setExtraStackFrame(null)}function re(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function ie(){if(ee.current){var e=x(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Q=!1;var oe={};function ae(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=ie();if(!t){var n="string"==typeof e?e:e.displayName||e.name;n&&(t="\n\nCheck the top-level render call using <"+n+">.")}return t}(t);if(!oe[n]){oe[n]=!0;var r="";e&&e._owner&&e._owner!==ee.current&&(r=" It was passed a child from "+x(e._owner.type)+"."),ne(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),ne(null)}}}function se(e,t){if("object"==typeof e)if(W(e))for(var n=0;n<e.length;n++){var r=e[n];re(r)&&ae(r,t)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var i=function(e){if(null===e||"object"!=typeof e)return null;var t=m&&e[m]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof i&&i!==e.entries)for(var o,a=i.call(e);!(o=a.next()).done;)re(o.value)&&ae(o.value,t)}}function le(e){var t,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)t=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==p)return;t=n.propTypes}if(t){var r=x(n);!function(e,t,n,r,i){var o=Function.call.bind(B);for(var a in e)if(o(e,a)){var s=void 0;try{if("function"!=typeof e[a]){var l=Error((r||"React class")+": "+n+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}s=e[a](t,a,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(H(i),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,a,typeof s),H(null)),s instanceof Error&&!(s.message in F)&&(F[s.message]=!0,H(i),y("Failed %s type: %s",n,s.message),H(null))}}(t,e.props,"prop",r,e)}else void 0===n.PropTypes||Q||(Q=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(n)||"Unknown"));"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ue={};function ce(e,n,i,m,v,_){var b=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===s||e===a||e===h||e===d||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===p||e.$$typeof===l||e.$$typeof===u||e.$$typeof===c||e.$$typeof===t||void 0!==e.getModuleId)}(e);if(!b){var w,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=ie(),null===e?w="null":W(e)?w="array":void 0!==e&&e.$$typeof===r?(w="<"+(x(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,S)}var T=J(e,n,i,v,_);if(null==T)return T;if(b){var M=n.children;if(void 0!==M)if(m)if(W(M)){for(var C=0;C<M.length;C++)se(M[C],e);Object.freeze&&Object.freeze(M)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else se(M,e)}if(B.call(n,"key")){var D=x(e),A=Object.keys(n).filter((function(e){return"key"!==e})),I=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";ue[D+I]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,D,A.length>0?"{"+A.join(": ..., ")+": ...}":"{}",D),ue[D+I]=!0)}return e===o?function(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if("children"!==r&&"key"!==r){ne(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),ne(null);break}}null!==e.ref&&(ne(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(T):le(T),T}var he=function(e,t,n){return ce(e,t,n,!1)},de=function(e,t,n){return ce(e,t,n,!0)};vU.Fragment=o,vU.jsx=he,vU.jsxs=de}()),vU);var yU=fU.exports;function _U(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var xU=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,bU=_U((function(e){return xU.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),wU="-ms-",SU="-moz-",TU="-webkit-",MU="comm",CU="rule",DU="decl",AU="@keyframes",IU=Math.abs,EU=String.fromCharCode,LU=Object.assign;function NU(e){return e.trim()}function PU(e,t){return(e=t.exec(e))?e[0]:e}function OU(e,t,n){return e.replace(t,n)}function RU(e,t,n){return e.indexOf(t,n)}function kU(e,t){return 0|e.charCodeAt(t)}function zU(e,t,n){return e.slice(t,n)}function VU(e){return e.length}function BU(e){return e.length}function FU(e,t){return t.push(e),e}function GU(e,t){return e.filter((function(e){return!PU(e,t)}))}var HU=1,UU=1,WU=0,jU=0,XU=0,YU="";function ZU(e,t,n,r,i,o,a,s){return{value:e,root:t,parent:n,type:r,props:i,children:o,line:HU,column:UU,length:a,return:"",siblings:s}}function qU(e,t){return LU(ZU("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function KU(e){for(;e.root;)e=qU(e.root,{children:[e]});FU(e,e.siblings)}function $U(){return XU=jU>0?kU(YU,--jU):0,UU--,10===XU&&(UU=1,HU--),XU}function JU(){return XU=jU<WU?kU(YU,jU++):0,UU++,10===XU&&(UU=1,HU++),XU}function QU(){return kU(YU,jU)}function eW(){return jU}function tW(e,t){return zU(YU,e,t)}function nW(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function rW(e){return NU(tW(jU-1,aW(91===e?e+2:40===e?e+1:e)))}function iW(e){for(;(XU=QU())&&XU<33;)JU();return nW(e)>2||nW(XU)>3?"":" "}function oW(e,t){for(;--t&&JU()&&!(XU<48||XU>102||XU>57&&XU<65||XU>70&&XU<97););return tW(e,eW()+(t<6&&32==QU()&&32==JU()))}function aW(e){for(;JU();)switch(XU){case e:return jU;case 34:case 39:34!==e&&39!==e&&aW(XU);break;case 40:41===e&&aW(e);break;case 92:JU()}return jU}function sW(e,t){for(;JU()&&e+XU!==57&&(e+XU!==84||47!==QU()););return"/*"+tW(t,jU-1)+"*"+EU(47===e?e:JU())}function lW(e){for(;!nW(QU());)JU();return tW(e,jU)}function uW(e){return function(e){return YU="",e}(cW("",null,null,null,[""],e=function(e){return HU=UU=1,WU=VU(YU=e),jU=0,[]}(e),0,[0],e))}function cW(e,t,n,r,i,o,a,s,l){for(var u=0,c=0,h=a,d=0,p=0,f=0,g=1,m=1,v=1,y=0,_="",x=i,b=o,w=r,S=_;m;)switch(f=y,y=JU()){case 40:if(108!=f&&58==kU(S,h-1)){-1!=RU(S+=OU(rW(y),"&","&\f"),"&\f",IU(u?s[u-1]:0))&&(v=-1);break}case 34:case 39:case 91:S+=rW(y);break;case 9:case 10:case 13:case 32:S+=iW(f);break;case 92:S+=oW(eW()-1,7);continue;case 47:switch(QU()){case 42:case 47:FU(dW(sW(JU(),eW()),t,n,l),l);break;default:S+="/"}break;case 123*g:s[u++]=VU(S)*v;case 125*g:case 59:case 0:switch(y){case 0:case 125:m=0;case 59+c:-1==v&&(S=OU(S,/\f/g,"")),p>0&&VU(S)-h&&FU(p>32?pW(S+";",r,n,h-1,l):pW(OU(S," ","")+";",r,n,h-2,l),l);break;case 59:S+=";";default:if(FU(w=hW(S,t,n,u,c,i,s,_,x=[],b=[],h,o),o),123===y)if(0===c)cW(S,t,w,w,x,o,h,s,b);else switch(99===d&&110===kU(S,3)?100:d){case 100:case 108:case 109:case 115:cW(e,w,w,r&&FU(hW(e,w,w,0,0,i,s,_,i,x=[],h,b),b),i,b,h,s,r?x:b);break;default:cW(S,w,w,w,[""],b,0,s,b)}}u=c=p=0,g=v=1,_=S="",h=a;break;case 58:h=1+VU(S),p=f;default:if(g<1)if(123==y)--g;else if(125==y&&0==g++&&125==$U())continue;switch(S+=EU(y),y*g){case 38:v=c>0?1:(S+="\f",-1);break;case 44:s[u++]=(VU(S)-1)*v,v=1;break;case 64:45===QU()&&(S+=rW(JU())),d=QU(),c=h=VU(_=S+=lW(eW())),y++;break;case 45:45===f&&2==VU(S)&&(g=0)}}return o}function hW(e,t,n,r,i,o,a,s,l,u,c,h){for(var d=i-1,p=0===i?o:[""],f=BU(p),g=0,m=0,v=0;g<r;++g)for(var y=0,_=zU(e,d+1,d=IU(m=a[g])),x=e;y<f;++y)(x=NU(m>0?p[y]+" "+_:OU(_,/&\f/g,p[y])))&&(l[v++]=x);return ZU(e,t,n,0===i?CU:s,l,u,c,h)}function dW(e,t,n,r){return ZU(e,t,n,MU,EU(XU),zU(e,2,-2),0,r)}function pW(e,t,n,r,i){return ZU(e,t,n,DU,zU(e,0,r),zU(e,r+1,-1),r,i)}function fW(e,t,n){switch(function(e,t){return 45^kU(e,0)?(((t<<2^kU(e,0))<<2^kU(e,1))<<2^kU(e,2))<<2^kU(e,3):0}(e,t)){case 5103:return TU+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return TU+e+e;case 4789:return SU+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return TU+e+SU+e+wU+e+e;case 5936:switch(kU(e,t+11)){case 114:return TU+e+wU+OU(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return TU+e+wU+OU(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return TU+e+wU+OU(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return TU+e+wU+e+e;case 6165:return TU+e+wU+"flex-"+e+e;case 5187:return TU+e+OU(e,/(\w+).+(:[^]+)/,TU+"box-$1$2"+wU+"flex-$1$2")+e;case 5443:return TU+e+wU+"flex-item-"+OU(e,/flex-|-self/g,"")+(PU(e,/flex-|baseline/)?"":wU+"grid-row-"+OU(e,/flex-|-self/g,""))+e;case 4675:return TU+e+wU+"flex-line-pack"+OU(e,/align-content|flex-|-self/g,"")+e;case 5548:return TU+e+wU+OU(e,"shrink","negative")+e;case 5292:return TU+e+wU+OU(e,"basis","preferred-size")+e;case 6060:return TU+"box-"+OU(e,"-grow","")+TU+e+wU+OU(e,"grow","positive")+e;case 4554:return TU+OU(e,/([^-])(transform)/g,"$1"+TU+"$2")+e;case 6187:return OU(OU(OU(e,/(zoom-|grab)/,TU+"$1"),/(image-set)/,TU+"$1"),e,"")+e;case 5495:case 3959:return OU(e,/(image-set\([^]*)/,TU+"$1$`$1");case 4968:return OU(OU(e,/(.+:)(flex-)?(.*)/,TU+"box-pack:$3"+wU+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+TU+e+e;case 4200:if(!PU(e,/flex-|baseline/))return wU+"grid-column-align"+zU(e,t)+e;break;case 2592:case 3360:return wU+OU(e,"template-","")+e;case 4384:case 3616:return n&&n.some((function(e,n){return t=n,PU(e.props,/grid-\w+-end/)}))?~RU(e+(n=n[t].value),"span",0)?e:wU+OU(e,"-start","")+e+wU+"grid-row-span:"+(~RU(n,"span",0)?PU(n,/\d+/):+PU(n,/\d+/)-+PU(e,/\d+/))+";":wU+OU(e,"-start","")+e;case 4896:case 4128:return n&&n.some((function(e){return PU(e.props,/grid-\w+-start/)}))?e:wU+OU(OU(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return OU(e,/(.+)-inline(.+)/,TU+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(VU(e)-1-t>6)switch(kU(e,t+1)){case 109:if(45!==kU(e,t+4))break;case 102:return OU(e,/(.+:)(.+)-([^]+)/,"$1"+TU+"$2-$3$1"+SU+(108==kU(e,t+3)?"$3":"$2-$3"))+e;case 115:return~RU(e,"stretch",0)?fW(OU(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return OU(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(t,n,r,i,o,a,s){return wU+n+":"+r+s+(i?wU+n+"-span:"+(o?a:+a-+r)+s:"")+e}));case 4949:if(121===kU(e,t+6))return OU(e,":",":"+TU)+e;break;case 6444:switch(kU(e,45===kU(e,14)?18:11)){case 120:return OU(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+TU+(45===kU(e,14)?"inline-":"")+"box$3$1"+TU+"$2$3$1"+wU+"$2box$3")+e;case 100:return OU(e,":",":"+wU)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return OU(e,"scroll-","scroll-snap-")+e}return e}function gW(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function mW(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case DU:return e.return=e.return||e.value;case MU:return"";case AU:return e.return=e.value+"{"+gW(e.children,r)+"}";case CU:if(!VU(e.value=e.props.join(",")))return""}return VU(n=gW(e.children,r))?e.return=e.value+"{"+n+"}":""}function vW(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case DU:return void(e.return=fW(e.value,e.length,n));case AU:return gW([qU(e,{value:OU(e.value,"@","@"+TU)})],r);case CU:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,(function(t){switch(PU(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":KU(qU(e,{props:[OU(t,/:(read-\w+)/,":-moz-$1")]})),KU(qU(e,{props:[t]})),LU(e,{props:GU(n,r)});break;case"::placeholder":KU(qU(e,{props:[OU(t,/:(plac\w+)/,":"+TU+"input-$1")]})),KU(qU(e,{props:[OU(t,/:(plac\w+)/,":-moz-$1")]})),KU(qU(e,{props:[OU(t,/:(plac\w+)/,wU+"input-$1")]})),KU(qU(e,{props:[t]})),LU(e,{props:GU(n,r)})}return""}))}}var yW={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},_W="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",xW="active",bW="data-styled-version",wW="6.1.13",SW="/*!sc*/\n",TW="undefined"!=typeof window&&"HTMLElement"in window,MW=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),CW=/invalid hook call/i,DW=new Set,AW=function(e,n){if("production"!==process.env.NODE_ENV){var r=n?' with the id of "'.concat(n,'"'):"",i="The component ".concat(e).concat(r," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",o=console.error;try{var a=!0;console.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];CW.test(e)?(a=!1,DW.delete(i)):o.apply(void 0,c([e],t,!1))},t(),a&&!DW.has(i)&&(console.warn(i),DW.add(i))}catch(e){CW.test(e.message)&&DW.delete(i)}finally{console.error=o}}},IW=Object.freeze([]),EW=Object.freeze({});var LW=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),NW=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,PW=/(^-|-$)/g;function OW(e){return e.replace(NW,"-").replace(PW,"")}var RW=/(a)(d)/gi,kW=function(e){return String.fromCharCode(e+(e>25?39:97))};function zW(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=kW(t%52)+n;return(kW(t%52)+n).replace(RW,"$1-$2")}var VW,BW=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},FW=function(e){return BW(5381,e)};function GW(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function HW(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var UW="function"==typeof Symbol&&Symbol.for,WW=UW?Symbol.for("react.memo"):60115,jW=UW?Symbol.for("react.forward_ref"):60112,XW={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},YW={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},ZW={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},qW=((VW={})[jW]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},VW[WW]=ZW,VW);function KW(e){return("type"in(t=e)&&t.type.$$typeof)===WW?ZW:"$$typeof"in e?qW[e.$$typeof]:XW;var t}var $W=Object.defineProperty,JW=Object.getOwnPropertyNames,QW=Object.getOwnPropertySymbols,ej=Object.getOwnPropertyDescriptor,tj=Object.getPrototypeOf,nj=Object.prototype;function rj(e,t,n){if("string"!=typeof t){if(nj){var r=tj(t);r&&r!==nj&&rj(e,r,n)}var i=JW(t);QW&&(i=i.concat(QW(t)));for(var o=KW(e),a=KW(t),s=0;s<i.length;++s){var l=i[s];if(!(l in YW||n&&n[l]||a&&l in a||o&&l in o)){var u=ej(t,l);try{$W(e,l,u)}catch(e){}}}}return e}function ij(e){return"function"==typeof e}function oj(e){return"object"==typeof e&&"styledComponentId"in e}function aj(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function sj(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function lj(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function uj(e,t,n){if(void 0===n&&(n=!1),!n&&!lj(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=uj(e[r],t[r]);else if(lj(t))for(var r in t)e[r]=uj(e[r],t[r]);return e}function cj(e,t){Object.defineProperty(e,"toString",{value:t})}var hj="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function dj(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],i=1,o=e.length;i<o;i+=1)r.push(e[i]);return r.forEach((function(e){n=n.replace(/%[a-z]/,e)})),n}function pj(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):"")):new Error(dj.apply(void 0,c([hj[e]],t,!1)).trim())}var fj=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,i=r;e>=i;)if((i<<=1)<0)throw pj(16,"".concat(e));this.groupSizes=new Uint32Array(i),this.groupSizes.set(n),this.length=i;for(var o=r;o<i;o++)this.groupSizes[o]=0}for(var a=this.indexOfGroup(e+1),s=(o=0,t.length);o<s;o++)this.tag.insertRule(a,t[o])&&(this.groupSizes[e]++,a++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var i=n;i<r;i++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),i=r+n,o=r;o<i;o++)t+="".concat(this.tag.getRule(o)).concat(SW);return t},e}(),gj=1<<30,mj=new Map,vj=new Map,yj=1,_j=function(e){if(mj.has(e))return mj.get(e);for(;vj.has(yj);)yj++;var t=yj++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>gj))throw pj(16,"".concat(t));return mj.set(e,t),vj.set(t,e),t},xj=function(e,t){yj=t+1,mj.set(e,t),vj.set(t,e)},bj="style[".concat(_W,"][").concat(bW,'="').concat(wW,'"]'),wj=new RegExp("^".concat(_W,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Sj=function(e,t,n){for(var r,i=n.split(","),o=0,a=i.length;o<a;o++)(r=i[o])&&e.registerName(t,r)},Tj=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(SW),i=[],o=0,a=r.length;o<a;o++){var s=r[o].trim();if(s){var l=s.match(wj);if(l){var u=0|parseInt(l[1],10),c=l[2];0!==u&&(xj(c,u),Sj(e,c,l[3]),e.getTag().insertRules(u,i)),i.length=0}else i.push(s)}}},Mj=function(e){for(var t=document.querySelectorAll(bj),n=0,r=t.length;n<r;n++){var i=t[n];i&&i.getAttribute(_W)!==xW&&(Tj(e,i),i.parentNode&&i.parentNode.removeChild(i))}};var Cj=function(e){var t=document.head,n=e||t,r=document.createElement("style"),i=function(e){var t=Array.from(e.querySelectorAll("style[".concat(_W,"]")));return t[t.length-1]}(n),o=void 0!==i?i.nextSibling:null;r.setAttribute(_W,xW),r.setAttribute(bW,wW);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,o),r},Dj=function(){function e(e){this.element=Cj(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var i=t[n];if(i.ownerNode===e)return i}throw pj(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Aj=function(){function e(e){this.element=Cj(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),Ij=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Ej=TW,Lj={isServer:!TW,useCSSOMInjection:!MW},Nj=function(){function e(e,t,n){void 0===e&&(e=EW),void 0===t&&(t={});var r=this;this.options=u(u({},Lj),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&TW&&Ej&&(Ej=!1,Mj(this)),cj(this,(function(){return function(e){for(var t=e.getTag(),n=t.length,r="",i=function(n){var i=function(e){return vj.get(e)}(n);if(void 0===i)return"continue";var o=e.names.get(i),a=t.getGroup(n);if(void 0===o||!o.size||0===a.length)return"continue";var s="".concat(_W,".g").concat(n,'[id="').concat(i,'"]'),l="";void 0!==o&&o.forEach((function(e){e.length>0&&(l+="".concat(e,","))})),r+="".concat(a).concat(s,'{content:"').concat(l,'"}').concat(SW)},o=0;o<n;o++)i(o);return r}(r)}))}return e.registerId=function(e){return _j(e)},e.prototype.rehydrate=function(){!this.server&&TW&&Mj(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(u(u({},this.options),t),this.gs,n&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new Ij(n):t?new Dj(n):new Aj(n)}(this.options),new fj(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(_j(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(_j(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(_j(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Pj=/&/g,Oj=/^\s*\/\/.*$/gm;function Rj(e,t){return e.map((function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map((function(e){return"".concat(t," ").concat(e)}))),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Rj(e.children,t)),e}))}var kj=new Nj,zj=function(){var e,t,n,r=EW,i=r.options,o=void 0===i?EW:i,a=r.plugins,s=void 0===a?IW:a,l=function(n,r,i){return i.startsWith(t)&&i.endsWith(t)&&i.replaceAll(t,"").length>0?".".concat(e):n},u=s.slice();u.push((function(e){e.type===CU&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Pj,t).replace(n,l))})),o.prefix&&u.push(vW),u.push(mW);var c=function(r,i,a,s){void 0===i&&(i=""),void 0===a&&(a=""),void 0===s&&(s="&"),e=s,t=i,n=new RegExp("\\".concat(t,"\\b"),"g");var l=r.replace(Oj,""),c=uW(a||i?"".concat(a," ").concat(i," { ").concat(l," }"):l);o.namespace&&(c=Rj(c,o.namespace));var h,d=[];return gW(c,function(e){var t=BU(e);return function(n,r,i,o){for(var a="",s=0;s<t;s++)a+=e[s](n,r,i,o)||"";return a}}(u.concat((h=function(e){return d.push(e)},function(e){e.root||(e=e.return)&&h(e)})))),d};return c.hash=s.length?s.reduce((function(e,t){return t.name||pj(15),BW(e,t.name)}),5381).toString():"",c}(),Vj=e.createContext({shouldForwardProp:void 0,styleSheet:kj,stylis:zj});function Bj(){return i(Vj)}Vj.Consumer,e.createContext(void 0);var Fj=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=zj);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,cj(this,(function(){throw pj(12,String(n.name))}))}return e.prototype.getName=function(e){return void 0===e&&(e=zj),this.name+e.hash},e}(),Gj=function(e){return e>="A"&&e<="Z"};function Hj(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Gj(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Uj=function(e){return null==e||!1===e||""===e},Wj=function(e){var t,n,r=[];for(var i in e){var o=e[i];e.hasOwnProperty(i)&&!Uj(o)&&(Array.isArray(o)&&o.isCss||ij(o)?r.push("".concat(Hj(i),":"),o,";"):lj(o)?r.push.apply(r,c(c(["".concat(i," {")],Wj(o),!1),["}"],!1)):r.push("".concat(Hj(i),": ").concat((t=i,null==(n=o)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in yW||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function jj(e,t,n,r){if(Uj(e))return[];if(oj(e))return[".".concat(e.styledComponentId)];if(ij(e)){if(!ij(o=e)||o.prototype&&o.prototype.isReactComponent||!t)return[e];var i=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof i||Array.isArray(i)||i instanceof Fj||lj(i)||null===i||console.error("".concat(GW(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),jj(i,t,n,r)}var o;return e instanceof Fj?n?(e.inject(n,r),[e.getName(r)]):[e]:lj(e)?Wj(e):Array.isArray(e)?Array.prototype.concat.apply(IW,e.map((function(e){return jj(e,t,n,r)}))):[e.toString()]}var Xj=FW(wW),Yj=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&function(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(ij(n)&&!oj(n))return!1}return!0}(e),this.componentId=t,this.baseHash=BW(Xj,t),this.baseStyle=n,Nj.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))r=aj(r,this.staticRulesId);else{var i=sj(jj(this.rules,e,t,n)),o=zW(BW(this.baseHash,i)>>>0);if(!t.hasNameForId(this.componentId,o)){var a=n(i,".".concat(o),void 0,this.componentId);t.insertRules(this.componentId,o,a)}r=aj(r,o),this.staticRulesId=o}else{for(var s=BW(this.baseHash,n.hash),l="",u=0;u<this.rules.length;u++){var c=this.rules[u];if("string"==typeof c)l+=c,"production"!==process.env.NODE_ENV&&(s=BW(s,c));else if(c){var h=sj(jj(c,e,t,n));s=BW(s,h+u),l+=h}}if(l){var d=zW(s>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(l,".".concat(d),void 0,this.componentId)),r=aj(r,d)}}return r},e}(),Zj=e.createContext(void 0);Zj.Consumer;var qj={},Kj=new Set;function $j(t,i,o){var a=oj(t),s=t,l=!HW(t),c=i.attrs,h=void 0===c?IW:c,d=i.componentId,p=void 0===d?function(e,t){var n="string"!=typeof e?"sc":OW(e);qj[n]=(qj[n]||0)+1;var r="".concat(n,"-").concat(function(e){return zW(FW(e)>>>0)}(wW+n+qj[n]));return t?"".concat(t,"-").concat(r):r}(i.displayName,i.parentComponentId):d,f=i.displayName,g=void 0===f?function(e){return HW(e)?"styled.".concat(e):"Styled(".concat(GW(e),")")}(t):f,m=i.displayName&&i.componentId?"".concat(OW(i.displayName),"-").concat(i.componentId):i.componentId||p,v=a&&s.attrs?s.attrs.concat(h).filter(Boolean):h,y=i.shouldForwardProp;if(a&&s.shouldForwardProp){var _=s.shouldForwardProp;if(i.shouldForwardProp){var x=i.shouldForwardProp;y=function(e,t){return _(e,t)&&x(e,t)}}else y=_}var b=new Yj(o,m,a?s.componentStyle:void 0);function w(t,i){return function(t,i,o){var a=t.attrs,s=t.componentStyle,l=t.defaultProps,c=t.foldedComponentIds,h=t.styledComponentId,d=t.target,p=e.useContext(Zj),f=Bj(),g=t.shouldForwardProp||f.shouldForwardProp;"production"!==process.env.NODE_ENV&&n(h);var m=function(e,t,n){return void 0===n&&(n=EW),e.theme!==n.theme&&e.theme||t||n.theme}(i,p,l)||EW,v=function(e,t,n){for(var r,i=u(u({},t),{className:void 0,theme:n}),o=0;o<e.length;o+=1){var a=ij(r=e[o])?r(i):r;for(var s in a)i[s]="className"===s?aj(i[s],a[s]):"style"===s?u(u({},i[s]),a[s]):a[s]}return t.className&&(i.className=aj(i.className,t.className)),i}(a,i,m),y=v.as||d,_={};for(var x in v)void 0===v[x]||"$"===x[0]||"as"===x||"theme"===x&&v.theme===m||("forwardedAs"===x?_.as=v.forwardedAs:g&&!g(x,y)||(_[x]=v[x],g||"development"!==process.env.NODE_ENV||bU(x)||Kj.has(x)||!LW.has(y)||(Kj.add(x),console.warn('styled-components: it looks like an unknown prop "'.concat(x,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var b=function(e,t){var r=Bj(),i=e.generateAndInjectStyles(t,r.styleSheet,r.stylis);return"production"!==process.env.NODE_ENV&&n(i),i}(s,v);"production"!==process.env.NODE_ENV&&t.warnTooManyClasses&&t.warnTooManyClasses(b);var w=aj(c,h);return b&&(w+=" "+b),v.className&&(w+=" "+v.className),_[HW(y)&&!LW.has(y)?"class":"className"]=w,_.ref=o,r(y,_)}(S,t,i)}w.displayName=g;var S=e.forwardRef(w);return S.attrs=v,S.componentStyle=b,S.displayName=g,S.shouldForwardProp=y,S.foldedComponentIds=a?aj(s.foldedComponentIds,s.styledComponentId):"",S.styledComponentId=m,S.target=a?s.target:t,Object.defineProperty(S,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=a?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,i=t;r<i.length;r++)uj(e,i[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(AW(g,m),S.warnTooManyClasses=function(e,t){var n={},r=!1;return function(i){if(!r&&(n[i]=!0,Object.keys(n).length>=200)){var o=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(o,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),r=!0,n={}}}}(g,m)),cj(S,(function(){return".".concat(S.styledComponentId)})),l&&rj(S,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),S}function Jj(e,t){for(var n=[e[0]],r=0,i=t.length;r<i;r+=1)n.push(t[r],e[r+1]);return n}var Qj=function(e){return Object.assign(e,{isCss:!0})};function eX(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(ij(e)||lj(e))return Qj(jj(Jj(IW,c([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?jj(r):Qj(jj(Jj(r,t)))}function tX(e,t,n){if(void 0===n&&(n=EW),!t)throw pj(1,t);var r=function(r){for(var i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];return e(t,n,eX.apply(void 0,c([r],i,!1)))};return r.attrs=function(r){return tX(e,t,u(u({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return tX(e,t,u(u({},n),r))},r}var nX=function(e){return tX($j,e)},rX=nX;LW.forEach((function(e){rX[e]=nX(e)})),"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var iX="__sc-".concat(_W,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[iX]||(window[iX]=0),1===window[iX]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[iX]+=1);const oX=rX.div`
21
21
  height: 100%;
22
- `;var aX;!function(e){e[e.MINI_AREA=0]="MINI_AREA",e[e.AREA=1]="AREA",e[e.DUAL_LINE_BAR=2]="DUAL_LINE_BAR",e[e.STACK_DUAL_LINE_BAR=3]="STACK_DUAL_LINE_BAR",e[e.COLUMN=4]="COLUMN",e[e.STACK_COLUMN=5]="STACK_COLUMN",e[e.LINE=6]="LINE",e[e.BAR=7]="BAR",e[e.STACK_BAR=8]="STACK_BAR",e[e.FUNNEL=9]="FUNNEL",e[e.PIE=10]="PIE",e[e.CYCLE=11]="CYCLE",e[e.RADAR=12]="RADAR"}(aX||(aX={}));const sX=["#3D84FF","#00DCF0","#FCBC26","#00DB75","#BDB8FF","#40B4FF","#FFA101","#90ABE0","#6EE67A","#6B84FF","#FA6B69"],lX={grid:{top:24,left:0,right:12,bottom:32,containLabel:!0},color:sX,legend:{itemWidth:10,itemHeight:10,bottom:0,type:"scroll",icon:"circle"}};function uX(){return uX=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uX.apply(null,arguments)}function cX(e,t){return cX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},cX(e,t)}function hX(e){return hX=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},hX(e)}function dX(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(dX=function(){return!!e})()}function pX(e){var t="function"==typeof Map?new Map:void 0;return pX=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(dX())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&cX(i,n.prototype),i}(e,arguments,hX(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),cX(n,e)},pX(e)}var fX={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function gX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach((function(e){i=i.replace(/%[a-z]/,e)})),i}var mX=function(e){function t(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,gX.apply(void 0,[fX[t]].concat(i)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,cX(e,t)}(t,e),t}(pX(Error));function vX(e){return Math.round(255*e)}function yX(e,t,n){return vX(e)+","+vX(t)+","+vX(n)}function _X(e,t,n,r){if(void 0===r&&(r=yX),0===t)return r(n,n,n);var i=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*t,a=o*(1-Math.abs(i%2-1)),s=0,l=0,u=0;i>=0&&i<1?(s=o,l=a):i>=1&&i<2?(s=a,l=o):i>=2&&i<3?(l=o,u=a):i>=3&&i<4?(l=a,u=o):i>=4&&i<5?(s=a,u=o):i>=5&&i<6&&(s=o,u=a);var c=n-o/2;return r(s+c,l+c,u+c)}var xX={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",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",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",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",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",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:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var bX=/^#[a-fA-F0-9]{6}$/,wX=/^#[a-fA-F0-9]{8}$/,SX=/^#[a-fA-F0-9]{3}$/,TX=/^#[a-fA-F0-9]{4}$/,MX=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,CX=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,DX=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,AX=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function IX(e){if("string"!=typeof e)throw new mX(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return xX[t]?"#"+xX[t]:e}(e);if(t.match(bX))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(wX)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(SX))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(TX)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var i=MX.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var o=CX.exec(t.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=DX.exec(t);if(a){var s="rgb("+_X(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",l=MX.exec(s);if(!l)throw new mX(4,t,s);return{red:parseInt(""+l[1],10),green:parseInt(""+l[2],10),blue:parseInt(""+l[3],10)}}var u=AX.exec(t.substring(0,50));if(u){var c="rgb("+_X(parseInt(""+u[1],10),parseInt(""+u[2],10)/100,parseInt(""+u[3],10)/100)+")",h=MX.exec(c);if(!h)throw new mX(4,t,c);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10),alpha:parseFloat(""+u[4])>1?parseFloat(""+u[4])/100:parseFloat(""+u[4])}}throw new mX(5)}function EX(e){return function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var l=o-a,u=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:u,lightness:s,alpha:e.alpha}:{hue:t,saturation:u,lightness:s}}(IX(e))}var LX=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function NX(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function PX(e){return NX(Math.round(255*e))}function OX(e,t,n){return LX("#"+PX(e)+PX(t)+PX(n))}function RX(e,t,n){return _X(e,t,n,OX)}function kX(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return LX("#"+NX(e)+NX(t)+NX(n));if("object"==typeof e&&void 0===t&&void 0===n)return LX("#"+NX(e.red)+NX(e.green)+NX(e.blue));throw new mX(6)}function zX(e,t,n,r){if("string"==typeof e&&"number"==typeof t){var i=IX(e);return"rgba("+i.red+","+i.green+","+i.blue+","+t+")"}if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return r>=1?kX(e,t,n):"rgba("+e+","+t+","+n+","+r+")";if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?kX(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new mX(7)}function VX(e){if("object"!=typeof e)throw new mX(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return zX(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return kX(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return"rgba("+_X(e,t,n)+","+r+")";if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?RX(e.hue,e.saturation,e.lightness):"rgba("+_X(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new mX(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return RX(e,t,n);if("object"==typeof e&&void 0===t&&void 0===n)return RX(e.hue,e.saturation,e.lightness);throw new mX(1)}(e);throw new mX(8)}function BX(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):BX(e,t,r)}}function FX(e){return BX(e,e.length,[])}function GX(e,t,n){return Math.max(e,Math.min(t,n))}FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{hue:n.hue+parseFloat(e)}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{lightness:GX(0,1,n.lightness-parseFloat(e))}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{saturation:GX(0,1,n.saturation-parseFloat(e))}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{lightness:GX(0,1,n.lightness+parseFloat(e))}))}));var HX=FX((function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=IX(t),i=uX({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),o=IX(n),a=uX({},o,{alpha:"number"==typeof o.alpha?o.alpha:1}),s=i.alpha-a.alpha,l=2*parseFloat(e)-1,u=((l*s==-1?l:l+s)/(1+l*s)+1)/2,c=1-u;return zX({red:Math.floor(i.red*u+a.red*c),green:Math.floor(i.green*u+a.green*c),blue:Math.floor(i.blue*u+a.blue*c),alpha:i.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})})),UX=HX;function WX(e){return Array.isArray(e)&&e.length>0}FX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(uX({},n,{alpha:GX(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{saturation:GX(0,1,n.saturation+parseFloat(e))}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{hue:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{lightness:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{saturation:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:UX(parseFloat(e),"rgb(0, 0, 0)",t)})),FX((function(e,t){return"transparent"===t?t:UX(parseFloat(e),"rgb(255, 255, 255)",t)})),FX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(uX({},n,{alpha:GX(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}));const jX=(e,t=2)=>"number"==typeof e?`${Number((100*e).toFixed(t))}%`:"-%";function XX(e){return Array.isArray(e)?[...new Set(e)]:[]}const YX=e=>Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>{const n=Number(t);return e+(Object.is(n,NaN)?0:n)}),0):0,ZX=e=>Array.isArray(e)?e.sort(((e,t)=>t.value-e.value)):e,qX=e=>{let t=e.data;return(e=>Array.isArray(e)&&e.length>0)(t)||(t=e.extraData),{boundaryGap:!0,axisTick:{alignWithLabel:!0},data:XX(null==t?void 0:t.map((e=>e.label))),axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}}},KX=(e,t)=>(e.sort(((e,n)=>t.indexOf(e.label)-t.indexOf(n.label))),e);function $X(e,t){let n=null;return function(...r){clearTimeout(n),n=setTimeout((()=>{e.apply(globalThis,r)}),t)}}const JX=e=>"dark"===e.theme?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)";function QX(e){const t=e.reduce(((e,t)=>{const{label:n,value:r}=t;return e[n]||(e[n]=0),r&&(e[n]+=Number(r)),e}),{});return Object.values(t).map((e=>parseFloat(e.toFixed(2))))}const eY=e=>{const t=(e=>{const{data:t,extraData:n,sort:r}=e;if(t&&r){const a=(i=[...t],"asc"===(o=r)?i.sort(((e,t)=>e.value-t.value)):"desc"===o&&i.sort(((e,t)=>t.value-e.value)),i),s=XX(a.map((e=>e.label))),l=KX(a,s),u=KX([...null!=n?n:[]],s);return Object.assign(Object.assign({},e),{data:l,extraData:u})}var i,o;return e})(e);switch(t.chartType){case aX.MINI_AREA:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),o=e.color;return{color:o,grid:{top:4,left:0,right:0,bottom:0,containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{show:!1},xAxis:{show:!1,boundaryGap:!1,data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label)))},yAxis:{show:!1,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},series:[...i.map(((t,n)=>{var r,i;const a=null!==(r=null==o?void 0:o[n])&&void 0!==r?r:sX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new wc(0,0,0,1,[{offset:0,color:zX(a,.5)},{offset:1,color:"dark"===e.theme?zX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(i=e.data)||void 0===i?void 0:i.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.AREA:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:qX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:[...r.map(((t,n)=>{var r;const i=sX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new wc(0,0,0,1,[{offset:0,color:zX(i,.5)},{offset:1,color:"dark"===e.theme?zX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"},showSymbol:!0}),{data:null===(r=e.data)||void 0===r?void 0:r.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.LINE:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:qX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!1,lineStyle:{width:2},showSymbol:!0,emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))}})(t);case aX.COLUMN:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})}))}})(t);case aX.STACK_COLUMN:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})}))}})(t);case aX.BAR:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:{},yAxis:{data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:[0,500,500,0]}})))})}))}})(t);case aX.STACK_BAR:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{grid:Object.assign({},e.showStackTotal&&{right:32}),tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll",data:i},xAxis:{},yAxis:{data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:[...i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&!e.showStackTotal&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),Object.assign(Object.assign({name:"总和",type:"bar",stack:"abc",barGap:"-100%",barMaxWidth:8,itemStyle:{normal:{color:"transparent"}},tooltip:{show:!1}},e.showStackTotal&&{label:{normal:{show:!0,position:"right",color:"#000"},formatter:t=>{var n;return String(Number(YX(null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.label===t.name)).map((e=>e.value))).toFixed(2)))}}}),{data:QX(e.data)})]}})(t);case aX.FUNNEL:return(e=>{var t,n;const r=null!==(n=null===(t=ZX(e.data))||void 0===t?void 0:t.map((t=>{var n;return{value:null!==(n=t.value)&&void 0!==n?n:0,name:e.reserveValueWithLabelType?t.label:t.type}})))&&void 0!==n?n:[],i={type:"funnel",minSize:"20%",left:10,top:24,width:"76%",sort:"descending",data:r};return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[Object.assign(Object.assign({},i),{label:{show:!0,position:"outer",formatter:"{c}"}}),Object.assign(Object.assign({},i),{emphasis:{label:{fontSize:20}},label:{show:!0,position:"inner",color:"#fff",formatter:e=>{const t=e.dataIndex;if(0===t)return"100%";const n=r[t-1].value;return jX(e.value/n)}}})]}})(t);case aX.DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=XX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.STACK_DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=XX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.PIE:return(e=>{var t,n;const r=YX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:"50%",data:null===(n=ZX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:JX(e),position:"outside",formatter:e=>jX(e.value/(r||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}})(t);case aX.CYCLE:return(e=>{var t,n,r,i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x;const b=YX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:["60%","48%"],data:null===(n=ZX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:JX(e),position:"outside",formatter:e=>jX(e.value/(b||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}],graphic:[{type:"text",left:"center",top:null!==(o=null===(i=null===(r=e.cycleCenterConfig)||void 0===r?void 0:r.content)||void 0===i?void 0:i.top)&&void 0!==o?o:76,style:{text:null!==(l=null===(s=null===(a=e.cycleCenterConfig)||void 0===a?void 0:a.content)||void 0===s?void 0:s.value)&&void 0!==l?l:Number(b.toFixed(2)).toString(),fill:"dark"===e.theme?"#fff":"#12161F",fontFamily:"roboto",fontSize:null!==(h=null===(c=null===(u=e.cycleCenterConfig)||void 0===u?void 0:u.content)||void 0===c?void 0:c.fontSize)&&void 0!==h?h:28,fontWeight:"bold"}},{type:"text",left:"center",top:null!==(f=null===(p=null===(d=e.cycleCenterConfig)||void 0===d?void 0:d.title)||void 0===p?void 0:p.top)&&void 0!==f?f:112,style:{text:null!==(v=null===(m=null===(g=e.cycleCenterConfig)||void 0===g?void 0:g.title)||void 0===m?void 0:m.value)&&void 0!==v?v:"总计",fill:"dark"===e.theme?"#fff":"#394252 ",fontSize:null!==(x=null===(_=null===(y=e.cycleCenterConfig)||void 0===y?void 0:y.title)||void 0===_?void 0:_.fontSize)&&void 0!==x?x:14}}]}})(t);case aX.RADAR:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((t=>e.reserveValueWithLabelType?t.label:t.type)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},radar:{shape:"circle",radius:"60%",indicator:XX(null===(n=e.data)||void 0===n?void 0:n.map((t=>e.reserveValueWithLabelType?t.type:t.label))).map((e=>({name:e}))),axisName:{color:"#5d677a"},splitArea:{areaStyle:{color:["transparent"]}},axisLine:{lineStyle:{color:"rgba(226, 229, 235, .3)"}},splitLine:{lineStyle:{color:"#e2e5eb",type:"dashed",dashOffset:1.5}}},series:[{type:"radar",data:r.map(((t,n)=>{var r;return{name:t,value:null===(r=e.data)||void 0===r?void 0:r.filter((n=>e.reserveValueWithLabelType?n.label:n.type===t)).map((e=>e.value)),areaStyle:{color:zX(sX[n],.2)},label:{show:e.reserveValueWithLabelType,formatter:e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.toString()}}}})),emphasis:{lineStyle:{width:4}}}]}})(t);default:return{}}};var tY={color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"rgba(0,0,0,0)",textStyle:{},title:{textStyle:{color:"#272f3d"},subtextStyle:{color:"#394252"}},line:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},radar:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#dfe3eb"},symbolSize:4,symbol:"emptyCircle",smooth:!1,color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#828c9e"},emphasis:{iconStyle:{borderColor:"#394252"}}},legend:{textStyle:{color:"#828b9e"}},tooltip:{axisPointer:{lineStyle:{color:"#ccd1db",width:"1"},crossStyle:{color:"#ccd1db",width:"1"}}},timeline:{lineStyle:{color:"#eef0f5",width:2},itemStyle:{color:"#eef0f5",borderWidth:"1"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},checkpointStyle:{color:"#3379ff",borderColor:"#ffffff"},label:{color:"#b1b9c7"},emphasis:{itemStyle:{color:"#3379ff"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},label:{color:"#b1b9c7"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},nY={color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"transparent",textStyle:{},title:{textStyle:{color:"#ffffff"},subtextStyle:{color:"#ffffff"}},line:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},radar:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#ffffff"},symbolSize:"6",symbol:"emptyCircle",smooth:!0,color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#ffffff"},emphasis:{iconStyle:{borderColor:"#ffffff"}}},legend:{textStyle:{color:"#ffffff"}},tooltip:{axisPointer:{lineStyle:{color:"#ffffff",width:"1"},crossStyle:{color:"#ffffff",width:"1"}}},timeline:{lineStyle:{color:"#ffffff",width:2},itemStyle:{color:"#ffffff",borderWidth:"1"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},checkpointStyle:{color:"#5798ff",borderColor:"#ffffff"},label:{color:"#ffffff"},emphasis:{itemStyle:{color:"#5798ff"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},label:{color:"#ffffff"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},rY=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===iY}(e)}(e)};var iY="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function oY(e,t){return!1!==t.clone&&t.isMergeableObject(e)?cY((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function aY(e,t,n){return e.concat(t).map((function(e){return oY(e,n)}))}function sY(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function lY(e,t){try{return t in e}catch(e){return!1}}function uY(e,t,n){var r={};return n.isMergeableObject(e)&&sY(e).forEach((function(t){r[t]=oY(e[t],n)})),sY(t).forEach((function(i){(function(e,t){return lY(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(lY(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return cY;var n=t.customMerge(e);return"function"==typeof n?n:cY}(i,n)(e[i],t[i],n):r[i]=oY(t[i],n))})),r}function cY(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||aY,n.isMergeableObject=n.isMergeableObject||rY,n.cloneUnlessOtherwiseSpecified=oY;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):uY(e,t,n):oY(t,n)}cY.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return cY(e,n,t)}),{})};var hY=dU(cY);Uy("light",hY(tY,lX)),Uy("dark",hY(nY,lX));const dY={arrayMerge:(e,t)=>t},pY=e=>{const n=t(null),[r,i]=o();return a((()=>{var t;const r=By(n.current,null!==(t=e.theme)&&void 0!==t?t:"light");i(r);const o=$X(r.resize,500),a=()=>{o()};return globalThis.addEventListener("resize",a),()=>{globalThis.removeEventListener("resize",a)}}),[e.theme]),a((()=>{var t;if(r){const{data:n,extraOption:i={},extraSeriesOption:o}=e;WX(n)||r.clear();const a=hY(((e,t)=>(WX(e.series)&&WX(t)&&t.forEach((t=>{e.series=e.series.map((e=>Object.assign(Object.assign({},e),e.name===t.name&&t)))})),e))(eY(e),o),i,dY);r.setOption(a),null===(t=e.onLoad)||void 0===t||t.call(e,r);const s=setTimeout((()=>{r.resize()}),500);return()=>{clearTimeout(s)}}}),[r,e]),yU.jsx(oX,{ref:n,className:e.className,style:e.style})};function fY(e,t,n){"object"==typeof t&&(n=t,t=null);var r,i=this;if(!(e instanceof Function))for(var o in r=[],e)e.hasOwnProperty(o)&&r.push(o);var a=function(t){if(i.apply(this,arguments),e instanceof Function?gY(this,e.call(this,t)):function(e,t,n){for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}}(this,e,r),this.constructor===a)for(var n=a.__initializers__,o=0;o<n.length;o++)n[o].apply(this,arguments)};a.__super__=i,i.__initializers__?a.__initializers__=i.__initializers__.slice():a.__initializers__=[],t&&a.__initializers__.push(t);var s=function(){};return s.prototype=i.prototype,a.prototype=new s,a.prototype.constructor=a,gY(a.prototype,n),a.extend=i.extend,a.derive=i.extend,a}function gY(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}l_([FS,yH]),l_(xw);var mY={extend:fY,derive:fY};function vY(e,t){this.action=e,this.context=t}var yY={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,r=-1,i=arguments;switch(i.length){case 1:for(;++r<n;)t[r].action.call(t[r].context);return;case 2:for(;++r<n;)t[r].action.call(t[r].context,i[1]);return;case 3:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2]);return;case 4:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3]);return;case 5:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3],i[4]);return;default:for(;++r<n;)t[r].action.apply(t[r].context,Array.prototype.slice.call(i,1));return}}},on:function(e,t,n){if(e&&t){var r=this.__handlers__||(this.__handlers__={});if(r[e]){if(this.has(e,t))return}else r[e]=[];var i=new vY(t,n||this);return r[e].push(i),this}},once:function(e,t,n){if(e&&t){var r=this;return this.on(e,(function n(){r.off(e,n),t.apply(this,arguments)}),n)}},before:function(e,t,n){if(e&&t)return e="before"+e,this.on(e,t,n)},after:function(e,t,n){if(e&&t)return e="after"+e,this.on(e,t,n)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var n=this.__handlers__||(this.__handlers__={});if(t){if(n[e]){for(var r=n[e],i=[],o=0;o<r.length;o++)t&&r[o].action!==t&&i.push(r[o]);n[e]=i}return this}n[e]=[]},has:function(e,t){var n=this.__handlers__;if(!n||!n[e])return!1;for(var r=n[e],i=0;i<r.length;i++)if(r[i].action===t)return!0}},_Y=0,xY=Array.prototype.forEach,bY={genGUID:function(){return++_Y},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var n=e.split("/"),r=t.split("/"),i=n[0];"."===i||".."===i;)".."===i&&r.pop(),n.shift(),i=n[0];return r.join("/")+"/"+n.join("/")},extend:function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},defaults:function(e,t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n]);return e},extendWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];null==e[i]&&(e[i]=t[i])}return e},each:function(e,t,n){if(e&&t)if(e.forEach&&e.forEach===xY)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(n,e[o],o,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return!!e&&e.length===+e.length},clone:function(e){if(bY.isObject(e)){if(bY.isArray(e))return e.slice();if(bY.isArrayLike(e)){for(var t=new e.constructor(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return bY.extend({},e)}return e}},wY=function(){this.__uid__=bY.genGUID()};wY.__initializers__=[function(e){bY.extend(this,e)}],bY.extend(wY,mY),bY.extend(wY.prototype,yY);var SY=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],TY=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function MY(e){for(var t={},n={},r=0;r<SY.length;r++){o(SY[r])}for(r=0;r<TY.length;r++){var i=TY[r];n[i]=e.getParameter(e[i])}function o(n){if(e.getExtension){var r=e.getExtension(n);r||(r=e.getExtension("MOZ_"+n)),r||(r=e.getExtension("WEBKIT_"+n)),t[n]=r}}this.getExtension=function(e){return e in t||o(e),t[e]},this.getParameter=function(e){return n[e]}}var CY=256,DY=1024,AY=16384,IY=0,EY=1,LY=2,NY=3,PY=4,OY=5,RY=6,kY=35040,zY=35044,VY=35048,BY=1028,FY=1029,GY=1032,HY=2304,UY=2305,WY=5120,jY=5121,XY=5122,YY=5123,ZY=5124,qY=5125,KY=5126,$Y=6402,JY=6406,QY=6407,eZ=6408,tZ=6409,nZ=6410,rZ=9728,iZ=9729,oZ=9984,aZ=9985,sZ=9986,lZ=9987,uZ=3553,cZ=34067,hZ=10497,dZ=33071,pZ=33648,fZ=36160,gZ=36161,mZ=34041,vZ=36064,yZ=36096,_Z=36128,xZ=33306;var bZ,wZ={get:function(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(t){if(t.lengthComputable){var n=t.loaded/t.total;e.onprogress(n,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(n){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}},SZ={supportWebGL:function(){if(null==bZ)try{var e=document.createElement("canvas");if(!(e.getContext("webgl")||e.getContext("experimental-webgl")))throw new Error}catch(e){bZ=!1}return bZ}};SZ.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,SZ.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,SZ.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,SZ.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,SZ.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,SZ.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,SZ.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var TZ={};"undefined"!=typeof window?TZ=window:"undefined"!=typeof global&&(TZ=global),SZ.requestAnimationFrame=TZ.requestAnimationFrame||TZ.msRequestAnimationFrame||TZ.mozRequestAnimationFrame||TZ.webkitRequestAnimationFrame||function(e){setTimeout(e,16)},SZ.createCanvas=function(){return document.createElement("canvas")},SZ.createImage=function(){return new TZ.Image},SZ.request={get:wZ.get},SZ.addEventListener=function(e,t,n,r){e.addEventListener(t,n,r)},SZ.removeEventListener=function(e,t,n){e.removeEventListener(t,n)};var MZ=function(){this.head=null,this.tail=null,this._length=0};MZ.prototype.insert=function(e){var t=new MZ.Entry(e);return this.insertEntry(t),t},MZ.prototype.insertAt=function(e,t){if(!(e<0)){for(var n=this.head,r=0;n&&r!=e;)n=n.next,r++;if(n){var i=new MZ.Entry(t),o=n.prev;o?(o.next=i,i.prev=o):this.head=i,i.next=n,n.prev=i}else this.insert(t)}},MZ.prototype.insertBeforeEntry=function(e,t){var n=new MZ.Entry(e),r=t.prev;r?(r.next=n,n.prev=r):this.head=n,n.next=t,t.prev=n,this._length++},MZ.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},MZ.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._length--},MZ.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t?(this.remove(t),t.value):void 0}},MZ.prototype.getHead=function(){if(this.head)return this.head.value},MZ.prototype.getTail=function(){if(this.tail)return this.tail.value},MZ.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t.value}},MZ.prototype.indexOf=function(e){for(var t=this.head,n=0;t;){if(t.value===e)return n;t=t.next,n++}},MZ.prototype.length=function(){return this._length},MZ.prototype.isEmpty=function(){return 0===this._length},MZ.prototype.forEach=function(e,t){for(var n=this.head,r=0,i=void 0!==t;n;)i?e.call(t,n.value,r):e(n.value,r),n=n.next,r++},MZ.prototype.clear=function(){this.tail=this.head=null,this._length=0},MZ.Entry=function(e){this.value=e,this.next=null,this.prev=null};var CZ=function(e){this._list=new MZ,this._map={},this._maxSize=e||10};CZ.prototype.setMaxSize=function(e){this._maxSize=e},CZ.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},CZ.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},CZ.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},CZ.prototype.clear=function(){this._list.clear(),this._map={}};var DZ={},AZ={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],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 IZ(e){return(e=Math.round(e))<0?0:e>255?255:e}function EZ(e){return e<0?0:e>1?1:e}function LZ(e){return e.length&&"%"===e.charAt(e.length-1)?IZ(parseFloat(e)/100*255):IZ(parseInt(e,10))}function NZ(e){return e.length&&"%"===e.charAt(e.length-1)?EZ(parseFloat(e)/100):EZ(parseFloat(e))}function PZ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function OZ(e,t,n){return e+(t-e)*n}function RZ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function kZ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var zZ=new CZ(20),VZ=null;function BZ(e,t){VZ&&kZ(VZ,t),VZ=zZ.put(e,VZ||t.slice())}function FZ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=NZ(e[1]),i=NZ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return RZ(t=t||[],IZ(255*PZ(a,o,n+1/3)),IZ(255*PZ(a,o,n)),IZ(255*PZ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}DZ.parse=function(e,t){if(e){t=t||[];var n=zZ.get(e);if(n)return kZ(t,n);var r,i=(e+="").replace(/ /g,"").toLowerCase();if(i in AZ)return kZ(t,AZ[i]),BZ(e,t),t;if("#"===i.charAt(0))return 4===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=4095?(RZ(t,(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1),BZ(e,t),t):void RZ(t,0,0,0,1):7===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=16777215?(RZ(t,(16711680&r)>>16,(65280&r)>>8,255&r,1),BZ(e,t),t):void RZ(t,0,0,0,1):void 0;var o=i.indexOf("("),a=i.indexOf(")");if(-1!==o&&a+1===i.length){var s=i.substr(0,o),l=i.substr(o+1,a-(o+1)).split(","),u=1;switch(s){case"rgba":if(4!==l.length)return void RZ(t,0,0,0,1);u=NZ(l.pop());case"rgb":return 3!==l.length?void RZ(t,0,0,0,1):(RZ(t,LZ(l[0]),LZ(l[1]),LZ(l[2]),u),BZ(e,t),t);case"hsla":return 4!==l.length?void RZ(t,0,0,0,1):(l[3]=NZ(l[3]),FZ(l,t),BZ(e,t),t);case"hsl":return 3!==l.length?void RZ(t,0,0,0,1):(FZ(l,t),BZ(e,t),t);default:return}}RZ(t,0,0,0,1)}},DZ.parseToFloat=function(e,t){if(t=DZ.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},DZ.lift=function(e,t){var n=DZ.parse(e);if(n){for(var r=0;r<3;r++)n[r]=t<0?n[r]*(1-t)|0:(255-n[r])*t+n[r]|0;return DZ.stringify(n,4===n.length?"rgba":"rgb")}},DZ.toHex=function(e){var t=DZ.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},DZ.fastLerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){n=n||[];var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=t[i],s=t[o],l=r-i;return n[0]=IZ(OZ(a[0],s[0],l)),n[1]=IZ(OZ(a[1],s[1],l)),n[2]=IZ(OZ(a[2],s[2],l)),n[3]=EZ(OZ(a[3],s[3],l)),n}},DZ.fastMapToColor=DZ.fastLerp,DZ.lerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=DZ.parse(t[i]),s=DZ.parse(t[o]),l=r-i,u=DZ.stringify([IZ(OZ(a[0],s[0],l)),IZ(OZ(a[1],s[1],l)),IZ(OZ(a[2],s[2],l)),EZ(OZ(a[3],s[3],l))],"rgba");return n?{color:u,leftIndex:i,rightIndex:o,value:r}:u}},DZ.mapToColor=DZ.lerp,DZ.modifyHSL=function(e,t,n,r){if(e=DZ.parse(e))return e=function(e){if(e){var t,n,r=e[0]/255,i=e[1]/255,o=e[2]/255,a=Math.min(r,i,o),s=Math.max(r,i,o),l=s-a,u=(s+a)/2;if(0===l)t=0,n=0;else{n=u<.5?l/(s+a):l/(2-s-a);var c=((s-r)/6+l/2)/l,h=((s-i)/6+l/2)/l,d=((s-o)/6+l/2)/l;r===s?t=d-h:i===s?t=1/3+c-d:o===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var p=[360*t,n,u];return null!=e[3]&&p.push(e[3]),p}}(e),null!=t&&(e[0]=function(e){return(e=Math.round(e))<0?0:e>360?360:e}(t)),null!=n&&(e[1]=NZ(n)),null!=r&&(e[2]=NZ(r)),DZ.stringify(FZ(e),"rgba")},DZ.modifyAlpha=function(e,t){if((e=DZ.parse(e))&&null!=t)return e[3]=EZ(t),DZ.stringify(e,"rgba")},DZ.stringify=function(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}};var GZ=DZ.parseToFloat,HZ={};function UZ(e){var t=Object.keys(e);t.sort();for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e[i];null===o?n.push(i):n.push(i+" "+o.toString())}return n.join("\n")}var WZ,jZ=wY.extend((function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}}),(function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)}),{precision:"highp",setUniform:function(e,t){void 0===t&&console.warn('Uniform value "'+e+'" is undefined');var n=this.uniforms[e];n&&("string"==typeof t&&(t=GZ(t)||t),n.value=t,this.autoUpdateTextureStatus&&"t"===n.type&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var n=e[t];this.setUniform(t,n)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var n in e){var r=e[n];this.setUniform(n,r)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var r=this.uniforms;this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t}),this);var i=this.vertexDefines,o=this.fragmentDefines;if(this.vertexDefines=bY.clone(e.vertexDefines),this.fragmentDefines=bY.clone(e.fragmentDefines),t){for(var a in n)r[a]&&(r[a].value=n[a].value);bY.defaults(this.vertexDefines,i),bY.defaults(this.fragmentDefines,o)}var s={};for(var l in e.textures)s[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=bY.clone(this.vertexDefines),e.fragmentDefines=bY.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,n){var r=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(n=t,t=e,e="both"),n=null!=n?n:null,"vertex"!==e&&"both"!==e||r[t]!==n&&(r[t]=n,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==n&&(i[t]=n,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.enableTexture(e[t]);else{var n=this._textureStatus[e];if(n)n.enabled||(n.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this._programKey=""},disableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.disableTexture(e[t]);else{var n=this._textureStatus[e];if(n)!n.enabled||(n.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this._programKey=""},isTextureEnabled:function(e){var t=this._textureStatus;return!!t[e]&&t[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var n in t)t[n].enabled&&e.push(n);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(e,t,n){n.sort();for(var r=[],i=0;i<n.length;i++){var o=n[i];r.push(o)}var a=UZ(e)+"\n"+UZ(t)+"\n"+r.join("\n");if(HZ[a])return HZ[a];var s=bY.genGUID();return HZ[a]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),XZ=1e-6,YZ=Array,ZZ=Math.random,qZ={};qZ.create=function(){var e=new YZ(2);return e[0]=0,e[1]=0,e},qZ.clone=function(e){var t=new YZ(2);return t[0]=e[0],t[1]=e[1],t},qZ.fromValues=function(e,t){var n=new YZ(2);return n[0]=e,n[1]=t,n},qZ.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},qZ.set=function(e,t,n){return e[0]=t,e[1]=n,e},qZ.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},qZ.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},qZ.sub=qZ.subtract,qZ.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},qZ.mul=qZ.multiply,qZ.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},qZ.div=qZ.divide,qZ.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},qZ.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},qZ.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},qZ.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},qZ.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},qZ.dist=qZ.distance,qZ.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},qZ.sqrDist=qZ.squaredDistance,qZ.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},qZ.len=qZ.length,qZ.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},qZ.sqrLen=qZ.squaredLength,qZ.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},qZ.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},qZ.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},qZ.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},qZ.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},qZ.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},qZ.random=function(e,t){t=t||1;var n=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},qZ.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},qZ.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},qZ.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},qZ.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},qZ.forEach=(WZ=qZ.create(),function(e,t,n,r,i,o){var a,s;for(t||(t=2),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a<s;a+=t)WZ[0]=e[a],WZ[1]=e[a+1],i(WZ,WZ,o),e[a]=WZ[0],e[a+1]=WZ[1];return e});var KZ=function(e,t){e=e||0,t=t||0,this.array=qZ.fromValues(e,t),this._dirty=!0};if(KZ.prototype={constructor:KZ,add:function(e){return qZ.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t){return this.array[0]=e,this.array[1]=t,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this._dirty=!0,this},clone:function(){return new KZ(this.x,this.y)},copy:function(e){return qZ.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return qZ.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return qZ.dist(this.array,e.array)},distance:function(e){return qZ.distance(this.array,e.array)},div:function(e){return qZ.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return qZ.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return qZ.dot(this.array,e.array)},len:function(){return qZ.len(this.array)},length:function(){return qZ.length(this.array)},lerp:function(e,t,n){return qZ.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return qZ.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return qZ.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return qZ.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return qZ.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return qZ.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return qZ.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return qZ.random(this.array,e),this._dirty=!0,this},scale:function(e){return qZ.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return qZ.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return qZ.sqrDist(this.array,e.array)},squaredDistance:function(e){return qZ.squaredDistance(this.array,e.array)},sqrLen:function(){return qZ.sqrLen(this.array)},squaredLength:function(){return qZ.squaredLength(this.array)},sub:function(e){return qZ.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return qZ.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return qZ.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return qZ.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return qZ.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return qZ.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var $Z=KZ.prototype;Object.defineProperty($Z,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty($Z,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}KZ.add=function(e,t,n){return qZ.add(e.array,t.array,n.array),e._dirty=!0,e},KZ.set=function(e,t,n){return qZ.set(e.array,t,n),e._dirty=!0,e},KZ.copy=function(e,t){return qZ.copy(e.array,t.array),e._dirty=!0,e},KZ.cross=function(e,t,n){return qZ.cross(e.array,t.array,n.array),e._dirty=!0,e},KZ.distance=KZ.dist=function(e,t){return qZ.distance(e.array,t.array)},KZ.div=function(e,t,n){return qZ.divide(e.array,t.array,n.array),e._dirty=!0,e},KZ.divide=KZ.div,KZ.dot=function(e,t){return qZ.dot(e.array,t.array)},KZ.len=function(e){return qZ.length(e.array)},KZ.lerp=function(e,t,n,r){return qZ.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},KZ.min=function(e,t,n){return qZ.min(e.array,t.array,n.array),e._dirty=!0,e},KZ.max=function(e,t,n){return qZ.max(e.array,t.array,n.array),e._dirty=!0,e},KZ.mul=function(e,t,n){return qZ.multiply(e.array,t.array,n.array),e._dirty=!0,e},KZ.multiply=KZ.mul,KZ.negate=function(e,t){return qZ.negate(e.array,t.array),e._dirty=!0,e},KZ.normalize=function(e,t){return qZ.normalize(e.array,t.array),e._dirty=!0,e},KZ.random=function(e,t){return qZ.random(e.array,t),e._dirty=!0,e},KZ.scale=function(e,t,n){return qZ.scale(e.array,t.array,n),e._dirty=!0,e},KZ.scaleAndAdd=function(e,t,n,r){return qZ.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},KZ.squaredDistance=KZ.sqrDist=function(e,t){return qZ.sqrDist(e.array,t.array)},KZ.squaredLength=KZ.sqrLen=function(e){return qZ.sqrLen(e.array)},KZ.sub=function(e,t,n){return qZ.subtract(e.array,t.array,n.array),e._dirty=!0,e},KZ.subtract=KZ.sub,KZ.transformMat2=function(e,t,n){return qZ.transformMat2(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat2d=function(e,t,n){return qZ.transformMat2d(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat3=function(e,t,n){return qZ.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat4=function(e,t,n){return qZ.transformMat4(e.array,t.array,n.array),e._dirty=!0,e};var JZ={};function QZ(e){for(var t=e.split("\n"),n=0,r=t.length;n<r;n++)t[n]=n+1+": "+t[n];return t.join("\n")}function eq(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),QZ(n)].join("\n")}var tq=new SZ.Float32Array(16),nq=wY.extend({uniformSemantics:{},attributes:{}},(function(){this._locations={},this._textureSlot=0,this._program=null}),{bind:function(e){this._textureSlot=0,e.gl.useProgram(this._program)},hasUniform:function(e){var t=this._locations[e];return null!=t},useTextureSlot:function(e,t,n){t&&(e.gl.activeTexture(e.gl.TEXTURE0+n),t.isRenderable()?t.bind(e):t.unbind(e))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(e){this._textureSlot=e||0},takeCurrentTextureSlot:function(e,t){var n=this._textureSlot;return this.useTextureSlot(e,t,n),this._textureSlot++,n},setUniform:function(e,t,n,r){var i=this._locations[n];if(null==i)return!1;switch(t){case"m4":if(!(r instanceof Float32Array)){for(var o=0;o<r.length;o++)tq[o]=r[o];r=tq}e.uniformMatrix4fv(i,!1,r);break;case"2i":e.uniform2i(i,r[0],r[1]);break;case"2f":e.uniform2f(i,r[0],r[1]);break;case"3i":e.uniform3i(i,r[0],r[1],r[2]);break;case"3f":e.uniform3f(i,r[0],r[1],r[2]);break;case"4i":e.uniform4i(i,r[0],r[1],r[2],r[3]);break;case"4f":e.uniform4f(i,r[0],r[1],r[2],r[3]);break;case"1i":e.uniform1i(i,r);break;case"1f":e.uniform1f(i,r);break;case"1fv":e.uniform1fv(i,r);break;case"1iv":e.uniform1iv(i,r);break;case"2iv":e.uniform2iv(i,r);break;case"2fv":e.uniform2fv(i,r);break;case"3iv":e.uniform3iv(i,r);break;case"3fv":e.uniform3fv(i,r);break;case"4iv":e.uniform4iv(i,r);break;case"4fv":e.uniform4fv(i,r);break;case"m2":case"m2v":e.uniformMatrix2fv(i,!1,r);break;case"m3":case"m3v":e.uniformMatrix3fv(i,!1,r);break;case"m4v":if(Array.isArray(r)&&Array.isArray(r[0])){var a=new SZ.Float32Array(16*r.length),s=0;for(o=0;o<r.length;o++)for(var l=r[o],u=0;u<16;u++)a[s++]=l[u];e.uniformMatrix4fv(i,!1,a)}else e.uniformMatrix4fv(i,!1,r)}return!0},setUniformOfSemantic:function(e,t,n){var r=this.uniformSemantics[t];return!!r&&this.setUniform(e,r.type,r.symbol,n)},enableAttributes:function(e,t,n){var r,i=e.gl,o=this._program,a=this._locations;(r=n?n.__enabledAttributeList:JZ[e.__uid__])||(r=n?n.__enabledAttributeList=[]:JZ[e.__uid__]=[]);for(var s=[],l=0;l<t.length;l++){var u=t[l];if(this.attributes[u]){var c=a[u];if(null==c){if(-1===(c=i.getAttribLocation(o,u))){s[l]=-1;continue}a[u]=c}s[l]=c,r[c]?r[c]=2:r[c]=1}else s[l]=-1}for(l=0;l<r.length;l++)switch(r[l]){case 1:i.enableVertexAttribArray(l),r[l]=3;break;case 2:r[l]=3;break;case 3:i.disableVertexAttribArray(l),r[l]=0}return s},getAttribLocation:function(e,t){var n=this._locations,r=n[t];return null==r&&(r=e.getAttribLocation(this._program,t),n[t]=r),r},buildProgram:function(e,t,n,r){var i=e.createShader(e.VERTEX_SHADER),o=e.createProgram();e.shaderSource(i,n),e.compileShader(i);var a=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(a,r),e.compileShader(a);var s=eq(e,i,n);if(s)return s;if(s=eq(e,a,r))return s;if(e.attachShader(o,i),e.attachShader(o,a),t.attributeSemantics.POSITION)e.bindAttribLocation(o,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(o,0,l[0])}if(e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),this._program=o,this.vertexCode=n,this.fragmentCode=r,!e.getProgramParameter(o,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(o);for(var u=0;u<t.uniforms.length;u++){var c=t.uniforms[u];this._locations[c]=e.getUniformLocation(o,c)}}}),rq=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function iq(e,t,n){var r={};for(var i in n)r[i+"_COUNT"]=n[i];return e.replace(rq,(function(e,n,i,o){var a="";isNaN(n)&&(n=n in t?t[n]:r[n]),isNaN(i)&&(i=i in t?t[i]:r[i]);for(var s=parseInt(n);s<parseInt(i);s++)a+="{"+o.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return a}))}function oq(e,t,n){var r=[];if(t)for(var i in t){var o=t[i];o>0&&r.push("#define "+i.toUpperCase()+"_COUNT "+o)}if(n)for(var a=0;a<n.length;a++){var s=n[a];r.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in e){var l=e[s];null===l?r.push("#define "+s):r.push("#define "+s+" "+l.toString())}return r.join("\n")}function aq(e){this._renderer=e,this._cache={}}aq.prototype.getProgram=function(e,t,n){var r=this._cache,i=e.isSkinnedMesh&&e.isSkinnedMesh(),o=e.isInstancedMesh&&e.isInstancedMesh(),a="s"+t.shader.shaderID+"m"+t.getProgramKey();if(n&&(a+="se"+n.getProgramKey(e.lightGroup)),i&&(a+=",sk"+e.joints.length),o&&(a+=",is"),y=r[a])return y;var s=n?n.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,c=t.getEnabledTextures(),h="";if(i){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),h+="\n"+oq(d)+"\n"}o&&(h+="\n#define INSTANCING\n");var p=h+oq(t.vertexDefines,s,c),f=h+oq(t.fragmentDefines,s,c),g=p+"\n"+t.shader.vertex,m=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(e){return null!=l.getGLExtension(e)}));m.indexOf("EXT_shader_texture_lod")>=0&&(f+="\n#define SUPPORT_TEXTURE_LOD"),m.indexOf("OES_standard_derivatives")>=0&&(f+="\n#define SUPPORT_STANDARD_DERIVATIVES");var v,y,_=function(e){for(var t=[],n=0;n<e.length;n++)t.push("#extension GL_"+e[n]+" : enable");return t.join("\n")}(m)+"\n"+(["precision",v=t.precision,"float"].join(" ")+";\n"+["precision",v,"int"].join(" ")+";\n"+["precision",v,"sampler2D"].join(" ")+";\n\n")+f+"\n"+t.shader.fragment,x=iq(g,t.vertexDefines,s),b=iq(_,t.fragmentDefines,s);(y=new nq).uniformSemantics=t.shader.uniformSemantics,y.attributes=t.shader.attributes;var w=y.buildProgram(u,t.shader,x,b);return y.__error=w,r[a]=y,y};var sq=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,lq=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,uq=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,cq={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function hq(e){for(var t=[],n=0;n<e;n++)t[n]=0;return t}var dq={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return hq(2)},vec3:function(){return hq(3)},vec4:function(){return hq(4)},ivec2:function(){return hq(2)},ivec3:function(){return hq(3)},ivec4:function(){return hq(4)},mat2:function(){return hq(4)},mat3:function(){return hq(9)},mat4:function(){return hq(16)},array:function(){return[]}},pq=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],fq=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],gq=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],mq={vec4:4,vec3:3,vec2:2,float:1},vq={},yq={};function _q(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function xq(){console.error("Wrong uniform/attributes syntax")}function bq(e,t){for(var n=/[,=\(\):]/,r=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),i=[],o=0;o<r.length;o++)r[o].match(n)?i.push(r[o].charAt(0),r[o].slice(1)):i.push(r[o]);var a,s=0,l={},u=null;function c(e){e||xq();var t=e.match(/\[(.*?)\]/);a=e.replace(/\[(.*?)\]/,""),l[a]={},t&&(l[a].isArray=!0,l[a].arraySize=t[1])}c((r=i)[0]);for(o=1;o<r.length;o++){var h=r[o];if(h)if("="!==h)if(":"!==h)if(","!==h)if(")"!==h)if("("!==h)if(h.indexOf("vec")>=0){if(1!==s&&4!==s){xq();break}s=2,u=[]}else if(1!==s)if(4!==s)c(h),s=0;else{var d=h;pq.indexOf(d)>=0||fq.indexOf(d)>=0||gq.indexOf(d)>=0?l[a].semantic=d:"ignore"===d||"unconfigurable"===d?l[a].ignore=!0:l[a].value="bool"===e?"true"===d:parseFloat(d)}else l[a].value="bool"===e?"true"===h:parseFloat(h),u=null;else{if(2!==s){xq();break}if(!(u instanceof Array)){xq();break}u.push(+r[++o])}else l[a].value=new SZ.Float32Array(u),u=null,s=5;else if(2===s){if(!(u instanceof Array)){xq();break}u.push(+r[++o])}else s=5;else s=4;else{if(0!==s&&3!==s){xq();break}s=1}}return l}function wq(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=_q(e),t=_q(t),this._shaderID=function(e,t){var n="vertex:"+e+"fragment:"+t;if(vq[n])return vq[n];var r=bY.genGUID();return vq[n]=r,yq[r]={vertex:e,fragment:t},r}(e,t),this._vertexCode=wq.parseImport(e),this._fragmentCode=wq.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}wq.prototype={constructor:wq,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},_parseImport:function(){this._vertexCode=wq.parseImport(this.vertex),this._fragmentCode=wq.parseImport(this.fragment)},_addSemanticUniform:function(e,t,n){if(pq.indexOf(n)>=0)this.attributeSemantics[n]={symbol:e,type:t};else if(gq.indexOf(n)>=0){var r=!1,i=n;n.match(/TRANSPOSE$/)&&(r=!0,i=n.slice(0,-9)),this.matrixSemantics[n]={symbol:e,type:t,isTranspose:r,semanticNoTranspose:i}}else fq.indexOf(n)>=0&&(this.uniformSemantics[n]={symbol:e,type:t})},_addMaterialUniform:function(e,t,n,r,i,o){o[e]={type:n,value:i?dq.array:r||dq[t],semantic:null}},_parseUniforms:function(){var e={},t=this,n="vertex";function r(e){return null!=e?function(){return e}:null}function i(i,o,a){var s=bq(o,a),l=[];for(var u in s){var c=s[u],h=c.semantic,d=u,p=cq[o],f=r(s[u].value);s[u].isArray&&(d+="["+s[u].arraySize+"]",p+="v"),l.push(d),t._uniformList.push(u),c.ignore||("sampler2D"!==o&&"samplerCube"!==o||(t.textures[u]={shaderType:n,type:o}),h?t._addSemanticUniform(u,p,h):t._addMaterialUniform(u,o,p,f,s[u].isArray,e))}return l.length>0?"uniform "+o+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(sq,i),n="fragment",this._fragmentCode=this._fragmentCode.replace(sq,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(lq,(function(n,r,i){var o=bq(r,i),a=mq[r]||1,s=[];for(var l in o){var u=o[l].semantic;if(e[l]={type:"float",size:a,semantic:u||null},u){if(pq.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:l,type:r}}s.push(l)}return"attribute "+r+" "+s.join(",")+";\n"})),this.attributes=e},_parseDefines:function(){var e=this,t="vertex";function n(n,r,i){var o="vertex"===t?e.vertexDefines:e.fragmentDefines;return o[r]||(o[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(uq,n),t="fragment",this._fragmentCode=this._fragmentCode.replace(uq,n)},clone:function(){var e=yq[this._shaderID];return new wq(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(wq.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(wq.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(wq.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(wq.prototype,"uniforms",{get:function(){return this._uniformList}}));var Sq=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;wq.parseImport=function(e){return e=e.replace(Sq,(function(e,t,n){return(e=wq.source(n))?wq.parseImport(e):(console.error('Shader chunk "'+n+'" not existed in library'),"")}))};var Tq=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;wq.import=function(e){e.replace(Tq,(function(e,t,n,r){if(r=r.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var i,o=n.split("."),a=wq.codes,s=0;s<o.length-1;)a[i=o[s++]]||(a[i]={}),a=a[i];a[i=o[s]]=r}return r}))},wq.codes={},wq.source=function(e){for(var t=e.split("."),n=wq.codes,r=0;n&&r<t.length;){n=n[t[r++]]}return"string"!=typeof n?(console.error('Shader "'+e+'" not existed in library'),""):n};var Mq="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",Cq={create:function(){var e=new YZ(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},clone:function(e){var t=new YZ(16);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(i*A-r*I-o*D)*E,e[2]=(g*S-m*w+v*b)*E,e[3]=(d*w-h*S-p*b)*E,e[4]=(l*C-a*I-u*M)*E,e[5]=(n*I-i*C+o*M)*E,e[6]=(m*x-f*S-v*_)*E,e[7]=(c*S-d*x+p*_)*E,e[8]=(a*A-s*C+u*T)*E,e[9]=(r*C-n*A-o*T)*E,e[10]=(f*w-g*x+v*y)*E,e[11]=(h*x-c*w-p*y)*E,e[12]=(s*M-a*D-l*T)*E,e[13]=(n*D-r*M+i*T)*E,e[14]=(g*_-f*b-m*y)*E,e[15]=(c*b-h*_+d*y)*E,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15];return e[0]=s*(d*v-p*m)-h*(l*v-u*m)+g*(l*p-u*d),e[1]=-(r*(d*v-p*m)-h*(i*v-o*m)+g*(i*p-o*d)),e[2]=r*(l*v-u*m)-s*(i*v-o*m)+g*(i*u-o*l),e[3]=-(r*(l*p-u*d)-s*(i*p-o*d)+h*(i*u-o*l)),e[4]=-(a*(d*v-p*m)-c*(l*v-u*m)+f*(l*p-u*d)),e[5]=n*(d*v-p*m)-c*(i*v-o*m)+f*(i*p-o*d),e[6]=-(n*(l*v-u*m)-a*(i*v-o*m)+f*(i*u-o*l)),e[7]=n*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(h*v-p*g)-c*(s*v-u*g)+f*(s*p-u*h),e[9]=-(n*(h*v-p*g)-c*(r*v-o*g)+f*(r*p-o*h)),e[10]=n*(s*v-u*g)-a*(r*v-o*g)+f*(r*u-o*s),e[11]=-(n*(s*p-u*h)-a*(r*p-o*h)+c*(r*u-o*s)),e[12]=-(a*(h*m-d*g)-c*(s*m-l*g)+f*(s*d-l*h)),e[13]=n*(h*m-d*g)-c*(r*m-i*g)+f*(r*d-i*h),e[14]=-(n*(s*m-l*g)-a*(r*m-i*g)+f*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15];return(t*a-n*o)*(h*m-d*g)-(t*s-r*o)*(c*m-d*f)+(t*l-i*o)*(c*g-h*f)+(n*s-r*a)*(u*m-d*p)-(n*l-i*a)*(u*g-h*p)+(r*l-i*s)*(u*f-c*p)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],g=t[12],m=t[13],v=t[14],y=t[15],_=n[0],x=n[1],b=n[2],w=n[3];return e[0]=_*r+x*s+b*h+w*g,e[1]=_*i+x*l+b*d+w*m,e[2]=_*o+x*u+b*p+w*v,e[3]=_*a+x*c+b*f+w*y,_=n[4],x=n[5],b=n[6],w=n[7],e[4]=_*r+x*s+b*h+w*g,e[5]=_*i+x*l+b*d+w*m,e[6]=_*o+x*u+b*p+w*v,e[7]=_*a+x*c+b*f+w*y,_=n[8],x=n[9],b=n[10],w=n[11],e[8]=_*r+x*s+b*h+w*g,e[9]=_*i+x*l+b*d+w*m,e[10]=_*o+x*u+b*p+w*v,e[11]=_*a+x*c+b*f+w*y,_=n[12],x=n[13],b=n[14],w=n[15],e[12]=_*r+x*s+b*h+w*g,e[13]=_*i+x*l+b*d+w*m,e[14]=_*o+x*u+b*p+w*v,e[15]=_*a+x*c+b*f+w*y,e},multiplyAffine:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[4],s=t[5],l=t[6],u=t[8],c=t[9],h=t[10],d=t[12],p=t[13],f=t[14],g=n[0],m=n[1],v=n[2];return e[0]=g*r+m*a+v*u,e[1]=g*i+m*s+v*c,e[2]=g*o+m*l+v*h,g=n[4],m=n[5],v=n[6],e[4]=g*r+m*a+v*u,e[5]=g*i+m*s+v*c,e[6]=g*o+m*l+v*h,g=n[8],m=n[9],v=n[10],e[8]=g*r+m*a+v*u,e[9]=g*i+m*s+v*c,e[10]=g*o+m*l+v*h,g=n[12],m=n[13],v=n[14],e[12]=g*r+m*a+v*u+d,e[13]=g*i+m*s+v*c+p,e[14]=g*o+m*l+v*h+f,e}};Cq.mul=Cq.multiply,Cq.mulAffine=Cq.multiplyAffine,Cq.translate=function(e,t,n){var r,i,o,a,s,l,u,c,h,d,p,f,g=n[0],m=n[1],v=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*v+t[12],e[13]=t[1]*g+t[5]*m+t[9]*v+t[13],e[14]=t[2]*g+t[6]*m+t[10]*v+t[14],e[15]=t[3]*g+t[7]*m+t[11]*v+t[15]):(r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*g+s*m+h*v+t[12],e[13]=i*g+l*m+d*v+t[13],e[14]=o*g+u*m+p*v+t[14],e[15]=a*g+c*m+f*v+t[15]),e},Cq.scale=function(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Cq.rotate=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x,b,w,S,T,M,C,D,A=r[0],I=r[1],E=r[2],L=Math.sqrt(A*A+I*I+E*E);return Math.abs(L)<XZ?null:(A*=L=1/L,I*=L,E*=L,i=Math.sin(n),a=1-(o=Math.cos(n)),s=t[0],l=t[1],u=t[2],c=t[3],h=t[4],d=t[5],p=t[6],f=t[7],g=t[8],m=t[9],v=t[10],y=t[11],_=A*A*a+o,x=I*A*a+E*i,b=E*A*a-I*i,w=A*I*a-E*i,S=I*I*a+o,T=E*I*a+A*i,M=A*E*a+I*i,C=I*E*a-A*i,D=E*E*a+o,e[0]=s*_+h*x+g*b,e[1]=l*_+d*x+m*b,e[2]=u*_+p*x+v*b,e[3]=c*_+f*x+y*b,e[4]=s*w+h*S+g*T,e[5]=l*w+d*S+m*T,e[6]=u*w+p*S+v*T,e[7]=c*w+f*S+y*T,e[8]=s*M+h*C+g*D,e[9]=l*M+d*C+m*D,e[10]=u*M+p*C+v*D,e[11]=c*M+f*C+y*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Cq.rotateX=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e},Cq.rotateY=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e},Cq.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},Cq.fromRotationTranslation=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,p=i*l,f=i*u,g=o*u,m=a*s,v=a*l,y=a*u;return e[0]=1-(p+g),e[1]=h+y,e[2]=d-v,e[3]=0,e[4]=h-y,e[5]=1-(c+g),e[6]=f+m,e[7]=0,e[8]=d+v,e[9]=f-m,e[10]=1-(c+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},Cq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[1]=c+v,e[2]=d-m,e[3]=0,e[4]=c-v,e[5]=1-u-f,e[6]=p+g,e[7]=0,e[8]=d+m,e[9]=p-g,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Cq.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},Cq.perspective=function(e,t,n,r,i){var o=1/Math.tan(t/2),a=1/(r-i);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*a,e[15]=0,e},Cq.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},Cq.lookAt=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f=t[0],g=t[1],m=t[2],v=r[0],y=r[1],_=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(f-x)<XZ&&Math.abs(g-b)<XZ&&Math.abs(m-w)<XZ?Cq.identity(e):(c=f-x,h=g-b,d=m-w,i=y*(d*=p=1/Math.sqrt(c*c+h*h+d*d))-_*(h*=p),o=_*(c*=p)-v*d,a=v*h-y*c,(p=Math.sqrt(i*i+o*o+a*a))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(p=Math.sqrt(s*s+l*l+u*u))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*f+o*g+a*m),e[13]=-(s*f+l*g+u*m),e[14]=-(c*f+h*g+d*m),e[15]=1,e)},Cq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))};var Dq={create:function(){var e=new YZ(3);return e[0]=0,e[1]=0,e[2]=0,e},clone:function(e){var t=new YZ(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},fromValues:function(e,t,n){var r=new YZ(3);return r[0]=e,r[1]=t,r[2]=n,r},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set:function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}};Dq.sub=Dq.subtract,Dq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e},Dq.mul=Dq.multiply,Dq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},Dq.div=Dq.divide,Dq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},Dq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},Dq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},Dq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},Dq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},Dq.dist=Dq.distance,Dq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},Dq.sqrDist=Dq.squaredDistance,Dq.length=function(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)},Dq.len=Dq.length,Dq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Dq.sqrLen=Dq.squaredLength,Dq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Dq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Dq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o),e},Dq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},Dq.cross=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e},Dq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},Dq.random=function(e,t){t=t||1;var n=2*ZZ()*Math.PI,r=2*ZZ()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},Dq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e},Dq.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},Dq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Dq.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.forEach=function(){var e=Dq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=3),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),Dq.angle=function(e,t){var n=Dq.fromValues(e[0],e[1],e[2]),r=Dq.fromValues(t[0],t[1],t[2]);Dq.normalize(n,n),Dq.normalize(r,r);var i=Dq.dot(n,r);return i>1?0:Math.acos(i)},wq.import(Mq);var Aq=Cq.create,Iq={};function Eq(e){return e.material}function Lq(e,t,n){return t.uniforms[n].value}function Nq(e,t,n,r){return n!==r}function Pq(e){return!0}function Oq(){}var Rq={float:KY,byte:WY,ubyte:jY,short:XY,ushort:YY};function kq(e,t,n){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=n,this.vao=null}function zq(e){var t,n;this.bind=function(e){t||((t=SZ.createCanvas()).width=t.height=1,t.getContext("2d"));var r=e.gl,i=!n;i&&(n=r.createTexture()),r.bindTexture(r.TEXTURE_2D,n),i&&r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var Vq=wY.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=SZ.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new MY(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new aq(this),this._placeholderTexture=new zq}),{resize:function(e,t){var n=this.canvas,r=this.devicePixelRatio;null!=e?(n.style&&(n.style.width=e+"px",n.style.height=t+"px"),n.width=e*r,n.height=t*r,this._width=e,this._height=t):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,r,i){if("object"==typeof e){var o=e;e=o.x,t=o.y,n=o.width,r=o.height,i=o.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,r*i),this.viewport={x:e,y:t,width:n,height:r,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,n,r){var i=this.gl,o=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var a=this.viewport,s=!1,l=a.devicePixelRatio;(a.width!==this._width||a.height!==this._height||l&&l!==this.devicePixelRatio||a.x||a.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(a.x*l,a.y*l,a.width*l,a.height*l)),i.clearColor(o[0],o[1],o[2],o[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(n||e.update(!1),e.updateLights(),t=t||e.getMainCamera()){t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var c=u.opaque,h=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),r?(this.renderPreZ(c,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var p=Aq(),f=Dq.create(),g=0;g<h.length;g++){var m=h[g];Cq.multiplyAffine(p,t.viewMatrix.array,m.worldTransform.array),Dq.transformMat4(f,m.position.array,p),m.__depth=f[2]}this.renderPass(c,t,{getMaterial:function(e){return d||e.material},sortCompare:this.opaqueSortCompare}),this.renderPass(h,t,{getMaterial:function(e){return d||e.material},sortCompare:this.transparentSortCompare}),e.trigger("afterrender",this,e,t,u),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(e,t,n){return t=t||e.material,this._programMgr.getProgram(e,t,n)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Iq[e.__uid__])return;if(Iq[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,n){var r=n&&n.getMaterial||Eq;t=t||null;for(var i=0;i<e.length;i++){var o=e[i],a=r.call(this,o);if(i>0){var s=e[i-1],l=s.joints?s.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===s.material&&o.lightGroup===s.lightGroup){o.__program=s.__program;continue}}var u=this._programMgr.getProgram(o,a,t);this.validateProgram(u),o.__program=u}},renderPass:function(e,t,n){this.trigger("beforerenderpass",this,e,t,n),(n=n||{}).getMaterial=n.getMaterial||Eq,n.getUniform=n.getUniform||Lq,n.isMaterialChanged=n.isMaterialChanged||Nq,n.beforeRender=n.beforeRender||Oq,n.afterRender=n.afterRender||Oq;var r=n.ifRender||Pq;this.updatePrograms(e,this._sceneRendering,n),n.sortCompare&&e.sort(n.sortCompare);var i=this.viewport,o=i.devicePixelRatio,a=[i.x*o,i.y*o,i.width*o,i.height*o],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],u=[a[2],a[3]],c=Date.now();t?(Cq.copy(Bq.VIEW,t.viewMatrix.array),Cq.copy(Bq.PROJECTION,t.projectionMatrix.array),Cq.copy(Bq.VIEWINVERSE,t.worldTransform.array)):(Cq.identity(Bq.VIEW),Cq.identity(Bq.PROJECTION),Cq.identity(Bq.VIEWINVERSE)),Cq.multiply(Bq.VIEWPROJECTION,Bq.PROJECTION,Bq.VIEW),Cq.invert(Bq.PROJECTIONINVERSE,Bq.PROJECTION),Cq.invert(Bq.VIEWPROJECTIONINVERSE,Bq.VIEWPROJECTION);for(var h,d,p,f,g,m,v,y,_,x,b,w,S=this.gl,T=this._sceneRendering,M=null,C=0;C<e.length;C++){var D,A=e[C],I=null!=A.worldTransform;if(r(A)){I&&(D=A.isSkinnedMesh&&A.isSkinnedMesh()?A.offsetMatrix?A.offsetMatrix.array:Bq.IDENTITY:A.worldTransform.array);var E=A.geometry,L=n.getMaterial.call(this,A),N=A.__program,P=L.shader,O=E.__uid__+"-"+N.__uid__,R=O!==x;x=O,I&&(Cq.copy(Bq.WORLD,D),Cq.multiply(Bq.WORLDVIEWPROJECTION,Bq.VIEWPROJECTION,D),Cq.multiplyAffine(Bq.WORLDVIEW,Bq.VIEW,D),(P.matrixSemantics.WORLDINVERSE||P.matrixSemantics.WORLDINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDINVERSE,D),(P.matrixSemantics.WORLDVIEWINVERSE||P.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDVIEWINVERSE,Bq.WORLDVIEW),(P.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||P.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDVIEWPROJECTIONINVERSE,Bq.WORLDVIEWPROJECTION)),A.beforeRender&&A.beforeRender(this),n.beforeRender.call(this,A,L,h);var k=N!==d;k?(N.bind(this),N.setUniformOfSemantic(S,"VIEWPORT",a),N.setUniformOfSemantic(S,"WINDOW_SIZE",l),t&&(N.setUniformOfSemantic(S,"NEAR",t.near),N.setUniformOfSemantic(S,"FAR",t.far)),N.setUniformOfSemantic(S,"DEVICEPIXELRATIO",o),N.setUniformOfSemantic(S,"TIME",c),N.setUniformOfSemantic(S,"VIEWPORT_SIZE",u),T&&T.setLightUniforms(N,A.lightGroup,this)):N=d,(k||n.isMaterialChanged(A,p,L,h))&&(L.depthTest!==f&&(L.depthTest?S.enable(S.DEPTH_TEST):S.disable(S.DEPTH_TEST),f=L.depthTest),L.depthMask!==g&&(S.depthMask(L.depthMask),g=L.depthMask),L.transparent!==_&&(L.transparent?S.enable(S.BLEND):S.disable(S.BLEND),_=L.transparent),L.transparent&&(L.blend?L.blend(S):(S.blendEquationSeparate(S.FUNC_ADD,S.FUNC_ADD),S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(A,L,N,p||null,h||null,d||null,n.getUniform),h=L);var z=P.matrixSemanticKeys;if(I)for(var V=0;V<z.length;V++){var B=z[V],F=P.matrixSemantics[B],G=Bq[B];if(F.isTranspose){var H=Bq[F.semanticNoTranspose];Cq.transpose(G,H)}N.setUniform(S,F.type,F.symbol,G)}A.cullFace!==v&&(v=A.cullFace,S.cullFace(v)),A.frontFace!==y&&(y=A.frontFace,S.frontFace(y)),A.culling!==m&&((m=A.culling)?S.enable(S.CULL_FACE):S.disable(S.CULL_FACE)),this._updateSkeleton(A,N,w),R&&(b=this._bindVAO(M,P,E,N)),this._renderObject(A,b,N),n.afterRender(this,A),A.afterRender&&A.afterRender(this),d=N,p=A}}this.trigger("afterrenderpass",this,e,t,n)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,n){var r=this.gl,i=e.skeleton;if(i)if(i.update(),e.joints.length>this.getMaxJointNumber()){var o=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,o,n),t.setUniform(r,"1i","skinMatricesTexture",n),t.setUniform(r,"1f","skinMatricesTextureSize",o.width)}else{var a=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(r,"SKIN_MATRIX",a)}},_renderObject:function(e,t,n){var r=this.gl,i=e.geometry,o=e.mode;null==o&&(o=4);var a=null,s=e.isInstancedMesh&&e.isInstancedMesh();if(!s||(a=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(e,n,a)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint")&&i.indices instanceof Uint32Array?r.UNSIGNED_INT:r.UNSIGNED_SHORT;s?a.drawElementsInstancedANGLE(o,t.indicesBuffer.count,u,0,e.getInstanceCount()):r.drawElements(o,t.indicesBuffer.count,u,0)}else s?a.drawArraysInstancedANGLE(o,0,i.vertexCount,e.getInstanceCount()):r.drawArrays(o,0,i.vertexCount);if(s)for(var c=0;c<l.length;c++)r.disableVertexAttribArray(l[c])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(e,t,n){for(var r=this.gl,i=e.getInstancedAttributesBuffers(this),o=[],a=0;a<i.length;a++){var s=i[a],l=t.getAttribLocation(r,s.symbol);if(!(l<0)){var u=Rq[s.type]||r.FLOAT;r.enableVertexAttribArray(l),r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.vertexAttribPointer(l,s.size,u,!1,0,0),n.vertexAttribDivisorANGLE(l,s.divisor),o.push(l)}}return o},_bindMaterial:function(e,t,n,r,i,o,a){for(var s=this.gl,l=o===n,u=n.currentTextureSlot(),c=t.getEnabledUniforms(),h=t.getTextureUniforms(),d=this._placeholderTexture,p=0;p<h.length;p++){var f=a(e,t,v=h[p]);if("t"===(m=t.uniforms[v].type)&&f)f.__slot=-1;else if("tv"===m)for(var g=0;g<f.length;g++)f[g]&&(f[g].__slot=-1)}d.__slot=-1;for(p=0;p<c.length;p++){var m,v=c[p],y=t.uniforms[v],_=(f=a(e,t,v),"t"===(m=y.type));if(_&&(f&&f.isRenderable()||(f=d)),i&&l){var x=a(r,i,v);if(_&&(x&&x.isRenderable()||(x=d)),x===f){if(_)n.takeCurrentTextureSlot(this,null);else if("tv"===m&&f)for(g=0;g<f.length;g++)n.takeCurrentTextureSlot(this,null);continue}}if(null!=f)if(_)if(f.__slot<0){var b=n.currentTextureSlot();n.setUniform(s,"1i",v,b)&&(n.takeCurrentTextureSlot(this,f),f.__slot=b)}else n.setUniform(s,"1i",v,f.__slot);else if(Array.isArray(f)){if(0===f.length)continue;if("tv"===m){if(!n.hasUniform(v))continue;var w=[];for(g=0;g<f.length;g++){var S=f[g];if(S.__slot<0){b=n.currentTextureSlot();w.push(b),n.takeCurrentTextureSlot(this,S),S.__slot=b}else w.push(S.__slot)}n.setUniform(s,"1iv",v,w)}else n.setUniform(s,y.type,v,f)}else n.setUniform(s,y.type,v,f)}var T=n.currentTextureSlot();return n.resetTextureSlot(u),T},_bindVAO:function(e,t,n,r){var i=!n.dynamic,o=this.gl,a=this.__uid__+"-"+r.__uid__,s=n.__vaoCache[a];if(!s){var l=n.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],c=u.attributeBuffers,h=u.indicesBuffer,d=[],p=[],f=0;f<c.length;f++){var g,m=(w=c[f]).name,v=w.semantic;if(v){var y=t.attributeSemantics[v];g=y&&y.symbol}else g=m;g&&r.attributes[g]&&(d.push(w),p.push(g))}s=new kq(d,p,h),i&&(n.__vaoCache[a]=s)}var _=!0;e&&i&&(null==s.vao?s.vao=e.createVertexArrayOES():_=!1,e.bindVertexArrayOES(s.vao));d=s.availableAttributes,h=s.indicesBuffer;if(_){var x=r.enableAttributes(this,s.availableAttributeSymbols,e&&i&&s);for(f=0;f<d.length;f++){var b=x[f];if(-1!==b){var w,S=(w=d[f]).buffer,T=w.size,M=Rq[w.type]||o.FLOAT;o.bindBuffer(o.ARRAY_BUFFER,S),o.vertexAttribPointer(b,T,M,!1,0,0)}}n.isUseIndices()&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.buffer)}return s},renderPreZ:function(e,t,n){var r=this.gl,i=this._prezMaterial||new jZ({shader:new wq(wq.source("clay.prez.vertex"),wq.source("clay.prez.fragment"))});this._prezMaterial=i,r.colorMask(!1,!1,!1,!1),r.depthMask(!0),this.renderPass(e,n,{ifRender:function(e){return!e.ignorePreZ},isMaterialChanged:function(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)},getUniform:function(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)},getMaterial:function(){return i},sort:this.opaqueSortCompare}),r.colorMask(!0,!0,!0,!0),r.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){e.getParent()&&e.getParent().remove(e);var r={};e.traverse((function(e){var i=e.material;if(e.geometry&&t&&e.geometry.dispose(this),n&&i&&!r[i.__uid__]){for(var o=i.getTextureUniforms(),a=0;a<o.length;a++){var s=o[a],l=i.uniforms[s].value,u=i.uniforms[s].type;if(l)if("t"===u)l.dispose&&l.dispose(this);else if("tv"===u)for(var c=0;c<l.length;c++)l[c]&&l[c].dispose&&l[c].dispose(this)}r[i.__uid__]=!0}e.dispose&&e.dispose(this)}),this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new KZ),t=this._height-t;var r=this.viewport,i=n.array;return i[0]=(e-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(t-r.y)/r.height,i[1]=2*i[1]-1,n}});Vq.opaqueSortCompare=Vq.prototype.opaqueSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.renderOrder-t.renderOrder},Vq.transparentSortCompare=Vq.prototype.transparentSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var Bq={IDENTITY:Aq(),WORLD:Aq(),VIEW:Aq(),PROJECTION:Aq(),WORLDVIEW:Aq(),VIEWPROJECTION:Aq(),WORLDVIEWPROJECTION:Aq(),WORLDINVERSE:Aq(),VIEWINVERSE:Aq(),PROJECTIONINVERSE:Aq(),WORLDVIEWINVERSE:Aq(),VIEWPROJECTIONINVERSE:Aq(),WORLDVIEWPROJECTIONINVERSE:Aq(),WORLDTRANSPOSE:Aq(),VIEWTRANSPOSE:Aq(),PROJECTIONTRANSPOSE:Aq(),WORLDVIEWTRANSPOSE:Aq(),VIEWPROJECTIONTRANSPOSE:Aq(),WORLDVIEWPROJECTIONTRANSPOSE:Aq(),WORLDINVERSETRANSPOSE:Aq(),VIEWINVERSETRANSPOSE:Aq(),PROJECTIONINVERSETRANSPOSE:Aq(),WORLDVIEWINVERSETRANSPOSE:Aq(),VIEWPROJECTIONINVERSETRANSPOSE:Aq(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Aq()};Vq.COLOR_BUFFER_BIT=AY,Vq.DEPTH_BUFFER_BIT=CY,Vq.STENCIL_BUFFER_BIT=DY;var Fq=function(e,t,n){e=e||0,t=t||0,n=n||0,this.array=Dq.fromValues(e,t,n),this._dirty=!0};Fq.prototype={constructor:Fq,add:function(e){return Dq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new Fq(this.x,this.y,this.z)},copy:function(e){return Dq.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return Dq.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return Dq.dist(this.array,e.array)},distance:function(e){return Dq.distance(this.array,e.array)},div:function(e){return Dq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Dq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Dq.dot(this.array,e.array)},len:function(){return Dq.len(this.array)},length:function(){return Dq.length(this.array)},lerp:function(e,t,n){return Dq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Dq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Dq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Dq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Dq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Dq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Dq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Dq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Dq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Dq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Dq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Dq.squaredDistance(this.array,e.array)},sqrLen:function(){return Dq.sqrLen(this.array)},squaredLength:function(){return Dq.squaredLength(this.array)},sub:function(e){return Dq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Dq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return Dq.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Dq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Dq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(0===(e=e.array)[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){Fq.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){Fq.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Gq=Object.defineProperty;if(Gq){var Hq=Fq.prototype;Gq(Hq,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Gq(Hq,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Gq(Hq,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}function Uq(e,t,n){return e<t?t:e>n?n:e}Fq.add=function(e,t,n){return Dq.add(e.array,t.array,n.array),e._dirty=!0,e},Fq.set=function(e,t,n,r){Dq.set(e.array,t,n,r),e._dirty=!0},Fq.copy=function(e,t){return Dq.copy(e.array,t.array),e._dirty=!0,e},Fq.cross=function(e,t,n){return Dq.cross(e.array,t.array,n.array),e._dirty=!0,e},Fq.distance=Fq.dist=function(e,t){return Dq.distance(e.array,t.array)},Fq.div=function(e,t,n){return Dq.divide(e.array,t.array,n.array),e._dirty=!0,e},Fq.divide=Fq.div,Fq.dot=function(e,t){return Dq.dot(e.array,t.array)},Fq.len=function(e){return Dq.length(e.array)},Fq.lerp=function(e,t,n,r){return Dq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},Fq.min=function(e,t,n){return Dq.min(e.array,t.array,n.array),e._dirty=!0,e},Fq.max=function(e,t,n){return Dq.max(e.array,t.array,n.array),e._dirty=!0,e},Fq.mul=function(e,t,n){return Dq.multiply(e.array,t.array,n.array),e._dirty=!0,e},Fq.multiply=Fq.mul,Fq.negate=function(e,t){return Dq.negate(e.array,t.array),e._dirty=!0,e},Fq.normalize=function(e,t){return Dq.normalize(e.array,t.array),e._dirty=!0,e},Fq.random=function(e,t){return Dq.random(e.array,t),e._dirty=!0,e},Fq.scale=function(e,t,n){return Dq.scale(e.array,t.array,n),e._dirty=!0,e},Fq.scaleAndAdd=function(e,t,n,r){return Dq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},Fq.squaredDistance=Fq.sqrDist=function(e,t){return Dq.sqrDist(e.array,t.array)},Fq.squaredLength=Fq.sqrLen=function(e){return Dq.sqrLen(e.array)},Fq.sub=function(e,t,n){return Dq.subtract(e.array,t.array,n.array),e._dirty=!0,e},Fq.subtract=Fq.sub,Fq.transformMat3=function(e,t,n){return Dq.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},Fq.transformMat4=function(e,t,n){return Dq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},Fq.transformQuat=function(e,t,n){return Dq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var Wq=Math.atan2,jq=Math.asin,Xq=Math.abs;Fq.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=t[0],o=t[1],a=t[2],s=t[3],l=i*i,u=o*o,c=a*a,h=s*s;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=Wq(2*(i*s-o*a),h-l-u+c),r[1]=jq(Uq(2*(i*a+o*s),-1,1)),r[2]=Wq(2*(a*s-i*o),h+l-u-c);break;case"YXZ":r[0]=jq(Uq(2*(i*s-o*a),-1,1)),r[1]=Wq(2*(i*a+o*s),h-l-u+c),r[2]=Wq(2*(i*o+a*s),h-l+u-c);break;case"ZXY":r[0]=jq(Uq(2*(i*s+o*a),-1,1)),r[1]=Wq(2*(o*s-a*i),h-l-u+c),r[2]=Wq(2*(a*s-i*o),h-l+u-c);break;case"ZYX":r[0]=Wq(2*(i*s+a*o),h-l-u+c),r[1]=jq(Uq(2*(o*s-i*a),-1,1)),r[2]=Wq(2*(i*o+a*s),h+l-u-c);break;case"YZX":r[0]=Wq(2*(i*s-a*o),h-l+u-c),r[1]=Wq(2*(o*s-i*a),h+l-u-c),r[2]=jq(Uq(2*(i*o+a*s),-1,1));break;case"XZY":r[0]=Wq(2*(i*s+o*a),h-l+u-c),r[1]=Wq(2*(i*a+o*s),h+l-u-c),r[2]=jq(Uq(2*(a*s-i*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},Fq.eulerFromMat3=function(e,t,n){var r=t.array,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7],c=r[2],h=r[5],d=r[8],p=e.array;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":p[1]=jq(Uq(a,-1,1)),Xq(a)<.99999?(p[0]=Wq(-u,d),p[2]=Wq(-o,i)):(p[0]=Wq(h,l),p[2]=0);break;case"YXZ":p[0]=jq(-Uq(u,-1,1)),Xq(u)<.99999?(p[1]=Wq(a,d),p[2]=Wq(s,l)):(p[1]=Wq(-c,i),p[2]=0);break;case"ZXY":p[0]=jq(Uq(h,-1,1)),Xq(h)<.99999?(p[1]=Wq(-c,d),p[2]=Wq(-o,l)):(p[1]=0,p[2]=Wq(s,i));break;case"ZYX":p[1]=jq(-Uq(c,-1,1)),Xq(c)<.99999?(p[0]=Wq(h,d),p[2]=Wq(s,i)):(p[0]=0,p[2]=Wq(-o,l));break;case"YZX":p[2]=jq(Uq(s,-1,1)),Xq(s)<.99999?(p[0]=Wq(-u,l),p[1]=Wq(-c,i)):(p[0]=0,p[1]=Wq(a,d));break;case"XZY":p[2]=jq(-Uq(o,-1,1)),Xq(o)<.99999?(p[0]=Wq(h,l),p[1]=Wq(a,i)):(p[0]=Wq(-u,d),p[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},Object.defineProperties(Fq,{POSITIVE_X:{get:function(){return new Fq(1,0,0)}},NEGATIVE_X:{get:function(){return new Fq(-1,0,0)}},POSITIVE_Y:{get:function(){return new Fq(0,1,0)}},NEGATIVE_Y:{get:function(){return new Fq(0,-1,0)}},POSITIVE_Z:{get:function(){return new Fq(0,0,1)}},NEGATIVE_Z:{get:function(){return new Fq(0,0,-1)}},UP:{get:function(){return new Fq(0,1,0)}},ZERO:{get:function(){return new Fq}}});var Yq,Zq,qq,Kq,$q=1e-5,Jq=function(e,t){this.origin=e||new Fq,this.direction=t||new Fq};Jq.prototype={constructor:Jq,intersectPlane:function(e,t){var n=e.normal.array,r=e.distance,i=this.origin.array,o=this.direction.array,a=Dq.dot(n,o);if(0===a)return null;t||(t=new Fq);var s=(Dq.dot(n,i)-r)/a;return Dq.scaleAndAdd(t.array,i,o,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Dq.dot(e.normal.array,this.direction.array);Dq.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Dq.create();return function(t){Dq.sub(e,t,this.origin.array);var n=Dq.dot(e,this.direction.array);if(n<0)return Dq.distance(this.origin.array,t);var r=Dq.lenSquared(e);return Math.sqrt(r-n*n)}}(),intersectSphere:function(){var e=Dq.create();return function(t,n,r){var i=this.origin.array,o=this.direction.array;t=t.array,Dq.sub(e,t,i);var a=Dq.dot(e,o),s=Dq.squaredLength(e)-a*a,l=n*n;if(!(s>l)){var u=Math.sqrt(l-s),c=a-u,h=a+u;return r||(r=new Fq),c<0?h<0?null:(Dq.scaleAndAdd(r.array,i,o,h),r):(Dq.scaleAndAdd(r.array,i,o,c),r)}}}(),intersectBoundingBox:function(e,t){var n,r,i,o,a,s,l=this.direction.array,u=this.origin.array,c=e.min.array,h=e.max.array,d=1/l[0],p=1/l[1],f=1/l[2];if(d>=0?(n=(c[0]-u[0])*d,r=(h[0]-u[0])*d):(r=(c[0]-u[0])*d,n=(h[0]-u[0])*d),p>=0?(i=(c[1]-u[1])*p,o=(h[1]-u[1])*p):(o=(c[1]-u[1])*p,i=(h[1]-u[1])*p),n>o||i>r)return null;if((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),f>=0?(a=(c[2]-u[2])*f,s=(h[2]-u[2])*f):(s=(c[2]-u[2])*f,a=(h[2]-u[2])*f),n>s||a>r)return null;if((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0)return null;var g=n>=0?n:r;return t||(t=new Fq),Dq.scaleAndAdd(t.array,u,l,g),t},intersectTriangle:(Yq=Dq.create(),Zq=Dq.create(),qq=Dq.create(),Kq=Dq.create(),function(e,t,n,r,i,o){var a=this.direction.array,s=this.origin.array;e=e.array,t=t.array,n=n.array,Dq.sub(Yq,t,e),Dq.sub(Zq,n,e),Dq.cross(Kq,Zq,a);var l=Dq.dot(Yq,Kq);if(r){if(l>-1e-5)return null}else if(l>-1e-5&&l<$q)return null;Dq.sub(qq,s,e);var u=Dq.dot(Kq,qq)/l;if(u<0||u>1)return null;Dq.cross(Kq,Yq,qq);var c=Dq.dot(a,Kq)/l;if(c<0||c>1||u+c>1)return null;Dq.cross(Kq,Yq,Zq);var h=-Dq.dot(qq,Kq)/l;return h<0?null:(i||(i=new Fq),o&&Fq.set(o,1-u-c,u,c),Dq.scaleAndAdd(i.array,s,a,h),i)}),applyTransform:function(e){Fq.add(this.direction,this.direction,this.origin),Fq.transformMat4(this.origin,this.origin,e),Fq.transformMat4(this.direction,this.direction,e),Fq.sub(this.direction,this.direction,this.origin),Fq.normalize(this.direction,this.direction)},copy:function(e){Fq.copy(this.origin,e.origin),Fq.copy(this.direction,e.direction)},clone:function(){var e=new Jq;return e.copy(this),e}};var Qq={create:function(){var e=new YZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},clone:function(e){var t=new YZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues:function(e,t,n,r){var i=new YZ(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set:function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}};Qq.sub=Qq.subtract,Qq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},Qq.mul=Qq.multiply,Qq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},Qq.div=Qq.divide,Qq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},Qq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},Qq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},Qq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},Qq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+o*o)},Qq.dist=Qq.distance,Qq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o},Qq.sqrDist=Qq.squaredDistance,Qq.length=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)},Qq.len=Qq.length,Qq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i},Qq.sqrLen=Qq.squaredLength,Qq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},Qq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},Qq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e[3]=t[3]*a),e},Qq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Qq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},Qq.random=function(e,t){return t=t||1,e[0]=ZZ(),e[1]=ZZ(),e[2]=ZZ(),e[3]=ZZ(),Qq.normalize(e,e),Qq.scale(e,e,t),e},Qq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e},Qq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Qq.forEach=function(){var e=Qq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var eK={create:function(){var e=new YZ(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat4:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone:function(e){var t=new YZ(9);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,d=-c*o+s*l,p=u*o-a*l,f=n*h+r*d+i*p;return f?(f=1/f,e[0]=h*f,e[1]=(-c*r+i*u)*f,e[2]=(s*r-i*a)*f,e[3]=d*f,e[4]=(c*n-i*l)*f,e[5]=(-s*n+i*o)*f,e[6]=p*f,e[7]=(-u*n+r*l)*f,e[8]=(a*n-r*o)*f,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8];return t*(u*o-a*l)+n*(-u*i+a*s)+r*(l*i-o*s)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1],f=n[2],g=n[3],m=n[4],v=n[5],y=n[6],_=n[7],x=n[8];return e[0]=d*r+p*a+f*u,e[1]=d*i+p*s+f*c,e[2]=d*o+p*l+f*h,e[3]=g*r+m*a+v*u,e[4]=g*i+m*s+v*c,e[5]=g*o+m*l+v*h,e[6]=y*r+_*a+x*u,e[7]=y*i+_*s+x*c,e[8]=y*o+_*l+x*h,e}};eK.mul=eK.multiply,eK.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+p*a+u,e[7]=d*i+p*s+c,e[8]=d*o+p*l+h,e},eK.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=Math.sin(n),p=Math.cos(n);return e[0]=p*r+d*a,e[1]=p*i+d*s,e[2]=p*o+d*l,e[3]=p*a-d*r,e[4]=p*s-d*i,e[5]=p*l-d*o,e[6]=u,e[7]=c,e[8]=h,e},eK.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},eK.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},eK.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[3]=c-v,e[6]=d+m,e[1]=c+v,e[4]=1-u-f,e[7]=p-g,e[2]=d-m,e[5]=p+g,e[8]=1-u-h,e},eK.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(l*C-a*I-u*M)*E,e[2]=(a*A-s*C+u*T)*E,e[3]=(i*A-r*I-o*D)*E,e[4]=(n*I-i*C+o*M)*E,e[5]=(r*C-n*A-o*T)*E,e[6]=(g*S-m*w+v*b)*E,e[7]=(m*x-f*S-v*_)*E,e[8]=(f*w-g*x+v*y)*E,e):null},eK.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))};var tK,nK,rK,iK,oK={};oK.create=function(){var e=new YZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},oK.rotationTo=(tK=Dq.create(),nK=Dq.fromValues(1,0,0),rK=Dq.fromValues(0,1,0),function(e,t,n){var r=Dq.dot(t,n);return r<-.999999?(Dq.cross(tK,nK,t),Dq.length(tK)<1e-6&&Dq.cross(tK,rK,t),Dq.normalize(tK,tK),oK.setAxisAngle(e,tK,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Dq.cross(tK,t,n),e[0]=tK[0],e[1]=tK[1],e[2]=tK[2],e[3]=1+r,oK.normalize(e,e))}),oK.setAxes=(iK=eK.create(),function(e,t,n,r){return iK[0]=n[0],iK[3]=n[1],iK[6]=n[2],iK[1]=r[0],iK[4]=r[1],iK[7]=r[2],iK[2]=-t[0],iK[5]=-t[1],iK[8]=-t[2],oK.normalize(e,oK.fromMat3(e,iK))}),oK.clone=Qq.clone,oK.fromValues=Qq.fromValues,oK.copy=Qq.copy,oK.set=Qq.set,oK.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},oK.setAxisAngle=function(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e},oK.add=Qq.add,oK.multiply=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e},oK.mul=oK.multiply,oK.scale=Qq.scale,oK.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},oK.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},oK.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},oK.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},oK.dot=Qq.dot,oK.lerp=Qq.lerp,oK.slerp=function(e,t,n,r){var i,o,a,s,l,u=t[0],c=t[1],h=t[2],d=t[3],p=n[0],f=n[1],g=n[2],m=n[3];return(o=u*p+c*f+h*g+d*m)<0&&(o=-o,p=-p,f=-f,g=-g,m=-m),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*u+l*p,e[1]=s*c+l*f,e[2]=s*h+l*g,e[3]=s*d+l*m,e},oK.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},oK.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},oK.length=Qq.length,oK.len=oK.length,oK.squaredLength=Qq.squaredLength,oK.sqrLen=oK.squaredLength,oK.normalize=Qq.normalize,oK.fromMat3=function(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*o+a]-t[3*a+o])*n,e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e};var aK=function(){this._axisX=new Fq,this._axisY=new Fq,this._axisZ=new Fq,this.array=Cq.create(),this._dirty=!0};aK.prototype={constructor:aK,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Cq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new aK).copy(this)},copy:function(e){return Cq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Cq.determinant(this.array)},fromQuat:function(e){return Cq.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return Cq.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return aK.fromMat2d(this,e),this},frustum:function(e,t,n,r,i,o){return Cq.frustum(this.array,e,t,n,r,i,o),this._dirty=!0,this},identity:function(){return Cq.identity(this.array),this._dirty=!0,this},invert:function(){return Cq.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,n){return Cq.lookAt(this.array,e.array,t.array,n.array),this._dirty=!0,this},mul:function(e){return Cq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Cq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Cq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Cq.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,n,r,i,o){return Cq.ortho(this.array,e,t,n,r,i,o),this._dirty=!0,this},perspective:function(e,t,n,r){return Cq.perspective(this.array,e,t,n,r),this._dirty=!0,this},rotate:function(e,t){return Cq.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return Cq.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return Cq.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return Cq.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Cq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Cq.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return Cq.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:function(){var e=Dq.create(),t=Dq.create(),n=Dq.create(),r=eK.create();return function(i,o,a){var s=this.array;Dq.set(e,s[0],s[1],s[2]),Dq.set(t,s[4],s[5],s[6]),Dq.set(n,s[8],s[9],s[10]);var l=Dq.length(e),u=Dq.length(t),c=Dq.length(n);this.determinant()<0&&(l=-l),i&&i.set(l,u,c),a.set(s[12],s[13],s[14]),eK.fromMat4(r,s),r[0]/=l,r[1]/=l,r[2]/=l,r[3]/=u,r[4]/=u,r[5]/=u,r[6]/=c,r[7]/=c,r[8]/=c,oK.fromMat3(o.array,r),oK.normalize(o.array,o.array),o._dirty=!0,a._dirty=!0}}(),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var sK=Object.defineProperty;if(sK){var lK=aK.prototype;sK(lK,"z",{get:function(){var e=this.array;return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this.array;e=e.array,t[8]=e[0],t[9]=e[1],t[10]=e[2],this._dirty=!0}}),sK(lK,"y",{get:function(){var e=this.array;return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this.array;e=e.array,t[4]=e[0],t[5]=e[1],t[6]=e[2],this._dirty=!0}}),sK(lK,"x",{get:function(){var e=this.array;return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this.array;e=e.array,t[0]=e[0],t[1]=e[1],t[2]=e[2],this._dirty=!0}})}aK.adjoint=function(e,t){return Cq.adjoint(e.array,t.array),e._dirty=!0,e},aK.copy=function(e,t){return Cq.copy(e.array,t.array),e._dirty=!0,e},aK.determinant=function(e){return Cq.determinant(e.array)},aK.identity=function(e){return Cq.identity(e.array),e._dirty=!0,e},aK.ortho=function(e,t,n,r,i,o,a){return Cq.ortho(e.array,t,n,r,i,o,a),e._dirty=!0,e},aK.perspective=function(e,t,n,r,i){return Cq.perspective(e.array,t,n,r,i),e._dirty=!0,e},aK.lookAt=function(e,t,n,r){return Cq.lookAt(e.array,t.array,n.array,r.array),e._dirty=!0,e},aK.invert=function(e,t){return Cq.invert(e.array,t.array),e._dirty=!0,e},aK.mul=function(e,t,n){return Cq.mul(e.array,t.array,n.array),e._dirty=!0,e},aK.multiply=aK.mul,aK.fromQuat=function(e,t){return Cq.fromQuat(e.array,t.array),e._dirty=!0,e},aK.fromRotationTranslation=function(e,t,n){return Cq.fromRotationTranslation(e.array,t.array,n.array),e._dirty=!0,e},aK.fromMat2d=function(e,t){e._dirty=!0;t=t.array;return(e=e.array)[0]=t[0],e[4]=t[2],e[12]=t[4],e[1]=t[1],e[5]=t[3],e[13]=t[5],e},aK.rotate=function(e,t,n,r){return Cq.rotate(e.array,t.array,n,r.array),e._dirty=!0,e},aK.rotateX=function(e,t,n){return Cq.rotateX(e.array,t.array,n),e._dirty=!0,e},aK.rotateY=function(e,t,n){return Cq.rotateY(e.array,t.array,n),e._dirty=!0,e},aK.rotateZ=function(e,t,n){return Cq.rotateZ(e.array,t.array,n),e._dirty=!0,e},aK.scale=function(e,t,n){return Cq.scale(e.array,t.array,n.array),e._dirty=!0,e},aK.transpose=function(e,t){return Cq.transpose(e.array,t.array),e._dirty=!0,e},aK.translate=function(e,t,n){return Cq.translate(e.array,t.array,n.array),e._dirty=!0,e};var uK,cK=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=void 0===r?1:r,this.array=oK.fromValues(e,t,n,r),this._dirty=!0};cK.prototype={constructor:cK,add:function(e){return oK.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return oK.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new cK(this.x,this.y,this.z,this.w)},conjugate:function(){return oK.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return oK.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return oK.dot(this.array,e.array)},fromMat3:function(e){return oK.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:(uK=eK.create(),function(e){return eK.fromMat4(uK,e.array),eK.transpose(uK,uK),oK.fromMat3(this.array,uK),this._dirty=!0,this}),identity:function(){return oK.identity(this.array),this._dirty=!0,this},invert:function(){return oK.invert(this.array,this.array),this._dirty=!0,this},len:function(){return oK.len(this.array)},length:function(){return oK.length(this.array)},lerp:function(e,t,n){return oK.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},mul:function(e){return oK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return oK.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return oK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return oK.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return oK.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return oK.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return oK.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return oK.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return oK.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,n){return oK.setAxes(this.array,e.array,t.array,n.array),this._dirty=!0,this},setAxisAngle:function(e,t){return oK.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,n){return oK.slerp(this.array,e.array,t.array,n),this._dirty=!0,this},sqrLen:function(){return oK.sqrLen(this.array)},squaredLength:function(){return oK.squaredLength(this.array)},fromEuler:function(e,t){return cK.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var hK=Object.defineProperty;if(hK){var dK=cK.prototype;hK(dK,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),hK(dK,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),hK(dK,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),hK(dK,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}cK.add=function(e,t,n){return oK.add(e.array,t.array,n.array),e._dirty=!0,e},cK.set=function(e,t,n,r,i){oK.set(e.array,t,n,r,i),e._dirty=!0},cK.copy=function(e,t){return oK.copy(e.array,t.array),e._dirty=!0,e},cK.calculateW=function(e,t){return oK.calculateW(e.array,t.array),e._dirty=!0,e},cK.conjugate=function(e,t){return oK.conjugate(e.array,t.array),e._dirty=!0,e},cK.identity=function(e){return oK.identity(e.array),e._dirty=!0,e},cK.invert=function(e,t){return oK.invert(e.array,t.array),e._dirty=!0,e},cK.dot=function(e,t){return oK.dot(e.array,t.array)},cK.len=function(e){return oK.length(e.array)},cK.lerp=function(e,t,n,r){return oK.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},cK.slerp=function(e,t,n,r){return oK.slerp(e.array,t.array,n.array,r),e._dirty=!0,e},cK.mul=function(e,t,n){return oK.multiply(e.array,t.array,n.array),e._dirty=!0,e},cK.multiply=cK.mul,cK.rotateX=function(e,t,n){return oK.rotateX(e.array,t.array,n),e._dirty=!0,e},cK.rotateY=function(e,t,n){return oK.rotateY(e.array,t.array,n),e._dirty=!0,e},cK.rotateZ=function(e,t,n){return oK.rotateZ(e.array,t.array,n),e._dirty=!0,e},cK.setAxisAngle=function(e,t,n){return oK.setAxisAngle(e.array,t.array,n),e._dirty=!0,e},cK.normalize=function(e,t){return oK.normalize(e.array,t.array),e._dirty=!0,e},cK.squaredLength=cK.sqrLen=function(e){return oK.sqrLen(e.array)},cK.fromMat3=function(e,t){return oK.fromMat3(e.array,t.array),e._dirty=!0,e},cK.setAxes=function(e,t,n,r){return oK.setAxes(e.array,t.array,n.array,r.array),e._dirty=!0,e},cK.rotationTo=function(e,t,n){return oK.rotationTo(e.array,t.array,n.array),e._dirty=!0,e},cK.fromEuler=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=Math.cos(t[0]/2),o=Math.cos(t[1]/2),a=Math.cos(t[2]/2),s=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2);switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"YXZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"ZXY":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"ZYX":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"YZX":r[0]=s*o*a+i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a-s*l*u;break;case"XZY":r[0]=s*o*a-i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a+s*l*u}};var pK,fK,gK,mK,vK,yK,_K=Dq.set,xK=Dq.copy,bK=function(e,t){this.min=e||new Fq(1/0,1/0,1/0),this.max=t||new Fq(-1/0,-1/0,-1/0),this.vertices=null};bK.prototype={constructor:bK,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,r=t.array,i=n.array;xK(r,e[0]),xK(i,e[0]);for(var o=1;o<e.length;o++){var a=e[o];a[0]<r[0]&&(r[0]=a[0]),a[1]<r[1]&&(r[1]=a[1]),a[2]<r[2]&&(r[2]=a[2]),a[0]>i[0]&&(i[0]=a[0]),a[1]>i[1]&&(i[1]=a[1]),a[2]>i[2]&&(i[2]=a[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return Dq.min(t.array,t.array,e.min.array),Dq.max(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return Dq.max(t.array,t.array,e.min.array),Dq.min(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]<r[0]||n[1]<r[1]||n[2]<r[2])},containBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min.array,n=this.max.array,r=e.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:(pK=Dq.create(),fK=Dq.create(),gK=Dq.create(),mK=Dq.create(),vK=Dq.create(),yK=Dq.create(),function(e,t){var n=e.min.array,r=e.max.array,i=t.array;return pK[0]=i[0]*n[0],pK[1]=i[1]*n[0],pK[2]=i[2]*n[0],fK[0]=i[0]*r[0],fK[1]=i[1]*r[0],fK[2]=i[2]*r[0],gK[0]=i[4]*n[1],gK[1]=i[5]*n[1],gK[2]=i[6]*n[1],mK[0]=i[4]*r[1],mK[1]=i[5]*r[1],mK[2]=i[6]*r[1],vK[0]=i[8]*n[2],vK[1]=i[9]*n[2],vK[2]=i[10]*n[2],yK[0]=i[8]*r[2],yK[1]=i[9]*r[2],yK[2]=i[10]*r[2],n=this.min.array,r=this.max.array,n[0]=Math.min(pK[0],fK[0])+Math.min(gK[0],mK[0])+Math.min(vK[0],yK[0])+i[12],n[1]=Math.min(pK[1],fK[1])+Math.min(gK[1],mK[1])+Math.min(vK[1],yK[1])+i[13],n[2]=Math.min(pK[2],fK[2])+Math.min(gK[2],mK[2])+Math.min(vK[2],yK[2])+i[14],r[0]=Math.max(pK[0],fK[0])+Math.max(gK[0],mK[0])+Math.max(vK[0],yK[0])+i[12],r[1]=Math.max(pK[1],fK[1])+Math.max(gK[1],mK[1])+Math.max(vK[1],yK[1])+i[13],r[2]=Math.max(pK[2],fK[2])+Math.max(gK[2],mK[2])+Math.max(vK[2],yK[2])+i[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(e){var t=this.min.array,n=this.max.array,r=e.array,i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=t[2],c=n[0],h=n[1],d=n[2];if(1===r[15])t[0]=r[0]*i+r[12],t[1]=r[5]*o+r[13],n[2]=r[10]*a+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],t[2]=r[10]*d+r[14];else{var p=-1/a;t[0]=r[0]*i*p,t[1]=r[5]*o*p,n[2]=(r[10]*a+r[14])*p,p=-1/u,n[0]=r[0]*s*p,n[1]=r[5]*l*p,p=-1/d,t[2]=(r[10]*d+r[14])*p}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=Dq.fromValues(0,0,0);this.vertices=e}var n=this.min.array,r=this.max.array;return _K(e[0],n[0],n[1],n[2]),_K(e[1],n[0],r[1],n[2]),_K(e[2],r[0],n[1],n[2]),_K(e[3],r[0],r[1],n[2]),_K(e[4],n[0],n[1],r[2]),_K(e[5],n[0],r[1],r[2]),_K(e[6],r[0],n[1],r[2]),_K(e[7],r[0],r[1],r[2]),this},copy:function(e){var t=this.min,n=this.max;return xK(t.array,e.min.array),xK(n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new bK;return e.copy(this),e}};var wK,SK,TK=0,MK=wY.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+TK++),this.position||(this.position=new Fq),this.rotation||(this.rotation=new cK),this.scale||(this.scale=new Fq(1,1,1)),this.worldTransform=new aK,this.localTransform=new aK,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t<e.length;t++)e[t]._parent=null,this._scene&&e[t].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){for(var t=e._parent;t;){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){for(var t=this._children,n=0;n<t.length;n++)if(t[n].name===e)return t[n]},getDescendantByName:function(e){for(var t=this._children,n=0;n<t.length;n++){var r=t[n];if(r.name===e)return r;var i=r.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(e){for(var t=e.split("/"),n=this,r=0;r<t.length;r++){var i=t[r];if(i){for(var o=!1,a=n._children,s=0;s<a.length;s++){var l=a[s];if(l.name===i){n=l,o=!0;break}}if(!o)return}}return n}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,n=this.name;t._parent&&(n=t.name+"/"+n,t._parent!=e);)t=t._parent;return!t._parent&&e?null:n},traverse:function(e,t){e.call(t,this);for(var n=this._children,r=0,i=n.length;r<i;r++)n[r].traverse(e,t)},eachChild:function(e,t){for(var n=this._children,r=0,i=n.length;r<i;r++){var o=n[r];e.call(t,o,r)}},setLocalTransform:function(e){Cq.copy(this.localTransform.array,e.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){Cq.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:(wK=Cq.create(),function(e){var t=this.localTransform,n=this.worldTransform;this._parent?(Cq.invert(wK,this._parent.worldTransform.array),Cq.multiply(t.array,wK,n.array)):Cq.copy(t.array,n.array);var r=e?null:this.scale;t.decomposeMatrix(r,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var e=this.position,t=this.rotation,n=this.scale;if(this.transformNeedsUpdate()){var r=this.localTransform.array;Cq.fromRotationTranslation(r,t.array,e.array),Cq.scale(r,r,n.array),t._dirty=!1,n._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?Cq.multiplyAffine(t,this._parent.worldTransform.array,e):Cq.copy(t,e)},updateWorldTransform:function(){for(var e=this;e&&e.getParent()&&e.getParent().transformNeedsUpdate();)e=e.getParent();e.update()},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0,(e||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),e=!0,this._needsUpdateWorldTransform=!1);for(var t=this._children,n=0,r=t.length;n<r;n++)t[n].update(e)},getBoundingBox:function(){function e(e){return!e.invisible&&e.geometry}var t=new bK,n=new aK,r=new aK;return function(i,o){return o=o||new bK,this._parent?aK.invert(r,this._parent.worldTransform):aK.identity(r),this.traverse((function(e){e.geometry&&e.geometry.boundingBox&&(t.copy(e.geometry.boundingBox),aK.multiply(n,r,e.worldTransform),t.applyTransform(n),o.union(t))}),this,e),o}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var n=e.array;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e}return new Fq(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var n=0;n<t.length;n++)e.add(t[n].clone());return e},rotateAround:function(){var e=new Fq,t=new aK;return function(n,r,i){e.copy(this.position).subtract(n);var o=this.localTransform;o.identity(),o.translate(n),o.rotate(i,r),t.fromRotationTranslation(this.rotation,e),o.multiply(t),o.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new aK;return function(t,n){e.lookAt(this.position,t,n||this.localTransform.y).invert(),this.setLocalTransform(e),this.target=t}}()}),CK=MK.extend({material:null,geometry:null,mode:PY,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:FY,frontFace:UY,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=MK.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:(SK=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var e=MK.prototype.clone.call(this);e.geometry=this.geometry,e.material=this.material;for(var t=0;t<SK.length;t++){var n=SK[t];e[n]!==this[n]&&(e[n]=this[n])}return e})});CK.POINTS=IY,CK.LINES=EY,CK.LINE_LOOP=LY,CK.LINE_STRIP=NY,CK.TRIANGLES=PY,CK.TRIANGLE_STRIP=OY,CK.TRIANGLE_FAN=RY,CK.BACK=FY,CK.FRONT=BY,CK.FRONT_AND_BACK=GY,CK.CW=HY,CK.CCW=UY;var DK=wY.extend({scene:null,camera:null,renderer:null},(function(){this._ray=new Jq,this._ndc=new KZ}),{pick:function(e,t,n){return this.pickAll(e,t,[],n)[0]||null},pickAll:function(e,t,n,r){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),n=n||[],this._intersectNode(this.scene,n,r||!1),n.sort(this._intersectionCompareFunc),n},_intersectNode:function(e,t,n){e instanceof CK&&e.isRenderable()&&(e.ignorePicking&&!n||!(e.mode===PY&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)||this._intersectRenderable(e,t));for(var r=0;r<e._children.length;r++)this._intersectNode(e._children[r],t,n)},_intersectRenderable:function(){var e=new Fq,t=new Fq,n=new Fq,r=new Jq,i=new aK;return function(o,a){var s=o.isSkinnedMesh();r.copy(this._ray),aK.invert(i,o.worldTransform),s||r.applyTransform(i);var l=o.geometry,u=s?o.skeleton.boundingBox:l.boundingBox;if(!u||r.intersectBoundingBox(u))if(l.pick)l.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,o,a);else if(l.pickByRay)l.pickByRay(r,o,a);else{var c,h,d=o.cullFace===FY&&o.frontFace===UY||o.cullFace===BY&&o.frontFace===HY,p=l.indices,f=l.attributes.position,g=l.attributes.weight,m=l.attributes.joint,v=[];if(f&&f.value&&p){if(s){h=o.skeleton.getSubSkinMatrices(o.__uid__,o.joints);for(var y=0;y<o.joints.length;y++){v[y]=v[y]||[];for(var _=0;_<16;_++)v[y][_]=h[16*y+_]}var x=[],b=[],w=[],S=[],T=[],M=l.attributes.skinnedPosition;M&&M.value||(l.createAttribute("skinnedPosition","f",3),(M=l.attributes.skinnedPosition).init(l.vertexCount));for(y=0;y<l.vertexCount;y++){f.get(y,x),g.get(y,b),m.get(y,w),b[3]=1-b[0]-b[1]-b[2],Dq.set(S,0,0,0);for(_=0;_<4;_++)w[_]>=0&&b[_]>1e-4&&(Dq.transformMat4(T,x,v[w[_]]),Dq.scaleAndAdd(S,S,T,b[_]));M.set(y,S)}}for(y=0;y<p.length;y+=3){var C=p[y],D=p[y+1],A=p[y+2],I=s?l.attributes.skinnedPosition:f;if(I.get(C,e.array),I.get(D,t.array),I.get(A,n.array),c=d?r.intersectTriangle(e,t,n,o.culling):r.intersectTriangle(e,n,t,o.culling)){var E=new Fq;s?Fq.copy(E,c):Fq.transformMat4(E,c,o.worldTransform),a.push(new DK.Intersection(c,E,o,[C,D,A],y/3,Fq.dist(E,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});DK.Intersection=function(e,t,n,r,i,o){this.point=e,this.pointWorld=t,this.target=n,this.triangle=r,this.triangleIndex=i,this.distance=o};var AK="__dt__",IK=function(){this._contextId=0,this._caches=[],this._context={}};IK.prototype={use:function(e,t){var n=this._caches;n[e]||(n[e]={},t&&(n[e]=t())),this._contextId=e,this._context=n[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){var t=AK+(e=e||"");this.put(t,!0)},dirtyAll:function(e){for(var t=AK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!0)},fresh:function(e){var t=AK+(e=e||"");this.put(t,!1)},freshAll:function(e){for(var t=AK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!1)},isDirty:function(e){var t=AK+(e=e||""),n=this._context;return!n.hasOwnProperty(t)||!0===n[t]},deleteContext:function(e){delete this._caches[e],this._context={}},delete:function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(e,t){Object.keys(this._caches).forEach((function(n){e&&e.call(t,n)}))},miss:function(e){return!this._context.hasOwnProperty(e)}},IK.prototype.constructor=IK;var EK=wY.extend({width:512,height:512,type:jY,format:eZ,wrapS:hZ,wrapT:hZ,minFilter:lZ,magFilter:iZ,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},(function(){this._cache=new IK}),{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__uid__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===$Y&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==EK.SRGB||n||(this.format=EK.RGB),this.format!==EK.SRGB_ALPHA||n||(this.format=EK.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?dZ:this.wrapS},getAvailableWrapT:function(){return this.NPOT?dZ:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===oZ||e===sZ?rZ:e===lZ||e===aZ?iZ:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(EK.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(EK.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),EK.BYTE=WY,EK.UNSIGNED_BYTE=jY,EK.SHORT=XY,EK.UNSIGNED_SHORT=YY,EK.INT=ZY,EK.UNSIGNED_INT=qY,EK.FLOAT=KY,EK.HALF_FLOAT=36193,EK.UNSIGNED_INT_24_8_WEBGL=34042,EK.DEPTH_COMPONENT=$Y,EK.DEPTH_STENCIL=mZ,EK.ALPHA=JY,EK.RGB=QY,EK.RGBA=eZ,EK.LUMINANCE=tZ,EK.LUMINANCE_ALPHA=nZ,EK.SRGB=35904,EK.SRGB_ALPHA=35906,EK.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,EK.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,EK.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,EK.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,EK.NEAREST=rZ,EK.LINEAR=iZ,EK.NEAREST_MIPMAP_NEAREST=oZ,EK.LINEAR_MIPMAP_NEAREST=aZ,EK.NEAREST_MIPMAP_LINEAR=sZ,EK.LINEAR_MIPMAP_LINEAR=lZ,EK.REPEAT=hZ,EK.CLAMP_TO_EDGE=dZ,EK.MIRRORED_REPEAT=pZ;var LK=CK.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=CK.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});LK.POINTS=IY,LK.LINES=EY,LK.LINE_LOOP=LY,LK.LINE_STRIP=NY,LK.TRIANGLES=PY,LK.TRIANGLE_STRIP=OY,LK.TRIANGLE_FAN=RY,LK.BACK=FY,LK.FRONT=BY,LK.FRONT_AND_BACK=GY,LK.CW=HY,LK.CCW=UY;var NK={isPowerOfTwo:function(e){return!(e&e-1)},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}},PK=NK.isPowerOfTwo;function OK(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}var RK=EK.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==EK.REPEAT&&this.wrapT!==EK.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var o=e.getGLExtension("EXT_texture_filter_anisotropic");(o&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,o.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=KY));if(this.mipmaps.length)for(var a=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,a,s,n,r,!1),a/=2,s/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r,i),!this.useMipmap||this.NPOT&&!i||t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,n,r,i,o,a,s){if(t.image){var l=t.image;s&&(this._potCanvas=function(e,t){var n=OK(e.width),r=OK(e.height);return(t=t||document.createElement("canvas")).width=n,t.height=r,t.getContext("2d").drawImage(e.image,0,0,n,r),t}(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,n,o,o,a,l)}else o<=EK.COMPRESSED_RGBA_S3TC_DXT5_EXT&&o>=EK.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,r,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,r,i,0,o,a,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return PK(this.width)&&PK(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=SZ.createImage();t&&(n.crossOrigin=t);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r)},n.onerror=function(){r.trigger("error",r)},n.src=e,this.image=n,this}});function kK(e){return{byte:SZ.Int8Array,ubyte:SZ.Uint8Array,short:SZ.Int16Array,ushort:SZ.Uint16Array}[e]||SZ.Float32Array}function zK(e){return"attr_"+e}function VK(e,t,n,r){switch(this.name=e,this.type=t,this.size=n,this.semantic=r||"",this.value=null,n){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var n=this.value;return t[0]=n[2*e],t[1]=n[2*e+1],t},this.set=function(e,t){var n=this.value;n[2*e]=t[0],n[2*e+1]=t[1]},this.copy=function(e,t){var n=this.value;t*=2,n[e*=2]=n[t],n[e+1]=n[t+1]};break;case 3:this.get=function(e,t){var n=3*e,r=this.value;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t},this.set=function(e,t){var n=3*e,r=this.value;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2]},this.copy=function(e,t){var n=this.value;t*=3,n[e*=3]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2]};break;case 4:this.get=function(e,t){var n=this.value,r=4*e;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t},this.set=function(e,t){var n=this.value,r=4*e;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2],n[r+3]=t[3]},this.copy=function(e,t){var n=this.value;t*=4,n[e*=4]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2],n[e+3]=n[t+3]}}}function BK(e,t,n,r,i){this.name=e,this.type=t,this.buffer=n,this.size=r,this.semantic=i,this.symbol="",this.needsRemove=!1}function FK(e){this.buffer=e,this.count=0}Object.defineProperty(RK.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(RK.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),VK.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=kK(this.type);this.value=new t(e*this.size)}},VK.prototype.fromArray=function(e){var t,n=kK(this.type);if(e[0]&&e[0].length){var r=0,i=this.size;t=new n(e.length*i);for(var o=0;o<e.length;o++)for(var a=0;a<i;a++)t[r++]=e[o][a]}else t=new n(e);this.value=t},VK.prototype.clone=function(e){var t=new VK(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};var GK=wY.extend((function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}}),(function(){this._cache=new IK,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}}),{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t<e.length;t++)this.dirtyAttribute(e[t]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(e){this._cache.dirtyAll(zK(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?SZ.Uint32Array:SZ.Uint16Array;if(e[0]&&e[0].length){var r=0;t=new n(3*e.length);for(var i=0;i<e.length;i++)for(var o=0;o<3;o++)t[r++]=e[i][o]}else t=new n(e);this.indices=t},createAttribute:function(e,t,n,r){var i=new VK(e,t,n,r);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,n=t.indexOf(e);return n>=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],r=this.vertexCount,i=0;i<t.length;i++){var o=t[i],a=this.attributes[o];a.value&&a.value.length===r*a.size&&n.push(o)}return this._enabledAttributes=n,n},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var n=t.isDirty("attributes"),r=t.isDirty("indices");if(n||r){this._updateBuffer(e.gl,n,r);for(var i=this.getEnabledAttributes(),o=0;o<i.length;o++)t.fresh(zK(i[o]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,n){var r=this._cache,i=r.get("chunks"),o=!1;i||((i=[])[0]={attributeBuffers:[],indicesBuffer:null},r.put("chunks",i),o=!0);var a=i[0],s=a.attributeBuffers,l=a.indicesBuffer;if(t||o){var u=this.getEnabledAttributes(),c={};if(!o)for(var h=0;h<s.length;h++)c[s[h].name]=s[h];for(var d=0;d<u.length;d++){var p,f,g=u[d],m=this.attributes[g];o||(p=c[g]),f=p?p.buffer:e.createBuffer(),r.isDirty(zK(g))&&(e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,m.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),s[d]=new BK(g,m.type,f,m.size,m.semantic)}for(h=d;h<s.length;h++)e.deleteBuffer(s[h].buffer);s.length=d}this.isUseIndices()&&(n||o)&&(l||(l=new FK(e.createBuffer()),a.indicesBuffer=l),l.count=this.indices.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW))},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});Object.defineProperty&&(Object.defineProperty(GK.prototype,"vertexCount",{enumerable:!1,get:function(){var e=this.attributes[this.mainAttribute];return e||(e=this.attributes[this._attributeList[0]]),e&&e.value?e.value.length/e.size:0}}),Object.defineProperty(GK.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}})),GK.STATIC_DRAW=zY,GK.DYNAMIC_DRAW=VY,GK.STREAM_DRAW=kY,GK.AttributeBuffer=BK,GK.IndicesBuffer=FK,GK.Attribute=VK;var HK=Dq.create,UK=Dq.add,WK=Dq.set,jK=GK.Attribute,XK=GK.extend((function(){return{attributes:{position:new jK("position","float",3,"POSITION"),texcoord0:new jK("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new jK("texcoord1","float",2,"TEXCOORD_1"),normal:new jK("normal","float",3,"NORMAL"),tangent:new jK("tangent","float",4,"TANGENT"),color:new jK("color","float",4,"COLOR"),weight:new jK("weight","float",3,"WEIGHT"),joint:new jK("joint","float",4,"JOINT"),barycentric:new jK("barycentric","float",3,null)},boundingBox:null}}),{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new bK);var t=this.attributes.position.value;if(t&&t.length){var n=e.min,r=e.max,i=n.array,o=r.array;Dq.set(i,t[0],t[1],t[2]),Dq.set(o,t[0],t[1],t[2]);for(var a=3;a<t.length;){var s=t[a++],l=t[a++],u=t[a++];s<i[0]&&(i[0]=s),l<i[1]&&(i[1]=l),u<i[2]&&(i[2]=u),s>o[0]&&(o[0]=s),l>o[1]&&(o[1]=l),u>o[2]&&(o[2]=u)}n._dirty=!0,r._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value;if(r&&r.length===n.length)for(var i=0;i<r.length;i++)r[i]=0;else r=t.normal.value=new SZ.Float32Array(n.length);for(var o,a,s,l=HK(),u=HK(),c=HK(),h=HK(),d=HK(),p=HK(),f=e?e.length:this.vertexCount,g=0;g<f;){e?(o=e[g++],a=e[g++],s=e[g++]):(o=g++,a=g++,s=g++),WK(l,n[3*o],n[3*o+1],n[3*o+2]),WK(u,n[3*a],n[3*a+1],n[3*a+2]),WK(c,n[3*s],n[3*s+1],n[3*s+2]),Dq.sub(h,l,u),Dq.sub(d,u,c),Dq.cross(p,h,d);for(i=0;i<3;i++)r[3*o+i]=r[3*o+i]+p[i],r[3*a+i]=r[3*a+i]+p[i],r[3*s+i]=r[3*s+i]+p[i]}for(i=0;i<r.length;)WK(p,r[i],r[i+1],r[i+2]),Dq.normalize(p,p),r[i++]=p[0],r[i++]=p[1],r[i++]=p[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value,i=HK(),o=HK(),a=HK(),s=HK(),l=HK(),u=HK();r||(r=t.normal.value=new Float32Array(n.length));for(var c,h,d,p=e?e.length:this.vertexCount,f=0;f<p;){e?(c=e[f++],h=e[f++],d=e[f++]):(c=f++,h=f++,d=f++),WK(i,n[3*c],n[3*c+1],n[3*c+2]),WK(o,n[3*h],n[3*h+1],n[3*h+2]),WK(a,n[3*d],n[3*d+1],n[3*d+2]),Dq.sub(s,i,o),Dq.sub(l,o,a),Dq.cross(u,s,l),Dq.normalize(u,u);for(var g=0;g<3;g++)r[3*c+g]=u[g],r[3*h+g]=u[g],r[3*d+g]=u[g]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var e=this.vertexCount,t=this.attributes;t.tangent.value||(t.tangent.value=new Float32Array(4*e));var n=t.texcoord0.value,r=t.position.value,i=t.tangent.value,o=t.normal.value;if(n){for(var a=[],s=[],l=0;l<e;l++)a[l]=[0,0,0],s[l]=[0,0,0];var u,c,h,d=[0,0,0],p=[0,0,0],f=this.indices,g=f?f.length:this.vertexCount;for(l=0;l<g;){f?(u=f[l++],c=f[l++],h=f[l++]):(u=l++,c=l++,h=l++);var m=n[2*u],v=n[2*c],y=n[2*h],_=n[2*u+1],x=n[2*c+1],b=n[2*h+1],w=r[3*u],S=r[3*c],T=r[3*h],M=r[3*u+1],C=r[3*c+1],D=r[3*h+1],A=r[3*u+2],I=S-w,E=T-w,L=C-M,N=D-M,P=r[3*c+2]-A,O=r[3*h+2]-A,R=v-m,k=y-m,z=x-_,V=b-_,B=1/(R*V-z*k);d[0]=(V*I-z*E)*B,d[1]=(V*L-z*N)*B,d[2]=(V*P-z*O)*B,p[0]=(R*E-k*I)*B,p[1]=(R*N-k*L)*B,p[2]=(R*O-k*P)*B,UK(a[u],a[u],d),UK(a[c],a[c],d),UK(a[h],a[h],d),UK(s[u],s[u],p),UK(s[c],s[c],p),UK(s[h],s[h],p)}var F=HK(),G=HK(),H=HK();for(l=0;l<e;l++){H[0]=o[3*l],H[1]=o[3*l+1],H[2]=o[3*l+2];var U=a[l];Dq.scale(F,H,Dq.dot(H,U)),Dq.sub(F,U,F),Dq.normalize(F,F),Dq.cross(G,H,U),i[4*l]=F[0],i[4*l+1]=F[1],i[4*l+2]=F[2],i[4*l+3]=Dq.dot(G,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new SZ.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),r={},i=0;i<n.length;i++){r[l=n[i]]=e[l].value,e[l].init(this.indices.length)}for(var o=0,a=0;a<t.length;a++){var s=t[a];for(i=0;i<n.length;i++)for(var l,u=e[l=n[i]].value,c=e[l].size,h=0;h<c;h++)u[o*c+h]=r[l][s*c+h];t[a]=o,o++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,n=this.indices;if(!t||t.length!==3*n.length){t=e.barycentric.value=new Float32Array(3*n.length);for(var r=0;r<(n?n.length:this.vertexCount/3);)for(var i=0;i<3;i++){t[3*(n?n[r++]:3*r+i)+i]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,n=t.position.value,r=t.normal.value,i=t.tangent.value;e=e.array;var o=Cq.create();Cq.invert(o,e),Cq.transpose(o,o);var a=Dq.transformMat4,s=Dq.forEach;s(n,3,0,null,a,e),r&&s(r,3,0,null,a,o),i&&s(i,4,0,null,a,o),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});XK.STATIC_DRAW=GK.STATIC_DRAW,XK.DYNAMIC_DRAW=GK.DYNAMIC_DRAW,XK.STREAM_DRAW=GK.STREAM_DRAW,XK.AttributeBuffer=GK.AttributeBuffer,XK.IndicesBuffer=GK.IndicesBuffer,XK.Attribute=jK;var YK="uniform vec3 ",ZK="uniform float ",qK="@export clay.header.",KK="@end",$K=":unconfigurable;",JK=[qK+"directional_light",YK+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+$K,YK+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+$K,KK,qK+"ambient_light",YK+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+$K,KK,qK+"ambient_sh_light",YK+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+$K,YK+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+$K,"vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",KK,qK+"ambient_cubemap_light",YK+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,KK,qK+"point_light",YK+"pointLightPosition[POINT_LIGHT_COUNT]"+$K,ZK+"pointLightRange[POINT_LIGHT_COUNT]"+$K,YK+"pointLightColor[POINT_LIGHT_COUNT]"+$K,KK,qK+"spot_light",YK+"spotLightPosition[SPOT_LIGHT_COUNT]"+$K,YK+"spotLightDirection[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightRange[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+$K,YK+"spotLightColor[SPOT_LIGHT_COUNT]"+$K,KK].join("\n");wq.import(JK);var QK,e$,t$,n$,r$=MK.extend((function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}}),{type:"",clone:function(){var e=MK.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}}),i$=function(e,t){this.normal=e||new Fq(0,1,0),this.distance=t||0};i$.prototype={constructor:i$,distanceToPoint:function(e){return Dq.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new Fq);var n=this.distanceToPoint(e);return Dq.scaleAndAdd(t.array,e.array,this.normal.array,-n),t._dirty=!0,t},normalize:function(){var e=1/Dq.len(this.normal.array);Dq.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,n=this.normal.array,r=Dq.dot(t[0].array,n)>this.distance,i=1;i<8;i++)if(Dq.dot(t[i].array,n)>this.distance!=r)return!0},intersectLine:(n$=Dq.create(),function(e,t,n){var r=this.distanceToPoint(e),i=this.distanceToPoint(t);if(r>0&&i>0||r<0&&i<0)return null;var o=this.normal.array,a=this.distance,s=e.array;Dq.sub(n$,t.array,e.array),Dq.normalize(n$,n$);var l=Dq.dot(o,n$);if(0===l)return null;n||(n=new Fq);var u=(Dq.dot(o,s)-a)/l;return Dq.scaleAndAdd(n.array,s,n$,-u),n._dirty=!0,n}),applyTransform:(QK=Cq.create(),e$=Qq.create(),t$=Qq.create(),t$[3]=1,function(e){e=e.array,Dq.scale(t$,this.normal.array,this.distance),Qq.transformMat4(t$,t$,e),this.distance=Dq.dot(t$,this.normal.array),Cq.invert(QK,e),Cq.transpose(QK,QK),e$[3]=0,Dq.copy(e$,this.normal.array),Qq.transformMat4(e$,e$,QK),Dq.copy(this.normal.array,e$)}),copy:function(e){Dq.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new i$;return e.copy(this),e}};var o$,a$=Dq.set,s$=Dq.copy,l$=Dq.transformMat4,u$=Math.min,c$=Math.max,h$=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new i$);this.boundingBox=new bK,this.vertices=[];for(e=0;e<8;e++)this.vertices[e]=Dq.fromValues(0,0,0)};h$.prototype={setFromProjection:function(e){var t=this.planes,n=e.array,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],d=n[9],p=n[10],f=n[11],g=n[12],m=n[13],v=n[14],y=n[15];a$(t[0].normal.array,a-r,c-s,f-h),t[0].distance=-(y-g),t[0].normalize(),a$(t[1].normal.array,a+r,c+s,f+h),t[1].distance=-(y+g),t[1].normalize(),a$(t[2].normal.array,a+i,c+l,f+d),t[2].distance=-(y+m),t[2].normalize(),a$(t[3].normal.array,a-i,c-l,f-d),t[3].distance=-(y-m),t[3].normalize(),a$(t[4].normal.array,a-o,c-u,f-p),t[4].distance=-(y-v),t[4].normalize(),a$(t[5].normal.array,a+o,c+u,f+p),t[5].distance=-(y+v),t[5].normalize();var _=this.boundingBox,x=this.vertices;if(0===y){var b=l/r,w=-v/(p-1),S=-v/(p+1),T=-S/l,M=-w/l;_.min.set(-T*b,-T,S),_.max.set(T*b,T,w),a$(x[0],-T*b,-T,S),a$(x[1],-T*b,T,S),a$(x[2],T*b,-T,S),a$(x[3],T*b,T,S),a$(x[4],-M*b,-M,w),a$(x[5],-M*b,M,w),a$(x[6],M*b,-M,w),a$(x[7],M*b,M,w)}else{var C=(-1-g)/r,D=(1-g)/r,A=(1-m)/l,I=(-1-m)/l,E=(-1-v)/p,L=(1-v)/p;_.min.set(Math.min(C,D),Math.min(I,A),Math.min(L,E)),_.max.set(Math.max(D,C),Math.max(A,I),Math.max(E,L));var N=_.min.array,P=_.max.array;a$(x[0],N[0],N[1],N[2]),a$(x[1],N[0],P[1],N[2]),a$(x[2],P[0],N[1],N[2]),a$(x[3],P[0],P[1],N[2]),a$(x[4],N[0],N[1],P[2]),a$(x[5],N[0],P[1],P[2]),a$(x[6],P[0],N[1],P[2]),a$(x[7],P[0],P[1],P[2])}},getTransformedBoundingBox:(o$=Dq.create(),function(e,t){var n=this.vertices,r=t.array,i=e.min,o=e.max,a=i.array,s=o.array,l=n[0];l$(o$,l,r),s$(a,o$),s$(s,o$);for(var u=1;u<8;u++)l=n[u],l$(o$,l,r),a[0]=u$(o$[0],a[0]),a[1]=u$(o$[1],a[1]),a[2]=u$(o$[2],a[2]),s[0]=c$(o$[0],s[0]),s[1]=c$(o$[1],s[1]),s[2]=c$(o$[2],s[2]);return i._dirty=!0,o._dirty=!0,e})};var d$,p$=MK.extend((function(){return{projectionMatrix:new aK,invProjectionMatrix:new aK,viewMatrix:new aK,frustum:new h$}}),(function(){this.update(!0)}),{update:function(e){MK.prototype.update.call(this,e),aK.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),aK.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){aK.copy(this.viewMatrix,e),aK.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){aK.copy(this.projectionMatrix,e),aK.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(d$=Qq.create(),function(e,t){var n=void 0!==t?t:new Jq,r=e.array[0],i=e.array[1];return Qq.set(d$,r,i,-1,1),Qq.transformMat4(d$,d$,this.invProjectionMatrix.array),Qq.transformMat4(d$,d$,this.worldTransform.array),Dq.scale(n.origin.array,d$,1/d$[3]),Qq.set(d$,r,i,1,1),Qq.transformMat4(d$,d$,this.invProjectionMatrix.array),Qq.transformMat4(d$,d$,this.worldTransform.array),Dq.scale(d$,d$,1/d$[3]),Dq.sub(n.direction.array,d$,n.origin.array),Dq.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n})}),f$=Cq.create(),g$=Cq.create(),m$={};function v$(e){var t=[],n=Object.keys(e);n.sort();for(var r=0;r<n.length;r++){var i=n[r];t.push(i+" "+e[i])}var o=t.join("\n");if(m$[o])return m$[o];var a=bY.genGUID();return m$[o]=a,a}function y$(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}y$.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},y$.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e},y$.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var _$,x$,b$=MK.extend((function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new bK,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new CZ(20)}}),(function(){this._scene=this}),{addToScene:function(e){e instanceof p$?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof r$&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof p$?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof r$&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},n=0;n<e.length;n++){var r=e[n];if(!r.invisible){var i=r.group;t[i]||(t[i]={}),t[i][r.type]=t[i][r.type]||0,t[i][r.type]++}}for(var o in this._lightNumber=t,t)this._lightProgramKeys[o]=v$(t[o]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),n={};return function e(t,r){n[t.__uid__]=r;for(var i=0;i<t._children.length;i++){e(t._children[i],r._children[i])}}(e,t),t.traverse((function(e){e.skeleton&&(e.skeleton=e.skeleton.clone(n)),e.material&&(e.material=e.material.clone())})),t},updateRenderList:function(e,t){var n=e.__uid__,r=this._renderLists.get(n);r||(r=new y$,this._renderLists.put(n,r)),r.startCount(),t&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var i=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,e,i,r,t),r.endCount(),r},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,n,r,i){if(!e.invisible)for(var o=0;o<e._children.length;o++){var a=e._children[o];if(a.isRenderable()){var s=a.isSkinnedMesh()?f$:a.worldTransform.array,l=a.geometry;Cq.multiplyAffine(g$,t.viewMatrix.array,s),(i&&!l.boundingBox||!this.isFrustumCulled(a,t,g$))&&r.add(a,a.material.transparent||n)}a._children.length>0&&this._doUpdateRenderList(a,t,n,r,i)}},isFrustumCulled:(_$=new bK,x$=new aK,function(e,t,n){var r=e.boundingBox;if(r||(r=e.skeleton&&e.skeleton.boundingBox?e.skeleton.boundingBox:e.geometry.boundingBox),!r)return!1;if(x$.array=n,_$.transformFrom(r,x$),e.castShadow&&this.viewBoundingBoxLastFrame.union(_$),e.frustumCulling){if(!_$.intersectBoundingBox(t.frustum.boundingBox))return!0;x$.array=t.projectionMatrix.array,_$.max.array[2]>0&&_$.min.array[2]<0&&(_$.max.array[2]=-1e-20),_$.applyProjection(x$);var i=_$.min.array,o=_$.max.array;if(o[0]<-1||i[0]>1||o[1]<-1||i[1]>1||o[2]<-1||i[2]>1)return!0}return!1}),_updateLightUniforms:function(){var e=this.lights;e.sort(w$);var t=this._lightUniforms;for(var n in t)for(var r in t[n])t[n][r].value.length=0;for(var i=0;i<e.length;i++){var o=e[i];if(!o.invisible){n=o.group;for(var r in o.uniformTemplates){var a=o.uniformTemplates[r],s=a.value(o);if(null!=s){t[n]||(t[n]={}),t[n][r]||(t[n][r]={type:"",value:[]});var l=t[n][r];switch(l.type=a.type+"v",a.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var u=0;u<s.length;u++)l.value.push(s[u]);break;default:console.error("Unkown light uniform type "+a.type)}}}}}},getLightGroups:function(){var e=[];for(var t in this._lightNumber)e.push(t);return e},getNumberChangedLightGroups:function(){var e=[];for(var t in this._lightNumber)this.isLightNumberChanged(t)&&e.push(t);return e},isLightNumberChanged:function(e){var t=this._previousLightNumber,n=this._lightNumber;for(var r in n[e]){if(!t[e])return!0;if(n[e][r]!==t[e][r])return!0}for(var r in t[e]){if(!n[e])return!0;if(n[e][r]!==t[e][r])return!0}return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(e,t,n){for(var r in e){var i=e[r];if("tv"===i.type){if(!t.hasUniform(r))continue;for(var o=[],a=0;a<i.value.length;a++){var s=i.value[a],l=t.takeCurrentTextureSlot(n,s);o.push(l)}t.setUniform(n.gl,"1iv",r,o)}else t.setUniform(n.gl,i.type,r,i.value)}}return function(t,n,r){e(this._lightUniforms[n],t,r),e(this.shadowUniforms,t,r)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function w$(e,t){if(t.castShadow&&!e.castShadow)return!0}var S$=function(e){this.value=e},T$=function(){function e(){this._len=0}return e.prototype.insert=function(e){var t=new S$(e);return this.insertEntry(t),t},e.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e):this.head=this.tail=e,this._len++},e.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._len--},e.prototype.len=function(){return this._len},e.prototype.clear=function(){this.head=this.tail=null,this._len=0},e}(),M$=function(){function e(e){this._list=new T$,this._maxSize=10,this._map={},this._maxSize=e}return e.prototype.put=function(e,t){var n=this._list,r=this._map,i=null;if(null==r[e]){var o=n.len(),a=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var s=n.head;n.remove(s),delete r[s.key],i=s.value,this._lastRemovedEntry=s}a?a.value=t:a=new S$(t),a.key=e,n.insertEntry(a),r[e]=a}return i},e.prototype.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},e.prototype.clear=function(){this._list.clear(),this._map={}},e.prototype.len=function(){return this._list.len()},e}(),C$=NK.isPowerOfTwo,D$=["px","nx","py","ny","pz","nz"],A$=EK.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=KY));if(this.mipmaps.length)for(var o=this.width,a=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(t,l,s,o,a,n,r),o/=2,a/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,n,r,i,o,a){for(var s=0;s<6;s++){var l=D$[s],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,o,a,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,r,i,0,o,a,t.pixels&&t.pixels[l])}},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_CUBE_MAP))},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?C$(this.image.px.width)&&C$(this.image.px.height):C$(this.width)&&C$(this.height)},isRenderable:function(){return this.image.px?I$(this.image.px)&&I$(this.image.nx)&&I$(this.image.py)&&I$(this.image.ny)&&I$(this.image.pz)&&I$(this.image.nz):!(!this.width||!this.height)},load:function(e,t){var n=0,r=this;return bY.each(e,(function(e,i){var o=SZ.createImage();t&&(o.crossOrigin=t),o.onload=function(){0===--n&&(r.dirty(),r.trigger("success",r))},o.onerror=function(){n--},n++,o.src=e,r.image[i]=o})),this}});function I$(e){return e.width>0&&e.height>0}Object.defineProperty(A$.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(A$.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});var E$=p$.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=p$.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),L$="framebuffer",N$="renderbuffer",P$=N$+"_width",O$=N$+"_height",R$=N$+"_attached",k$="depthtexture_attached",z$=fZ,V$=gZ,B$=yZ,F$=vZ,G$=wY.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new IK,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(e){if(e.__currentFrameBuffer){if(e.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}e.__currentFrameBuffer=this;var t=e.gl;t.bindFramebuffer(z$,this._getFrameBufferGL(e)),this._boundRenderer=e;var n=this._cache;n.put("viewport",e.viewport);var r,i,o=!1;for(var a in this._textures){o=!0;var s=this._textures[a];s&&(r=s.texture.width,i=s.texture.height,this._doAttach(e,s.texture,a,s.target))}this._width=r,this._height=i,!o&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?e.setViewport(this.viewport):e.setViewport(0,0,r,i,1);var l=n.get("attached_textures");if(l)for(var a in l)if(!this._textures[a]){var u=l[a];this._doDetach(t,a,u)}if(!n.get(k$)&&this.depthBuffer){n.miss(N$)&&n.put(N$,t.createRenderbuffer());var c=n.get(N$);r===n.get(P$)&&i===n.get(O$)||(t.bindRenderbuffer(V$,c),t.renderbufferStorage(V$,t.DEPTH_COMPONENT16,r,i),n.put(P$,r),n.put(O$,i),t.bindRenderbuffer(V$,null)),n.get(R$)||(t.framebufferRenderbuffer(z$,B$,V$,c),n.put(R$,!0))}},unbind:function(e){e.__currentFrameBuffer=null,e.gl.bindFramebuffer(z$,null),this._boundRenderer=null,this._cache.use(e.__uid__);var t=this._cache.get("viewport");t&&e.setViewport(t),this.updateMipmap(e)},updateMipmap:function(e){var t=e.gl;for(var n in this._textures){var r=this._textures[n];if(r){var i=r.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===EK.LINEAR_MIPMAP_LINEAR){var o="textureCube"===i.textureType?cZ:uZ;t.bindTexture(o,i.getWebGLTexture(e)),t.generateMipmap(o),t.bindTexture(o,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(z$)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(L$)&&t.put(L$,e.gl.createFramebuffer()),t.get(L$)},attach:function(e,t,n){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||F$,n=n||uZ;var r,i=this._boundRenderer;if(i&&i.gl){var o=this._cache;o.use(i.__uid__),r=o.get("attached_textures")}var a=this._textures[t];if(!a||a.target!==n||a.texture!==e||!r||null==r[t]){var s=!0;i&&(s=this._doAttach(i,e,t,n),this.viewport||i.setViewport(0,0,e.width,e.height,1)),s&&(this._textures[t]=this._textures[t]||{},this._textures[t].texture=e,this._textures[t].target=n)}},_doAttach:function(e,t,n,r){var i=e.gl,o=t.getWebGLTexture(e),a=this._cache.get("attached_textures");if(a&&a[n]){var s=a[n];if(s.texture===t&&s.target===r)return}var l=!0;if(((n=+n)===B$||n===xZ)&&(e.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==$Y&&t.format!==mZ&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var u=this._cache.get(N$);u&&(i.framebufferRenderbuffer(z$,B$,V$,null),i.deleteRenderbuffer(u),this._cache.put(N$,!1)),this._cache.put(R$,!1),this._cache.put(k$,!0)}return i.framebufferTexture2D(z$,n,r,o,0),a||(a={},this._cache.put("attached_textures",a)),a[n]=a[n]||{},a[n].texture=t,a[n].target=r,l},_doDetach:function(e,t,n){e.framebufferTexture2D(z$,t,n,null,0);var r=this._cache.get("attached_textures");r&&r[t]&&(r[t]=null),t!==B$&&t!==xZ||this._cache.put(k$,!1)},detach:function(e,t){(this._textures[e]=null,this._boundRenderer)&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,e,t))},dispose:function(e){var t=e.gl,n=this._cache;n.use(e.__uid__);var r=n.get(N$);r&&t.deleteRenderbuffer(r);var i=n.get(L$);i&&t.deleteFramebuffer(i),n.deleteContext(e.__uid__),this._textures={}}});G$.DEPTH_ATTACHMENT=B$,G$.COLOR_ATTACHMENT0=F$,G$.STENCIL_ATTACHMENT=_Z,G$.DEPTH_STENCIL_ATTACHMENT=xZ;var H$=["px","nx","py","ny","pz","nz"],U$=wY.extend((function(){var e={position:new Fq,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new E$({fov:90}),nx:new E$({fov:90}),py:new E$({fov:90}),ny:new E$({fov:90}),pz:new E$({fov:90}),nz:new E$({fov:90})};return t.px.lookAt(Fq.POSITIVE_X,Fq.NEGATIVE_Y),t.nx.lookAt(Fq.NEGATIVE_X,Fq.NEGATIVE_Y),t.py.lookAt(Fq.POSITIVE_Y,Fq.POSITIVE_Z),t.ny.lookAt(Fq.NEGATIVE_Y,Fq.NEGATIVE_Z),t.pz.lookAt(Fq.POSITIVE_Z,Fq.NEGATIVE_Y),t.nz.lookAt(Fq.NEGATIVE_Z,Fq.NEGATIVE_Y),e._frameBuffer=new G$,e}),{getCamera:function(e){return this._cameras[e]},render:function(e,t,n){var r=e.gl;n||t.update();for(var i=this.texture.width,o=2*Math.atan(i/(i-.5))/Math.PI*180,a=0;a<6;a++){var s=H$[a],l=this._cameras[s];if(Fq.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=o,this.shadowMapPass){l.update();var u=t.getBoundingBox();u.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(u),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),W$=XK.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,r=[],i=[],o=[],a=[],s=0;s<=e;s++)for(var l=s/e,u=0;u<=t;u++){var c=u/t;if(r.push([2*c-1,2*l-1,0]),i&&i.push([c,l]),o&&o.push([0,0,1]),u<t&&s<e){var h=u+s*(t+1);a.push([h,h+1,h+t+1]),a.push([h+t+1,h+1,h+t+2])}}n.position.fromArray(r),n.texcoord0.fromArray(i),n.normal.fromArray(o),this.initIndicesFromArray(a),this.boundingBox=new bK,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),j$=new aK,X$=XK.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},(function(){this.build()}),{build:function(){var e={px:Y$("px",this.depthSegments,this.heightSegments),nx:Y$("nx",this.depthSegments,this.heightSegments),py:Y$("py",this.widthSegments,this.depthSegments),ny:Y$("ny",this.widthSegments,this.depthSegments),pz:Y$("pz",this.widthSegments,this.heightSegments),nz:Y$("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],n=0,r=0;for(var i in e)n+=e[i].vertexCount,r+=e[i].indices.length;for(var o=0;o<t.length;o++)this.attributes[t[o]].init(n);this.indices=new SZ.Uint16Array(r);var a=0,s=0;for(var i in e){var l=e[i];for(o=0;o<t.length;o++)for(var u=t[o],c=l.attributes[u].value,h=l.attributes[u].size,d="normal"===u,p=0;p<c.length;p++){var f=c[p];this.inside&&d&&(f=-f),this.attributes[u].value[p+h*s]=f}var g=l.indices.length;for(p=0;p<l.indices.length;p++)this.indices[p+a]=s+l.indices[this.inside?g-p-1:p];a+=l.indices.length,s+=l.vertexCount}this.boundingBox=new bK,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function Y$(e,t,n){j$.identity();var r=new W$({widthSegments:t,heightSegments:n});switch(e){case"px":aK.translate(j$,j$,Fq.POSITIVE_X),aK.rotateY(j$,j$,Math.PI/2);break;case"nx":aK.translate(j$,j$,Fq.NEGATIVE_X),aK.rotateY(j$,j$,-Math.PI/2);break;case"py":aK.translate(j$,j$,Fq.POSITIVE_Y),aK.rotateX(j$,j$,-Math.PI/2);break;case"ny":aK.translate(j$,j$,Fq.NEGATIVE_Y),aK.rotateX(j$,j$,Math.PI/2);break;case"pz":aK.translate(j$,j$,Fq.POSITIVE_Z);break;case"nz":aK.translate(j$,j$,Fq.NEGATIVE_Z),aK.rotateY(j$,j$,Math.PI)}return r.applyTransform(j$),r}wq.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");var Z$=LK.extend((function(){var e=new wq({vertex:wq.source("clay.skybox.vertex"),fragment:wq.source("clay.skybox.fragment")}),t=new jZ({shader:e,depthMask:!1});return{scene:null,geometry:new X$,material:t,environmentMap:null,culling:!1,_dummyCamera:new E$}}),(function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)}),{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){"texture2D"===e.textureType?(this.material.define("EQUIRECTANGULAR"),e.minFilter=EK.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,n){this.renderSkybox(e,n)},renderSkybox:function(e,t){var n=this._dummyCamera;n.aspect=e.getViewportAspect(),n.fov=t.fov||50,n.updateProjectionMatrix(),aK.invert(n.invProjectionMatrix,n.projectionMatrix),n.worldTransform.copy(t.worldTransform),n.viewMatrix.copy(t.viewMatrix),this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],n)}});function q$(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var K$=q$("DXT1"),$$=q$("DXT3"),J$=q$("DXT5"),Q$=function(e,t){var n=new Int32Array(e,0,31);if(542327876!==n[0])return null;if(4&!n(20))return null;var r,i,o=n(21),a=n[4],s=n[3],l=512&n[28],u=131072&n[2];switch(o){case K$:r=8,i=EK.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case $$:r=16,i=EK.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case J$:r=16,i=EK.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var c=n[1]+4,h=l?6:1,d=1;u&&(d=Math.max(1,n[7]));for(var p=[],f=0;f<h;f++){var g=a,m=s;p[f]=new RK({width:g,height:m,format:i});for(var v=[],y=0;y<d;y++){var _=Math.max(4,g)/4*Math.max(4,m)/4*r,x=new Uint8Array(e,c,_);c+=_,g*=.5,m*=.5,v[y]=x}p[f].pixels=v[0],u&&(p[f].mipmaps=v)}if(!t)return p[0];t.width=p[0].width,t.height=p[0].height,t.format=p[0].format,t.pixels=p[0].pixels,t.mipmaps=p[0].mipmaps},eJ=String.fromCharCode;function tJ(e,t,n,r){if(e[3]>0){var i=Math.pow(2,e[3]-128-8+r);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function nJ(e,t,n,r){for(var i,o,a=0,s=0,l=r;l>0;)if(e[s][0]=t[n++],e[s][1]=t[n++],e[s][2]=t[n++],e[s][3]=t[n++],1===e[s][0]&&1===e[s][1]&&1===e[s][2]){for(var u=e[s][3]<<a>>>0;u>0;u--)i=e[s-1],(o=e[s])[0]=i[0],o[1]=i[1],o[2]=i[2],o[3]=i[3],s++,l--;a+=8}else s++,l--,a=0;return n}function rJ(e,t,n,r){if(r<8|r>32767)return nJ(e,t,n,r);if(2!=(i=t[n++]))return nJ(e,t,n-1,r);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var o=0;o<r;){var a=t[n++];if(a>128){a=(127&a)>>>0;for(var s=t[n++];a--;)e[o++][i]=s}else for(;a--;)e[o++][i]=t[n++]}return n}var iJ=function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),i=r.length;if("#?"===function(e,t,n){for(var r="",i=t;i<n;i++)r+=eJ(e[i]);return r}(r,0,2)){for(var o=2;o<i&&("\n"!==eJ(r[o])||"\n"!==eJ(r[o+1]));o++);if(!(o>=i)){o+=2;for(var a="";o<i;o++){var s=eJ(r[o]);if("\n"===s)break;a+=s}var l=a.split(" "),u=parseInt(l[1]),c=parseInt(l[3]);if(c&&u){for(var h=o+1,d=[],p=0;p<c;p++){d[p]=[];for(var f=0;f<4;f++)d[p][f]=0}for(var g=new Float32Array(c*u*4),m=0,v=0;v<u;v++){if(!(h=rJ(d,r,h,c)))return null;for(p=0;p<c;p++)tJ(d[p],g,m,n),m+=4}return t||(t=new RK),t.width=c,t.height=u,t.pixels=g,t.type=EK.FLOAT,t}}}},oJ={loadTexture:function(e,t,n,r){var i;if("function"==typeof t?(r=n=t,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return i=new RK({width:0,height:0,sRGB:!1}),oJ._fetchTexture(e,(function(e){iJ(e,i,t.exposure),i.dirty(),n&&n(i)}),r),i;e.match(/.dds$/)||"dds"===t.fileType?(i=new RK({width:0,height:0}),oJ._fetchTexture(e,(function(e){Q$(e,i),i.dirty(),n&&n(i)}),r)):((i=new RK).load(e),i.success(n),i.error(r))}else"object"==typeof e&&void 0!==e.px&&((i=new A$).load(e),i.success(n),i.error(r));return i},loadPanorama:function(e,t,n,r,i,o){var a=this;"function"==typeof r?(o=i=r,r={}):r=r||{},oJ.loadTexture(t,r,(function(t){t.flipY=r.flipY||!1,a.panoramaToCubeMap(e,t,n,r),t.dispose(e),i&&i(n)}),o)},panoramaToCubeMap:function(e,t,n,r){var i=new U$,o=new Z$({scene:new b$});return o.setEnvironmentMap(t),(r=r||{}).encodeRGBM&&o.material.define("fragment","RGBM_ENCODE"),n.sRGB=t.sRGB,i.texture=n,i.render(e,o.scene),i.texture=null,i.dispose(e),n},heightToNormal:function(e,t){var n=document.createElement("canvas"),r=n.width=e.width,i=n.height=e.height,o=n.getContext("2d");o.drawImage(e,0,0,r,i),t=t||!1;for(var a=o.getImageData(0,0,r,i),s=o.createImageData(r,i),l=0;l<a.data.length;l+=4){if(t){var u=a.data[l],c=a.data[l+1],h=a.data[l+2];if(Math.abs(u-c)+Math.abs(c-h)>20)return console.warn("Given image is not a height map"),e}var d,p,f,g;l%(4*r)==0?(d=a.data[l],f=a.data[l+4]):l%(4*r)==4*(r-1)?(d=a.data[l-4],f=a.data[l]):(d=a.data[l-4],f=a.data[l+4]),l<4*r?(p=a.data[l],g=a.data[l+4*r]):l>r*(i-1)*4?(p=a.data[l-4*r],g=a.data[l]):(p=a.data[l-4*r],g=a.data[l+4*r]),s.data[l]=d-f+127,s.data[l+1]=p-g+127,s.data[l+2]=255,s.data[l+3]=255}return o.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var r=document.createElement("canvas"),i=r.getContext("2d"),o=t||32;n=n||20,r.width=r.height=o,i.drawImage(e,0,0,o,o);for(var a=i.getImageData(0,0,o,o),s=0;s<a.data.length;s+=4){var l=a.data[s],u=a.data[s+1],c=a.data[s+2];if(Math.abs(l-u)+Math.abs(u-c)>n)return!1}return!0},_fetchTexture:function(e,t,n){SZ.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,r){e=e||512,t=t||64,n=n||"black",r=r||"white";var i=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var a=o.getContext("2d");a.fillStyle=r,a.fillRect(0,0,e,e),a.fillStyle=n;for(var s=0;s<i;s++)for(var l=0;l<i;l++){(l%2?s%2:s%2-1)&&a.fillRect(s*t,l*t,t,t)}return new RK({image:o,anisotropic:8})},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,1,1),new RK({image:t})}},aJ=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function sJ(e){return"_on"+e}var lJ=function(e){var t=this;this._texture=new RK({anisotropic:32,flipY:!1,surface:this,dispose:function(e){t.dispose(),RK.prototype.dispose.call(this,e)}}),aJ.forEach((function(e){this[sJ(e)]=function(t){t.triangle&&this._meshes.forEach((function(n){this.dispatchEvent(e,n,t.triangle,t.point)}),this)}}),this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};lJ.prototype={constructor:lJ,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(t instanceof HTMLCanvasElement){var n=this,r=e.getZr(),i=r.__oldRefreshImmediately||r.refreshImmediately;r.refreshImmediately=function(){i.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},r.__oldRefreshImmediately=i}else console.error("ECharts must init on canvas if it is used as texture."),t=document.createElement("canvas");this._texture.image=t,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var e=new Fq,t=new Fq,n=new Fq,r=new KZ,i=new KZ,o=new KZ,a=new KZ,s=new Fq;return function(l,u,c,h){var d=u.geometry,p=d.attributes.position,f=d.attributes.texcoord0,g=Fq.dot,m=Fq.cross;p.get(c[0],e.array),p.get(c[1],t.array),p.get(c[2],n.array),f.get(c[0],r.array),f.get(c[1],i.array),f.get(c[2],o.array),m(s,t,n);var v=g(e,s),y=g(h,s)/v;m(s,n,e);var _=g(h,s)/v;m(s,e,t);var x=g(h,s)/v;KZ.scale(a,r,y),KZ.scaleAndAdd(a,a,i,_),KZ.scaleAndAdd(a,a,o,x);var b=a.x*this._chart.getWidth(),w=a.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(aJ.forEach((function(t){e.on(t,this[sJ(t)],this)}),this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),aJ.forEach((function(t){e.off(t,this[sJ(t)])}),this)},dispose:function(){this._meshes.forEach((function(e){this.detachFromMesh(e)}),this)}};var uJ=p$.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=p$.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});wq.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var cJ=new W$,hJ=new LK({geometry:cJ,frustumCulling:!1}),dJ=new uJ,pJ=wY.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var e=new wq(wq.source("clay.compositor.vertex"),this.fragment),t=new jZ({shader:e});t.enableTexturesAll(),this.material=t}),{setUniform:function(e,t){this.material.setUniform(e,t)},getUniform:function(e){var t=this.material.uniforms[e];if(t)return t.value},attachOutput:function(e,t){this.outputs||(this.outputs={}),t=t||vZ,this.outputs[t]=e},detachOutput:function(e){for(var t in this.outputs)this.outputs[t]===e&&(this.outputs[t]=null)},bind:function(e,t){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&t.attach(r,n)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var n=e.gl;if(t){this.bind(e,t);var r=e.getGLExtension("EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var o in this.outputs)(o=+o)>=n.COLOR_ATTACHMENT0&&o<=n.COLOR_ATTACHMENT0+8&&i.push(o);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var a=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){a|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(a),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){hJ.material=this.material,e.renderPass([hJ],dJ)},dispose:function(e){}}),fJ={},gJ=["px","nx","py","ny","pz","nz"];fJ.prefilterEnvironmentMap=function(e,t,n,r,i){i&&r||(r=fJ.generateNormalDistribution(),i=fJ.integrateBRDF(e,r));var o=(n=n||{}).width||64,a=n.height||64,s=n.type||t.type,l=new A$({width:o,height:a,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(o,a),c=Math.log(u)/Math.log(2)+1,h=new jZ({shader:new wq({vertex:wq.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});h.set("normalDistribution",r),n.encodeRGBM&&h.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&h.define("fragment","RGBM_DECODE");var d,p=new b$;if("texture2D"===t.textureType){var f=new A$({width:o,height:a,type:s===EK.FLOAT?EK.HALF_FLOAT:s});oJ.panoramaToCubeMap(e,t,f,{encodeRGBM:n.decodeRGBM}),t=f}(d=new Z$({scene:p,material:h})).material.set("environmentMap",t);var g=new U$({texture:l});n.encodeRGBM&&(s=l.type=EK.UNSIGNED_BYTE);for(var m=new RK({width:o,height:a,type:s}),v=new G$({depthBuffer:!1}),y=SZ[s===EK.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],_=0;_<c;_++){l.mipmaps[_]={pixels:{}},d.material.set("roughness",_/(c-1));for(var x=m.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<gJ.length;w++){var S=new y(m.width*m.height*4);v.attach(m),v.bind(e);var T=g.getCamera(gJ[w]);T.fov=b,e.render(p,T),e.gl.readPixels(0,0,m.width,m.height,EK.RGBA,s,S),v.unbind(e),l.mipmaps[_].pixels[gJ[w]]=S}m.width/=2,m.height/=2,m.dirty()}return v.dispose(e),m.dispose(e),d.dispose(e),r.dispose(e),{environmentMap:l,brdfLookup:i,normalDistribution:r,maxMipmapLevel:c}},fJ.integrateBRDF=function(e,t){t=t||fJ.generateNormalDistribution();var n=new G$({depthBuffer:!1}),r=new pJ({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),i=new RK({width:512,height:256,type:EK.HALF_FLOAT,wrapS:EK.CLAMP_TO_EDGE,wrapT:EK.CLAMP_TO_EDGE,minFilter:EK.NEAREST,magFilter:EK.NEAREST,useMipmap:!1});return r.setUniform("normalDistribution",t),r.setUniform("viewportSize",[512,256]),r.attachOutput(i),r.render(e,n),n.dispose(e),i},fJ.generateNormalDistribution=function(e,t){for(var n=new RK({width:e=e||256,height:t=t||1024,type:EK.FLOAT,minFilter:EK.NEAREST,magFilter:EK.NEAREST,wrapS:EK.CLAMP_TO_EDGE,wrapT:EK.CLAMP_TO_EDGE,useMipmap:!1}),r=new Float32Array(t*e*4),i=[],o=0;o<e;o++){for(var a=o/e,s=a*a,l=0;l<t;l++){var u=(l<<16|l>>>16)>>>0;u=(((16711935&(u=((252645135&(u=((858993459&(u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0))<<2|(3435973836&u)>>>2)>>>0))<<4|(4042322160&u)>>>4)>>>0))<<8|(4278255360&u)>>>8)>>>0)/4294967296;var c=Math.sqrt((1-u)/(1+(s*s-1)*u));i[l]=c}for(l=0;l<t;l++){var h=4*(l*e+o),d=(c=i[l],Math.sqrt(1-c*c)),p=l/t,f=2*Math.PI*p;r[h]=d*Math.cos(f),r[h+1]=c,r[h+2]=d*Math.sin(f),r[h+3]=1}}return n.pixels=r,n};var mJ=r$.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(e.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=fJ.generateNormalDistribution(),this._brdfLookup=fJ.integrateBRDF(e,this._normalDistribution));var n=this.cubemap;if(!n.__prefiltered){var r=fJ.prefilterEnvironmentMap(e,n,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=r.environmentMap,this.cubemap.__prefiltered=!0,n.dispose(e)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),vJ=r$.extend({castShadow:!1,coefficients:[]},(function(){this._coefficientsTmpArr=new SZ.Float32Array(27)}),{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,n=0;n<e.coefficients.length;n++)t[n]=e.coefficients[n];return t}}}}),yJ={},_J=["px","nx","py","ny","pz","nz"];function xJ(e,t){var n=e[0],r=e[1],i=e[2];return 0===t?1:1===t?n:2===t?r:3===t?i:4===t?n*i:5===t?r*i:6===t?n*r:7===t?3*i*i-1:n*n-r*r}var bJ={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};yJ.projectEnvironmentMap=function(e,t,n){var r;(n=n||{}).lod=n.lod||0;var i=new b$,o=64;"texture2D"===t.textureType||(o=t.image&&t.image.px?t.image.px.width:t.width),r=new Z$({scene:i,environmentMap:t});var a=Math.ceil(o/Math.pow(2,n.lod)),s=Math.ceil(o/Math.pow(2,n.lod)),l=new RK({width:a,height:s}),u=new G$;r.material.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&r.material.define("fragment","RGBM_DECODE"),r.material.set("lod",n.lod);for(var c=new U$({texture:l}),h={},d=0;d<_J.length;d++){h[_J[d]]=new Uint8Array(a*s*4);var p=c.getCamera(_J[d]);p.fov=90,u.attach(l),u.bind(e),e.render(i,p),e.gl.readPixels(0,0,a,s,EK.RGBA,EK.UNSIGNED_BYTE,h[_J[d]]),u.unbind(e)}return r.dispose(e),u.dispose(e),l.dispose(e),function(e,t,n,r){for(var i=new SZ.Float32Array(27),o=Dq.create(),a=Dq.create(),s=Dq.create(),l=0;l<9;l++){for(var u=Dq.create(),c=0;c<_J.length;c++){for(var h=t[_J[c]],d=Dq.create(),p=0,f=0,g=bJ[_J[c]],m=0;m<r;m++)for(var v=0;v<n;v++){o[0]=v/(n-1)*2-1,o[1]=m/(r-1)*2-1,o[2]=-1,Dq.normalize(o,o),s[0]=o[g[0]]*g[3],s[1]=o[g[1]]*g[4],s[2]=o[g[2]]*g[5],a[0]=h[f++]/255,a[1]=h[f++]/255,a[2]=h[f++]/255;var y=h[f++]/255*8.12;a[0]*=y,a[1]*=y,a[2]*=y,Dq.scaleAndAdd(d,d,a,xJ(s,l)*-o[2]),p+=-o[2]}Dq.scaleAndAdd(u,u,d,1/p)}i[3*l]=u[0]/6,i[3*l+1]=u[1]/6,i[3*l+2]=u[2]/6}return i}(0,h,a,s)};var wJ=function(){for(var e=0,t=arguments.length;e<t;e++)if(null!=arguments[e])return arguments[e]},SJ=function(e,t){return null!=t.dataIndexInside?t.dataIndexInside:null!=t.dataIndex?J(t.dataIndex)?j(t.dataIndex,(function(t){return e.indexOfRawIndex(t)})):e.indexOfRawIndex(t.dataIndex):null!=t.name?J(t.name)?j(t.name,(function(t){return e.indexOfName(t)})):e.indexOfName(t.name):void 0},TJ=XK.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,r=this.attributes.texcoord0,i=this.attributes.normal,o=(t+1)*(e+1);n.init(o),r.init(o),i.init(o);var a,s,l,u,c,h,d,p,f,g,m,v=o>65535?Uint32Array:Uint16Array,y=this.indices=new v(t*e*6),_=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,S=this.thetaLength,T=[],M=[],C=0,D=1/(_=this.radius);for(d=0;d<=e;d++)for(h=0;h<=t;h++)u=h/t,c=d/e,a=-_*Math.cos(x+u*b)*Math.sin(w+c*S),s=_*Math.cos(w+c*S),l=_*Math.sin(x+u*b)*Math.sin(w+c*S),T[0]=a,T[1]=s,T[2]=l,M[0]=u,M[1]=c,n.set(C,T),r.set(C,M),T[0]*=D,T[1]*=D,T[2]*=D,i.set(C,T),C++;var A=t+1,I=0;for(d=0;d<e;d++)for(h=0;h<t;h++)f=d*A+h,p=d*A+h+1,m=(d+1)*A+h+1,g=(d+1)*A+h,y[I++]=p,y[I++]=f,y[I++]=m,y[I++]=f,y[I++]=g,y[I++]=m;this.boundingBox=new bK,this.boundingBox.max.set(_,_,_),this.boundingBox.min.set(-_,-_,-_)}}),MJ=r$.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}}),CJ=r$.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Fq,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),DJ=r$.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(e){return e.range}},pointLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.range=this.range,e}}),AJ=r$.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(e){return e.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(e){return e.falloffFactor}},spotLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Fq,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.range=this.range,e.umbraAngle=this.umbraAngle,e.penumbraAngle=this.penumbraAngle,e.falloffFactor=this.falloffFactor,e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),IJ=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=r||0,this.array=Qq.fromValues(e,t,n,r),this._dirty=!0};IJ.prototype={constructor:IJ,add:function(e){return Qq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new IJ(this.x,this.y,this.z,this.w)},copy:function(e){return Qq.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return Qq.dist(this.array,e.array)},distance:function(e){return Qq.distance(this.array,e.array)},div:function(e){return Qq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Qq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Qq.dot(this.array,e.array)},len:function(){return Qq.len(this.array)},length:function(){return Qq.length(this.array)},lerp:function(e,t,n){return Qq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Qq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Qq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Qq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Qq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Qq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Qq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Qq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Qq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Qq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Qq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Qq.squaredDistance(this.array,e.array)},sqrLen:function(){return Qq.sqrLen(this.array)},squaredLength:function(){return Qq.squaredLength(this.array)},sub:function(e){return Qq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Qq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Qq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Qq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var EJ=Object.defineProperty;if(EJ){var LJ=IJ.prototype;EJ(LJ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),EJ(LJ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),EJ(LJ,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),EJ(LJ,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}IJ.add=function(e,t,n){return Qq.add(e.array,t.array,n.array),e._dirty=!0,e},IJ.set=function(e,t,n,r,i){Qq.set(e.array,t,n,r,i),e._dirty=!0},IJ.copy=function(e,t){return Qq.copy(e.array,t.array),e._dirty=!0,e},IJ.distance=IJ.dist=function(e,t){return Qq.distance(e.array,t.array)},IJ.div=function(e,t,n){return Qq.divide(e.array,t.array,n.array),e._dirty=!0,e},IJ.divide=IJ.div,IJ.dot=function(e,t){return Qq.dot(e.array,t.array)},IJ.len=function(e){return Qq.length(e.array)},IJ.lerp=function(e,t,n,r){return Qq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},IJ.min=function(e,t,n){return Qq.min(e.array,t.array,n.array),e._dirty=!0,e},IJ.max=function(e,t,n){return Qq.max(e.array,t.array,n.array),e._dirty=!0,e},IJ.mul=function(e,t,n){return Qq.multiply(e.array,t.array,n.array),e._dirty=!0,e},IJ.multiply=IJ.mul,IJ.negate=function(e,t){return Qq.negate(e.array,t.array),e._dirty=!0,e},IJ.normalize=function(e,t){return Qq.normalize(e.array,t.array),e._dirty=!0,e},IJ.random=function(e,t){return Qq.random(e.array,t),e._dirty=!0,e},IJ.scale=function(e,t,n){return Qq.scale(e.array,t.array,n),e._dirty=!0,e},IJ.scaleAndAdd=function(e,t,n,r){return Qq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},IJ.squaredDistance=IJ.sqrDist=function(e,t){return Qq.sqrDist(e.array,t.array)},IJ.squaredLength=IJ.sqrLen=function(e){return Qq.sqrLen(e.array)},IJ.sub=function(e,t,n){return Qq.subtract(e.array,t.array,n.array),e._dirty=!0,e},IJ.subtract=IJ.sub,IJ.transformMat4=function(e,t,n){return Qq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},IJ.transformQuat=function(e,t,n){return Qq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var NJ={create:function(){var e=new YZ(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},clone:function(e){var t=new YZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},transpose:function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(a=1/a,e[0]=o*a,e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null},adjoint:function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},determinant:function(e){return e[0]*e[3]-e[2]*e[1]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*u+o*c,e[3]=i*u+a*c,e}};NJ.mul=NJ.multiply,NJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},NJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1];return e[0]=r*s,e[1]=i*s,e[2]=o*l,e[3]=a*l,e},NJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))},NJ.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]};var PJ=function(){this.array=NJ.create(),this._dirty=!0};PJ.prototype={constructor:PJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new PJ).copy(this)},copy:function(e){return NJ.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return NJ.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return NJ.determinant(this.array)},identity:function(){return NJ.identity(this.array),this._dirty=!0,this},invert:function(){return NJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return NJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return NJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return NJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return NJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return NJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return NJ.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return NJ.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},PJ.adjoint=function(e,t){return NJ.adjoint(e.array,t.array),e._dirty=!0,e},PJ.copy=function(e,t){return NJ.copy(e.array,t.array),e._dirty=!0,e},PJ.determinant=function(e){return NJ.determinant(e.array)},PJ.identity=function(e){return NJ.identity(e.array),e._dirty=!0,e},PJ.invert=function(e,t){return NJ.invert(e.array,t.array),e._dirty=!0,e},PJ.mul=function(e,t,n){return NJ.mul(e.array,t.array,n.array),e._dirty=!0,e},PJ.multiply=PJ.mul,PJ.rotate=function(e,t,n){return NJ.rotate(e.array,t.array,n),e._dirty=!0,e},PJ.scale=function(e,t,n){return NJ.scale(e.array,t.array,n.array),e._dirty=!0,e},PJ.transpose=function(e,t){return NJ.transpose(e.array,t.array),e._dirty=!0,e};var OJ={create:function(){var e=new YZ(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},clone:function(e){var t=new YZ(6);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(l=1/l,e[0]=o*l,e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},determinant:function(e){return e[0]*e[3]-e[1]*e[2]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1],h=n[2],d=n[3],p=n[4],f=n[5];return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*p+o*f+s,e[5]=i*p+a*f+l,e}};OJ.mul=OJ.multiply,OJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=Math.sin(n),c=Math.cos(n);return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*-u+o*c,e[3]=i*-u+a*c,e[4]=s,e[5]=l,e},OJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r*u,e[1]=i*u,e[2]=o*c,e[3]=a*c,e[4]=s,e[5]=l,e},OJ.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*u+o*c+s,e[5]=i*u+a*c+l,e},OJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)};var RJ=function(){this.array=OJ.create(),this._dirty=!0};RJ.prototype={constructor:RJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new RJ).copy(this)},copy:function(e){return OJ.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return OJ.determinant(this.array)},identity:function(){return OJ.identity(this.array),this._dirty=!0,this},invert:function(){return OJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return OJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return OJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return OJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return OJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return OJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return OJ.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return OJ.translate(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},RJ.copy=function(e,t){return OJ.copy(e.array,t.array),e._dirty=!0,e},RJ.determinant=function(e){return OJ.determinant(e.array)},RJ.identity=function(e){return OJ.identity(e.array),e._dirty=!0,e},RJ.invert=function(e,t){return OJ.invert(e.array,t.array),e._dirty=!0,e},RJ.mul=function(e,t,n){return OJ.mul(e.array,t.array,n.array),e._dirty=!0,e},RJ.multiply=RJ.mul,RJ.rotate=function(e,t,n){return OJ.rotate(e.array,t.array,n),e._dirty=!0,e},RJ.scale=function(e,t,n){return OJ.scale(e.array,t.array,n.array),e._dirty=!0,e},RJ.translate=function(e,t,n){return OJ.translate(e.array,t.array,n.array),e._dirty=!0,e};var kJ=function(){this.array=eK.create(),this._dirty=!0};kJ.prototype={constructor:kJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return eK.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new kJ).copy(this)},copy:function(e){return eK.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return eK.determinant(this.array)},fromMat2d:function(e){return eK.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return eK.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return eK.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return eK.identity(this.array),this._dirty=!0,this},invert:function(){return eK.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return eK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return eK.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return eK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return eK.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return eK.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return eK.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return eK.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return eK.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return eK.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},kJ.adjoint=function(e,t){return eK.adjoint(e.array,t.array),e._dirty=!0,e},kJ.copy=function(e,t){return eK.copy(e.array,t.array),e._dirty=!0,e},kJ.determinant=function(e){return eK.determinant(e.array)},kJ.identity=function(e){return eK.identity(e.array),e._dirty=!0,e},kJ.invert=function(e,t){return eK.invert(e.array,t.array),e},kJ.mul=function(e,t,n){return eK.mul(e.array,t.array,n.array),e._dirty=!0,e},kJ.multiply=kJ.mul,kJ.fromMat2d=function(e,t){return eK.fromMat2d(e.array,t.array),e._dirty=!0,e},kJ.fromMat4=function(e,t){return eK.fromMat4(e.array,t.array),e._dirty=!0,e},kJ.fromQuat=function(e,t){return eK.fromQuat(e.array,t.array),e._dirty=!0,e},kJ.normalFromMat4=function(e,t){return eK.normalFromMat4(e.array,t.array),e._dirty=!0,e},kJ.rotate=function(e,t,n){return eK.rotate(e.array,t.array,n),e._dirty=!0,e},kJ.scale=function(e,t,n){return eK.scale(e.array,t.array,n.array),e._dirty=!0,e},kJ.transpose=function(e,t){return eK.transpose(e.array,t.array),e._dirty=!0,e},kJ.translate=function(e,t,n){return eK.translate(e.array,t.array,n.array),e._dirty=!0,e};var zJ={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quarticIn:function(e){return e*e*e*e},quarticOut:function(e){return 1- --e*e*e*e},quarticInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quinticIn:function(e){return e*e*e*e*e},quinticOut:function(e){return--e*e*e*e*e+1},quinticInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sinusoidalIn:function(e){return 1-Math.cos(e*Math.PI/2)},sinusoidalOut:function(e){return Math.sin(e*Math.PI/2)},sinusoidalInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},exponentialIn:function(e){return 0===e?0:Math.pow(1024,e-1)},exponentialOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},exponentialInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circularIn:function(e){return 1-Math.sqrt(1-e*e)},circularOut:function(e){return Math.sqrt(1- --e*e)},circularInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},elasticOut:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},elasticInOut:function(e){var t,n=.1,r=.4;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=r*Math.asin(1/n)/(2*Math.PI),(e*=2)<1?n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/r)*-.5:n*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/r)*.5+1)},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:function(e){return 1-zJ.bounceOut(1-e)},bounceOut:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},bounceInOut:function(e){return e<.5?.5*zJ.bounceIn(2*e):.5*zJ.bounceOut(2*e-1)+.5}};XJ(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],(function(e,t){return e["[object "+t+"]"]=!0,e}),{}),XJ(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],(function(e,t){return e["[object "+t+"Array]"]=!0,e}),{});var VJ=Array.prototype,BJ=VJ.slice,FJ=VJ.map,GJ=function(){}.constructor,HJ=GJ?GJ.prototype:null;function UJ(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];"undefined"!=typeof console&&console.error.apply(console,e)}function WJ(e){return!!e&&("string"!=typeof e&&"number"==typeof e.length)}function jJ(e,t,n){if(!e)return[];if(!t)return function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return BJ.apply(e,t)}(e);if(e.map&&e.map===FJ)return e.map(t,n);for(var r=[],i=0,o=e.length;i<o;i++)r.push(t.call(n,e[i],i,e));return r}function XJ(e,t,n,r){if(e&&t){for(var i=0,o=e.length;i<o;i++)n=t.call(r,n,e[i],i,e);return n}}function YJ(e){if(!e)return[];if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function ZJ(e){return"function"==typeof e}function qJ(e){return"number"==typeof e}function KJ(e){return null==e?null:"function"==typeof e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function $J(e,t){for(var n=new e.constructor(e.length+t.length),r=0;r<e.length;r++)n[r]=e[r];var i=e.length;for(r=0;r<t.length;r++)n[r+i]=t[r];return n}function JJ(){}function QJ(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}HJ&&ZJ(HJ.bind)&&HJ.call.bind(HJ.bind);var eQ=Math.pow,tQ=Math.sqrt,nQ=tQ(3),rQ=1/3;function iQ(e){return e>-1e-8&&e<1e-8}var oQ=/cubic-bezier\(([0-9,\.e ]+)\)/;function aQ(e){var t=e&&oQ.exec(e);if(t){var n=t[1].split(","),r=+KJ(n[0]),i=+KJ(n[1]),o=+KJ(n[2]),a=+KJ(n[3]);if(isNaN(r+i+o+a))return;var s=[];return function(e){return e<=0?0:e>=1?1:function(e,t,n,r,i,o){var a=r+3*(t-n)-e,s=3*(n-2*t+e),l=3*(t-e),u=e-i,c=s*s-3*a*l,h=s*l-9*a*u,d=l*l-3*s*u,p=0;if(iQ(c)&&iQ(h))iQ(s)?o[0]=0:(T=-l/s)>=0&&T<=1&&(o[p++]=T);else{var f=h*h-4*c*d;if(iQ(f)){var g=h/c,m=-g/2;(T=-s/a+g)>=0&&T<=1&&(o[p++]=T),m>=0&&m<=1&&(o[p++]=m)}else if(f>0){var v=tQ(f),y=c*s+1.5*a*(-h+v),_=c*s+1.5*a*(-h-v);(T=(-s-((y=y<0?-eQ(-y,rQ):eQ(y,rQ))+(_=_<0?-eQ(-_,rQ):eQ(_,rQ))))/(3*a))>=0&&T<=1&&(o[p++]=T)}else{var x=(2*c*s-3*a*h)/(2*tQ(c*c*c)),b=Math.acos(x)/3,w=tQ(c),S=Math.cos(b),T=(-s-2*w*S)/(3*a),M=(m=(-s+w*(S+nQ*Math.sin(b)))/(3*a),(-s+w*(S-nQ*Math.sin(b)))/(3*a));T>=0&&T<=1&&(o[p++]=T),m>=0&&m<=1&&(o[p++]=m),M>=0&&M<=1&&(o[p++]=M)}}return p}(0,r,o,1,e,s)&&function(e,t,n,r,i){var o=1-i;return o*o*(o*e+3*i*t)+i*i*(i*r+3*o*n)}(0,i,a,1,s[0])}}}var sQ=function(){function e(e){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=e.life||1e3,this._delay=e.delay||0,this.loop=e.loop||!1,this.onframe=e.onframe||JJ,this.ondestroy=e.ondestroy||JJ,this.onrestart=e.onrestart||JJ,e.easing&&this.setEasing(e.easing)}return e.prototype.step=function(e,t){if(this._inited||(this._startTime=e+this._delay,this._inited=!0),!this._paused){var n=this._life,r=e-this._startTime-this._pausedTime,i=r/n;i<0&&(i=0),i=Math.min(i,1);var o=this.easingFunc,a=o?o(i):i;if(this.onframe(a),1===i){if(!this.loop)return!0;var s=r%n;this._startTime=e-s,this._pausedTime=0,this.onrestart()}return!1}this._pausedTime+=t},e.prototype.pause=function(){this._paused=!0},e.prototype.resume=function(){this._paused=!1},e.prototype.setEasing=function(e){this.easing=e,this.easingFunc=ZJ(e)?e:zJ[e]||aQ(e)},e}(),lQ={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],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 uQ(e){return(e=Math.round(e))<0?0:e>255?255:e}function cQ(e){return e<0?0:e>1?1:e}function hQ(e){var t=e;return t.length&&"%"===t.charAt(t.length-1)?uQ(parseFloat(t)/100*255):uQ(parseInt(t,10))}function dQ(e){var t=e;return t.length&&"%"===t.charAt(t.length-1)?cQ(parseFloat(t)/100):cQ(parseFloat(t))}function pQ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function fQ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function gQ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var mQ=new M$(20),vQ=null;function yQ(e,t){vQ&&gQ(vQ,t),vQ=mQ.put(e,vQ||t.slice())}function _Q(e,t){if(e){t=t||[];var n=mQ.get(e);if(n)return gQ(t,n);var r=(e+="").replace(/ /g,"").toLowerCase();if(r in lQ)return gQ(t,lQ[r]),yQ(e,t),t;var i,o=r.length;if("#"===r.charAt(0))return 4===o||5===o?(i=parseInt(r.slice(1,4),16))>=0&&i<=4095?(fQ(t,(3840&i)>>4|(3840&i)>>8,240&i|(240&i)>>4,15&i|(15&i)<<4,5===o?parseInt(r.slice(4),16)/15:1),yQ(e,t),t):void fQ(t,0,0,0,1):7===o||9===o?(i=parseInt(r.slice(1,7),16))>=0&&i<=16777215?(fQ(t,(16711680&i)>>16,(65280&i)>>8,255&i,9===o?parseInt(r.slice(7),16)/255:1),yQ(e,t),t):void fQ(t,0,0,0,1):void 0;var a=r.indexOf("("),s=r.indexOf(")");if(-1!==a&&s+1===o){var l=r.substr(0,a),u=r.substr(a+1,s-(a+1)).split(","),c=1;switch(l){case"rgba":if(4!==u.length)return 3===u.length?fQ(t,+u[0],+u[1],+u[2],1):fQ(t,0,0,0,1);c=dQ(u.pop());case"rgb":return u.length>=3?(fQ(t,hQ(u[0]),hQ(u[1]),hQ(u[2]),3===u.length?c:dQ(u[3])),yQ(e,t),t):void fQ(t,0,0,0,1);case"hsla":return 4!==u.length?void fQ(t,0,0,0,1):(u[3]=dQ(u[3]),xQ(u,t),yQ(e,t),t);case"hsl":return 3!==u.length?void fQ(t,0,0,0,1):(xQ(u,t),yQ(e,t),t);default:return}}fQ(t,0,0,0,1)}}function xQ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=dQ(e[1]),i=dQ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return fQ(t=t||[],uQ(255*pQ(a,o,n+1/3)),uQ(255*pQ(a,o,n)),uQ(255*pQ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}var bQ=function(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1},wQ=new function(){this.browser=new bQ,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow="undefined"!=typeof window};"object"==typeof wx&&"function"==typeof wx.getSystemInfoSync?(wQ.wxa=!0,wQ.touchEventsSupported=!0):"undefined"==typeof document&&"undefined"!=typeof self?wQ.worker=!0:!wQ.hasGlobalWindow||"Deno"in window?(wQ.node=!0,wQ.svgSupported=!0):function(e,t){var n=t.browser,r=e.match(/Firefox\/([\d.]+)/),i=e.match(/MSIE\s([\d.]+)/)||e.match(/Trident\/.+?rv:(([\d.]+))/),o=e.match(/Edge?\/([\d.]+)/),a=/micromessenger/i.test(e);r&&(n.firefox=!0,n.version=r[1]);i&&(n.ie=!0,n.version=i[1]);o&&(n.edge=!0,n.version=o[1],n.newEdge=+o[1].split(".")[0]>18);a&&(n.weChat=!0);t.svgSupported="undefined"!=typeof SVGRect,t.touchEventsSupported="ontouchstart"in window&&!n.ie&&!n.edge,t.pointerEventsSupported="onpointerdown"in window&&(n.edge||n.ie&&+n.version>=11),t.domSupported="undefined"!=typeof document;var s=document.documentElement.style;t.transform3dSupported=(n.ie&&"transition"in s||n.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||n.ie&&+n.version>=9}(navigator.userAgent,wQ),wQ.hasGlobalWindow&&ZJ(window.btoa);var SQ=Array.prototype.slice;function TQ(e,t,n){return(t-e)*n+e}function MQ(e,t,n,r){for(var i=t.length,o=0;o<i;o++)e[o]=TQ(t[o],n[o],r);return e}function CQ(e,t,n,r){for(var i=t.length,o=0;o<i;o++)e[o]=t[o]+n[o]*r;return e}function DQ(e,t,n,r){for(var i=t.length,o=i&&t[0].length,a=0;a<i;a++){e[a]||(e[a]=[]);for(var s=0;s<o;s++)e[a][s]=t[a][s]+n[a][s]*r}return e}function AQ(e,t){for(var n=e.length,r=t.length,i=n>r?t:e,o=Math.min(n,r),a=i[o-1]||{color:[0,0,0,0],offset:0},s=o;s<Math.max(n,r);s++)i.push({offset:a.offset,color:a.color.slice()})}function IQ(e,t,n){var r=e,i=t;if(r.push&&i.push){var o=r.length,a=i.length;if(o!==a)if(o>a)r.length=a;else for(var s=o;s<a;s++)r.push(1===n?i[s]:SQ.call(i[s]));var l=r[0]&&r[0].length;for(s=0;s<r.length;s++)if(1===n)isNaN(r[s])&&(r[s]=i[s]);else for(var u=0;u<l;u++)isNaN(r[s][u])&&(r[s][u]=i[s][u])}}function EQ(e){if(WJ(e)){var t=e.length;if(WJ(e[0])){for(var n=[],r=0;r<t;r++)n.push(SQ.call(e[r]));return n}return SQ.call(e)}return e}function LQ(e){return e[0]=Math.floor(e[0])||0,e[1]=Math.floor(e[1])||0,e[2]=Math.floor(e[2])||0,e[3]=null==e[3]?1:e[3],"rgba("+e.join(",")+")"}function NQ(e){return 4===e||5===e}function PQ(e){return 1===e||2===e}var OQ=[0,0,0,0],RQ=function(){function e(e){this.keyframes=[],this.discrete=!1,this._invalid=!1,this._needsSort=!1,this._lastFr=0,this._lastFrP=0,this.propName=e}return e.prototype.isFinished=function(){return this._finished},e.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},e.prototype.needsAnimate=function(){return this.keyframes.length>=1},e.prototype.getAdditiveTrack=function(){return this._additiveTrack},e.prototype.addKeyframe=function(e,t,n){this._needsSort=!0;var r=this.keyframes,i=r.length,o=!1,a=6,s=t;if(WJ(t)){var l=function(e){return WJ(e&&e[0])?2:1}(t);a=l,(1===l&&!qJ(t[0])||2===l&&!qJ(t[0][0]))&&(o=!0)}else if(qJ(t)&&!function(e){return e!=e}(t))a=0;else if(function(e){return"string"==typeof e}(t))if(isNaN(+t)){var u=_Q(t);u&&(s=u,a=3)}else a=0;else if(function(e){return null!=e.colorStops}(t)){var c=function(e,t){if(Object.assign)Object.assign(e,t);else for(var n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=t[n]);return e}({},s);c.colorStops=jJ(t.colorStops,(function(e){return{offset:e.offset,color:_Q(e.color)}})),"linear"===t.type?a=4:function(e){return"radial"===e.type}(t)&&(a=5),s=c}0===i?this.valType=a:a===this.valType&&6!==a||(o=!0),this.discrete=this.discrete||o;var h={time:e,value:s,rawValue:t,percent:0};return n&&(h.easing=n,h.easingFunc=ZJ(n)?n:zJ[n]||aQ(n)),r.push(h),h},e.prototype.prepare=function(e,t){var n=this.keyframes;this._needsSort&&n.sort((function(e,t){return e.time-t.time}));for(var r=this.valType,i=n.length,o=n[i-1],a=this.discrete,s=PQ(r),l=NQ(r),u=0;u<i;u++){var c=n[u],h=c.value,d=o.value;c.percent=c.time/e,a||(s&&u!==i-1?IQ(h,d,r):l&&AQ(h.colorStops,d.colorStops))}if(!a&&5!==r&&t&&this.needsAnimate()&&t.needsAnimate()&&r===t.valType&&!t._finished){this._additiveTrack=t;var p=n[0].value;for(u=0;u<i;u++)0===r?n[u].additiveValue=n[u].value-p:3===r?n[u].additiveValue=CQ([],n[u].value,p,-1):PQ(r)&&(n[u].additiveValue=1===r?CQ([],n[u].value,p,-1):DQ([],n[u].value,p,-1))}},e.prototype.step=function(e,t){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var n,r,i,o=null!=this._additiveTrack,a=o?"additiveValue":"value",s=this.valType,l=this.keyframes,u=l.length,c=this.propName,h=3===s,d=this._lastFr,p=Math.min;if(1===u)r=i=l[0];else{if(t<0)n=0;else if(t<this._lastFrP){for(n=p(d+1,u-1);n>=0&&!(l[n].percent<=t);n--);n=p(n,u-2)}else{for(n=d;n<u&&!(l[n].percent>t);n++);n=p(n-1,u-2)}i=l[n+1],r=l[n]}if(r&&i){this._lastFr=n,this._lastFrP=t;var f=i.percent-r.percent,g=0===f?1:p((t-r.percent)/f,1);i.easingFunc&&(g=i.easingFunc(g));var m=o?this._additiveValue:h?OQ:e[c];if(!PQ(s)&&!h||m||(m=this._additiveValue=[]),this.discrete)e[c]=g<1?r.rawValue:i.rawValue;else if(PQ(s))1===s?MQ(m,r[a],i[a],g):function(e,t,n,r){for(var i=t.length,o=i&&t[0].length,a=0;a<i;a++){e[a]||(e[a]=[]);for(var s=0;s<o;s++)e[a][s]=TQ(t[a][s],n[a][s],r)}}(m,r[a],i[a],g);else if(NQ(s)){var v=r[a],y=i[a],_=4===s;e[c]={type:_?"linear":"radial",x:TQ(v.x,y.x,g),y:TQ(v.y,y.y,g),colorStops:jJ(v.colorStops,(function(e,t){var n=y.colorStops[t];return{offset:TQ(e.offset,n.offset,g),color:LQ(MQ([],e.color,n.color,g))}})),global:y.global},_?(e[c].x2=TQ(v.x2,y.x2,g),e[c].y2=TQ(v.y2,y.y2,g)):e[c].r=TQ(v.r,y.r,g)}else if(h)MQ(m,r[a],i[a],g),o||(e[c]=LQ(m));else{var x=TQ(r[a],i[a],g);o?this._additiveValue=x:e[c]=x}o&&this._addToTarget(e)}}},e.prototype._addToTarget=function(e){var t=this.valType,n=this.propName,r=this._additiveValue;0===t?e[n]=e[n]+r:3===t?(_Q(e[n],OQ),CQ(OQ,OQ,r,1),e[n]=LQ(OQ)):1===t?CQ(e[n],e[n],r,1):2===t&&DQ(e[n],e[n],r,1)},e}(),kQ=function(){function e(e,t,n,r){this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=e,this._loop=t,t&&r?UJ("Can' use additive animation on looped animation."):(this._additiveAnimators=r,this._allowDiscrete=n)}return e.prototype.getMaxTime=function(){return this._maxTime},e.prototype.getDelay=function(){return this._delay},e.prototype.getLoop=function(){return this._loop},e.prototype.getTarget=function(){return this._target},e.prototype.changeTarget=function(e){this._target=e},e.prototype.when=function(e,t,n){return this.whenWithKeys(e,t,YJ(t),n)},e.prototype.whenWithKeys=function(e,t,n,r){for(var i=this._tracks,o=0;o<n.length;o++){var a=n[o],s=i[a];if(!s){s=i[a]=new RQ(a);var l=void 0,u=this._getAdditiveTrack(a);if(u){var c=u.keyframes,h=c[c.length-1];l=h&&h.value,3===u.valType&&l&&(l=LQ(l))}else l=this._target[a];if(null==l)continue;e>0&&s.addKeyframe(0,EQ(l),r),this._trackKeys.push(a)}s.addKeyframe(e,EQ(t[a]),r)}return this._maxTime=Math.max(this._maxTime,e),this},e.prototype.pause=function(){this._clip.pause(),this._paused=!0},e.prototype.resume=function(){this._clip.resume(),this._paused=!1},e.prototype.isPaused=function(){return!!this._paused},e.prototype.duration=function(e){return this._maxTime=e,this._force=!0,this},e.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var e=this._doneCbs;if(e)for(var t=e.length,n=0;n<t;n++)e[n].call(this)},e.prototype._abortedCallback=function(){this._setTracksFinished();var e=this.animation,t=this._abortedCbs;if(e&&e.removeClip(this._clip),this._clip=null,t)for(var n=0;n<t.length;n++)t[n].call(this)},e.prototype._setTracksFinished=function(){for(var e=this._tracks,t=this._trackKeys,n=0;n<t.length;n++)e[t[n]].setFinished()},e.prototype._getAdditiveTrack=function(e){var t,n=this._additiveAnimators;if(n)for(var r=0;r<n.length;r++){var i=n[r].getTrack(e);i&&(t=i)}return t},e.prototype.start=function(e){if(!(this._started>0)){this._started=1;for(var t=this,n=[],r=this._maxTime||0,i=0;i<this._trackKeys.length;i++){var o=this._trackKeys[i],a=this._tracks[o],s=this._getAdditiveTrack(o),l=a.keyframes,u=l.length;if(a.prepare(r,s),a.needsAnimate())if(!this._allowDiscrete&&a.discrete){var c=l[u-1];c&&(t._target[a.propName]=c.rawValue),a.setFinished()}else n.push(a)}if(n.length||this._force){var h=new sQ({life:r,loop:this._loop,delay:this._delay||0,onframe:function(e){t._started=2;var r=t._additiveAnimators;if(r){for(var i=!1,o=0;o<r.length;o++)if(r[o]._clip){i=!0;break}i||(t._additiveAnimators=null)}for(o=0;o<n.length;o++)n[o].step(t._target,e);var a=t._onframeCbs;if(a)for(o=0;o<a.length;o++)a[o](t._target,e)},ondestroy:function(){t._doneCallback()}});this._clip=h,this.animation&&this.animation.addClip(h),e&&h.setEasing(e)}else this._doneCallback();return this}},e.prototype.stop=function(e){if(this._clip){var t=this._clip;e&&t.onframe(1),this._abortedCallback()}},e.prototype.delay=function(e){return this._delay=e,this},e.prototype.during=function(e){return e&&(this._onframeCbs||(this._onframeCbs=[]),this._onframeCbs.push(e)),this},e.prototype.done=function(e){return e&&(this._doneCbs||(this._doneCbs=[]),this._doneCbs.push(e)),this},e.prototype.aborted=function(e){return e&&(this._abortedCbs||(this._abortedCbs=[]),this._abortedCbs.push(e)),this},e.prototype.getClip=function(){return this._clip},e.prototype.getTrack=function(e){return this._tracks[e]},e.prototype.getTracks=function(){var e=this;return jJ(this._trackKeys,(function(t){return e._tracks[t]}))},e.prototype.stopTracks=function(e,t){if(!e.length||!this._clip)return!0;for(var n=this._tracks,r=this._trackKeys,i=0;i<e.length;i++){var o=n[e[i]];o&&!o.isFinished()&&(t?o.step(this._target,1):1===this._started&&o.step(this._target,0),o.setFinished())}var a=!0;for(i=0;i<r.length;i++)if(!n[r[i]].isFinished()){a=!1;break}return a&&this._abortedCallback(),a},e.prototype.saveTo=function(e,t,n){if(e){t=t||this._trackKeys;for(var r=0;r<t.length;r++){var i=t[r],o=this._tracks[i];if(o&&!o.isFinished()){var a=o.keyframes,s=a[n?0:a.length-1];s&&(e[i]=EQ(s.rawValue))}}}},e.prototype.__changeFinalValue=function(e,t){t=t||YJ(e);for(var n=0;n<t.length;n++){var r=t[n],i=this._tracks[r];if(i){var o=i.keyframes;if(o.length>1){var a=o.pop();i.addKeyframe(a.time,e[r]),i.prepare(this._maxTime,i.getAdditiveTrack())}}}},e}(),zQ={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var n;if(e){for(var r=e.split("."),i=this,o=0,a=r.length;o<a;o++)i&&(i=i[r[o]]);i&&(n=i)}else n=this;if(null==n)throw new Error("Target "+e+" not exists");var s=this._animators,l=new kQ(n,t),u=this;return l.during((function(){u.__zr&&u.__zr.refresh()})).done((function(){var e=s.indexOf(l);e>=0&&s.splice(e,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,n=t.length,r=0;r<n;r++)t[r].stop(e);return t.length=0,this},addAnimatorsToZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.addAnimator(this._animators[t])},removeAnimatorsFromZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.removeAnimator(this._animators[t])}},VQ="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";function BQ(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}Object.assign(MK.prototype,zQ),wq.import(VQ),wq.import(Mq),wq.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),wq.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),wq.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),wq.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),wq.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),wq.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var FQ=b$.prototype.addToScene,GQ=b$.prototype.removeFromScene;b$.prototype.addToScene=function(e){if(FQ.call(this,e),this.__zr){var t=this.__zr;e.traverse((function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)}))}},b$.prototype.removeFromScene=function(e){GQ.call(this,e),e.traverse((function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}))},jZ.prototype.setTextureImage=function(e,t,n,r){if(this.shader){var i,o,a=n.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),(o=t)&&"none"!==o&&(i=HQ.loadTexture(t,n,r,(function(t){s.enableTexture(e),a&&a.refresh()})),s.set(e,i)),i}};var HQ={};HQ.Renderer=Vq,HQ.Node=MK,HQ.Mesh=LK,HQ.Shader=wq,HQ.Material=jZ,HQ.Texture=EK,HQ.Texture2D=RK,HQ.Geometry=XK,HQ.SphereGeometry=TJ,HQ.PlaneGeometry=W$,HQ.CubeGeometry=X$,HQ.AmbientLight=MJ,HQ.DirectionalLight=CJ,HQ.PointLight=DJ,HQ.SpotLight=AJ,HQ.PerspectiveCamera=E$,HQ.OrthographicCamera=uJ,HQ.Vector2=KZ,HQ.Vector3=Fq,HQ.Vector4=IJ,HQ.Quaternion=cK,HQ.Matrix2=PJ,HQ.Matrix2d=RJ,HQ.Matrix3=kJ,HQ.Matrix4=aK,HQ.Plane=i$,HQ.Ray=Jq,HQ.BoundingBox=bK,HQ.Frustum=h$;var UQ,WQ=null;function jQ(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function XQ(e){if((e.wrapS===EK.REPEAT||e.wrapT===EK.REPEAT)&&e.image){var t=jQ(e.width),n=jQ(e.height);if(t!==e.width||n!==e.height){var r=document.createElement("canvas");r.width=t,r.height=n,r.getContext("2d").drawImage(e.image,0,0,t,n),e.image=r}}}HQ.loadTexture=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n||{};for(var i=Object.keys(n).sort(),o="",a=0;a<i.length;a++)o+=i[a]+"_"+n[i[a]]+"_";var s,l=t.__textureCache=t.__textureCache||new M$(20);if((s=e).getZr&&s.setOption){var u=e.__textureid__;if(h=l.get(o+u))h.texture.surface.setECharts(e),r&&r(h.texture);else{var c=new lJ(e);c.onupdate=function(){t.getZr().refresh()},h={texture:c.getTexture()};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_ec__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),r&&r(h.texture)}return h.texture}if(BQ(e)){var h;u=e.__textureid__;if(!(h=l.get(o+u))){h={texture:new HQ.Texture2D({image:e})};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_image__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),XQ(h.texture),r&&r(h.texture)}return h.texture}if(h=l.get(o+e))h.callbacks?h.callbacks.push(r):r&&r(h.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){h={callbacks:[r]};var d=oJ.loadTexture(e,{exposure:n.exposure,fileType:"hdr"},(function(){d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null}));h.texture=d,l.put(o+e,h)}else{for(d=new HQ.Texture2D({image:new Image}),a=0;a<i.length;a++)d[i[a]]=n[i[a]];h={texture:d,callbacks:[r]};var p=d.image;p.onload=function(){d.image=p,XQ(d),d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null},p.crossOrigin="Anonymous",p.src=e,d.image=null!==WQ?WQ:WQ=oJ.createBlank("rgba(255,255,255,0)").image,l.put(o+e,h)}return h.texture},HQ.createAmbientCubemap=function(e,t,n,r){var i=(e=e||{}).texture,o=wJ(e.exposure,1),a=new mJ({intensity:wJ(e.specularIntensity,1)}),s=new vJ({intensity:wJ(e.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return a.cubemap=HQ.loadTexture(i,n,{exposure:o},(function(){if(a.cubemap.flipY=!1,"production"!==process.env.NODE_ENV)var e=Date.now();if(a.prefilter(t,32),"production"!==process.env.NODE_ENV){var n=Date.now()-e;console.log("Prefilter environment map: "+n+"ms")}s.coefficients=yJ.projectEnvironmentMap(t,a.cubemap,{lod:1}),r&&r()})),{specular:a,diffuse:s}},HQ.createBlankTexture=oJ.createBlank,HQ.isImage=BQ,HQ.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)},HQ.parseColor=function(e,t){return e instanceof Array?(t||(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],e.length>3?t[3]=e[3]:t[3]=1,t):((t=rr(e||"#000",t)||[0,0,0,0])[0]/=255,t[1]/=255,t[2]/=255,t)},HQ.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,r=-t/180*Math.PI+Math.PI/2,i=[],o=Math.sin(n);return i[0]=o*Math.cos(r),i[1]=-Math.cos(n),i[2]=o*Math.sin(r),i},HQ.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},HQ.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],HQ.createShader=function(e){"ecgl.shadow"===e&&(e="ecgl.displayShadow");var t=wq.source(e+".vertex"),n=wq.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),n||console.error("Fragment shader of '%s' not exits",e);var r=new wq(t,n);return r.name=e,r},HQ.createMaterial=function(e,t){t instanceof Array||(t=[t]);var n=HQ.createShader(e),r=new jZ({shader:n});return t.forEach((function(e){"string"==typeof e&&r.define(e)})),r},HQ.setMaterialFromModel=function(e,t,n,r){t.autoUpdateTextureStatus=!1;var i=n.getModel(e+"Material"),o=i.get("detailTexture"),a=wJ(i.get("textureTiling"),1),s=wJ(i.get("textureOffset"),0);"number"==typeof a&&(a=[a,a]),"number"==typeof s&&(s=[s,s]);var l=a[0]>1||a[1]>1?HQ.Texture.REPEAT:HQ.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===e){var c=i.get("roughness"),h=i.get("metalness");null!=h?isNaN(h)&&(t.setTextureImage("metalnessMap",h,r,u),h=wJ(i.get("metalnessAdjust"),.5)):h=0,null!=c?isNaN(c)&&(t.setTextureImage("roughnessMap",c,r,u),c=wJ(i.get("roughnessAdjust"),.5)):c=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",o,r,u),t.setTextureImage("normalMap",d,r,u),t.set({roughness:c,metalness:h,detailUvRepeat:a,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("hatching"===e){var p=i.get("hatchingTextures")||[];p.length<6&&"production"!==process.env.NODE_ENV&&console.error("Invalid hatchingTextures.");for(var f=0;f<6;f++)t.setTextureImage("hatch"+(f+1),p[f],r,{anisotropic:8,wrapS:HQ.Texture.REPEAT,wrapT:HQ.Texture.REPEAT});t.set({detailUvRepeat:a,detailUvOffset:s})}},HQ.updateVertexAnimation=function(e,t,n,r){var i=r.get("animation"),o=r.get("animationDurationUpdate"),a=r.get("animationEasingUpdate"),s=n.shadowDepthMaterial;if(i&&t&&o>0&&t.geometry.vertexCount===n.geometry.vertexCount){n.material.define("vertex","VERTEX_ANIMATION"),n.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)n.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;n.geometry.dirty(),n.__percent=0,n.material.set("percent",0),n.stopAnimation(),n.animate().when(o,{__percent:1}).during((function(){n.material.set("percent",n.__percent),s&&s.set("percent",n.__percent)})).done((function(){n.ignorePreZ=!1,n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")})).start(a)}else n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")},UQ=wQ.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(e){return setTimeout(e,16)};var YQ=function(e,t){this.id=e,this.zr=t;try{this.renderer=new Vq({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(e){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(e)}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var n=this.dom.style;n.position="absolute",n.left="0",n.top="0",this.views=[],this._picking=new DK({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new ol({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};function ZQ(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}YQ.prototype.setUnpainted=function(){},YQ.prototype.addView=function(e){if(e.layer!==this){var t=this._viewsToDispose.indexOf(e);t>=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var n=this.zr;e.scene.traverse((function(e){e.__zr=n,e.addAnimatorsToZr&&e.addAnimatorsToZr(n)}))}},YQ.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(ZQ,this),e.layer=null,this._viewsToDispose.push(e))}},YQ.prototype.removeViewsAll=function(){this.views.forEach((function(e){e.scene.traverse(ZQ,this),e.layer=null,this._viewsToDispose.push(e)}),this),this.views.length=0},YQ.prototype.resize=function(e,t){this.renderer.resize(e,t)},YQ.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},YQ.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},YQ.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},YQ.prototype.needsRefresh=function(){this.zr.refresh()},YQ.prototype.refresh=function(e){this._backgroundColor=e?HQ.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t<this.views.length;t++)this.views[t].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(t=0;t<this._viewsToDispose.length;t++)this._viewsToDispose[t].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},YQ.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)},YQ.prototype._doRender=function(e){this.clear(),this.renderer.saveViewport();for(var t=0;t<this.views.length;t++)this.views[t].render(this.renderer,e);this.renderer.restoreViewport()},YQ.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var qQ=1;function KQ(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function $Q(e,t){for(var n=0;n<t.length;n++)t[n].__used__||t[n].dispose(e)}function JQ(e,t){e.__used__=e.__used__||0,e.__used__++,1===e.__used__&&t.push(e)}function QQ(e,t,n){var r,i;e.traverse((function(e){if(e.isRenderable()){var o=e.geometry,a=e.material;if(a!==r)for(var s=a.getTextureUniforms(),l=0;l<s.length;l++){var u=s[l],c=a.uniforms[u].value;if(c)if(c instanceof EK)JQ(c,t);else if(c instanceof Array)for(var h=0;h<c.length;h++)c[h]instanceof EK&&JQ(c[h],t)}o!==i&&JQ(o,n),r=a,i=o}}));for(var o=0;o<e.lights.length;o++)e.lights[o].cubemap&&JQ(e.lights[o].cubemap,t)}YQ.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var n=!1,r=0;r<this.views.length;r++)n=this.views[r].needsAccumulate()||n;function i(r){if(t._accumulatingId&&r===t._accumulatingId){for(var o=!0,a=0;a<t.views.length;a++)o=t.views[a].isAccumulateFinished()&&n;o||(t._doRender(!0),e?i(r):UQ((function(){i(r)})))}}n&&(this._accumulatingId=qQ++,e?i(t._accumulatingId):this._accumulatingTimeout=setTimeout((function(){i(t._accumulatingId)}),50))},YQ.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(KQ(this._textureList),KQ(this._geometriesList));for(var n=0;n<this.views.length;n++)QQ(this.views[n].scene,e,t);this._textureList&&($Q(this.renderer,this._textureList),$Q(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t},YQ.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(KQ(this._textureList),KQ(this._geometriesList),$Q(this.renderer,this._textureList),$Q(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)},YQ.prototype.onmousedown=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mousedown",e,t),this._dispatchDataEvent("mousedown",e,t)),this._downX=e.offsetX,this._downY=e.offsetY}},YQ.prototype.onmousemove=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),n=t&&t.target,r=this._hovered;this._hovered=t,r&&n!==r.target&&(r.relatedTarget=n,this._dispatchEvent("mouseout",e,r),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),r&&n===r.target||this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}},YQ.prototype.onmouseup=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mouseup",e,t),this._dispatchDataEvent("mouseup",e,t)),this._upX=e.offsetX,this._upY=e.offsetY}},YQ.prototype.onclick=YQ.prototype.dblclick=function(e){if(!e.target||!e.target.__isGLToZRProxy){var t=this._upX-this._downX,n=this._upY-this._downY;if(!(Math.sqrt(t*t+n*n)>20)){e=e.event;var r=this.pickObject(e.offsetX,e.offsetY);r&&(this._dispatchEvent(e.type,e,r),this._dispatchDataEvent(e.type,e,r));var i=this._clickToSetFocusPoint(e);if(i)i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}},YQ.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,n=t.viewport,r=this.views.length-1;r>=0;r--){var i=this.views[r];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var o=this._picking.pick(e.offsetX,e.offsetY,!0);if(o)return o.view=i,o}}t.viewport=n},YQ.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},YQ.prototype.pickObject=function(e,t){for(var n=[],r=this.renderer,i=r.viewport,o=0;o<this.views.length;o++){var a=this.views[o];a.containPoint(e,t)&&(this._picking.scene=a.scene,this._picking.camera=a.camera,r.viewport=a.viewport,this._picking.pickAll(e,t,n))}return r.viewport=i,n.sort((function(e,t){return e.distance-t.distance})),n[0]},YQ.prototype._dispatchEvent=function(e,t,n){n||(n={});var r=n.target;for(n.cancelBubble=!1,n.event=t,n.type=e,n.offsetX=t.offsetX,n.offsetY=t.offsetY;r&&(r.trigger(e,n),r=r.getParent(),!n.cancelBubble););this._dispatchToView(e,n)},YQ.prototype._dispatchDataEvent=function(e,t,n){var r=n&&n.target,i=r&&r.dataIndex,o=r&&r.seriesIndex,a=r&&r.eventData,s=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l};const c=bl(l);"mousemove"===e&&(null!=i?i!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0):null!=a&&a!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0),this._lastEventData=a,this._lastDataIndex=i,this._lastSeriesIndex=o),c.eventData=a,c.dataIndex=i,c.seriesIndex=o,(null!=a||parseInt(i,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),s&&this.zr.handler.dispatchToElement(u,"mouseover",t))},YQ.prototype._dispatchToView=function(e,t){for(var n=0;n<this.views.length;n++)this.views[n].containPoint(t.offsetX,t.offsetY)&&this.views[n].trigger(e,t)},Object.assign(YQ.prototype,yY);var e0=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function t0(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var n=e[t].normal,r=e[t].emphasis;n&&(e[t]=n),r&&(e.emphasis=e.emphasis||{},e.emphasis[t]=r)}}function n0(e){e&&(e instanceof Array||(e=[e]),W(e,(function(e){if(e.axisLabel){var t=e.axisLabel;Object.assign(t,t.textStyle),t.textStyle=null}})))}function r0(e){this._layers={},this._zr=e}r0.prototype.update=function(e,t){var n=this,r=t.getZr();if(r.getWidth()&&r.getHeight()){for(var i in this._layers)this._layers[i].removeViewsAll();e.eachComponent((function(n,r){if("series"!==n){var i=t.getViewOfComponentModel(r),s=r.coordinateSystem;if(i.__ecgl__){if(s){if(!s.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+r.id);l=s.viewGL}else{if(!r.viewGL)return void console.error("Can't find viewGL of component "+r.id);l=s.viewGL}var l=s.viewGL,u=o(r);u.addView(l),i.afterRender&&i.afterRender(r,e,t,u),a(i.groupGL,r.get("silent"))}}})),e.eachSeries((function(n){var r=t.getViewOfSeriesModel(n),i=n.coordinateSystem;if(r.__ecgl__){if(i&&!i.viewGL&&!r.viewGL)return void console.error("Can't find viewGL of series "+r.id);var s=i&&i.viewGL||r.viewGL,l=o(n);l.addView(s),r.afterRender&&r.afterRender(n,e,t,l),a(r.groupGL,n.get("silent"))}}))}else console.warn("Dom has no width or height");function o(e){var t;r.setSleepAfterStill(0),t=(e.coordinateSystem&&e.coordinateSystem.model,e.get("zlevel"));var i=n._layers,o=i[t];if(!o){if(o=i[t]=new YQ("gl-"+t,r),r.painter.isSingleCanvas()){o.virtual=!0;var a=new Js({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=a,r.add(a)}r.painter.insertLayer(t,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function a(e,t){e&&e.traverse((function(e){e.isRenderable&&e.isRenderable()&&(e.ignorePicking=null!=e.$ignorePicking?e.$ignorePicking:t)}))}},Xy((function(e){var t=e.getZr(),n=t.painter.dispose;t.painter.dispose=function(){"function"==typeof this.eachOtherLayer&&this.eachOtherLayer((function(e){e instanceof YQ&&e.dispose()})),n.call(this)},t.painter.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas)return this._layers[0].dom;var t=document.createElement("canvas"),n=e.pixelRatio||this.dpr;t.width=this.getWidth()*n,t.height=this.getHeight()*n;var r=t.getContext("2d");r.dpr=n,r.clearRect(0,0,t.width,t.height),e.backgroundColor&&(r.fillStyle=e.backgroundColor,r.fillRect(0,0,t.width,t.height));var i,o=this.storage.getDisplayList(!0),a={},s=this;function l(e,t){var n,i=s._zlevelList;null==e&&(e=-1/0);for(var o=0;o<i.length;o++){var a=i[o],l=s._layers[a];if(!l.__builtin__&&a>e&&a<t){n=l;break}}n&&n.renderToCanvas&&(r.save(),n.renderToCanvas(r),r.restore())}for(var u={ctx:r},c=0;c<o.length;c++){var h=o[c];h.zlevel!==i&&(l(i,h.zlevel),i=h.zlevel),this._doPaintEl(h,u,!0,null,a)}return l(i,1/0),t}})),Yy((function(e,t){var n=t.getZr();(n.__egl=n.__egl||new r0(n)).update(e,t)})),Wy((function(e){W(e.series,(function(t){F(e0,t.type)>=0&&(!function(e){t0(e,"itemStyle"),t0(e,"lineStyle"),t0(e,"areaStyle"),t0(e,"label")}(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))})),n0(e.xAxis3D),n0(e.yAxis3D),n0(e.zAxis3D),n0(e.grid3D),t0(e.geo3D)}));var i0={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(e){e=e||{},this.option.viewControl=this.option.viewControl||{},null!=e.alpha&&(this.option.viewControl.alpha=e.alpha),null!=e.beta&&(this.option.viewControl.beta=e.beta),null!=e.distance&&(this.option.viewControl.distance=e.distance),null!=e.center&&(this.option.viewControl.center=e.center)}},o0={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},a0={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}},s0=tp.extend({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});R(s0.prototype,i0),R(s0.prototype,o0),R(s0.prototype,a0);var l0=wJ,u0={left:0,middle:1,right:2};function c0(e){return e instanceof Array||(e=[e,e]),e}var h0=wY.extend((function(){return{zr:null,viewGL:null,_center:new Fq,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new KZ,_panVelocity:new KZ,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}}),(function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach((function(e){this[e]=this[e].bind(this)}),this)}),{init:function(){var e=this.zr;e&&(e.on("mousedown",this._mouseDownHandler),e.on("globalout",this._mouseUpHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("pinch",this._pinchHandler),e.animation.on("frame",this._update),e.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var e=this.zr;e&&(e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("pinch",this._pinchHandler),e.off("globalout",this._mouseUpHandler),e.dom.removeEventListener("contextmenu",this._contextMenuHandler),e.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(e){this._orthoSize=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setViewGL:function(e){this.viewGL=e},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(e,t){var n=(t=t||{}).baseDistance||0,r=t.baseOrthoSize||1,i=e.get("projection");"perspective"!==i&&"orthographic"!==i&&"isometric"!==i&&("production"!==process.env.NODE_ENV&&console.error("Unkown projection type %s, use perspective projection instead.",i),i="perspective"),this._projection=i,this.viewGL.setProjection(i);var o=e.get("distance")+n,a=e.get("orthographicSize")+r;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach((function(t){this[t[0]]=l0(e.get(t[0]),t[1])}),this),this.minDistance+=n,this.maxDistance+=n,this.minOrthographicSize+=r,this.maxOrthographicSize+=r;var s=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach((function(t){l[t]=l0(e.get(t),s&&s.get(t))}));var u=l0(t.alpha,e.get("alpha"))||0,c=l0(t.beta,e.get("beta"))||0,h=l0(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:c,center:h,distance:o,orthographicSize:a,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(o),this.setAlpha(u),this.setBeta(c),this.setCenter(h),this.setOrthographicSize(a)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){"production"!==process.env.NODE_ENV&&(null==u0[this.panMouseButton]&&console.error("Unkown panMouseButton %s. It should be left|middle|right",this.panMouseButton),null==u0[this.rotateMouseButton]&&console.error("Unkown rotateMouseButton %s. It should be left|middle|right",this.rotateMouseButton),"cw"!==this.autoRotateDirection&&"ccw"!==this.autoRotateDirection&&console.error("Unkown autoRotateDirection %s. It should be cw|ccw",this.autoRotateDirection))},animateTo:function(e){var t=this.zr,n=this,r={},i={};return null!=e.distance&&(r.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(r.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(r.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(r).when(e.duration||1e3,i).during((function(){null!=r.alpha&&n.setAlpha(r.alpha),null!=r.beta&&n.setBeta(r.beta),null!=r.distance&&n.setDistance(r.distance),null!=r.center&&n.setCenter(r.center),null!=r.orthographicSize&&n.setOrthographicSize(r.orthographicSize),n._needsUpdate=!0}))).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e<this._animators.length;e++)this._animators[e].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),n=this._orthoSize,r=n/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-r/2,t.right=r/2,t.top=n/2,t.bottom=-n/2},_updatePan:function(e){var t=this._panVelocity,n=this._distance,r=this.getCamera(),i=r.worldTransform.y,o=r.worldTransform.x;this._center.scaleAndAdd(o,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new Fq,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(r),t.y=-Math.cos(n),t.z=i*Math.sin(r),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout((function(){t._rotating=!0}),1e3*e))},_vectorDamping:function(e,t){var n=e.len();(n*=t)<1e-4&&(n=0),e.normalize().scale(n)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),n=Math.atan2(e.x,e.z);this._theta=t,this._phi=-n,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,n=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,n)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===u0[this.rotateMouseButton]?this._mode="rotate":e.event.button===u0[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=c0(this.panSensitivity),n=c0(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*n[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*n[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var n,r=e.offsetX,i=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i))n="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*n*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done((function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)})),e}});Object.defineProperty(h0.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});var d0={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var n in t)e||!t[n].value?t[n].value=[]:t[n].value=Array.prototype.slice.call(t[n].value);e||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var e=this.attributes;for(var t in e)e[t].value&&e[t].value.length>0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},p0={vec2:qZ,vec3:Dq,vec4:Qq,mat2:NJ,mat2d:OJ,mat3:eK,mat4:Cq,quat:oK},f0=p0.vec3,g0=[[0,0],[1,1]],m0=XK.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION"),positionPrev:new XK.Attribute("positionPrev","float",3),positionNext:new XK.Attribute("positionNext","float",3),prevPositionPrev:new XK.Attribute("prevPositionPrev","float",3),prevPosition:new XK.Attribute("prevPosition","float",3),prevPositionNext:new XK.Attribute("prevPositionNext","float",3),offset:new XK.Attribute("offset","float",1),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.positionPrev.init(e),t.positionNext.init(e),t.offset.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(f0.dist(e,t)+f0.dist(n,t)+f0.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(g0)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(g0)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=e[2],u=t[0],c=t[1],h=t[2],d=n[0],p=n[1],f=n[2],g=r[0],m=r[1],v=r[2],y=this._getCubicCurveApproxStep(e,t,n,r),_=y*y,x=_*y,b=3*y,w=3*_,S=6*_,T=6*x,M=a-2*u+d,C=s-2*c+p,D=l-2*h+f,A=3*(u-d)-a+g,I=3*(c-p)-s+m,E=3*(h-f)-l+v,L=a,N=s,P=l,O=(u-a)*b+M*w+A*x,R=(c-s)*b+C*w+I*x,k=(h-l)*b+D*w+E*x,z=M*S+A*T,V=C*S+I*T,B=D*S+E*T,F=A*T,G=I*T,H=E*T,U=0,W=0,j=Math.ceil(1/y),X=new Float32Array(3*(j+1)),Y=(X=[],0);for(W=0;W<j+1;W++)X[Y++]=L,X[Y++]=N,X[Y++]=P,L+=O,N+=R,P+=k,O+=z,R+=V,k+=B,z+=F,V+=G,B+=H,(U+=y)>1&&(L=O>0?Math.min(L,g):Math.max(L,g),N=R>0?Math.min(N,m):Math.max(N,m),P=k>0?Math.min(P,v):Math.max(P,v));return this.addPolyline(X,i,o)},addLine:function(e,t,n,r){return this.addPolyline([e,t],n,r)},addPolyline:function(e,t,n,r,i){if(e.length){var o="number"!=typeof e[0];if(null==i&&(i=o?e.length:e.length/3),!(i<2)){null==r&&(r=0),null==n&&(n=1),this._itemVertexOffsets.push(this._vertexOffset);var a,s,l=(o="number"!=typeof e[0])?"number"!=typeof t[0]:t.length/4===i,u=this.attributes.position,c=this.attributes.positionPrev,h=this.attributes.positionNext,d=this.attributes.color,p=this.attributes.offset,f=this.indices,g=this._vertexOffset;n=Math.max(n,.01);for(var m=r;m<i;m++){if(o)a=e[m],s=l?t[m]:t;else{var v=3*m;if((a=a||[])[0]=e[v],a[1]=e[v+1],a[2]=e[v+2],l){var y=4*m;(s=s||[])[0]=t[y],s[1]=t[y+1],s[2]=t[y+2],s[3]=t[y+3]}else s=t}if(this.useNativeLine?m>1&&(u.copy(g,g-1),d.copy(g,g-1),g++):(m<i-1&&(c.set(g+2,a),c.set(g+3,a)),m>0&&(h.set(g-2,a),h.set(g-1,a)),u.set(g,a),u.set(g+1,a),d.set(g,s),d.set(g+1,s),p.set(g,n/2),p.set(g+1,-n/2),g+=2),this.useNativeLine)d.set(g,s),u.set(g,a),g++;else if(m>0){var _=3*this._triangleOffset;(f=this.indices)[_]=g-4,f[_+1]=g-3,f[_+2]=g-2,f[_+3]=g-3,f[_+4]=g-1,f[_+5]=g-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*i;c.copy(x,x+2),c.copy(x+1,x+3),h.copy(b-1,b-3),h.copy(b-2,b-4)}return this._vertexOffset=g,this._vertexOffset}}},setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});function v0(e,t,n,r,i,o,a){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=r,this.height=i,this.offsetX=t,this.offsetY=n,this.dpr=a,this.gap=o}function y0(e){(e=e||{}).width=e.width||512,e.height=e.height||512,e.devicePixelRatio=e.devicePixelRatio||1,e.gap=null==e.gap?2:e.gap;var t=document.createElement("canvas");t.width=e.width*e.devicePixelRatio,t.height=e.height*e.devicePixelRatio,this._canvas=t,this._texture=new RK({image:t,flipY:!1});var n=this;this._zr=Ji(t);var r=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){r.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new v0(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}function _0(){}V(m0.prototype,d0),v0.prototype={constructor:v0,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,n){var r=e.getBoundingRect();null==t&&(t=r.width),null==n&&(n=r.height),t*=this.dpr,n*=this.dpr,this._fitElement(e,t,n);var i=this._x,o=this._y,a=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(i+t+l>a&&(i=this._x=0,o+=this._rowHeight+l,this._y=o,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,n),o+n+l>s)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+o,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height];return[[i/a+u[0],o/s+u[1]],[(i+t)/a+u[0],(o+n)/s+u[1]]]},_fitElement:function(e,t,n){var r=e.getBoundingRect(),i=t/r.width,o=n/r.height;e.x=-r.x*i,e.y=-r.y*o,e.scaleX=i,e.scaleY=o,e.update()}},y0.prototype={clear:function(){for(var e=0;e<this._textureAtlasNodes.length;e++)this._textureAtlasNodes[e].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var e=4096/this._dpr,t=this._textureAtlasNodes.length,n=t*this._nodeWidth%e,r=Math.floor(t*this._nodeWidth/e)*this._nodeHeight;if(!(r>=e)){var i=(n+this._nodeWidth)*this._dpr,o=(r+this._nodeHeight)*this._dpr;try{this._zr.resize({width:i,height:o})}catch(e){this._canvas.width=i,this._canvas.height=o}var a=new v0(this._zr,n,r,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(a),a}"production"!==process.env.NODE_ENV&&console.error("Too much labels. Some will be ignored.")},add:function(e,t,n){if(this._coords[e.id])return"production"!==process.env.NODE_ENV&&console.warn("Element already been add"),this._coords[e.id];var r=this._getCurrentNode().add(e,t,n);if(!r){var i=this._expand();if(!i)return;r=i.add(e,t,n)}return this._coords[e.id]=r,r},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}},_0.prototype={constructor:_0,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new HQ.DirectionalLight({shadowBias:.005}),this.ambientLight=new HQ.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,n=this.ambientLight,r=e.getModel("light"),i=r.getModel("main"),o=r.getModel("ambient");t.intensity=i.get("intensity"),n.intensity=o.get("intensity"),t.color=HQ.parseColor(i.get("color")).slice(0,3),n.color=HQ.parseColor(o.get("color")).slice(0,3);var a=i.get("alpha")||0,s=i.get("beta")||0;t.position.setArray(HQ.directionFromAlphaBeta(a,s)),t.lookAt(HQ.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=HQ.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,n){var r=t.getModel("light.ambientCubemap"),i=r.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var o=this._cubemapLightsCache[i];if(!o){var a=this;o=this._cubemapLightsCache[i]=HQ.createAmbientCubemap(r.option,e,n,(function(){a._isSkyboxFromAmbientCubemap&&a._skybox.setEnvironmentMap(o.specular.cubemap),n.getZr().refresh()}))}this._lightRoot.add(o.diffuse),this._lightRoot.add(o.specular),this._currentCubemapLights=o}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,t,n){var r=t.get("environment"),i=this;var o=(i._skybox=i._skybox||new Z$,i._skybox);if(r&&"none"!==r)if("auto"===r)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var a=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(a),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof r&&r.colorStops||"string"==typeof r&&rr(r)){this._isSkyboxFromAmbientCubemap=!1;var s=new HQ.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(s);var l=s.image=document.createElement("canvas");l.width=l.height=16,Ov(l.getContext("2d"),new ol({shape:{x:0,y:0,width:16,height:16},style:{fill:r}})),o.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;s=HQ.loadTexture(r,n,{anisotropic:8,flipY:!1});o.setEnvironmentMap(s),o.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var u=t.coordinateSystem;if(this._skybox)if(!u||!u.viewGL||"auto"===r||r.match&&r.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var c=u.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[c]("fragment","SRGB_DECODE")}}};var x0=p0.vec3,b0=XK.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION"),normal:new XK.Attribute("normal","float",3,"NORMAL"),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,n=this.getQuadVertexCount()*e,r=this.getQuadTriangleCount()*e;this.vertexCount!==n&&(t.position.init(n),t.normal.init(n),t.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=x0.create(),t=x0.create(),n=x0.create(),r=[0,3,1,3,2,1];return function(i,o){var a=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;x0.sub(e,i[1],i[0]),x0.sub(t,i[2],i[1]),x0.cross(n,e,t),x0.normalize(n,n);for(var u=0;u<4;u++)a.set(this._vertexOffset+u,i[u]),l.set(this._vertexOffset+u,o),s.set(this._vertexOffset+u,n);var c=3*this._faceOffset;for(u=0;u<6;u++)this.indices[c+u]=r[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});V(b0.prototype,d0);var w0=wJ,S0={x:0,y:2,z:1};function T0(e,t,n){this.rootNode=new HQ.Node;var r=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new HQ.Mesh({geometry:new b0,material:n,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(r),this.faceInfo=e,this.plane=new HQ.Plane,this.linesMesh=r,this.quadsMesh=i}T0.prototype.update=function(e,t,n){var r=e.coordinateSystem,i=[r.getAxis(this.faceInfo[0]),r.getAxis(this.faceInfo[1])],o=this.linesMesh.geometry,a=this.quadsMesh.geometry;o.convertToDynamicArray(!0),a.convertToDynamicArray(!0),this._updateSplitLines(o,i,e,n),this._udpateSplitAreas(a,i,e,n),o.convertToTypedArray(),a.convertToTypedArray();var s=r.getAxis(this.faceInfo[2]);!function(e,t,n,r){var i=[0,0,0],o=r<0?n.getExtentMin():n.getExtentMax();i[S0[n.dim]]=o,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(o),t.normal.set(0,0,0),"x"===n.dim?(e.rotation.rotateY(r*Math.PI/2),t.normal.x=-r):"z"===n.dim?(e.rotation.rotateX(-r*Math.PI/2),t.normal.y=-r):(r>0&&e.rotation.rotateY(Math.PI),t.normal.z=-r)}(this.rootNode,this.plane,s,this.faceInfo[3])},T0.prototype._updateSplitLines=function(e,t,n,r){var i=r.getDevicePixelRatio();t.forEach((function(r,o){var a=r.model,s=t[1-o].getExtent();if(!r.scale.isBlank()){var l=a.getModel("splitLine",n.getModel("splitLine"));if(l.get("show")){var u=l.getModel("lineStyle"),c=u.get("color"),h=w0(u.get("opacity"),1),d=w0(u.get("width"),1);c=J(c)?c:[c];for(var p=r.getTicksCoords({tickModel:l}),f=0,g=0;g<p.length;g++){var m=p[g].coord,v=HQ.parseColor(c[f%c.length]);v[3]*=h;var y=[0,0,0],_=[0,0,0];y[o]=_[o]=m,y[1-o]=s[0],_[1-o]=s[1],e.addLine(y,_,v,d*i),f++}}}}))},T0.prototype._udpateSplitAreas=function(e,t,n,r){t.forEach((function(r,i){var o=r.model,a=t[1-i].getExtent();if(!r.scale.isBlank()){var s=o.getModel("splitArea",n.getModel("splitArea"));if(s.get("show")){var l=s.getModel("areaStyle"),u=l.get("color"),c=w0(l.get("opacity"),1);u=J(u)?u:[u];for(var h=r.getTicksCoords({tickModel:s,clamp:!0}),d=0,p=[0,0,0],f=[0,0,0],g=0;g<h.length;g++){var m=h[g].coord,v=[0,0,0],y=[0,0,0];if(v[i]=y[i]=m,v[1-i]=a[0],y[1-i]=a[1],0!==g){var _=HQ.parseColor(u[d%u.length]);_[3]*=c,e.addQuad([p,v,y,f],_),p=v,f=y,d++}else p=v,f=y}}}}))};var M0=[0,1,2,0,2,3],C0=XK.extend((function(){return{attributes:{position:new XK.Attribute("position","float",3,"POSITION"),texcoord:new XK.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new XK.Attribute("offset","float",2),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=4*e,n=2*e;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==n&&(this.indices=t>65535?new Uint32Array(3*n):new Uint16Array(3*n))},setSpriteAlign:function(e,t,n,r,i){var o,a,s,l;switch(null==n&&(n="left"),null==r&&(r="top"),i=i||0,n){case"left":o=i,s=t[0]+i;break;case"center":case"middle":o=-t[0]/2,s=t[0]/2;break;case"right":o=-t[0]-i,s=-i}switch(r){case"bottom":a=i,l=t[1]+i;break;case"middle":a=-t[1]/2,l=t[1]/2;break;case"top":a=-t[1]-i,l=-i}var u=4*e,c=this.attributes.offset;c.set(u,[o,l]),c.set(u+1,[s,l]),c.set(u+2,[s,a]),c.set(u+3,[o,a])},addSprite:function(e,t,n,r,i,o){var a=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,n,r,i,o);for(var s=0;s<M0.length;s++)this.indices[3*this._faceOffset+s]=M0[s]+a;return this._faceOffset+=2,this._vertexOffset+=4,a/4},setSprite:function(e,t,n,r,i,o,a){for(var s=4*e,l=this.attributes,u=0;u<4;u++)l.position.set(s+u,t);var c=l.texcoord;c.set(s,[r[0][0],r[0][1]]),c.set(s+1,[r[1][0],r[0][1]]),c.set(s+2,[r[1][0],r[1][1]]),c.set(s+3,[r[0][0],r[1][1]]),this.setSpriteAlign(e,n,i,o,a)}});V(C0.prototype,d0);HQ.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");var D0=HQ.Mesh.extend((function(){return{geometry:new C0({dynamic:!0}),material:new HQ.Material({shader:HQ.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}})),A0=wJ,I0={x:0,y:2,z:1};function E0(e,t){var n=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),r=new D0;r.material.depthMask=!1;var i=new HQ.Node;i.add(n),i.add(r),this.rootNode=i,this.dim=e,this.linesMesh=n,this.labelsMesh=r,this.axisLineCoords=null,this.labelElements=[]}var L0={x:"y",y:"x",z:"y"};E0.prototype.update=function(e,t,n){var r=e.coordinateSystem.getAxis(this.dim),i=this.linesMesh.geometry,o=this.labelsMesh.geometry;i.convertToDynamicArray(!0),o.convertToDynamicArray(!0);var a=r.model,s=r.getExtent(),l=n.getDevicePixelRatio(),u=a.getModel("axisLine",e.getModel("axisLine")),c=a.getModel("axisTick",e.getModel("axisTick")),h=a.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var p=u.getModel("lineStyle"),f=[0,0,0];(T=[0,0,0])[M=I0[r.dim]]=s[0],f[M]=s[1],this.axisLineCoords=[T,f];var g=HQ.parseColor(d),m=A0(p.get("width"),1),v=A0(p.get("opacity"),1);g[3]*=v,i.addLine(T,f,g,m*l)}if(c.get("show")){var y=c.getModel("lineStyle"),_=HQ.parseColor(A0(y.get("color"),d));m=A0(y.get("width"),1);_[3]*=A0(y.get("opacity"),1);for(var x=r.getTicksCoords(),b=c.get("length"),w=0;w<x.length;w++){var S=x[w].coord,T=[0,0,0],M=(f=[0,0,0],I0[r.dim]),C=I0[L0[r.dim]];T[M]=f[M]=S,f[C]=b,i.addLine(T,f,_,m*l)}}this.labelElements=[];l=n.getDevicePixelRatio();if(h.get("show")){x=r.getTicksCoords();var D=a.get("data"),A=h.get("margin"),I=r.getViewLabels();for(w=0;w<I.length;w++){var E=I[w].tickValue,L=I[w].formattedLabel,N=I[w].rawLabel,P=(S=r.dataToCoord(E),[0,0,0]);M=I0[r.dim],C=I0[L0[r.dim]];P[M]=P[M]=S,P[C]=A;var O=h;D&&D[E]&&D[E].textStyle&&(O=new Wh(D[E].textStyle,h,a.ecModel));var R=A0(O.get("color"),d),k=new ll({style:wh(O,{text:L,fill:"function"==typeof R?R("category"===r.type?N:"value"===r.type?E+"":E,w):R,verticalAlign:"top",align:"left"})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),this.labelElements.push(k)}}if(a.get("name")){var B=a.getModel("nameTextStyle"),F=(P=[0,0,0],M=I0[r.dim],C=I0[L0[r.dim]],A0(B.get("color"),d)),G=B.get("borderColor");m=B.get("borderWidth");P[M]=P[M]=(s[0]+s[1])/2,P[C]=a.get("nameGap");k=new ll({style:wh(B,{text:a.get("name"),fill:F,stroke:G,lineWidth:m})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),k.__idx=this.labelElements.length,this.nameLabelElement=k}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),i.convertToTypedArray(),o.convertToTypedArray()},E0.prototype.setSpriteAlign=function(e,t,n){for(var r=n.getDevicePixelRatio(),i=this.labelsMesh.geometry,o=0;o<this.labelElements.length;o++){var a=this.labelElements[o].getBoundingRect();i.setSpriteAlign(o,[a.width*r,a.height*r],e,t)}var s=this.nameLabelElement;if(s){a=s.getBoundingRect();i.setSpriteAlign(s.__idx,[a.width*r,a.height*r],e,t),i.dirty()}this.textAlign=e,this.textVerticalAlign=t};var N0="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end",P0=wJ;HQ.Shader.import(N0);var O0={x:0,y:2,z:1},R0=Kg.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var n=new HQ.Material({shader:HQ.createShader("ecgl.color"),depthMask:!1,transparent:!0}),r=new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});n.define("fragment","DOUBLE_SIDED"),n.define("both","VERTEX_COLOR"),this.groupGL=new HQ.Node,this._control=new h0({zr:t.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(e){var t=new T0(e,r,n);return this.groupGL.add(t.rootNode),t}),this),this._axes=["x","y","z"].map((function(e){var t=new E0(e,r);return this.groupGL.add(t.rootNode),t}),this);var i=t.getDevicePixelRatio();this._axisLabelSurface=new y0({width:256,height:256,devicePixelRatio:i}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:r,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new y0({width:128,height:128,devicePixelRatio:i}),this._axisPointerLabelsMesh=new D0({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new HQ.Node,this._sceneHelper=new _0,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,n){this._model=e,this._api=n;var r=e.coordinateSystem;r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach((function(r){r.update(e,t,n)}),this),this._axes.forEach((function(t){t.update(e,this._axisLabelSurface,n)}),this)),i.on("update",this._onCameraChange.bind(this,e,n),this),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},showAxisPointer:function(e,t,n,r){this._doShowAxisPointer(),this._updateAxisPointer(r.value)},hideAxisPointer:function(e,t,n,r){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem.viewGL;e.get("show")&&e.get("axisPointer.show")?t.on("mousemove",this._updateAxisPointerOnMousePosition,this):t.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,n=this._model.coordinateSystem,r=n.viewGL,i=r.castRay(e.offsetX,e.offsetY,new HQ.Ray),o=0;o<this._faces.length;o++){var a=this._faces[o];if(!a.rootNode.invisible){a.plane.normal.dot(r.camera.worldTransform.z)<0&&a.plane.normal.negate();var s=i.intersectPlane(a.plane);if(s){var l=n.getAxis(a.faceInfo[0]),u=n.getAxis(a.faceInfo[1]),c=O0[a.faceInfo[0]],h=O0[a.faceInfo[1]];l.contain(s.array[c])&&u.contain(s.array[h])&&(t=s)}}}if(t){var d=n.pointToData(t.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var n=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new HQ.Vector3;e.update();for(var n=0;n<this._faces.length/2;n++){for(var r=[],i=0;i<2;i++){this._faces[2*n+i].rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),r[i]=t.z}var o=r[0]>r[1]?0:1,a=this._faces[2*n+o],s=this._faces[2*n+1-o];a.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),n=e.getAxis("y"),r=e.getAxis("z"),i=r.getExtentMax(),o=r.getExtentMin(),a=t.getExtentMin(),s=t.getExtentMax(),l=n.getExtentMax(),u=n.getExtentMin(),c=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,p=this._faces,f=p[4].rootNode.invisible?u:l,g=p[2].rootNode.invisible?i:o,m=p[0].rootNode.invisible?a:s,v=p[2].rootNode.invisible?i:o,y=p[0].rootNode.invisible?s:a,_=p[4].rootNode.invisible?u:l;c.rotation.identity(),h.rotation.identity(),d.rotation.identity(),p[4].rootNode.invisible&&(this._axes[0].flipped=!0,c.rotation.rotateX(Math.PI)),p[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),p[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),c.position.set(0,g,f),h.position.set(m,v,0),d.position.set(y,0,_),c.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new HQ.Vector4,new HQ.Vector4],n=new HQ.Vector4;this.groupGL.getWorldPosition(n),n.w=1,n.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),n.x/=n.w,n.y/=n.w,this._axes.forEach((function(r){var i=r.axisLineCoords;r.labelsMesh.geometry;for(var o=0;o<t.length;o++)t[o].setArray(i[o]),t[o].w=1,t[o].transformMat4(r.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[o].x/=t[o].w,t[o].y/=t[o].w;var a,s,l=t[1].x-t[0].x,u=t[1].y-t[0].y,c=(t[1].x+t[0].x)/2,h=(t[1].y+t[0].y)/2;Math.abs(u/l)<.5?(a="center",s=h>n.y?"bottom":"top"):(s="middle",a=c>n.x?"left":"right"),r.setSpriteAlign(a,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,n=t.dataToPoint(e),r=this._axisPointerLineMesh.geometry,i=this._model.getModel("axisPointer"),o=this._api.getDevicePixelRatio();function a(e){return wJ(e.model.get("axisPointer.show"),i.get("show"))}function s(e){var t=e.model.getModel("axisPointer",i).getModel("lineStyle"),n=HQ.parseColor(t.get("color")),r=P0(t.get("width"),1),o=P0(t.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:r}}r.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var u=this._faces[l];if(!u.rootNode.invisible){for(var c=u.faceInfo,h=c[3]<0?t.getAxis(c[2]).getExtentMin():t.getAxis(c[2]).getExtentMax(),d=O0[c[2]],p=0;p<2;p++){var f=c[p],g=c[1-p],m=t.getAxis(f),v=t.getAxis(g);if(a(m)){var y=O0[f],_=O0[g];(w=[0,0,0])[y]=(b=[0,0,0])[y]=n[y],w[d]=b[d]=h,w[_]=v.getExtentMin(),b[_]=v.getExtentMax();var x=s(m);r.addLine(w,b,x.color,x.lineWidth*o)}}if(a(t.getAxis(c[2]))){var b,w=n.slice();(b=n.slice())[d]=h;x=s(t.getAxis(c[2]));r.addLine(w,b,x.color,x.lineWidth*o)}}}r.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,n=this._axisPointerLabelsMesh,r=this._axisPointerLabelsSurface,i=t.coordinateSystem,o=t.getModel("axisPointer");n.geometry.convertToDynamicArray(!0),r.clear();var a={x:"y",y:"x",z:"y"};this._axes.forEach((function(t,s){var l=i.getAxis(t.dim),u=l.model.getModel("axisPointer",o),c=u.getModel("label"),h=u.get("lineStyle.color");if(c.get("show")&&u.get("show")){var d=e[s],p=c.get("formatter"),f=l.scale.getLabel({value:d});if(null!=p)f=p(f,e);else if("interval"===l.scale.type||"log"===l.scale.type){var g=uo(l.scale.getTicks()[0]);f=d.toFixed(g+2)}var m=c.get("color"),v=new ll({style:wh(c,{text:f,fill:m||h,align:"left",verticalAlign:"top"})}),y=r.add(v),_=v.getBoundingRect(),x=this._api.getDevicePixelRatio(),b=t.rootNode.position.toArray();b[O0[a[t.dim]]]+=(t.flipped?-1:1)*c.get("margin"),b[O0[t.dim]]=l.dataToCoord(e[s]),n.geometry.addSprite(b,[_.width*x,_.height*x],y,t.textAlign,t.textVerticalAlign)}}),this),r.getZr().refreshImmediately(),n.material.set("uvScale",r.getCoordsScale()),n.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function k0(e){IM.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}function z0(e,t,n){Ob.call(this,e,t,n)}k0.prototype={constructor:k0,model:null,containPoint:function(e){return this.getAxis("x").contain(e[0])&&this.getAxis("y").contain(e[2])&&this.getAxis("z").contain(e[1])},containData:function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])&&this.getAxis("z").containData(e[2])},dataToPoint:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").dataToCoord(e[0],n),t[2]=this.getAxis("y").dataToCoord(e[1],n),t[1]=this.getAxis("z").dataToCoord(e[2],n),t},pointToData:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").coordToData(e[0],n),t[1]=this.getAxis("y").coordToData(e[2],n),t[2]=this.getAxis("z").coordToData(e[1],n),t}},G(k0,IM),z0.prototype={constructor:z0,getExtentMin:function(){var e=this._extent;return Math.min(e[0],e[1])},getExtentMax:function(){var e=this._extent;return Math.max(e[0],e[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}},G(z0,Ob);var V0=function(){this._pool={},this._allocatedTextures=[]};V0.prototype={constructor:V0,get:function(e){var t=G0(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var n=this._pool[t];if(!n.length){var r=new RK(e);return this._allocatedTextures.push(r),r}return n.pop()},put:function(e){var t=G0(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t<this._allocatedTextures.length;t++)this._allocatedTextures[t].dispose(e);this._pool={},this._allocatedTextures=[]}};var B0={width:512,height:512,type:jY,format:eZ,wrapS:dZ,wrapT:dZ,minFilter:lZ,magFilter:iZ,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},F0=Object.keys(B0);function G0(e){bY.defaultsWithPropList(e,B0,F0),function(e){var t=(n=e.width,r=e.height,!(n&n-1||r&r-1));var n,r;e.format===$Y&&(e.useMipmap=!1);t&&e.useMipmap||(e.minFilter==oZ||e.minFilter==sZ?e.minFilter=rZ:e.minFilter!=lZ&&e.minFilter!=aZ||(e.minFilter=iZ));t||(e.wrapS=dZ,e.wrapT=dZ)}(e);for(var t="",n=0;n<F0.length;n++){t+=e[F0[n]].toString()}return t}var H0=["px","nx","py","ny","pz","nz"];function U0(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)}function W0(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)}wq.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");var j0,X0,Y0,Z0,q0,K0,$0,J0=wY.extend((function(){return{softShadow:J0.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"highp",_lastRenderNotCastShadow:!1,_frameBuffer:new G$,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new V0}}),(function(){this._gaussianPassH=new pJ({fragment:wq.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new pJ({fragment:wq.source("clay.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new pJ({fragment:wq.source("clay.sm.debug_depth")})}),{render:function(e,t,n,r){n||(n=t.getMainCamera()),this.trigger("beforerender",this,e,t,n),this._renderShadowPass(e,t,n,r),this.trigger("afterrender",this,e,t,n)},renderDebug:function(e,t){e.saveClear();var n=e.viewport,r=0,i=t||n.width/4,o=i;for(var a in this.softShadow===J0.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[a];e.setViewport(r,0,i*s.width/s.height,o),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),r+=i*s.width/s.height}e.setViewport(n),e.restoreClear()},_updateReceivers:function(e,t){if(t.receiveShadow?(this._receivers.push(t),t.material.set("shadowEnabled",1),t.material.set("pcfKernel",this.kernelPCF)):t.material.set("shadowEnabled",0),this.softShadow===J0.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var n=this.kernelPCF;n&&n.length?t.material.define("fragment","PCF_KERNEL_SIZE",n.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var n=this;t.traverse((function(t){t.isRenderable()&&n._updateReceivers(e,t)}));for(var r=0;r<t.lights.length;r++){var i=t.lights[r];i.castShadow&&!i.invisible&&this._lightsCastShadow.push(i)}},_renderShadowPass:function(e,t,n,r){for(var i in this._shadowMapNumber)this._shadowMapNumber[i]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var o=e.gl;if(r||t.update(),n&&n.update(),t.updateLights(),this._update(e,t),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,o.enable(o.DEPTH_TEST),o.depthMask(!0),o.disable(o.BLEND),o.clearColor(1,1,1,1);for(var a,s=[],l=[],u=[],c=[],h=[],d=[],p=0;p<this._lightsCastShadow.length;p++){var f=this._lightsCastShadow[p];if("DIRECTIONAL_LIGHT"===f.type){if(a){console.warn("Only one direectional light supported with shadow cascade");continue}if(f.shadowCascade>4){console.warn("Support at most 4 cascade");continue}f.shadowCascade>1&&(a=f),this.renderDirectionalLightShadow(e,t,n,f,h,c,u)}else"SPOT_LIGHT"===f.type?this.renderSpotLightShadow(e,t,f,l,s):"POINT_LIGHT"===f.type&&this.renderPointLightShadow(e,t,f,d);this._shadowMapNumber[f.type]++}for(var g in this._shadowMapNumber){var m=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT";for(p=0;p<this._receivers.length;p++){(y=this._receivers[p].material).fragmentDefines[v]!==m&&(m>0?y.define("fragment",v,m):y.isDefined("fragment",v)&&y.undefine("fragment",v))}}for(p=0;p<this._receivers.length;p++){var y=this._receivers[p].material;a?y.define("fragment","SHADOW_CASCADE",a.shadowCascade):y.undefine("fragment","SHADOW_CASCADE")}var _=t.shadowUniforms;if(u.length>0){var x=u.map(T);if(_.directionalLightShadowMaps={value:u,type:"tv"},_.directionalLightMatrices={value:c,type:"m4v"},_.directionalLightShadowMapSizes={value:x,type:"1fv"},a){var b=h.slice(),w=h.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),c.reverse(),_.shadowCascadeClipsNear={value:b,type:"1fv"},_.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var S=s.map(T);(_=t.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},_.spotLightMatrices={value:l,type:"m4v"},_.spotLightShadowMapSizes={value:S,type:"1fv"}}d.length>0&&(_.pointLightShadowMaps={value:d,type:"tv"})}function T(e){return e.height}},renderDirectionalLightShadow:(j0=new h$,X0=new aK,Y0=new bK,Z0=new aK,q0=new aK,K0=new aK,$0=new aK,function(e,t,n,r,i,o,a){var s=this._getDepthMaterial(r),l={getMaterial:function(e){return e.shadowDepthMaterial||s},isMaterialChanged:W0,getUniform:U0,ifRender:function(e){return e.castShadow},sortCompare:Vq.opaqueSortCompare};if(!t.viewBoundingBoxLastFrame.isFinite()){var u=t.getBoundingBox();t.viewBoundingBoxLastFrame.copy(u).applyTransform(n.viewMatrix)}var c=Math.min(-t.viewBoundingBoxLastFrame.min.z,n.far),h=Math.max(-t.viewBoundingBoxLastFrame.max.z,n.near),d=this._getDirectionalLightCamera(r,t,n),p=K0.array;$0.copy(d.projectionMatrix),Cq.invert(q0.array,d.worldTransform.array),Cq.multiply(q0.array,q0.array,n.worldTransform.array),Cq.multiply(p,$0.array,q0.array);for(var f=[],g=n instanceof E$,m=(n.near+n.far)/(n.near-n.far),v=2*n.near*n.far/(n.near-n.far),y=0;y<=r.shadowCascade;y++){var _=h*Math.pow(c/h,y/r.shadowCascade),x=h+(c-h)*y/r.shadowCascade,b=_*r.cascadeSplitLogFactor+x*(1-r.cascadeSplitLogFactor);f.push(b),i.push(-(-b*m+v)/-b)}var w=this._getTexture(r,r.shadowCascade);a.push(w);var S=e.viewport,T=e.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(e),T.clear(T.COLOR_BUFFER_BIT|T.DEPTH_BUFFER_BIT),y=0;y<r.shadowCascade;y++){var M=f[y],C=f[y+1];g?Cq.perspective(X0.array,n.fov/180*Math.PI,n.aspect,M,C):Cq.ortho(X0.array,n.left,n.right,n.bottom,n.top,M,C),j0.setFromProjection(X0),j0.getTransformedBoundingBox(Y0,q0),Y0.applyProjection($0);var D=Y0.min.array,A=Y0.max.array;D[0]=Math.max(D[0],-1),D[1]=Math.max(D[1],-1),A[0]=Math.min(A[0],1),A[1]=Math.min(A[1],1),Z0.ortho(D[0],A[0],D[1],A[1],1,-1),d.projectionMatrix.multiplyLeft(Z0);var I=r.shadowResolution||512;e.setViewport((r.shadowCascade-y-1)*I,0,I,I,1);var E=t.updateRenderList(d);e.renderPass(E.opaque,d,l),this.softShadow===J0.VSM&&this._gaussianFilter(e,w,w.width);var L=new aK;L.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),o.push(L.array),d.projectionMatrix.copy($0)}this._frameBuffer.unbind(e),e.setViewport(S)}),renderSpotLightShadow:function(e,t,n,r,i){var o=this._getTexture(n),a=this._getSpotLightCamera(n),s=e.gl;this._frameBuffer.attach(o),this._frameBuffer.bind(e),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(n),u={getMaterial:function(e){return e.shadowDepthMaterial||l},isMaterialChanged:W0,getUniform:U0,ifRender:function(e){return e.castShadow},sortCompare:Vq.opaqueSortCompare},c=t.updateRenderList(a);e.renderPass(c.opaque,a,u),this._frameBuffer.unbind(e),this.softShadow===J0.VSM&&this._gaussianFilter(e,o,o.width);var h=new aK;h.copy(a.worldTransform).invert().multiplyLeft(a.projectionMatrix),i.push(o),r.push(h.array)},renderPointLightShadow:function(e,t,n,r){var i=this._getTexture(n),o=e.gl;r.push(i);var a=this._getDepthMaterial(n),s={getMaterial:function(e){return e.shadowDepthMaterial||a},getUniform:U0,sortCompare:Vq.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new bK,c=n.getWorldPosition().array,h=new bK,d=n.range;h.min.setArray(c),h.max.setArray(c);var p=new Fq(d,d,d);h.max.add(p),h.min.sub(p);var f={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};t.traverse((function(e){if(e.isRenderable()&&e.castShadow){var t=e.geometry;if(!t.boundingBox){for(var n=0;n<H0.length;n++)l[H0[n]].push(e);return}if(u.transformFrom(t.boundingBox,e.worldTransform),!u.intersectBoundingBox(h))return;u.updateVertices();for(n=0;n<H0.length;n++)f[H0[n]]=!1;for(n=0;n<8;n++){var r=u.vertices[n],i=r[0]-c[0],o=r[1]-c[1],a=r[2]-c[2],s=Math.abs(i),d=Math.abs(o),p=Math.abs(a);s>d?s>p?f[i>0?"px":"nx"]=!0:f[a>0?"pz":"nz"]=!0:d>p?f[o>0?"py":"ny"]=!0:f[a>0?"pz":"nz"]=!0}for(n=0;n<H0.length;n++)f[H0[n]]&&l[H0[n]].push(e)}}));for(var g=0;g<6;g++){var m=H0[g],v=this._getPointLightCamera(n,m);this._frameBuffer.attach(i,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+g),this._frameBuffer.bind(e),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),e.renderPass(l[m],v,s)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],n="POINT_LIGHT"===e.type;if(!t){var r=n?"clay.sm.distance.":"clay.sm.depth.";t=new jZ({precision:this.precision,shader:new wq(wq.source(r+"vertex"),wq.source(r+"fragment"))}),this._lightMaterials[e.__uid__]=t}return null!=e.shadowSlopeScale&&t.setUniform("slopeScale",e.shadowSlopeScale),null!=e.shadowBias&&t.setUniform("bias",e.shadowBias),this.softShadow===J0.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),n&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,n){var r={width:n,height:n,type:EK.FLOAT},i=this._texturePool.get(r);this._frameBuffer.attach(i),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",n),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",n),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(i)},_getTexture:function(e,t){var n=e.__uid__,r=this._textures[n],i=e.shadowResolution||512;return t=t||1,r||((r="POINT_LIGHT"===e.type?new A$:new RK).width=i*t,r.height=i,this.softShadow===J0.VSM?(r.type=EK.FLOAT,r.anisotropic=4):(r.minFilter=rZ,r.magFilter=rZ,r.useMipmap=!1),this._textures[n]=r),r},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new E$,nx:new E$,py:new E$,ny:new E$,pz:new E$,nz:new E$});var n=this._lightCameras.point[t];switch(n.far=e.range,n.fov=90,n.position.set(0,0,0),t){case"px":n.lookAt(Fq.POSITIVE_X,Fq.NEGATIVE_Y);break;case"nx":n.lookAt(Fq.NEGATIVE_X,Fq.NEGATIVE_Y);break;case"py":n.lookAt(Fq.POSITIVE_Y,Fq.POSITIVE_Z);break;case"ny":n.lookAt(Fq.NEGATIVE_Y,Fq.NEGATIVE_Z);break;case"pz":n.lookAt(Fq.POSITIVE_Z,Fq.NEGATIVE_Y);break;case"nz":n.lookAt(Fq.NEGATIVE_Z,Fq.NEGATIVE_Y)}return e.getWorldPosition(n.position),n.update(),n},_getDirectionalLightCamera:function(){var e=new aK,t=new bK,n=new bK;return function(r,i,o){this._lightCameras.directional||(this._lightCameras.directional=new uJ);var a=this._lightCameras.directional;t.copy(i.viewBoundingBoxLastFrame),t.intersection(o.frustum.boundingBox),a.position.copy(t.min).add(t.max).scale(.5).transformMat4(o.worldTransform),a.rotation.copy(r.rotation),a.scale.copy(r.scale),a.updateWorldTransform(),aK.invert(e,a.worldTransform),aK.multiply(e,e,o.worldTransform),n.copy(t).applyTransform(e);var s=n.min.array,l=n.max.array;return a.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(a.worldTransform),a.near=0,a.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?a.far*=4:a.far+=this.lightFrustumBias,a.left=s[0],a.right=l[0],a.top=l[1],a.bottom=s[1],a.update(!0),a}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new E$);var t=this._lightCameras.spot;return t.fov=2*e.penumbraAngle,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),Cq.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;for(var n in this._frameBuffer&&this._frameBuffer.dispose(t),this._textures)this._textures[n].dispose(t);this._texturePool.clear(e.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var r=0;r<this._receivers.length;r++){var i=this._receivers[r];if(i.material){var o=i.material;o.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),o.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),o.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),o.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});J0.VSM=1,J0.PCF=2;var Q0=wY.extend((function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),{updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n=o.width instanceof Function?o.width.call(this,t):o.width,r=o.height instanceof Function?o.height.call(this,t):o.height,a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),a.width=n,a.height=r,a},setParameter:function(e,t){},getParameter:function(e){},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},render:function(){},getOutput:function(e,t){if(null==t)return t=e,this._outputTextures[t];var n=this.outputs[t];return n?this._rendered?n.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(n.parameters||{})),this._prevOutputTextures[t]):(this.render(e),this._outputTextures[t]):void 0},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.enableTexture(e)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(e){if(!this._rendering){for(var t in this._rendering=!0,this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){for(var e in this._rendered=!1,this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks){if(this._outputReferences[e]>0)this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}}),e1=wY.extend((function(){return{nodes:[]}}),{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t<this.nodes.length;t++)if(this.nodes[t].name===e)return this.nodes[t]},update:function(){for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear();for(e=0;e<this.nodes.length;e++){var t=this.nodes[e];if(t.inputs)for(var n in t.inputs)if(t.inputs[n])if(!t.pass||t.pass.material.isUniformEnabled(n)){var r=t.inputs[n],i=this.findPin(r);i?t.link(n,i.node,i.pin):"string"==typeof r?console.warn("Node "+r+" not exist"):console.warn("Pin of "+r.node+"."+r.pin+" not exist")}else console.warn("Pin "+t.name+"."+n+" not used.")}},findPin:function(e){var t;if(("string"==typeof e||e instanceof Q0)&&(e={node:e}),"string"==typeof e.node)for(var n=0;n<this.nodes.length;n++){var r=this.nodes[n];r.name===e.node&&(t=r)}else t=e.node;if(t){var i=e.pin;if(i||t.outputs&&(i=Object.keys(t.outputs)[0]),t.outputs[i])return{node:t,pin:i}}}}),t1=e1.extend((function(){return{_outputs:[],_texturePool:new V0,_frameBuffer:new G$({depthBuffer:!1})}}),{addNode:function(e){e1.prototype.addNode.call(this,e),e._compositor=this},render:function(e,t){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var n=0;n<this.nodes.length;n++)this.nodes[n].outputs||this._outputs.push(this.nodes[n])}for(n=0;n<this.nodes.length;n++)this.nodes[n].beforeFrame();for(n=0;n<this._outputs.length;n++)this._outputs[n].updateReference();for(n=0;n<this._outputs.length;n++)this._outputs[n].render(e,t);for(n=0;n<this.nodes.length;n++)this.nodes[n].afterFrame()},allocateTexture:function(e){return this._texturePool.get(e)},releaseTexture:function(e){this._texturePool.put(e)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(e){this._texturePool.clear(e)}}),n1=Q0.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},(function(){this.frameBuffer=new G$}),{render:function(e){this._rendering=!0;var t,n=e.gl;if(this.trigger("beforerender"),this.outputs){var r=this.frameBuffer;for(var i in this.outputs){var o=this.updateParameter(i,e),a=this.outputs[i],s=this._compositor.allocateTexture(o);this._outputTextures[i]=s,"string"==typeof(c=a.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),r.attach(s,c)}r.bind(e);var l=e.getGLExtension("EXT_draw_buffers");if(l){var u=[];for(var c in this.outputs)(c=parseInt(c))>=n.COLOR_ATTACHMENT0&&c<=n.COLOR_ATTACHMENT0+8&&u.push(c);l.drawBuffersEXT(u)}e.saveClear(),e.clearBit=CY|AY,t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),r.unbind(e)}else t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",t),this._rendering=!1,this._rendered=!0}}),r1=Q0.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),i1=Q0.extend((function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),(function(){var e=new pJ({fragment:this.shader});this.pass=e}),{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var r in this.inputLinks){var i=(h=this.inputLinks[r]).node.getOutput(e,h.pin);this.pass.setUniform(r,i)}if(this.outputs){this.pass.outputs={};var o={};for(var a in this.outputs){var s=this.updateParameter(a,e);isNaN(s.width)&&this.updateParameter(a,e);var l=this.outputs[a],u=this._compositor.allocateTexture(s);this._outputTextures[a]=u,"string"==typeof(c=l.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),o[c]=u}for(var c in this._compositor.getFrameBuffer().bind(e),o)this._compositor.getFrameBuffer().attach(o[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var r in this.inputLinks){var h;(h=this.inputLinks[r]).node.removeReference(h.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n="function"==typeof o.width?o.width.call(this,t):o.width,r="function"==typeof o.height?o.height.call(this,t):o.height,n=Math.ceil(n),r=Math.ceil(r),a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t),a.width=n,a.height=r,a},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},clear:function(){Q0.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),o1="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",a1="\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end",s1="@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",l1="@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n",u1="@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end",c1="\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end",h1="@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",d1="@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end",p1="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(e){e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),e.import(o1),e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),e.import(a1),e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),e.import(s1),e.import(l1),e.import(u1),e.import(c1),e.import(h1),e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),e.import(d1),e.import(p1)}(wq);var f1=/^#source\((.*?)\)/;function g1(e,t){var n=new t1;t=t||{};var r={textures:{},parameters:{}};for(var i in e.parameters){var o=e.parameters[i];r.parameters[i]=_1(o)}return function(e,t,n,r){if(!e.textures)return void r({});var i={},o=0,a=!1,s=n.textureRootPath;bY.each(e.textures,(function(e,t){var n,l=e.path,u=_1(e.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(e){return bY.relative2absolute(e,s)}))),n=new A$(u);else{if("string"!=typeof l)return;s&&(l=bY.relative2absolute(l,s)),n=new RK(u)}n.load(l),o++,n.once("success",(function(){i[t]=n,0===--o&&(r(i),a=!0)}))})),0!==o||a||r(i)}(e,0,t,(function(i){r.textures=i,function(){for(var i=0;i<e.nodes.length;i++){var o=m1(e.nodes[i],r,t);o&&n.addNode(o)}}()})),n}function m1(e,t,n){var r,i,o,a,s=e.type||"filter";if("filter"===s){var l=e.shader.trim(),u=f1.exec(l);if(u?r=wq.source(u[1].trim()):"#"===l.charAt(0)&&(r=t.shaders[l.substr(1)]),r||(r=l),!r)return}if(e.inputs)for(var c in i={},e.inputs)"string"==typeof e.inputs[c]?i[c]=e.inputs[c]:i[c]={node:e.inputs[c].node,pin:e.inputs[c].pin};if(e.outputs)for(var c in o={},e.outputs){var h=e.outputs[c];o[c]={},null!=h.attachment&&(o[c].attachment=h.attachment),null!=h.keepLastFrame&&(o[c].keepLastFrame=h.keepLastFrame),null!=h.outputLastFrame&&(o[c].outputLastFrame=h.outputLastFrame),h.parameters&&(o[c].parameters=_1(h.parameters))}if(a="scene"===s?new n1({name:e.name,scene:n.scene,camera:n.camera,outputs:o}):"texture"===s?new r1({name:e.name,outputs:o}):new i1({name:e.name,shader:r,inputs:i,outputs:o})){if(e.parameters)for(var c in e.parameters){"string"==typeof(d=e.parameters[c])?"#"===(d=d.trim()).charAt(0)?d=t.textures[d.substr(1)]:a.on("beforerender",x1(c,b1(d))):"function"==typeof d&&a.on("beforerender",d),a.setParameter(c,d)}if(e.defines&&a.pass)for(var c in e.defines){var d=e.defines[c];a.pass.material.define("fragment",c,d)}}return a}function v1(e,t){return e}function y1(e,t){return t}function _1(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach((function(n){var r=e[n];null!=r&&("string"==typeof r&&(r=EK[r]),t[n]=r)}));var n=e.scale||1;return["width","height"].forEach((function(r){if(null!=e[r]){var i=e[r];"string"==typeof i?(i=i.trim(),t[r]=function(e,t,n){return n=n||1,function(e){var r=e.getDevicePixelRatio(),i=e.getWidth()*n,o=e.getHeight()*n;return t(i,o,r)}}(0,b1(i),n)):t[r]=i}})),t.width||(t.width=v1),t.height||(t.height=y1),null!=e.useMipmap&&(t.useMipmap=e.useMipmap),t}function x1(e,t){return function(n){var r=n.getDevicePixelRatio(),i=n.getWidth(),o=n.getHeight(),a=t(i,o,r);this.setParameter(e,a)}}function b1(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var n=new Function("width","height","dpr","return "+t[1]);return n(1,1),n}catch(e){throw new Error("Invalid expression.")}}function w1(e,t){for(var n=0,r=1/t,i=e;i>0;)n+=r*(i%t),i=Math.floor(i/t),r/=t;return n}function S1(e){for(var t=new Uint8Array(e*e*4),n=0,r=new Fq,i=0;i<e;i++)for(var o=0;o<e;o++)r.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),t[n++]=255*(.5*r.x+.5),t[n++]=255*(.5*r.y+.5),t[n++]=0,t[n++]=255;return t}function T1(e){return new RK({pixels:S1(e),wrapS:EK.REPEAT,wrapT:EK.REPEAT,width:e,height:e})}function M1(e,t,n){var r=new Float32Array(3*e);t=t||0;for(var i=0;i<e;i++){var o=w1(i+t,2)*(n?1:2)*Math.PI,a=w1(i+t,3)*Math.PI,s=Math.random(),l=Math.cos(o)*Math.sin(a)*s,u=Math.cos(a)*s,c=Math.sin(o)*Math.sin(a)*s;r[3*i]=l,r[3*i+1]=u,r[3*i+2]=c}return r}function C1(e){e=e||{},this._ssaoPass=new pJ({fragment:wq.source("ecgl.ssao.estimate")}),this._blurPass=new pJ({fragment:wq.source("ecgl.ssao.blur")}),this._framebuffer=new G$({depthBuffer:!1}),this._ssaoTexture=new RK,this._blurTexture=new RK,this._blurTexture2=new RK,this._depthTex=e.depthTexture,this._normalTex=e.normalTexture,this.setNoiseSize(4),this.setKernelSize(e.kernelSize||12),null!=e.radius&&this.setParameter("radius",e.radius),null!=e.power&&this.setParameter("power",e.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}wq.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),C1.prototype.setDepthTexture=function(e){this._depthTex=e},C1.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},C1.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._ssaoPass,a=this._blurPass;o.setUniform("kernel",this._kernels[n%this._kernels.length]),o.setUniform("depthTex",this._depthTex),null!=this._normalTex&&o.setUniform("normalTex",this._normalTex),o.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new aK;aK.transpose(s,t.worldTransform),o.setUniform("projection",t.projectionMatrix.array),o.setUniform("projectionInv",t.invProjectionMatrix.array),o.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,u=this._blurTexture,c=this._blurTexture2;l.width=r/2,l.height=i/2,u.width=r,u.height=i,c.width=r,c.height=i,this._framebuffer.attach(l),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),o.render(e),a.setUniform("textureSize",[r/2,i/2]),a.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),a.setUniform("direction",0),a.setUniform("ssaoTexture",l),a.render(e),this._framebuffer.attach(c),a.setUniform("textureSize",[r,i]),a.setUniform("direction",1),a.setUniform("ssaoTexture",u),a.render(e),this._framebuffer.unbind(e);var h=e.clearColor;e.gl.clearColor(h[0],h[1],h[2],h[3])},C1.prototype.getTargetTexture=function(){return this._blurTexture2},C1.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},C1.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=M1(e,t*e,!!this._normalTex)},C1.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=S1(e),t.width=t.height=e,t.dirty()):(t=T1(e),this._ssaoPass.setUniform("noiseTex",T1(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},C1.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};function D1(e){e=e||{},this._ssrPass=new pJ({fragment:wq.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new pJ({fragment:wq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new pJ({fragment:wq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new pJ({fragment:wq.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",e.normalTexture),this._ssrPass.setUniform("gBufferTexture2",e.depthTexture),this._blurPass1.setUniform("gBufferTexture1",e.normalTexture),this._blurPass1.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.setUniform("gBufferTexture1",e.normalTexture),this._blurPass2.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new RK({type:EK.HALF_FLOAT}),this._texture2=new RK({type:EK.HALF_FLOAT}),this._texture3=new RK({type:EK.HALF_FLOAT}),this._prevTexture=new RK({type:EK.HALF_FLOAT}),this._currentTexture=new RK({type:EK.HALF_FLOAT}),this._frameBuffer=new G$({depthBuffer:!1}),this._normalDistribution=null,this._totalSamples=256,this._samplePerFrame=4,this._ssrPass.material.define("fragment","SAMPLE_PER_FRAME",this._samplePerFrame),this._ssrPass.material.define("fragment","TOTAL_SAMPLES",this._totalSamples),this._downScale=1}wq.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),D1.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var n=e&&t;this._ssrPass.material[n?"enableTexture":"disableTexture"]("specularCubemap")},D1.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._ssrTexture,s=this._texture2,l=this._texture3;a.width=this._prevTexture.width=this._currentTexture.width=i/this._downScale,a.height=this._prevTexture.height=this._currentTexture.height=o/this._downScale,s.width=l.width=i,s.height=l.height=o;var u=this._frameBuffer,c=this._ssrPass,h=this._blurPass1,d=this._blurPass2,p=this._blendPass,f=new aK,g=new aK;aK.transpose(f,t.worldTransform),aK.transpose(g,t.viewMatrix),c.setUniform("sourceTexture",n),c.setUniform("projection",t.projectionMatrix.array),c.setUniform("projectionInv",t.invProjectionMatrix.array),c.setUniform("toViewSpace",f.array),c.setUniform("toWorldSpace",g.array),c.setUniform("nearZ",t.near);var m=r/this._totalSamples*this._samplePerFrame;if(c.setUniform("jitterOffset",m),c.setUniform("sampleOffset",r*this._samplePerFrame),h.setUniform("textureSize",[a.width,a.height]),d.setUniform("textureSize",[i,o]),d.setUniform("sourceTexture",n),h.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(a),u.bind(e),c.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),p.setUniform("texture1",this._prevTexture),p.setUniform("texture2",a),p.material.set({weight1:r>=1?.95:0,weight2:r>=1?.05:1}),p.render(e)),u.attach(s),h.setUniform("texture",this._physicallyCorrect?this._currentTexture:a),h.render(e),u.attach(l),d.setUniform("texture",s),d.render(e),u.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},D1.prototype.getTargetTexture=function(){return this._texture3},D1.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},D1.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=fJ.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},D1.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},D1.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},D1.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)};var A1=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925];function I1(e,t,n,r,i){var o=e.gl;t.setUniform(o,"1i",n,i),o.activeTexture(o.TEXTURE0+i),r.isRenderable()?r.bind(e):r.unbind(e)}function E1(e,t,n,r,i){var o,a,s,l,u=e.gl;return function(i,c,h){if(!l||l.material!==i.material){var d=i.material,p=i.__program,f=d.get("roughness");null==f&&(f=1);var g=d.get("normalMap")||t,m=d.get("roughnessMap"),v=d.get("bumpMap"),y=d.get("uvRepeat"),_=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!v&&d.isTextureEnabled("bumpMap"),S=!!m&&d.isTextureEnabled("roughnessMap"),T=d.isDefined("fragment","DOUBLE_SIDED");v=v||n,m=m||r,h!==c?(c.set("normalMap",g),c.set("bumpMap",v),c.set("roughnessMap",m),c.set("useBumpMap",w),c.set("useRoughnessMap",S),c.set("doubleSide",T),null!=y&&c.set("uvRepeat",y),null!=_&&c.set("uvOffset",_),null!=x&&c.set("detailUvRepeat",x),null!=b&&c.set("detailUvOffset",b),c.set("roughness",f)):(p.setUniform(u,"1f","roughness",f),o!==g&&I1(e,p,"normalMap",g,0),a!==v&&v&&I1(e,p,"bumpMap",v,1),s!==m&&m&&I1(e,p,"roughnessMap",m,2),null!=y&&p.setUniform(u,"2f","uvRepeat",y),null!=_&&p.setUniform(u,"2f","uvOffset",_),null!=x&&p.setUniform(u,"2f","detailUvRepeat",x),null!=b&&p.setUniform(u,"2f","detailUvOffset",b),p.setUniform(u,"1i","useBumpMap",+w),p.setUniform(u,"1i","useRoughnessMap",+S),p.setUniform(u,"1i","doubleSide",+T)),o=g,a=v,s=m,l=i}}}function L1(e){this._depthTex=new RK({format:EK.DEPTH_COMPONENT,type:EK.UNSIGNED_INT}),this._normalTex=new RK({type:EK.HALF_FLOAT}),this._framebuffer=new G$,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,G$.DEPTH_ATTACHMENT),this._normalMaterial=new jZ({shader:new wq(wq.source("ecgl.normal.vertex"),wq.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=oJ.createBlank("#000"),this._defaultBumpMap=oJ.createBlank("#000"),this._defaultRoughessMap=oJ.createBlank("#000"),this._debugPass=new pJ({fragment:wq.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}function N1(e){e=e||{},this._edgePass=new pJ({fragment:wq.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new RK({type:EK.HALF_FLOAT}),this._frameBuffer=new G$,this._frameBuffer.attach(this._targetTexture)}wq.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),L1.prototype.getDepthTexture=function(){return this._depthTex},L1.prototype.getNormalTexture=function(){return this._normalTex},L1.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._depthTex,a=this._normalTex,s=this._normalMaterial;o.width=r,o.height=i,a.width=r,a.height=i;var l=t.getRenderList(n).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,n,{getMaterial:function(){return s},ifRender:function(e){return e.renderNormal},beforeRender:E1(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},L1.prototype.renderDebug=function(e){this._debugPass.render(e)},L1.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},N1.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._targetTexture;a.width=i,a.height=o;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,o]),this._edgePass.setUniform("texture",n),this._edgePass.render(e),s.unbind(e)},N1.prototype.getTargetTexture=function(){return this._targetTexture},N1.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},N1.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};var P1={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]};function O1(e,t){return{color:{parameters:{width:e,height:t}}}}wq.import(o1),wq.import(a1),wq.import(s1),wq.import(l1),wq.import(u1),wq.import(c1),wq.import(h1),wq.import(d1),wq.import(p1),wq.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),wq.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");var R1=["composite","FXAA"];function k1(){this._width,this._height,this._dpr,this._sourceTexture=new RK({type:EK.HALF_FLOAT}),this._depthTexture=new RK({format:EK.DEPTH_COMPONENT,type:EK.UNSIGNED_INT}),this._framebuffer=new G$,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,G$.DEPTH_ATTACHMENT),this._normalPass=new L1,this._compositor=g1(P1);var e=this._compositor.getNodeByName("source");e.texture=this._sourceTexture;var t=this._compositor.getNodeByName("coc");this._sourceNode=e,this._cocNode=t,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map((function(e){return this._compositor.getNodeByName(e)}),this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=R1.map((function(e){return this._compositor.getNodeByName(e)}),this);var n={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new C1(n),this._ssrPass=new D1(n),this._edgePass=new N1(n)}function z1(e){for(var t=[],n=0;n<30;n++)t.push([w1(n,2),w1(n,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new RK,this._sourceFb=new G$,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new RK,this._outputTex=new RK;var r=this._blendPass=new pJ({fragment:wq.source("clay.compositor.blend")});r.material.disableTexturesAll(),r.material.enableTexture(["texture1","texture2"]),this._blendFb=new G$({depthBuffer:!1}),this._outputPass=new pJ({fragment:wq.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}function V1(e){e=e||"perspective",this.layer=null,this.scene=new b$,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new k1,this._temporalSS=new z1,this._shadowMapPass=new J0;for(var t=[],n=0,r=0;r<30;r++){for(var i=[],o=0;o<6;o++)i.push(4*w1(n,2)-2),i.push(4*w1(n,3)-2),n++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",(function(e,t,n){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,n)}),this)}k1.prototype.resize=function(e,t,n){e*=n=n||1,t*=n;var r=this._sourceTexture,i=this._depthTexture;r.width=e,r.height=t,i.width=e,i.height=t;var o={getWidth:function(){return e},getHeight:function(){return t},getDevicePixelRatio:function(){return n}};function a(e,t){if("function"==typeof e[t]){var n=e[t].__original||e[t];e[t]=function(e){return n.call(this,o)},e[t].__original=n}}this._compositor.nodes.forEach((function(e){for(var t in e.outputs){var n=e.outputs[t].parameters;n&&(a(n,"width"),a(n,"height"))}for(var r in e.parameters)a(e.parameters,r)})),this._width=e,this._height=t,this._dpr=n},k1.prototype.getWidth=function(){return this._width},k1.prototype.getHeight=function(){return this._height},k1.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},k1.prototype._getPrevNode=function(e){for(var t=R1.indexOf(e.name)-1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t-=1,n=this._finalNodesChain[t];return n},k1.prototype._getNextNode=function(e){for(var t=R1.indexOf(e.name)+1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t+=1,n=this._finalNodesChain[t];return n},k1.prototype._addChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(e.inputs.texture=t.name,n?(e.outputs=O1(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},k1.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(n?(t.outputs=O1(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},k1.prototype.updateNormal=function(e,t,n,r){this._ifRenderNormalPass()&&this._normalPass.update(e,t,n)},k1.prototype.updateSSAO=function(e,t,n,r){this._ssaoPass.update(e,n,r)},k1.prototype.enableSSAO=function(){this._enableSSAO=!0},k1.prototype.disableSSAO=function(){this._enableSSAO=!1},k1.prototype.enableSSR=function(){this._enableSSR=!0},k1.prototype.disableSSR=function(){this._enableSSR=!1},k1.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},k1.prototype.getSourceFrameBuffer=function(){return this._framebuffer},k1.prototype.getSourceTexture=function(){return this._sourceTexture},k1.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},k1.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},k1.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},k1.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},k1.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},k1.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},k1.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},k1.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},k1.prototype.enableEdge=function(){this._enableEdge=!0},k1.prototype.disableEdge=function(){this._enableEdge=!1},k1.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)},k1.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var n={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",n);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown SSAO parameter "+e)}},k1.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].setParameter("blurRadius",t);break;case"quality":var r={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=r;for(n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].pass.material.define("POISSON_KERNEL_SIZE",r);this._dofBlurKernel=new Float32Array(2*r);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown DOF parameter "+e)}},k1.prototype.setSSRParameter=function(e,t){if(null!=t)switch(e){case"quality":var n={low:10,medium:15,high:30,ultra:80}[t]||20,r={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",n),this._ssrPass.setParameter("pixelStride",r);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-t,1),0));break;case"physical":this.setPhysicallyCorrectSSR(t);break;default:console.warn("Unkown SSR parameter "+e)}},k1.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)},k1.prototype.setEdgeColor=function(e){var t=HQ.parseColor(e);this._edgePass.setParameter("edgeColor",t)},k1.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))},k1.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:HQ.Texture.NEAREST,magFilter:HQ.Texture.NEAREST,flipY:!1})},k1.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)},k1.prototype.isSSREnabled=function(){return this._enableSSR},k1.prototype.composite=function(e,t,n,r,i){var o=this._sourceTexture,a=o;this._enableEdge&&(this._edgePass.update(e,n,o,i),o=a=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,n,o,i),a=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=a,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,u=i%Math.floor(A1.length/2/l),c=0;c<2*l;c++)s[c]=A1[c+u*l*2];for(c=0;c<this._dofBlurNodes.length;c++)this._dofBlurNodes[c].setParameter("percent",i/30),this._dofBlurNodes[c].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",n.near),this._cocNode.setParameter("zFar",n.far),this._compositor.render(e,r)},k1.prototype.dispose=function(e){this._sourceTexture.dispose(e),this._depthTexture.dispose(e),this._framebuffer.dispose(e),this._compositor.dispose(e),this._normalPass.dispose(e),this._ssaoPass.dispose(e)},z1.prototype={constructor:z1,jitterProjection:function(e,t){var n=e.viewport,r=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*r,o=n.height*r,a=this._haltonSequence[this._frame%this._haltonSequence.length],s=new aK;s.array[12]=(2*a[0]-1)/i,s.array[13]=(2*a[1]-1)/o,aK.mul(t.projectionMatrix,s,t.projectionMatrix),aK.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,n){var r=this._blendPass;0===this._frame?(r.setUniform("weight1",0),r.setUniform("weight2",1)):(r.setUniform("weight1",.9),r.setUniform("weight2",.1)),r.setUniform("texture1",this._prevFrameTex),r.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),r.render(e),this._blendFb.unbind(e),n||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},V1.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof E$||(this.camera=new E$,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof uJ||(this.camera=new uJ,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},V1.prototype.setViewport=function(e,t,n,r,i){this.camera instanceof E$&&(this.camera.aspect=n/r),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=n,this.viewport.height=r,this.viewport.devicePixelRatio=i,this._compositor.resize(n*i,r*i),this._temporalSS.resize(n*i,r*i)},V1.prototype.containPoint=function(e,t){var n=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var B1=new KZ;function F1(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=e.get("boxWidth"),i=e.get("boxHeight"),o=e.get("boxDepth");"production"!==process.env.NODE_ENV&&["x","y","z"].forEach((function(t){if(!this.getAxis(t))throw new Error("Grid"+e.id+" don't have "+t+"Axis")}),this),this.getAxis("x").setExtent(-r/2,r/2),this.getAxis("y").setExtent(o/2,-o/2),this.getAxis("z").setExtent(-i/2,i/2),this.size=[r,i,o]}function G1(e,t){var n={};e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData();["x","y","z"].forEach((function(e){t.mapDimensionsAll(e,!0).forEach((function(r){!function(e,t){n[e]=n[e]||[1/0,-1/0],n[e][0]=Math.min(t[0],n[e][0]),n[e][1]=Math.max(t[1],n[e][1])}(e,t.getDataExtent(r,!0))}))}))}}),this),["xAxis3D","yAxis3D","zAxis3D"].forEach((function(t){e.eachComponent(t,(function(e){var r=t.charAt(0),i=e.getReferringComponents("grid3D").models[0],o=i.coordinateSystem;if(o===this){var a=o.getAxis(r);if(a)"production"!==process.env.NODE_ENV&&console.warn("Can't have two %s in one grid3D",t);else{(a=new z0(r,nb(n[r]||[1/0,-1/0],e))).type=e.get("type");var s="category"===a.type;a.onBand=s&&e.get("boundaryGap"),a.inverse=e.get("inverse"),e.axis=a,a.model=e,a.getLabelModel=function(){return e.getModel("axisLabel",i.getModel("axisLabel"))},a.getTickModel=function(){return e.getModel("axisTick",i.getModel("axisTick"))},o.addAxis(a)}}}),this)}),this),this.resize(this.model,t)}V1.prototype.castRay=function(e,t,n){var r=this.layer.renderer,i=r.viewport;return r.viewport=this.viewport,r.screenToNDC(e,t,B1),this.camera.castRay(B1,n),r.viewport=i,n},V1.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t<e.transparent.length;t++){var n=e.transparent[t].geometry;n.needsSortVerticesProgressively&&n.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),n.needsSortTrianglesProgressively&&n.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},V1.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++},V1.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},V1.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"===e&&(e=this._enablePostEffect),e},V1.prototype.hasDOF=function(){return this._enableDOF},V1.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},V1.prototype._doRender=function(e,t,n){var r=this.scene,i=this.camera;n=n||0,this._updateTransparent(e,r,i,n),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,r,i,!0)),this._updateShadowPCFKernel(n);var o,a=e.clearColor;(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,r,i,this._temporalSS.getFrame())),this._updateSSAO(e,r,i,this._temporalSS.getFrame()),this._enablePostEffect)?((o=this._compositor.getSourceFrameBuffer()).bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(r,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,r,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,r,i,null,0))):this.needsTemporalSS()&&t?((o=this._temporalSS.getSourceFrameBuffer()).bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(r,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),e.render(r,i,!0,!0))},V1.prototype._updateTransparent=function(e,t,n,r){for(var i=new Fq,o=new aK,a=n.getWorldPosition(),s=t.getRenderList(n).transparent,l=0;l<s.length;l++){var u=s[l],c=u.geometry;aK.invert(o,u.worldTransform),Fq.transformMat4(i,a,o),c.needsSortTriangles&&c.needsSortTriangles()&&c.doSortTriangles(i,r),c.needsSortVertices&&c.needsSortVertices()&&c.doSortVertices(i,r)}},V1.prototype._updateSSAO=function(e,t,n){var r=this._enableSSAO&&this._enablePostEffect;r&&this._compositor.updateSSAO(e,t,n,this._temporalSS.getFrame());for(var i=t.getRenderList(n),o=0;o<i.opaque.length;o++){var a=i.opaque[o];a.renderNormal&&a.material[r?"enableTexture":"disableTexture"]("ssaoMap"),r&&a.material.set("ssaoMap",this._compositor.getSSAOTexture())}},V1.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],n=this.scene.getRenderList(this.camera).opaque,r=0;r<n.length;r++)n[r].receiveShadow&&(n[r].material.set("pcfKernel",t),n[r].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))},V1.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)},V1.prototype.setPostEffect=function(e,t){var n=this._compositor;this._enablePostEffect=e.get("enable");var r=e.getModel("bloom"),i=e.getModel("edge"),o=e.getModel("DOF",e.getModel("depthOfField")),a=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),s=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");r.get("enable")?n.enableBloom():n.disableBloom(),o.get("enable")?n.enableDOF():n.disableDOF(),s.get("enable")?n.enableSSR():n.disableSSR(),u.get("enable")?n.enableColorCorrection():n.disableColorCorrection(),i.get("enable")?n.enableEdge():n.disableEdge(),l.get("enable")?n.enableFXAA():n.disableFXAA(),this._enableDOF=o.get("enable"),this._enableSSAO=a.get("enable"),this._enableSSAO?n.enableSSAO():n.disableSSAO(),n.setBloomIntensity(r.get("intensity")),n.setEdgeColor(i.get("color")),n.setColorLookupTexture(u.get("lookupTexture"),t),n.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach((function(e){n.setSSAOParameter(e,a.get(e))})),["quality","maxRoughness","physical"].forEach((function(e){n.setSSRParameter(e,s.get(e))})),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach((function(e){n.setDOFParameter(e,o.get(e))})),["brightness","contrast","saturation"].forEach((function(e){n.setColorCorrection(e,u.get(e))}))},V1.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect){if(e>this.camera.far||e<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",e),!0}},V1.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")},V1.prototype.isLinearSpace=function(){return this._enablePostEffect},V1.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),n=0;n<t.length;n++)e.add(t[n]);e!==this.scene&&this.scene.add(e),this.rootNode=e}},V1.prototype.add=function(e){this.rootNode.add(e)},V1.prototype.remove=function(e){this.rootNode.remove(e)},V1.prototype.removeAll=function(e){this.rootNode.removeAll(e)},Object.assign(V1.prototype,yY);var H1={dimensions:k0.prototype.dimensions,create:function(e,t){var n=[];e.eachComponent("grid3D",(function(e){e.__viewGL=e.__viewGL||new V1;var t=new k0;t.model=e,t.viewGL=e.__viewGL,e.coordinateSystem=t,n.push(t),t.resize=F1,t.update=G1}));var r=["xAxis3D","yAxis3D","zAxis3D"];return e.eachSeries((function(t){if("cartesian3D"===t.get("coordinateSystem")){if(null==(i=t.getReferringComponents("grid3D").models[0])){var n=function(e,t){return r.map((function(n){var r=e.getReferringComponents(n).models[0];if(null==r&&(r=t.getComponent(n)),"production"!==process.env.NODE_ENV&&!r)throw new Error(n+' "'+wJ(e.get(n+"Index"),e.get(n+"Id"),0)+'" not found');return r}))}(t,e),i=n[0].getCoordSysModel();n.forEach((function(e){var t=e.getCoordSysModel();if("production"!==process.env.NODE_ENV){if(!t)throw new Error('grid3D "'+wJ(e.get("gridIndex"),e.get("gridId"),0)+'" not found');if(t!==i)throw new Error("xAxis3D, yAxis3D, zAxis3D must use the same grid")}}))}var o=i.coordinateSystem;t.coordinateSystem=o}})),n}},U1=tp.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});rb(U1);var W1={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},j1=R({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},W1),X1=R({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},W1),Y1=V({scale:!0,min:"dataMin",max:"dataMax"},X1),Z1=V({logBase:10},X1);Z1.scale=!0;var q1={categoryAxis3D:j1,valueAxis3D:X1,timeAxis3D:Y1,logAxis3D:Z1},K1=["value","category","time","log"];function $1(e,t){return t.type||(t.data?"category":"value")}l_((function(e){e.registerComponentModel(s0),e.registerComponentView(R0),e.registerCoordinateSystem("grid3D",H1),["x","y","z"].forEach((function(t){!function(e,t,n,r,i){K1.forEach((function(o){var a=n.extend({type:t+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){R(e,n.getTheme().get(o+"Axis3D")),R(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=Z_.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:R(O(q1[o+"Axis3D"]),i||{},!0)});e.registerComponentModel(a)})),e.registerSubTypeDefaulter(t+"Axis3D",$(r,t))}(e,t,U1,$1,{name:t.toUpperCase()});const n=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(n)})),e.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"grid3D",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},(function(e,t){})),e.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},(function(e,t){}))}));var J1={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}},Q1={getFilledRegions:function(e,t){var n,r=(e||[]).slice();if("string"==typeof t?n=(t=i_(t))&&t.geoJson:t&&t.features&&(n=t),!n)return"production"!==process.env.NODE_ENV&&(console.error("Map "+t+" not exists. You can download map file on http://echarts.baidu.com/download-map.html"),n.features||console.error("Invalid GeoJSON for map3D")),[];for(var i={},o=n.features,a=0;a<r.length;a++)i[r[a].name]=r[a];for(a=0;a<o.length;a++){var s=o[a].properties.name;i[s]||r.push({name:s})}return r},defaultOption:{show:!0,zlevel:-10,map:"",left:0,top:0,width:"100%",height:"100%",boxWidth:100,boxHeight:10,boxDepth:"auto",regionHeight:3,environment:"auto",groundPlane:{show:!1,color:"#aaa"},shading:"lambert",light:{main:{alpha:40,beta:30}},viewControl:{alpha:40,beta:0,distance:100,orthographicSize:60,minAlpha:5,minBeta:-80,maxBeta:80},label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}},e2=tp.extend({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=k_(e.data||[],{coordDimensions:["value"],encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),n=new R_(t,this);n.initData(e.regions);var r={};n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,this._data=n},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Wh(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),n=this.coordinateSystem.getRegion(t);return n?n.geometries:[]},getFormattedLabel:function(e,t){var n=this._data.getName(e),r=this.getRegionModel(e),i=r.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=r.get(["label","formatter"]));var o={name:n};if("function"==typeof i)return o.status=t,i(o);if("string"==typeof i){var a=o.seriesName;return i.replace("{a}",null!=a?a:"")}return n},defaultOption:{regions:[]}});function t2(e,t,n){n=n||2;var r,i,o,a,s,l,u,c=t&&t.length,h=c?t[0]*n:e.length,d=n2(e,0,h,n,!0),p=[];if(!d)return p;if(c&&(d=function(e,t,n,r){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=n2(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(d2(a));for(s.sort(u2),i=0;i<s.length;i++)c2(s[i],n),n=r2(n,n.next);return n}(e,t,d,n)),e.length>80*n){r=o=e[0],i=a=e[1];for(var f=n;f<h;f+=n)(s=e[f])<r&&(r=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=Math.max(o-r,a-i)}return i2(d,p,n,r,i,u),p}function n2(e,t,n,r,i){var o,a;if(i===S2(e,t,n,r)>0)for(o=t;o<n;o+=r)a=x2(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=x2(o,e[o],e[o+1],a);return a&&m2(a,a.next)&&(b2(a),a=a.next),a}function r2(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m2(r,r.next)&&0!==g2(r.prev,r,r.next))r=r.next;else{if(b2(r),(r=t=r.prev)===r.next)return null;n=!0}}while(n||r!==t);return t}function i2(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=h2(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<u&&(s++,r=r.nextZ);t++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?a2(e,r,i,o):o2(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),b2(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?i2(e=s2(e,t,n),t,n,r,i,o,2):2===a&&l2(e,t,n,r,i,o):i2(r2(e),t,n,r,i,o,1);break}}}function o2(e){var t=e.prev,n=e,r=e.next;if(g2(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(p2(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&g2(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function a2(e,t,n,r){var i=e.prev,o=e,a=e.next;if(g2(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,h=h2(s,l,t,n,r),d=h2(u,c,t,n,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&p2(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&g2(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&p2(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&g2(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function s2(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!m2(i,o)&&v2(i,r,r.next,o)&&y2(i,o)&&y2(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),b2(r),b2(r.next),r=e=o),r=r.next}while(r!==e);return r}function l2(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&f2(a,s)){var l=_2(a,s);return a=r2(a,a.next),l=r2(l,l.next),i2(a,t,n,r,i,o),void i2(l,t,n,r,i,o)}s=s.next}a=a.next}while(a!==e)}function u2(e,t){return e.x-t.x}function c2(e,t){if(t=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n.prev;var l,u=n,c=n.x,h=n.y,d=1/0;r=n.next;for(;r!==u;)i>=r.x&&r.x>=c&&i!==r.x&&p2(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&((l=Math.abs(o-r.y)/(i-r.x))<d||l===d&&r.x>n.x)&&y2(r,e)&&(n=r,d=l),r=r.next;return n}(e,t),t){var n=_2(t,e);r2(n,n.next)}}function h2(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d2(e){var t=e,n=e;do{t.x<n.x&&(n=t),t=t.next}while(t!==e);return n}function p2(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function f2(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&v2(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&y2(e,t)&&y2(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)}function g2(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m2(e,t){return e.x===t.x&&e.y===t.y}function v2(e,t,n,r){return!!(m2(e,t)&&m2(n,r)||m2(e,r)&&m2(n,t))||g2(e,t,n)>0!=g2(e,t,r)>0&&g2(n,r,e)>0!=g2(n,r,t)>0}function y2(e,t){return g2(e.prev,e,e.next)<0?g2(e,t,e.next)>=0&&g2(e,e.prev,t)>=0:g2(e,t,e.prev)<0||g2(e,e.next,t)<0}function _2(e,t){var n=new w2(e.i,e.x,e.y),r=new w2(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function x2(e,t,n,r){var i=new w2(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function b2(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function w2(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S2(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}function T2(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function M2(e,t,n,r,i){var o=n,a=e[t];T2(e,t,r);for(var s=n;s<r;s++)i(e[s],a)<0&&(T2(e,s,o),o++);return T2(e,r,o),o}function C2(e,t,n,r){if(n<r){var i=M2(e,Math.floor((n+r)/2),n,r,t);C2(e,t,n,i-1),C2(e,t,i+1,r)}}function D2(){this._parts=[]}R(e2.prototype,Q1),R(e2.prototype,i0),R(e2.prototype,o0),R(e2.prototype,a0),R(e2.prototype,J1),t2.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(S2(e,0,o,n));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*n,c=s<l-1?t[s+1]*n:e.length;a-=Math.abs(S2(e,u,c,n))}var h=0;for(s=0;s<r.length;s+=3){var d=r[s]*n,p=r[s+1]*n,f=r[s+2]*n;h+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},D2.prototype.step=function(e,t,n){var r=e.length;if(0===n){this._parts=[],this._sorted=!1;var i=Math.floor(r/2);this._parts.push({pivot:i,left:0,right:r-1}),this._currentSortPartIdx=0}if(!this._sorted){var o=this._parts;if(0===o.length)return this._sorted=!0,!0;if(o.length<512){for(var a=0;a<o.length;a++)o[a].pivot=M2(e,o[a].pivot,o[a].left,o[a].right,t);var s=[];for(a=0;a<o.length;a++){var l=o[a].left;(u=o[a].pivot-1)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u});var u;l=o[a].pivot+1;(u=o[a].right)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u})}o=this._parts=s}else for(a=0;a<Math.floor(o.length/10);a++){var c=o.length-1-this._currentSortPartIdx;if(C2(e,t,o[c].left,o[c].right),this._currentSortPartIdx++,this._currentSortPartIdx===o.length)return this._sorted=!0,!0}return!1}},D2.sort=C2;var A2=p0.vec3,I2=A2.create(),E2=A2.create(),L2=A2.create(),N2={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var n=this.indices;if(0===t){var r=this.attributes.position;e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new n.constructor(n.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,o=0,a=0;a<n.length;){r.get(n[a++],I2),r.get(n[a++],E2),r.get(n[a++],L2);var s=A2.sqrDist(I2,e),l=A2.sqrDist(E2,e),u=A2.sqrDist(L2,e),c=Math.min(s,l);c=Math.min(c,u),3===a?(i=c,c=0):c-=i,this._triangleZList[o++]=c}}var h=this._sortedTriangleIndices;for(a=0;a<h.length;a++)h[a]=a;if(this.triangleCount<2e4)0===t&&this._simpleSort(!0);else for(a=0;a<3;a++)this._progressiveQuickSort(3*t+a);var d=this._indicesTmp,p=this._triangleZListTmp,f=this._triangleZList;for(a=0;a<this.triangleCount;a++){var g=3*h[a],m=3*a;d[m++]=n[g++],d[m++]=n[g++],d[m]=n[g],p[a]=f[h[a]]}var v=this._indicesTmp;this._indicesTmp=this.indices,this.indices=v;v=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=v,this.dirtyIndices()},_simpleSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):D2.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;this._quickSort=this._quickSort||new D2,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}};function P2(e,t){const n=e.getItemVisual(t,"style");if(n){return n[e.getVisual("drawType")]}}function O2(e,t){const n=e.getItemVisual(t,"style");return n&&n.opacity}function R2(e,t,n){this._labelsMesh=new D0,this._labelTextureSurface=new y0({width:512,height:512,devicePixelRatio:n.getDevicePixelRatio(),onupdate:function(){n.getZr().refresh()}}),this._api=n,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}R2.prototype.getLabelPosition=function(e,t,n){return[0,0,0]},R2.prototype.getLabelDistance=function(e,t,n){return 0},R2.prototype.getMesh=function(){return this._labelsMesh},R2.prototype.updateData=function(e,t,n){null==t&&(t=0),null==n&&(n=e.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===n-t||(this._labelsVisibilitiesBits=new Uint8Array(n-t));for(var r=["label","show"],i=["emphasis","label","show"],o=t;o<n;o++){var a=e.getItemModel(o),s=a.get(r),l=a.get(i);null==l&&(l=s);var u=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[o-t]=u}this._start=t,this._end=n,this._data=e},R2.prototype.updateLabels=function(e){if(this._data){for(var t=(e=e||[]).length>0,n={},r=0;r<e.length;r++)n[e[r]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var i=["label"],o=["emphasis","label"],a=this._data.hostModel,s=this._data,l=a.getModel(i),u=a.getModel(o,l),c={left:"right",right:"left",top:"center",bottom:"center"},h={left:"middle",right:"middle",top:"bottom",bottom:"top"},d=this._start;d<this._end;d++){var p=!1;if(t&&n[d]&&(p=!0),this._labelsVisibilitiesBits[d-this._start]&(p?2:1)){var f=s.getItemModel(d).getModel(p?o:i,p?u:l),g=f.get("distance")||0,m=f.get("position"),v=this._api.getDevicePixelRatio(),y=a.getFormattedLabel(d,p?"emphasis":"normal");if(null==y||""===y)return;var _=new ll({style:wh(f,{text:y,fill:f.get("color")||P2(s,d)||"#000",align:"left",verticalAlign:"top",opacity:wJ(f.get("opacity"),O2(s,d),1)})}),x=_.getBoundingRect();x.height*=1.2;var b=this._labelTextureSurface.add(_),w=c[m]||"center",S=h[m]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(d,m,g),[x.width*v,x.height*v],b,w,S,this.getLabelDistance(d,m,g)*v)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}},R2.prototype.dispose=function(){this._labelTextureSurface.dispose()};var k2=p0.vec3;function z2(e){this.rootNode=new HQ.Node,this._triangulationResults={},this._shadersMap=HQ.COMMON_SHADERS.filter((function(e){return"shadow"!==e})).reduce((function(e,t){return e[t]=HQ.createShader("ecgl."+t),e}),{}),this._linesShader=HQ.createShader("ecgl.meshLines3D");var t={};HQ.COMMON_SHADERS.forEach((function(e){t[e]=new HQ.Material({shader:HQ.createShader("ecgl."+e)})})),this._groundMaterials=t,this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new R2(512,512,e),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=e}HQ.Shader.import(N0),z2.prototype={constructor:z2,extrudeY:!0,update:function(e,t,n,r,i){var o=e.getData();null==r&&(r=0),null==i&&(i=o.count()),this._startIndex=r,this._endIndex=i-1,this._triangulation(e,r,i);var a=this._getShader(e.get("shading"));this._prepareMesh(e,a,n,r,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,n,r,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,n);var l=this;this._labelsBuilder.updateData(o,r,i),this._labelsBuilder.getLabelPosition=function(e,t,n){var r=o.getName(e),i=n;if("geo3D"===s.type){var a=s.getRegion(r);return a?(c=a.getCenter(),s.dataToPoint([c[0],c[1],i])):[NaN,NaN,NaN]}var u=l._triangulationResults[e-l._startIndex],c=l.extrudeY?[(u.max[0]+u.min[0])/2,u.max[1]+i,(u.max[2]+u.min[2])/2]:[(u.max[0]+u.min[0])/2,(u.max[1]+u.min[1])/2,u.max[2]+i]},this._data=o,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this;var t=function(){var t=new HQ.Mesh({name:"Polygon",material:new HQ.Material({shader:e._shadersMap.lambert}),geometry:new HQ.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(t.geometry,N2),t}(),n=new HQ.Mesh({material:new HQ.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new m0({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(n),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=n,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+e),t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,n,r,i){for(var o=0,a=0,s=0,l=0,u=r;u<i;u++){var c=this._getRegionPolygonInfo(u),h=this._getRegionLinesInfo(u,e,this._linesMesh.geometry);o+=c.vertexCount,a+=c.triangleCount,s+=h.vertexCount,l+=h.triangleCount}var d=this._polygonMesh,p=d.geometry;["position","normal","texcoord0","color"].forEach((function(e){p.attributes[e].init(o)})),p.indices=o>65535?new Uint32Array(3*a):new Uint16Array(3*a),d.material.shader!==t&&d.material.attachShader(t,!0),HQ.setMaterialFromModel(t.__shading,d.material,e,n),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(o),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-r))},_updateRegionMesh:function(e,t,n,r){for(var i=e.getData(),o=0,a=0,s=!1,l=this._polygonMesh,u=this._linesMesh,c=n;c<r;c++){var h=e.getRegionModel(c),d=h.getModel("itemStyle"),p=wJ(P2(i,c),d.get("color"),"#fff"),f=wJ(O2(i,c),d.get("opacity"),1),g=HQ.parseColor(p),m=HQ.parseColor(d.get("borderColor"));g[3]*=f,m[3]*=f;var v=g[3]<.99;l.material.set("color",[1,1,1,1]),s=s||v;for(var y=wJ(h.get("height",!0),e.get("regionHeight")),_=this._updatePolygonGeometry(e,l.geometry,c,y,o,a,g),x=o;x<_.vertexOffset;x++)this._dataIndexOfVertex[x]=c;this._vertexRangeOfDataIndex[2*(c-n)]=o,this._vertexRangeOfDataIndex[2*(c-n)+1]=_.vertexOffset,o=_.vertexOffset,a=_.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=t.getDevicePixelRatio(),this._updateLinesGeometry(u.geometry,e,c,y,b,e.coordinateSystem.transform)),u.invisible=!w,u.material.set({color:m})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?HQ.Mesh.CCW:HQ.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=e.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var n=HQ.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),r=wJ(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",n),i.material.set("wireframeLineWidth",r)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,n){var r=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!r.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),o=this._groundMaterials[i];o||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+i),o=this._groundMaterials.lambert),HQ.setMaterialFromModel(i,o,r,n),o.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=o,this._groundMesh.material.set("color",HQ.parseColor(r.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,n){this._triangulationResults=[];for(var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],o=e.coordinateSystem,a=t;a<n;a++){for(var s=[],l=e.getRegionPolygonCoords(a),u=0;u<l.length;u++){var c=l[u].exterior,h=l[u].interiors,d=[],p=[];if(!(c.length<3)){for(var f=0,g=0;g<c.length;g++){var m=c[g];d[f++]=m[0],d[f++]=m[1]}for(g=0;g<h.length;g++)if(!(h[g].length<3)){for(var v=d.length/2,y=0;y<h[g].length;y++){m=h[g][y];d.push(m[0]),d.push(m[1])}p.push(v)}var _=t2(d,p),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],S=[-1/0,-1/0,-1/0],T=0;for(g=0;g<d.length;)k2.set(b,d[g++],0,d[g++]),o&&o.transform&&k2.transformMat4(b,b,o.transform),k2.min(w,w,b),k2.max(S,S,b),x[T++]=b[0],x[T++]=b[1],x[T++]=b[2];k2.min(r,r,w),k2.max(i,i,S),s.push({points:x,indices:_,min:w,max:S})}}this._triangulationResults.push(s)}this._geoBoundingBox=[r,i]},_getRegionPolygonInfo:function(e){for(var t=this._triangulationResults[e-this._startIndex],n=0,r=0,i=0;i<t.length;i++)n+=t[i].points.length/3,r+=t[i].indices.length/3;return{vertexCount:2*n+4*n,triangleCount:2*r+2*n}},_updatePolygonGeometry:function(e,t,n,r,i,o,a){var s=e.get("projectUVOnGround"),l=t.attributes.position,u=t.attributes.normal,c=t.attributes.texcoord0,h=t.attributes.color,d=this._triangulationResults[n-this._startIndex],p=h.value&&a,f=t.indices,g=this.extrudeY?1:2,m=this.extrudeY?2:1,v=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],y=k2.mul([],this._geoBoundingBox[0],v),_=k2.mul([],this._geoBoundingBox[1],v),x=Math.max(_[0]-y[0],_[2]-y[2]);function b(e,t,n){var r=i;!function(e,t){for(var n=e.points,r=n.length,o=[],s=[],u=0;u<r;u+=3)o[0]=n[u],o[g]=t,o[m]=n[u+2],s[0]=(n[u]*v[0]-y[0])/x,s[1]=(n[u+2]*v[m]-y[2])/x,l.set(i,o),p&&h.set(i,a),c.set(i++,s)}(e,t);for(var s=e.indices.length,u=0;u<s;u++)f[3*o+u]=e.indices[u]+r;o+=e.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],S=k2.negate([],w),T=0;T<d.length;T++){var M=i,C=d[T];b(C,0),b(C,r);for(var D=C.points.length/3,A=0;A<D;A++)u.set(M+A,S),u.set(M+A+D,w);var I=[0,3,1,1,3,2],E=[[],[],[],[]],L=[],N=[],P=[],O=[],R=0;for(A=0;A<D;A++){for(var k=(A+1)%D,z=(C.points[3*k]-C.points[3*A])*v[0],V=(C.points[3*k+2]-C.points[3*A+2])*v[m],B=Math.sqrt(z*z+V*V),F=0;F<4;F++){var G=0===F||3===F,H=3*(G?A:k);E[F][0]=C.points[H],E[F][g]=F>1?r:0,E[F][m]=C.points[H+2],l.set(i+F,E[F]),s?(O[0]=(C.points[H]*v[0]-y[0])/x,O[1]=(C.points[H+2]*v[m]-y[m])/x):(O[0]=(G?R:R+B)/x,O[1]=(E[F][g]*v[g]-y[g])/x),c.set(i+F,O)}k2.sub(L,E[1],E[0]),k2.sub(N,E[3],E[0]),k2.cross(P,L,N),k2.normalize(P,P);for(F=0;F<4;F++)u.set(i+F,P),p&&h.set(i+F,a);for(F=0;F<6;F++)f[3*o+F]=I[F]+i;i+=4,o+=2,R+=B}}return t.dirty(),{vertexOffset:i,triangleOffset:o}},_getRegionLinesInfo:function(e,t,n){var r=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach((function(e){var t=e.exterior,o=e.interiors;r+=n.getPolylineVertexCount(t),i+=n.getPolylineTriangleCount(t);for(var a=0;a<o.length;a++)r+=n.getPolylineVertexCount(o[a]),i+=n.getPolylineTriangleCount(o[a])}),this);return{vertexCount:r,triangleCount:i}},_updateLinesGeometry:function(e,t,n,r,i,o){function a(e){for(var t=new Float64Array(3*e.length),n=0,i=[],a=0;a<e.length;a++)i[0]=e[a][0],i[1]=r+.1,i[2]=e[a][1],o&&k2.transformMat4(i,i,o),t[n++]=i[0],t[n++]=i[1],t[n++]=i[2];return t}var s=[1,1,1,1];t.getRegionPolygonCoords(n).forEach((function(t){var n=t.exterior,r=t.interiors;e.addPolyline(a(n),s,i);for(var o=0;o<r.length;o++)e.addPolyline(a(r[o]),s,i)}))},highlight:function(e){var t=this._data;if(t){var n=t.getItemModel(e).getModel(["emphasis","itemStyle"]),r=n.get("color"),i=wJ(n.get("opacity"),O2(t,e),1);if(null==r)r=or(P2(t,e),-.4);null==i&&(i=O2(t,e));var o=HQ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},downplay:function(e){var t=this._data;if(t){var n=t.getItemModel(e),r=wJ(P2(t,e),n.get(["itemStyle","color"]),"#fff"),i=wJ(O2(t,e),n.get(["itemStyle","opacity"]),1),o=HQ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},dispose:function(){this._labelsBuilder.dispose()},_setColorOfDataIndex:function(e,t,n){if(!(t<this._startIndex&&t>this._endIndex)){t-=this._startIndex;for(var r=this._vertexRangeOfDataIndex[2*t];r<this._vertexRangeOfDataIndex[2*t+1];r++)this._polygonMesh.geometry.attributes.color.set(r,n);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var V2=Kg.extend({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new z2(t),this.groupGL=new HQ.Node,this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new h0({zr:t.getZr()}),this._control.init()},render:function(e,t,n){this.groupGL.add(this._geo3DBuilder.rootNode);var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")})),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})})),i.update()}},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},dispose:function(){this._control.dispose(),this._geo3DBuilder.dispose()}}),B2={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var F2=p0.vec3,G2=p0.mat4,H2=[mD,function(e,t){if("world"===e){var n=B2[t.name];if(n){var r=[n[0],n[1]];t.setCenter(r)}}}];function U2(e,t,n,r,i){this.name=e,this.map=t,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(n,r,i),this.transform=G2.identity(new Float64Array(16)),this.invTransform=G2.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}function W2(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=this.getGeoBoundingRect(),i=r.width/r.height*(e.get("aspectScale")||.75),o=e.get("boxWidth"),a=e.get("boxDepth"),s=e.get("boxHeight");null==s&&(s=5),isNaN(o)&&isNaN(a)&&(o=100),isNaN(a)?a=o/i:isNaN(o)&&(o=a/i),this.setSize(o,s,a),this.regionHeight=e.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function j2(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this&&"series.map3D"!==e.type){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),n&&isFinite(n[1]-n[0])){var r=nb(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Ob("altitude",r),this.resize(this.model,t)}}if(U2.prototype={constructor:U2,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(e,t,n){var r=vb||vb;try{this.regions=e?r(e):[]}catch(e){throw"Invalid geoJson format\n"+e}t=t||{},n=n||{};for(var i=this.regions,o={},a=0;a<i.length;a++){var s=i[a].name;s=n[s]||s,i[a].name=s,o[s]=i[a],this.addGeoCoord(s,i[a].getCenter());var l=t[s];l&&i[a].transformTo(l.left,l.top,l.width,l.height)}this._regionsMap=o,this._geoRect=null,H2.forEach((function(e){e(this)}),this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var e,t=this.regions,n=0;n<t.length;n++){var r=t[n].getBoundingRect();(e=e||r.clone()).union(r)}return this._geoRect=e||new jt(0,0,0,0)},addGeoCoord:function(e,t){this._nameCoordMap[e]=t},getRegion:function(e){return this._regionsMap[e]},getRegionByCoord:function(e){for(var t=this.regions,n=0;n<t.length;n++)if(t[n].contain(e))return t[n]},setSize:function(e,t,n){this.size=[e,t,n];var r=this.getGeoBoundingRect(),i=e/r.width,o=-n/r.height,a=-e/2-r.x*i,s=n/2-r.y*o,l=this.extrudeY?[a,0,s]:[a,s,0],u=this.extrudeY?[i,1,o]:[i,o,1],c=this.transform;G2.identity(c),G2.translate(c,c,l),G2.scale(c,c,u),G2.invert(this.invTransform,c)},dataToPoint:function(e,t){t=t||[];var n=this.extrudeY?1:2,r=this.extrudeY?2:1,i=e[2];return isNaN(i)&&(i=0),t[0]=e[0],t[r]=e[1],this.altitudeAxis?t[n]=this.altitudeAxis.dataToCoord(i):t[n]=0,t[n]+=this.regionHeight,F2.transformMat4(t,t,this.transform),t},pointToData:function(e,t){}},"production"!==process.env.NODE_ENV)var X2=function(e){console.error("Map "+e+" not exists. You can download map file on http://echarts.baidu.com/download-map.html")};var Y2=0,Z2={dimensions:U2.prototype.dimensions,create:function(e,t){var n=[];if(!i_)throw new Error("geo3D component depends on geo component");function r(e,r){var i=Z2.createGeo3D(e);e.__viewGL=e.__viewGL||new V1,i.viewGL=e.__viewGL,e.coordinateSystem=i,i.model=e,n.push(i),i.resize=W2,i.resize(e,t),i.update=j2}return e.eachComponent("geo3D",(function(e,t){r(e)})),e.eachSeriesByType("map3D",(function(e,t){var n=e.get("coordinateSystem");null==n&&(n="geo3D"),"geo3D"===n&&r(e)})),e.eachSeries((function(t){if("geo3D"===t.get("coordinateSystem")){if("series.map3D"===t.type)return;var n=t.getReferringComponents("geo3D").models[0];if(n||(n=e.getComponent("geo3D")),!n)throw new Error('geo "'+wJ(t.get("geo3DIndex"),t.get("geo3DId"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n},createGeo3D:function(e){var t,n=e.get("map");if("string"==typeof n?(t=n,n=i_(n)):n&&n.features&&(n={geoJson:n}),"production"!==process.env.NODE_ENV&&(n||X2(n),!n.geoJson.features))throw new Error("Invalid GeoJSON for map3D");return null==t&&(t="GEO_ANONYMOUS_"+Y2++),new U2(t+Y2++,t,n&&n.geoJson,n&&n.specialAreas,e.get("nameMap"))}};function q2(e){e.registerComponentModel(e2),e.registerComponentView(V2),e.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"geo3D",query:e},(function(t){t.setView(e)}))})),e.registerCoordinateSystem("geo3D",Z2)}function K2(e,t){e.id=e.id||e.name||t+""}l_(q2);var $2=tp.extend({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){$2.superApply(this,"init",arguments),W(this.option.layers,(function(e,t){R(e,this.defaultLayerOption),K2(e,t)}),this)},mergeOption:function(e){var t=this.option.layers;function n(e){return X(e,(function(e,t,n){return K2(t,n),e[t.id]=t,e}),{})}if(this.option.layers=null,$2.superApply(this,"mergeOption",arguments),t&&t.length){var r=n(e.layers),i=n(t);for(var o in r)i[o]?R(i[o],r[o],!0):t.push(e.layers[o]);this.option.layers=t}W(this.option.layers,(function(e){R(e,this.defaultLayerOption)}),this)},optionUpdated:function(){this.updateDisplacementHash()},defaultLayerOption:{show:!0,type:"overlay"},defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",baseColor:"#fff",baseTexture:"",heightTexture:"",displacementTexture:"",displacementScale:0,displacementQuality:"medium",globeRadius:100,globeOuterRadius:150,shading:"lambert",light:{main:{time:""}},atmosphere:{show:!1,offset:5,color:"#ffffff",glowPower:6,innerGlowPower:2},viewControl:{autoRotate:!0,panSensitivity:0,targetCoord:null},layers:[]},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var e=this.getDisplacementTexture(),t=this.get("displacementScale");return e&&"none"!==e||(t=0),t},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});R($2.prototype,i0),R($2.prototype,o0),R($2.prototype,a0),R($2.prototype,J1);var J2=Math.PI,Q2=Math.sin,e3=Math.cos,t3=Math.tan,n3=Math.asin,r3=Math.atan2,i3=J2/180;var o3=23.4397*i3;function a3(e,t){return r3(Q2(e)*e3(o3)-t3(t)*Q2(o3),e3(e))}function s3(e,t,n){return r3(Q2(e),e3(e)*Q2(t)-t3(n)*e3(t))}function l3(e,t,n){return n3(Q2(t)*Q2(n)+e3(t)*e3(n)*e3(e))}function u3(e){var t,n,r=function(e){return i3*(357.5291+.98560028*e)}(e),i=function(e){return e+i3*(1.9148*Q2(e)+.02*Q2(2*e)+3e-4*Q2(3*e))+102.9372*i3+J2}(r);return{dec:(t=i,n=0,n3(Q2(n)*e3(o3)+e3(n)*Q2(o3)*Q2(t))),ra:a3(i,0)}}var c3={};c3.getPosition=function(e,t,n){var r=i3*-n,i=i3*t,o=function(e){return function(e){return e.valueOf()/864e5-.5+2440588}(e)-2451545}(e),a=u3(o),s=function(e,t){return i3*(280.16+360.9856235*e)-t}(o,r)-a.ra;return{azimuth:s3(s,i,a.dec),altitude:l3(s,i,a.dec)}};HQ.Shader.import(VQ),HQ.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");var h3=Kg.extend({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new HQ.Node,this._sphereGeometry=new HQ.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new HQ.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new HQ.PlaneGeometry,this._earthMesh=new HQ.Mesh({renderNormal:!0}),this._atmosphereMesh=new HQ.Mesh,this._atmosphereGeometry=new HQ.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.atmosphere.vertex"),HQ.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=HQ.Mesh.CW,this._lightRoot=new HQ.Node,this._sceneHelper=new _0,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new h0({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,n){var r=e.coordinateSystem,i=e.get("shading");r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL),this._sceneHelper.setScene(r.viewGL.scene),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var a="ecgl."+i;o.material&&o.material.shader.name===a||(o.material=HQ.createMaterial(a)),HQ.setMaterialFromModel(i,o.material,e,n),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach((function(e){var t=o.material.get(e);t&&(t.flipY=!1)})),o.material.set("color",HQ.parseColor(e.get("baseColor")));var s=.99*r.radius;if(o.scale.set(s,s,s),e.get("atmosphere.show")){o.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:e.get("atmosphere.glowPower")||6,glowColor:e.get("atmosphere.color")||"#ffffff"}),o.material.setUniforms({glowPower:e.get("atmosphere.innerGlowPower")||2,glowColor:e.get("atmosphere.color")||"#ffffff"});var l=e.get("atmosphere.offset")||5;this._atmosphereMesh.scale.set(s+l,s+l,s+l)}else o.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var u=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),n,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(o);var c=o.material.setTextureImage("bumpMap",e.get("heightTexture"),n,{flipY:!1,anisotropic:8});c&&c.surface&&c.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,n),this._displaceVertices(e,n),this._updateViewControl(e,n),this._updateLayers(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},_updateLayers:function(e,t){var n=e.coordinateSystem,r=e.get("layers"),i=n.radius,o=[],a=[],s=[],l=[];W(r,(function(e){var r=new Wh(e),u=r.get("type"),c=HQ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var h=r.get("blendTo"),d=wJ(r.get("intensity"),1);"emission"===h?(s.push(c),l.push(d)):(o.push(c),a.push(d))}else{var p=r.get("id"),f=this._layerMeshes[p];f||(f=this._layerMeshes[p]=new HQ.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===r.get("shading")?(f.material=f.__lambertMaterial||new HQ.Material({autoUpdateTextureStatus:!1,shader:HQ.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),f.__lambertMaterial=f.material):(f.material=f.__colorMaterial||new HQ.Material({autoUpdateTextureStatus:!1,shader:HQ.createShader("ecgl.color"),transparent:!0,depthMask:!1}),f.__colorMaterial=f.material),f.material.enableTexture("diffuseMap");var g=r.get("distance"),m=i+(null==g?n.radius/100:g);f.scale.set(m,m,m),i=m;var v=this._blankTexture||(this._blankTexture=HQ.createBlankTexture("rgba(255, 255, 255, 0)"));f.material.set("diffuseMap",v),HQ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8},(function(e){e.surface&&e.surface.attachToMesh(f),f.material.set("diffuseMap",e),t.getZr().refresh()})),r.get("show")?this.groupGL.add(f):this.groupGL.remove(f)}}),this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",s.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",a),u.set("layerEmissiveMap",s),u.set("layerEmissionIntensity",l);var c=e.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var h=HQ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),d=wJ(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",d),u.set("wireframeLineColor",h)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){var n=e.coordinateSystem,r=e.getModel("viewControl");n.viewGL.camera;var i=this;var o=this._control;o.setViewGL(n.viewGL);var a,s,l=r.get("targetCoord");null!=l&&(s=l[0]+90,a=l[1]),o.setFromViewControlModel(r,{baseDistance:n.radius,alpha:a,beta:s}),o.off("update"),o.on("update",(function(){t.dispatchAction({type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:i.uid,globeId:e.id})}))},_displaceVertices:function(e,t){var n=e.get("displacementQuality"),r=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||n!==this._displacementQuality||r!==this._showDebugWireframe){this._displacementQuality=n,this._showDebugWireframe=r;var o=this._sphereGeometry,a={low:100,medium:200,high:400,ultra:800}[n]||200,s=a/2;(o.widthSegments!==a||r)&&(o.widthSegments=a,o.heightSegments=s,o.build()),this._doDisplaceVertices(o,i),r&&o.generateBarycentric()}},_doDisplaceVertices:function(e,t){var n=e.attributes.position.value,r=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===n.length||((i=new Float32Array(n.length)).set(n),e.__originalPosition=i);for(var o=t.displacementWidth,a=t.displacementHeight,s=t.displacementData,l=0;l<e.vertexCount;l++){var u=3*l,c=2*l,h=i[u+1],d=i[u+2],p=i[u+3],f=r[c++],g=r[c++],m=Math.round(f*(o-1)),v=Math.round(g*(a-1)),y=s?s[v*o+m]:0;n[u+1]=h+h*y,n[u+2]=d+d*y,n[u+3]=p+p*y}e.generateVertexNormals(),e.dirty(),e.updateBoundingBox()},_updateLight:function(e,t){var n=this._earthMesh;this._sceneHelper.updateLight(e);var r=this._sceneHelper.mainLight,i=e.get("light.main.time")||new Date,o=c3.getPosition(yo(i),0,0),a=Math.cos(o.altitude);r.position.y=-a*Math.cos(o.azimuth),r.position.x=Math.sin(o.altitude),r.position.z=a*Math.sin(o.azimuth),r.lookAt(n.getWorldPosition())},dispose:function(e,t){this.groupGL.removeAll(),this._control.dispose()}}),d3=p0.vec3;function p3(e){this.radius=e,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}function f3(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio()),this.radius=e.get("globeRadius");var r=e.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,r-this.radius)}function g3(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),n&&isFinite(n[1]-n[0])){var r=nb(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Ob("altitude",r),this.resize(this.model,t)}}p3.prototype={constructor:p3,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},_getDisplacementScale:function(e,t){var n=(e+180)/360*(this.displacementWidth-1),r=(90-t)/180*(this.displacementHeight-1),i=Math.round(n)+Math.round(r)*this.displacementWidth;return this.displacementData[i]},dataToPoint:function(e,t){var n=e[0],r=e[1],i=e[2]||0,o=this.radius;this.displacementData&&(o*=1+this._getDisplacementScale(n,r)),this.altitudeAxis&&(o+=this.altitudeAxis.dataToCoord(i)),n=n*Math.PI/180,r=r*Math.PI/180;var a=Math.cos(r)*o;return(t=t||[])[0]=-a*Math.cos(n+Math.PI),t[1]=Math.sin(r)*o,t[2]=a*Math.sin(n+Math.PI),t},pointToData:function(e,t){var n=e[0],r=e[1],i=e[2],o=d3.len(e);n/=o,r/=o,i/=o;var a=Math.asin(r),s=Math.atan2(i,-n);s<0&&(s=2*Math.PI+s);var l=180*a/Math.PI,u=180*s/Math.PI-180;return(t=t||[])[0]=u,t[1]=l,t[2]=o-this.radius,this.altitudeAxis&&(t[2]=this.altitudeAxis.coordToData(t[2])),t}};var m3={dimensions:p3.prototype.dimensions,create:function(e,t){var n=[];return e.eachComponent("globe",(function(e){e.__viewGL=e.__viewGL||new V1;var r=new p3;r.viewGL=e.__viewGL,e.coordinateSystem=r,r.model=e,n.push(r),r.resize=f3,r.resize(e,t),r.update=g3})),e.eachSeries((function(t){if("globe"===t.get("coordinateSystem")){var n=t.getReferringComponents("globe").models[0];if(n||(n=e.getComponent("globe")),!n)throw new Error('globe "'+wJ(t.get("globe3DIndex"),t.get("globe3DId"),0)+'" not found');var r=n.coordinateSystem;t.coordinateSystem=r}})),e.eachComponent("globe",(function(e,n){var r=e.coordinateSystem,i=e.getDisplacementTexture(),o=e.getDisplacemenScale();if(e.isDisplacementChanged()){if(e.hasDisplacement()){var a=!0;HQ.loadTexture(i,t,(function(n){var r=function(e,t){var n=document.createElement("canvas"),r=n.getContext("2d"),i=e.width,o=e.height;n.width=i,n.height=o,r.drawImage(e,0,0,i,o);for(var a=r.getImageData(0,0,i,o).data,s=new Float32Array(a.length/4),l=0;l<a.length/4;l++){var u=a[4*l];s[l]=u/255*t}return{data:s,width:i,height:o}}(n.image,o);e.setDisplacementData(r.data,r.width,r.height),a||t.dispatchAction({type:"globeUpdateDisplacment"})})),a=!1}else r.setDisplacementData(null,0,0);r.setDisplacementData(e.displacementData,e.displacementWidth,e.displacementHeight)}})),n}};l_((function(e){e.registerComponentModel($2),e.registerComponentView(h3),e.registerCoordinateSystem("globe",m3),e.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"globe",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},(function(e,t){}))}));var v3=["zoom","center","pitch","bearing"],y3=tp.extend({type:"mapbox3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,style:"mapbox://styles/mapbox/light-v9",center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMapboxCameraOption:function(){var e=this;return v3.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMapboxCameraOption:function(e){null!=e&&v3.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(e){this._mapbox=e}});function _3(e,t){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!mapboxgl)throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");this._mapbox=new mapboxgl.Map({container:this.dom}),this._initEvents()}R(y3.prototype,o0),R(y3.prototype,a0),_3.prototype.setUnpainted=function(){},_3.prototype.resize=function(){this._mapbox.resize()},_3.prototype.getMapbox=function(){return this._mapbox},_3.prototype.clear=function(){},_3.prototype.refresh=function(){this._mapbox.resize()};var x3=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];_3.prototype._initEvents=function(){var e=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},x3.forEach((function(t){this._handlers[t]=function(t){var n={};for(var r in t)n[r]=t[r];n.bubbles=!1;var i=new t.constructor(t.type,n);e.dispatchEvent(i)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},_3.prototype.dispose=function(){x3.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this)};var b3="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";HQ.Shader.import(b3);var w3=Kg.extend({type:"mapbox3D",__ecgl__:!0,init:function(e,t){var n=t.getZr();this._zrLayer=new _3("mapbox3D",n),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMapbox(),i=this._dispatchInteractAction.bind(this,t,r);["zoom","rotate","drag","pitch","rotate","move"].forEach((function(e){r.on(e,i)})),this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.displayShadow.vertex"),fragment:HQ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(e,t,n){var r=this._zrLayer.getMapbox(),i=e.get("style"),o=JSON.stringify(i);o!==this._oldStyleStr&&i&&r.setStyle(i),this._oldStyleStr=o,r.setCenter(e.get("center")),r.setZoom(e.get("zoom")),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMapbox(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._mapbox3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){e.dispatchAction({type:"mapbox3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var e=this._mapbox3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new HQ.Plane(new HQ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new HQ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new HQ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}}),S3=p0.mat4,T3=512,M3=.6435011087932844,C3=Math.PI,D3=.1;function A3(){this.width=0,this.height=0,this.altitudeScale=1,this.boxHeight="auto",this.altitudeExtent,this.bearing=0,this.pitch=0,this.center=[0,0],this._origin,this.zoom=0,this._initialZoom,this.maxPitch=60,this.zoomOffset=0}function I3(){A3.apply(this,arguments)}function E3(e,t,n){function r(e,t){var n=t.getWidth(),r=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,n,r,i),this.width=n,this.height=r,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function i(e,t){if("auto"!==this.model.get("boxHeight")){var n=[1/0,-1/0];e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt")[0];if(r){var i=t.getDataExtent(r,!0);n[0]=Math.min(n[0],i[0]),n[1]=Math.max(n[1],i[1])}}}),this),n&&isFinite(n[1]-n[0])&&(this.altitudeExtent=n)}}return{dimensions:t.prototype.dimensions,create:function(o,a){var s=[];return o.eachComponent(e,(function(e){var n=e.__viewGL;n||(n=e.__viewGL=new V1).setRootNode(new HQ.Node);var o=new t;o.viewGL=e.__viewGL,o.resize=r,o.resize(e,a),s.push(o),e.coordinateSystem=o,o.model=e,o.update=i})),o.eachSeries((function(t){if(t.get("coordinateSystem")===e){var n=t.getReferringComponents(e).models[0];if(n||(n=o.getComponent(e)),!n)throw new Error(e+' "'+wJ(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n&&n(s,o,a),s}}}A3.prototype={constructor:A3,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(e){this.bearing=e.bearing,this.pitch=e.pitch,this.center=e.center,this.zoom=e.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,T3)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var e=.5/Math.tan(M3/2)*this.height*D3,t=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,n=M3/2,r=Math.PI/2+t,i=Math.sin(n)*e/Math.sin(Math.PI-r-n),o=1.1*(Math.cos(Math.PI/2-t)*i+e);this.pitch>50&&(o=1e3);var a=[];S3.perspective(a,M3,this.width/this.height,1,o),this.viewGL.camera.projectionMatrix.setArray(a),this.viewGL.camera.decomposeProjectionMatrix();a=S3.identity([]);var s=this.dataToPoint(this.center);S3.scale(a,a,[1,-1,1]),S3.translate(a,a,[0,0,-e]),S3.rotateX(a,a,t),S3.rotateZ(a,a,-this.bearing/180*Math.PI),S3.translate(a,a,[-s[0]*this.getScale()*D3,-s[1]*this.getScale()*D3,0]),this.viewGL.camera.viewMatrix.array=a;var l=[];S3.invert(l,a),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var u,c=T3*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var h=this.altitudeExtent[1]-this.altitudeExtent[0];u=this.boxHeight/h*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else u=c/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*D3;this.viewGL.rootNode.scale.set(this.getScale()*D3,this.getScale()*D3,u)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,this.getScale()*T3,t)},projectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1]*C3/180,o=t*(r*C3/180+C3)/(2*C3),a=t*(C3-Math.log(Math.tan(C3/4+.5*i)))/(2*C3);return(n=n||[])[0]=o,n[1]=a,n},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,this.getScale()*T3,t)},unprojectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1],o=r/t*(2*C3)-C3,a=2*(Math.atan(Math.exp(C3-i/t*(2*C3)))-C3/4);return(n=n||[])[0]=180*o/C3,n[1]=180*a/C3,n},dataToPoint:function(e,t){return(t=this.projectOnTileWithScale(e,T3,t))[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},I3.prototype=new A3,I3.prototype.constructor=I3,I3.prototype.type="mapbox3D";var L3=E3("mapbox3D",I3,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMapboxCameraOption())}))}));l_((function(e){e.registerComponentModel(y3),e.registerComponentView(w3),e.registerCoordinateSystem("mapbox3D",L3),e.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"mapbox3D",query:e},(function(t){t.setMapboxCameraOption(e)}))}))}));var N3=["zoom","center","pitch","bearing"],P3=tp.extend({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return N3.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMaptalksCameraOption:function(e){null!=e&&N3.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});function O3(e,t,n,r){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:n,zoom:r,doubleClickZoom:!1,fog:!1}),this._initEvents()}R(P3.prototype,o0),R(P3.prototype,a0),O3.prototype.setUnpainted=function(){},O3.prototype.resize=function(){this._maptalks.checkSize()},O3.prototype.getMaptalks=function(){return this._maptalks},O3.prototype.clear=function(){},O3.prototype.refresh=function(){this._maptalks.checkSize()};var R3=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];O3.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},R3.forEach((function(t){this._handlers[t]=function(n){var r={};for(var i in n)r[i]=n[i];r.bubbles=!1;var o=new n.constructor(n.type,r);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(o):e.firstElementChild.dispatchEvent(o)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},O3.prototype.dispose=function(){R3.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this),this._maptalks.remove()},HQ.Shader.import(b3);var k3=Kg.extend({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.displayShadow.vertex"),fragment:HQ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var n=t.getZr();this._zrLayer=new O3("maptalks3D",n,e.get("center"),e.get("zoom")),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,r);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach((function(e){r.on(e,i)}))},render:function(e,t,n){this._zrLayer||this._initMaptalksLayer(e,n);var r=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),o=r.getBaseLayer();i!==this._oldUrlTemplate&&(o?o.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(o=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),r.setBaseLayer(o))),this._oldUrlTemplate=i,r.setCenter(e.get("center")),r.setZoom(e.get("zoom"),{animation:!1}),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMaptalks(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){var r;e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:(r=t.getResolution(),19-Math.log(r/z3)/Math.LN2+1),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new HQ.Plane(new HQ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new HQ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new HQ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}});const z3=12756274*Math.PI/(256*Math.pow(2,20));function V3(){A3.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}V3.prototype=new A3,V3.prototype.constructor=V3,V3.prototype.type="maptalks3D";var B3=E3("maptalks3D",V3,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMaptalksCameraOption())}))}));l_((function(e){e.registerComponentModel(P3),e.registerComponentView(k3),e.registerCoordinateSystem("maptalks3D",B3),e.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"maptalks3D",query:e},(function(t){t.setMaptalksCameraOption(e)}))}))}));var F3=p0.vec3,G3=tb.isDimensionStacked;function H3(e,t,n){for(var r=e.getDataExtent(t),i=e.getDataExtent(n),o=r[1]-r[0]||r[0],a=i[1]-i[0]||i[0],s=new Uint8Array(2500),l=0;l<e.count();l++){var u=e.get(t,l),c=e.get(n,l),h=Math.floor((u-r[0])/o*49),d=50*Math.floor((c-i[0])/a*49)+h;s[d]=s[d]||1}var p=0;for(l=0;l<s.length;l++)s[l]&&p++;return p/s.length}var U3=p0.vec3,W3=tb.isDimensionStacked;function j3(e,t){var n=W3(e,t[2]);return{dimension:n?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:n}}function X3(e){e.registerLayout((function(e,t){e.eachSeriesByType("bar3D",(function(e){var t=e.coordinateSystem,n=t&&t.type;if("globe"===n)!function(e,t){var n=e.getData(),r=e.get("minHeight")||0,i=e.get("barSize"),o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==i){var a=t.radius*Math.PI,s=H3(n,o[0],o[1]);i=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(i)||(i=[i,i]);var l=j3(n,o);n.each(o,(function(e,o,a,s){var u=n.get(l.dimension,s),c=l.isStacked?u-a:t.altitudeAxis.scale.getExtent()[0],h=Math.max(t.altitudeAxis.dataToCoord(a),r),d=t.dataToPoint([e,o,c]),p=t.dataToPoint([e,o,u]),f=U3.sub([],p,d);U3.normalize(f,f);var g=[i[0],h,i[1]];n.setItemLayout(s,[d,f,g])})),n.setLayout("orient",Fq.UP.array)}(e,t);else if("cartesian3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize");if(null==r){var i,o,a=t.size,s=t.getAxis("x"),l=t.getAxis("y");i="category"===s.type?.7*s.getBandWidth():.6*Math.round(a[0]/Math.sqrt(n.count())),o="category"===l.type?.7*l.getBandWidth():.6*Math.round(a[1]/Math.sqrt(n.count())),r=[i,o]}else J(r)||(r=[r,r]);var u=t.getAxis("z").scale.getExtent(),c=function(e){var t=e[0],n=e[1];return!(t>0&&n>0||t<0&&n<0)}(u),h=["x","y","z"].map((function(t){return e.coordDimToDataDim(t)[0]})),d=G3(n,h[2]),p=d?n.getCalculationInfo("stackResultDimension"):h[2];n.each(h,(function(e,i,o,a){var s=n.get(p,a),l=d?s-o:c?0:u[0],h=t.dataToPoint([e,i,l]),f=t.dataToPoint([e,i,s]),g=F3.dist(h,f),m=[0,f[1]<h[1]?-1:1,0];0===Math.abs(g)&&(g=.1);var v=[r[0],g,r[1]];n.setItemLayout(a,[h,m,v])})),n.setLayout("orient",[1,0,0])}(e,t);else if("geo3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize"),i=e.get("minHeight")||0,o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==r){var a=Math.min(t.size[0],t.size[2]),s=H3(n,o[0],o[1]);r=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(r)||(r=[r,r]);var l=[0,1,0],u=j3(n,o);n.each(o,(function(e,o,a,s){var c=n.get(u.dimension,s),h=u.isStacked?c-a:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(a),i),p=t.dataToPoint([e,o,h]),f=[r[0],d,r[1]];n.setItemLayout(s,[p,l,f])})),n.setLayout("orient",[1,0,0])}(e,t);else if("mapbox3D"===n||"maptalks3D"===n)!function(e,t){var n=e.getData(),r=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],o=e.coordDimToDataDim("alt")[0],a=e.get("barSize"),s=e.get("minHeight")||0;if(null==a){var l=n.getDataExtent(r),u=n.getDataExtent(i),c=t.dataToPoint([l[0],u[0]]),h=t.dataToPoint([l[1],u[1]]),d=Math.min(Math.abs(c[0]-h[0]),Math.abs(c[1]-h[1]))||1,p=H3(n,r,i);a=[d/Math.sqrt(n.count()/p),d/Math.sqrt(n.count()/p)]}else J(a)||(a=[a,a]),a[0]/=t.getScale()/16,a[1]/=t.getScale()/16;var f=[0,0,1],g=[r,i,o],m=j3(n,g);n.each(g,(function(e,r,i,o){var l=n.get(m.dimension,o),u=m.isStacked?l-i:0,c=t.dataToPoint([e,r,u]),h=t.dataToPoint([e,r,l]),d=Math.max(h[2]-c[2],s),p=[a[0],d,a[1]];n.setItemLayout(o,[c,f,p])})),n.setLayout("orient",[1,0,0])}(e,t);else if("production"!==process.env.NODE_ENV)throw t?new Error("bar3D doesn't support coordinate system "+t.type):new Error("bar3D doesn't have coordinate system.")}))}))}var Y3={};function Z3(e,t,n){var r=e.getData(),i=e.getRawValue(t),o=J(i)?function(e){var i=[],o=function(e,t){var n=[];return W(e.dimensions,(function(r){var i=e.getDimensionInfo(r),o=i.otherDims[t];null!=o&&!1!==o&&(n[o]=i.name)})),n}(r,"tooltip");function a(e,t){var o=r.getDimensionInfo(t);if(o&&!1!==o.otherDims.tooltip){var a=o.type,s="- "+(o.tooltipName||o.name)+": "+("ordinal"===a?e+"":"time"===a?n?"":Fd("yyyy/MM/dd hh:mm:ss",e):Nd(e));s&&i.push(dt(s))}}return o.length?W(o,(function(e){a(r.get(e,t),e)})):W(e,a),"<br/>"+i.join("<br/>")}(i):dt(Nd(i)),a=r.getName(t),s=P2(r,t);re(s)&&s.colorStops&&(s=(s.colorStops[0]||{}).color);var l=Bd(s=s||"transparent"),u=e.name;return"\0-"===u&&(u=""),u=u?dt(u)+(n?": ":"<br/>"):"",n?l+u+o:u+l+(a?dt(a)+": "+o:o)}function q3(e,t,n){n=n||e.getSource();var r=t||$y(e.get("coordinateSystem"))||["x","y","z"],i=k_(n,{dimensionsDefine:n.dimensionsDefine||e.get("dimensions"),encodeDefine:n.encodeDefine||e.get("encode"),coordDimensions:r.map((function(t){var n=e.getReferringComponents(t+"Axis3D").models[0];return{type:n&&"category"===n.get("type")?"ordinal":"float",name:t}}))});"cartesian3D"===e.get("coordinateSystem")&&i.forEach((function(t){if(r.indexOf(t.coordDim)>=0){var n=e.getReferringComponents(t.coordDim+"Axis3D").models[0];n&&"category"===n.get("type")&&(t.ordinalMeta=n.getOrdinalMeta())}}));var o=tb.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),a=new R_(i,e);return a.setCalculationInfo(o),a.initData(n),a}Y3.getFormattedLabel=function(e,t,n,r,i){n=n||"normal";var o=e.getData(r).getItemModel(t),a=e.getDataParams(t,r);null!=i&&a.value instanceof Array&&(a.value=a.value[i]);var s,l=o.get("normal"===n?["label","formatter"]:["emphasis","label","formatter"]);return null==l&&(l=o.get(["label","formatter"])),"function"==typeof l?(a.status=n,s=l(a)):"string"==typeof l&&(s=Vd(l,a)),s},Y3.normalizeToArray=function(e){return e instanceof Array?e:null==e?[]:[e]};var K3=Hg.extend({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(e,t){return q3(this)},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);return null==i&&(i=this.getData().get("z",e)),i},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",globeIndex:0,grid3DIndex:0,zlevel:-10,bevelSize:0,bevelSmoothness:2,onGridPlane:"xy",shading:"color",minHeight:0,itemStyle:{opacity:1},label:{show:!1,distance:2,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},emphasis:{label:{show:!0}},animationDurationUpdate:500}});R(K3.prototype,J1);var $3,J3,Q3,e5,t5,n5,r5,i5,o5=p0.vec3,a5=p0.mat3,s5=XK.extend((function(){return{attributes:{position:new XK.Attribute("position","float",3,"POSITION"),normal:new XK.Attribute("normal","float",3,"NORMAL"),color:new XK.Attribute("color","float",4,"COLOR"),prevPosition:new XK.Attribute("prevPosition","float",3),prevNormal:new XK.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,n=this.getBarVertexCount()*e,r=this.getBarTriangleCount()*e;this.vertexCount!==n&&(this.attributes.position.init(n),t?this.attributes.normal.init(n):this.attributes.normal.value=null,this.attributes.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r),this._dataIndices=new Uint32Array(n))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var n=this.getBarVertexCount(),r=n*(e+1),i=n*e;i<r;i++)this.attributes.color.set(i,t);this.dirtyAttribute("color")},getDataIndexOfVertex:function(e){return this._dataIndices?this._dataIndices[e]:null},addBar:function(){for(var e=o5.create,t=o5.scaleAndAdd,n=e(),r=e(),i=e(),o=e(),a=e(),s=e(),l=e(),u=[],c=[],h=0;h<8;h++)u[h]=e();var d=[[0,1,5,4],[2,3,7,6],[4,5,6,7],[3,2,1,0],[0,4,7,3],[1,2,6,5]],p=[0,1,2,0,2,3],f=[];for(h=0;h<d.length;h++)for(var g=d[h],m=0;m<2;m++){for(var v=[],y=0;y<3;y++)v.push(g[p[3*m+y]]);f.push(v)}return function(e,h,g,m,v,y){var _=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(e,h,g,m,this.bevelSize,this.bevelSegments,v);else{o5.copy(i,h),o5.normalize(i,i),o5.cross(o,g,i),o5.normalize(o,o),o5.cross(r,i,o),o5.normalize(o,o),o5.negate(a,r),o5.negate(s,i),o5.negate(l,o),t(u[0],e,r,m[0]/2),t(u[0],u[0],o,m[2]/2),t(u[1],e,r,m[0]/2),t(u[1],u[1],l,m[2]/2),t(u[2],e,a,m[0]/2),t(u[2],u[2],l,m[2]/2),t(u[3],e,a,m[0]/2),t(u[3],u[3],o,m[2]/2),t(n,e,i,m[1]),t(u[4],n,r,m[0]/2),t(u[4],u[4],o,m[2]/2),t(u[5],n,r,m[0]/2),t(u[5],u[5],l,m[2]/2),t(u[6],n,a,m[0]/2),t(u[6],u[6],l,m[2]/2),t(u[7],n,a,m[0]/2),t(u[7],u[7],o,m[2]/2);var x=this.attributes;if(this.enableNormal){c[0]=r,c[1]=a,c[2]=i,c[3]=s,c[4]=o,c[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var S=3*this._triangleOffset,T=0;T<6;T++)this.indices[S++]=b+p[T];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=c[w];for(T=0;T<4;T++){var C=d[w][T];x.position.set(this._vertexOffset,u[C]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,v)}}}else{for(w=0;w<f.length;w++){for(S=3*this._triangleOffset,T=0;T<3;T++)this.indices[S+T]=f[w][T]+this._vertexOffset;this._triangleOffset++}for(w=0;w<u.length;w++)x.position.set(this._vertexOffset,u[w]),x.color.set(this._vertexOffset++,v)}}var D=this._vertexOffset;for(w=_;w<D;w++)this._dataIndices[w]=y}}(),_addBevelBar:($3=o5.create(),J3=o5.create(),Q3=o5.create(),e5=a5.create(),t5=[],n5=[1,-1,-1,1],r5=[1,1,-1,-1],i5=[2,0],function(e,t,n,r,i,o,a){o5.copy(J3,t),o5.normalize(J3,J3),o5.cross(Q3,n,J3),o5.normalize(Q3,Q3),o5.cross($3,J3,Q3),o5.normalize(Q3,Q3),e5[0]=$3[0],e5[1]=$3[1],e5[2]=$3[2],e5[3]=J3[0],e5[4]=J3[1],e5[5]=J3[2],e5[6]=Q3[0],e5[7]=Q3[1],e5[8]=Q3[2],i=Math.min(r[0],r[2])/2*i;for(var s=0;s<3;s++)t5[s]=Math.max(r[s]-2*i,0);var l=(r[0]-t5[0])/2,u=(r[1]-t5[1])/2,c=(r[2]-t5[2])/2,h=[],d=[],p=this._vertexOffset,f=[];for(s=0;s<2;s++){f[s]=f[s]=[];for(var g=0;g<=o;g++)for(var m=0;m<4;m++){(0===g&&0===s||1===s&&g===o)&&f[s].push(p);for(var v=0;v<=o;v++){var y=v/o*Math.PI/2+Math.PI/2*m,_=g/o*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(y)*Math.sin(_),d[1]=u*Math.cos(_),d[2]=c*Math.sin(y)*Math.sin(_),h[0]=d[0]+n5[m]*t5[0]/2,h[1]=d[1]+u+i5[s]*t5[1]/2,h[2]=d[2]+r5[m]*t5[2]/2,Math.abs(l-u)<1e-6&&Math.abs(u-c)<1e-6||(d[0]/=l*l,d[1]/=u*u,d[2]/=c*c),o5.normalize(d,d),o5.transformMat3(h,h,e5),o5.transformMat3(d,d,e5),o5.add(h,h,e),this.attributes.position.set(p,h),this.enableNormal&&this.attributes.normal.set(p,d),this.attributes.color.set(p,a),p++}}}var x=4*o+3,b=2*o+1,w=x+1;for(m=0;m<b;m++)for(s=0;s<=x;s++){var S=m*w+s+this._vertexOffset,T=m*w+(s+1)%w+this._vertexOffset,M=(m+1)*w+(s+1)%w+this._vertexOffset,C=(m+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,S,T]),this.setTriangleIndices(this._triangleOffset++,[M,C,S])}this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][2],f[0][1]]),this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][3],f[0][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][1],f[1][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][2],f[1][3]]),this._vertexOffset=p})});V(s5.prototype,d0),V(s5.prototype,N2);var l5=p0.vec3,u5=em.extend({type:"bar3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._api=t,this._labelsBuilder=new R2(256,256,t);var n=this;this._labelsBuilder.getLabelPosition=function(e,t,r){if(n._data){var i=n._data.getItemLayout(e),o=i[0],a=i[1],s=i[2][1];return l5.scaleAndAdd([],o,a,r+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(e,t,n){var r=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=r,this._barMesh||(this._barMesh=new HQ.Mesh({geometry:new s5,shadowDepthMaterial:new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.sm.depth.vertex"),HQ.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===e.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var i=e.coordinateSystem;if(this._doRender(e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[o]("fragment","SRGB_DECODE")}this._data=e.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(e)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,e)},_doRender:function(e,t){var n=e.getData(),r=e.get("shading"),i="color"!==r,o=this,a=this._barMesh,s="ecgl."+r;a.material&&a.material.shader.name===s||(a.material=HQ.createMaterial(s,["VERTEX_COLOR"])),HQ.setMaterialFromModel(r,a.material,e,t),a.geometry.enableNormal=i,a.geometry.resetOffset();var l=e.get("bevelSize"),u=e.get("bevelSmoothness");a.geometry.bevelSegments=u,a.geometry.bevelSize=l;var c=[],h=new Float32Array(4*n.count()),d=0,p=0,f=!1;n.each((function(e){if(n.hasValue(e)){var t=P2(n,e),r=O2(n,e);null==r&&(r=1),HQ.parseColor(t,c),c[3]*=r,h[d++]=c[0],h[d++]=c[1],h[d++]=c[2],h[d++]=c[3],c[3]>0&&(p++,c[3]<.99&&(f=!0))}})),a.geometry.setBarCount(p);var g=n.getLayout("orient"),m=this._barIndexOfData=new Int32Array(n.count());p=0;n.each((function(e){if(n.hasValue(e)){var t=n.getItemLayout(e),r=t[0],i=t[1],a=t[2],s=4*e;c[0]=h[s++],c[1]=h[s++],c[2]=h[s++],c[3]=h[s++],c[3]>0&&(o._barMesh.geometry.addBar(r,i,g,a,c,e),m[e]=p++)}else m[e]=-1})),a.geometry.dirty(),a.geometry.updateBoundingBox();var v=a.material;v.transparent=f,v.depthMask=!f,a.geometry.sortTriangles=f,this._initHandler(e,t)},_initHandler:function(e,t){var n=e.getData(),r=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=r.geometry.getDataIndexOfVertex(e.triangle[0]);a!==o&&(this._downplay(o),this._highlight(a),this._labelsBuilder.updateLabels([a]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",a),n.get("y",a),n.get("z",a,!0)]})),o=a,r.dataIndex=a}),this),r.on("mouseout",(function(e){this._downplay(o),this._labelsBuilder.updateLabels(),o=-1,r.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_highlight:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),i=r.get("color"),o=r.get("opacity");if(null==i)i=or(P2(t,e),-.4);null==o&&(o=O2(t,e));var a=HQ.parseColor(i);a[3]*=o,this._barMesh.geometry.setColor(n,a),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=P2(t,e),i=O2(t,e),o=HQ.parseColor(r);o[3]*=i,this._barMesh.geometry.setColor(n,o),this._api.getZr().refresh()}}},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=SJ(o,i),s=this;null!=a?W(Y3.normalizeToArray(a),(function(t){"highlight"===e?this._highlight(t):this._downplay(t)}),this):o.each((function(t){"highlight"===e?s._highlight(t):s._downplay(t)}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this._labelsBuilder.dispose(),this.groupGL.removeAll()}});l_((function(e){e.registerChartView(u5),e.registerSeriesModel(K3),X3(e),e.registerProcessor((function(e,t){e.eachSeriesByType("bar3d",(function(e){var t=e.getData();t.filterSelf((function(e){return t.hasValue(e)}))}))}))}));var c5=Hg.extend({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){return q3(this)},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}});function h5(e,t,n,r,i,o,a){if(0===i)return!1;var s=i,l=0;if(a>t+s&&a>r+s||a<t-s&&a<r-s||o>e+s&&o>n+s||o<e-s&&o<n-s)return!1;if(e===n)return Math.abs(o-e)<=s/2;var u=(l=(t-r)/(e-n))*o-a+(e*r-n*t)/(e-n);return u*u/(l*l+1)<=s/2*s/2}var d5=p0.vec3;HQ.Shader.import(N0);var p5=em.extend({type:"line3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._api=t},render:function(e,t,n){var r=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=r,this._line3DMesh||(this._line3DMesh=new HQ.Mesh({geometry:new m0({useNativeLine:!1,sortTriangles:!0}),material:new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var i=e.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[o]("fragment","SRGB_DECODE")}this._doRender(e,n),this._data=e.getData(),this._camera=i.viewGL.camera,this.updateCamera(),this._updateAnimation(e)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(e,t){var n=e.getData(),r=this._line3DMesh;r.geometry.resetOffset();var i=n.getLayout("points"),o=[],a=new Float32Array(i.length/3*4),s=0,l=!1;n.each((function(e){var t=P2(n,e),r=O2(n,e);null==r&&(r=1),HQ.parseColor(t,o),o[3]*=r,a[s++]=o[0],a[s++]=o[1],a[s++]=o[2],a[s++]=o[3],o[3]<.99&&(l=!0)})),r.geometry.setVertexCount(r.geometry.getPolylineVertexCount(i)),r.geometry.setTriangleCount(r.geometry.getPolylineTriangleCount(i)),r.geometry.addPolyline(i,a,wJ(e.get("lineStyle.width"),1)),r.geometry.dirty(),r.geometry.updateBoundingBox();var u=r.material;u.transparent=l,u.depthMask=!l;var c=e.getModel("debug.wireframe");c.get("show")?(r.geometry.createAttribute("barycentric","float",3),r.geometry.generateBarycentric(),r.material.set("both","WIREFRAME_TRIANGLE"),r.material.set("wireframeLineColor",HQ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)")),r.material.set("wireframeLineWidth",wJ(c.get("lineStyle.width"),1))):r.material.set("both","WIREFRAME_TRIANGLE"),this._points=i,this._initHandler(e,t)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,e)},_initHandler:function(e,t){var n=e.getData(),r=e.coordinateSystem,i=this._line3DMesh,o=-1;i.seriesIndex=e.seriesIndex,i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(e){var a=r.pointToData(e.point.array),s=n.indicesOfNearest("x",a[0])[0];s!==o&&(t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",s),n.get("y",s),n.get("z",s)]}),i.dataIndex=s),o=s}),this),i.on("mouseout",(function(e){o=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateNDCPosition:function(){var e=new aK,t=this._camera;aK.multiply(e,t.projectionMatrix,t.viewMatrix);var n=this._positionNDC,r=this._points,i=r.length/3;n&&n.length/2===i||(n=this._positionNDC=new Float32Array(2*i));for(var o=[],a=0;a<i;a++){var s=3*a,l=2*a;o[0]=r[s],o[1]=r[s+1],o[2]=r[s+2],o[3]=1,d5.transformMat4(o,o,e.array),n[l]=o[0]/o[3],n[l+1]=o[1]/o[3]}},_pick:function(e,t,n,r,i,o){var a=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,u=.5*n.viewport.width,c=.5*n.viewport.height;e=(e+1)*u,t=(t+1)*c;for(var h=1;h<a.length/2;h++){var d=(a[2*(h-1)]+1)*u,p=(a[2*(h-1)+1]+1)*c,f=(a[2*h]+1)*u,g=(a[2*h+1]+1)*c;if(h5(d,p,f,g,s,e,t))l=(d-e)*(d-e)+(p-t)*(p-t)<(f-e)*(f-e)+(g-t)*(g-t)?h-1:h}if(l>=0){var m=3*l,v=new Fq(this._points[m],this._points[m+1],this._points[m+2]);o.push({dataIndex:l,point:v,pointWorld:v.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(v)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(p5),e.registerSeriesModel(c5),e.registerLayout((function(e,t){e.eachSeriesByType("line3D",(function(e){var t=e.getData(),n=e.coordinateSystem;if(n){if("cartesian3D"!==n.type)return void("production"!==process.env.NODE_ENV&&console.error("line3D needs cartesian3D coordinateSystem"));var r=new Float32Array(3*t.count()),i=[],o=[],a=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n&&t.each(a,(function(e,t,a,s){i[0]=e,i[1]=t,i[2]=a,n.dataToPoint(i,o),r[3*s]=o[0],r[3*s+1]=o[1],r[3*s+2]=o[2]})),t.setLayout("points",r)}}))}))}));var f5=Hg.extend({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(e,t){return q3(this)},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,progressive:1e5,progressiveThreshold:1e5,grid3DIndex:0,globeIndex:0,symbol:"circle",symbolSize:10,blendMode:"source-over",label:{show:!1,position:"right",distance:5,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},itemStyle:{opacity:.8},emphasis:{label:{show:!0}},animationDurationUpdate:500}});function g5(e,t,n){(t=t||document.createElement("canvas")).width=e,t.height=e;var r=t.getContext("2d");return n&&n(r),t}var m5={getMarginByStyle:function(e){var t=e.minMargin||0,n=0;e.stroke&&"none"!==e.stroke&&(n=null==e.lineWidth?1:e.lineWidth);var r=e.shadowBlur||0,i=e.shadowOffsetX||0,o=e.shadowOffsetY||0,a={};return a.left=Math.max(n/2,-i+r,t),a.right=Math.max(n/2,i+r,t),a.top=Math.max(n/2,-o+r,t),a.bottom=Math.max(n/2,o+r,t),a},createSymbolSprite:function(e,t,n,r){var i=function(e,t,n,r){J(t)||(t=[t,t]);var i=m5.getMarginByStyle(n,r),o=t[0]+i.left+i.right,a=t[1]+i.top+i.bottom,s=dv(e,0,0,t[0],t[1]),l=Math.max(o,a);s.x=i.left,s.y=i.top,o>a?s.y+=(l-a)/2:s.x+=(l-o)/2;var u=s.getBoundingRect();return s.x-=u.x,s.y-=u.y,s.setStyle(n),s.update(),s.__size=l,s}(e,t,n),o=m5.getMarginByStyle(n);return{image:g5(i.__size,r,(function(e){Ov(e,i)})),margin:o}},createSDFFromCanvas:function(e,t,n,r){return g5(t,r,(function(t){var r=e.getContext("2d").getImageData(0,0,e.width,e.height);t.putImageData(function(e,t,n){var r=t.width,i=t.height,o=e.canvas.width,a=e.canvas.height,s=r/o,l=i/a;function u(e){return e<128?1:-1}function c(e,o){var a=1/0;e=Math.floor(e*s);for(var c=(o=Math.floor(o*l))*r+e,h=u(t.data[4*c]),d=Math.max(o-n,0);d<Math.min(o+n,i);d++)for(var p=Math.max(e-n,0);p<Math.min(e+n,r);p++){c=d*r+p;var f=p-e,g=d-o;if(h!==u(t.data[4*c])){var m=f*f+g*g;m<a&&(a=m)}}return h*Math.sqrt(a)}for(var h=e.createImageData(o,a),d=0;d<a;d++)for(var p=0;p<o;p++){var f=c(p,d)/n*.5+.5,g=4*(d*o+p);h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255}return h}(t,r,n),0,0)}))},createSimpleSprite:function(e,t){return g5(e,t,(function(t){var n=e/2;t.beginPath(),t.arc(n,n,60,0,2*Math.PI,!1),t.closePath();var r=t.createRadialGradient(n,n,0,n,n,n);r.addColorStop(0,"rgba(255, 255, 255, 1)"),r.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),r.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=r,t.fill()}))}},v5=p0.vec3,y5={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(e,t){var n=this.indices,r=v5.create();if(!n){n=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i<n.length;i++)n[i]=i}if(0===t){var o,a=this.attributes.position,s=(e=e.array,0);this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount));for(i=0;i<this.vertexCount;i++){a.get(i,r);var l=v5.sqrDist(r,e);isNaN(l)&&(l=1e7,s++),0===i?(o=l,l=0):l-=o,this._zList[i]=l}this._noneCount=s}if(this.vertexCount<2e4)0===t&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){var t=this._zList,n=this.indices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):D2.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._zList,n=this.indices;this._quickSort=this._quickSort||new D2,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}},_5=p0.vec4;HQ.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");var x5=HQ.Mesh.extend((function(){var e=new HQ.Geometry({dynamic:!0,attributes:{color:new HQ.Geometry.Attribute("color","float",4,"COLOR"),position:new HQ.Geometry.Attribute("position","float",3,"POSITION"),size:new HQ.Geometry.Attribute("size","float",1),prevPosition:new HQ.Geometry.Attribute("prevPosition","float",3),prevSize:new HQ.Geometry.Attribute("prevSize","float",1)}});Object.assign(e,y5);var t=new HQ.Material({shader:HQ.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});t.enableTexture("sprite"),t.define("both","VERTEX_COLOR"),t.define("both","VERTEX_SIZE");var n=new HQ.Texture2D({image:document.createElement("canvas"),flipY:!1});return t.set("sprite",n),e.pick=this._pick.bind(this),{geometry:e,material:t,mode:HQ.Mesh.POINTS,sizeScale:1}}),{_pick:function(e,t,n,r,i,o){var a=this._positionNDC;if(a)for(var s=n.viewport,l=2/s.width,u=2/s.height,c=this.geometry.vertexCount-1;c>=0;c--){var h,d=a[2*(h=this.geometry.indices?this.geometry.indices[c]:c)],p=a[2*h+1],f=this.geometry.attributes.size.get(h)/this.sizeScale/2;if(e>d-f*l&&e<d+f*l&&t>p-f*u&&t<p+f*u){var g=new HQ.Vector3,m=new HQ.Vector3;this.geometry.attributes.position.get(h,g.array),HQ.Vector3.transformMat4(m,g,this.worldTransform),o.push({vertexIndex:h,point:g,pointWorld:m,target:this,distance:m.distance(r.getWorldPosition())})}}},updateNDCPosition:function(e,t,n){var r=this._positionNDC,i=this.geometry;r&&r.length/2===i.vertexCount||(r=this._positionNDC=new Float32Array(2*i.vertexCount));for(var o=_5.create(),a=0;a<i.vertexCount;a++)i.attributes.position.get(a,o),o[3]=1,_5.transformMat4(o,o,e.array),_5.scale(o,o,1/o[3]),r[2*a]=o[0],r[2*a+1]=o[1]}});function b5(e,t){this.rootNode=new HQ.Node,this.is2D=e,this._labelsBuilder=new R2(256,256,t),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=t,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}b5.prototype={constructor:b5,highlightOnMouseover:!0,update:function(e,t,n,r,i){var o=this._prevMesh;this._prevMesh=this._mesh,this._mesh=o;var a=e.getData();if(null==r&&(r=0),null==i&&(i=a.count()),this._startDataIndex=r,this._endDataIndex=i-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new x5({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,u=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var c=this._getSymbolInfo(e,r,i),h=n.getDevicePixelRatio(),d=e.getModel("itemStyle").getItemStyle(),p=e.get("large"),f=1;c.maxSize>2?(f=this._updateSymbolSprite(e,d,c,h),s.enableTexture("sprite")):s.disableTexture("sprite"),u.position.init(i-r);var g=[];if(p){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var m=function(e){const t=e.getVisual("style");if(t)return t[e.getVisual("drawType")]}(a),v=function(e){return e.getVisual("style").opacity}(a);HQ.parseColor(m,g),g[3]*=v,s.set({color:g,u_Size:c.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),u.size.init(i-r),u.color.init(i-r),this._originalOpacity=new Float32Array(i-r);for(var y=a.getLayout("points"),_=u.position.value,x=0;x<i-r;x++){var b=3*x,w=2*x;if(this.is2D?(_[b]=y[w],_[b+1]=y[w+1],_[b+2]=-10):(_[b]=y[b],_[b+1]=y[b+1],_[b+2]=y[b+2]),!p){m=P2(a,x),v=O2(a,x);HQ.parseColor(m,g),g[3]*=v,u.color.set(x,g),g[3];var S=a.getItemVisual(x,"symbolSize");S=S instanceof Array?Math.max(S[0],S[1]):S,isNaN(S)&&(S=0),u.size.value[x]=S*f*this._sizeScale,this._originalOpacity[x]=g[3]}}this._mesh.sizeScale=f,l.updateBoundingBox(),l.dirty(),this._updateMaterial(e,d);var T=e.coordinateSystem;T&&T.viewGL&&s[T.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");p||this._updateLabelBuilder(e,r,i),this._updateHandler(e,t,n),this._updateAnimation(e),this._api=n},getPointsMesh:function(){return this._mesh},updateLabels:function(e){this._labelsBuilder.updateLabels(e)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},dispose:function(){this._labelsBuilder.dispose()},_updateSymbolSprite:function(e,t,n,r){n.maxSize=Math.min(2*n.maxSize,200);var i,o,a=[];return n.aspect>1?(a[0]=n.maxSize,a[1]=n.maxSize/n.aspect):(a[1]=n.maxSize,a[0]=n.maxSize*n.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===n.type&&(i=this._symbolSize,o=a,i&&o&&i[0]===o[0]&&i[1]===o[1])&&this._lineWidth===t.lineWidth||(m5.createSymbolSprite(n.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),m5.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=n.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/n.maxSize*r},_updateMaterial:function(e,t){var n="lighter"===e.get("blendMode")?HQ.additiveBlend:null,r=this._mesh.material;r.blend=n,r.set("lineWidth",t.lineWidth/20);var i=HQ.parseColor(t.stroke);r.set("strokeColor",i),r.transparent=!0,r.depthMask=!1,r.depthTest=!this.is2D,r.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,n){var r=e.getData(),i=this._mesh.geometry,o=i.attributes.position.value,a=(t=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(r,t,n),this._labelsBuilder.getLabelPosition=function(e,n,r){var i=3*(e-t);return[o[i],o[i+1],o[i+2]]},this._labelsBuilder.getLabelDistance=function(e,n,r){return i.attributes.size.get(e-t)/a/2+r},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,n){var r,i=e.getData(),o=this._mesh,a=this,s=-1,l=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;l&&(r=e.coordinateSystem.model),o.seriesIndex=e.seriesIndex,o.off("mousemove"),o.off("mouseout"),o.on("mousemove",(function(t){var u=t.vertexIndex+a._startDataIndex;u!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,u),this._labelsBuilder.updateLabels([u])),l&&n.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],u),i.get(e.coordDimToDataDim("y")[0],u),i.get(e.coordDimToDataDim("z")[0],u)],grid3DIndex:r.componentIndex})),o.dataIndex=u,s=u}),this),o.on("mouseout",(function(e){var t=e.vertexIndex+a._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,o.dataIndex=-1,l&&n.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:r.componentIndex})}),this)},updateLayout:function(e,t,n){var r=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,o=r.getLayout("points");if(this.is2D)for(var a=0;a<o.length/2;a++){var s=3*a,l=2*a;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=-10}else for(a=0;a<o.length;a++)i[a]=o[a];this._mesh.geometry.dirty(),n.getZr().refresh()}},updateView:function(e){if(this._mesh){var t=new aK;aK.mul(t,e.viewMatrix,this._mesh.worldTransform),aK.mul(t,e.projectionMatrix,t),this._mesh.updateNDCPosition(t,this.is2D,this._api)}},highlight:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),r=n.get("color"),i=n.get("opacity");if(null==r)r=or(P2(e,t),-.4);null==i&&(i=O2(e,t));var o=HQ.parseColor(r);o[3]*=i,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,o),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=P2(e,t),r=O2(e,t),i=HQ.parseColor(n);i[3]*=r,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,i),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(e){if(this._originalOpacity){for(var t=this._mesh.geometry,n=0;n<t.vertexCount;n++){var r=this._originalOpacity[n]*e;t.attributes.color.value[4*n+3]=r}t.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(e){this._mesh&&this._setPositionTextureToMesh(this._mesh,e),this._positionTexture=e},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(e){if(e!==this._sizeScale){if(this._mesh){var t=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",t/this._sizeScale*e);var n=this._mesh.geometry.attributes;if(n.size.value)for(var r=0;r<n.size.value.length;r++)n.size.value[r]=n.size.value[r]/this._sizeScale*e}this._sizeScale=e}},_setPositionTextureToMesh:function(e,t){t&&e.material.set("positionTexture",t),e.material[t?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(e,t,n){if(e.get("large"))return(h=wJ(e.get("symbolSize"),1))instanceof Array?(l=Math.max(h[0],h[1]),r=h[0]/h[1]):(l=h,r=1),{maxSize:h,type:e.get("symbol"),aspect:r};for(var r,i=e.getData(),o=!1,a=i.getItemVisual(0,"symbol")||"circle",s=!1,l=0,u=t;u<n;u++){var c,h=i.getItemVisual(u,"symbolSize"),d=i.getItemVisual(u,"symbol");if(h instanceof Array)c=h[0]/h[1],l=Math.max(Math.max(h[0],h[1]),l);else{if(isNaN(h))continue;c=1,l=Math.max(h,l)}"production"!==process.env.NODE_ENV&&(null!=r&&Math.abs(c-r)>.05&&(o=!0),d!==a&&(s=!0)),a=d,r=c}return"production"!==process.env.NODE_ENV&&(o&&console.warn("Different symbol width / height ratio will be ignored."),s&&console.warn("Different symbol type will be ignored.")),{maxSize:l,type:a,aspect:r}}};var w5=em.extend({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(e,t,n){if(this.groupGL.removeAll(),e.getData().count()){var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new b5(!1,n)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),i.update(e,t,n),i.updateView(r.viewGL.camera)}else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system")}},incrementalPrepareRender:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL)r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system");this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new b5(!1,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),i.update(t,n,r,e.start,e.end),i.updateView(t.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach((function(e){e.updateView(this._camera)}),this)},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=SJ(o,i),s="highlight"===e;null!=a?W(Y3.normalizeToArray(a),(function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}),this):o.each((function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}))},dispose:function(){this._pointsBuilderList.forEach((function(e){e.dispose()})),this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(w5),e.registerSeriesModel(f5),e.registerLayout({seriesType:"scatter3D",reset:function(e){var t=e.coordinateSystem;if(t){var n=t.dimensions;if(n.length<3)return void("production"!==process.env.NODE_ENV&&console.error("scatter3D needs 3D coordinateSystem"));var r=n.map((function(t){return e.coordDimToDataDim(t)[0]})),i=[],o=[];return{progress:function(e,n){for(var a=new Float32Array(3*(e.end-e.start)),s=e.start;s<e.end;s++){var l=3*(s-e.start);i[0]=n.get(r[0],s),i[1]=n.get(r[1],s),i[2]=n.get(r[2],s),t.dataToPoint(i,o),a[l]=o[0],a[l+1]=o[1],a[l+2]=o[2]}n.setLayout("points",a)}}}}})}));var S5=p0.vec3,T5=p0.vec2,M5=S5.normalize,C5=S5.cross,D5=S5.sub,A5=S5.add,I5=S5.create,E5=I5(),L5=I5(),N5=I5(),P5=I5(),O5=[],R5=[];function k5(e,t){T5.copy(O5,e[0]),T5.copy(R5,e[1]);var n=[],r=n[0]=I5(),i=n[1]=I5(),o=n[2]=I5(),a=n[3]=I5();t.dataToPoint(O5,r),t.dataToPoint(R5,a),M5(E5,r),D5(L5,a,r),M5(L5,L5),C5(N5,L5,E5),M5(N5,N5),C5(L5,E5,N5),A5(i,E5,L5),M5(i,i),M5(E5,a),D5(L5,r,a),M5(L5,L5),C5(N5,L5,E5),M5(N5,N5),C5(L5,E5,N5),A5(o,E5,L5),M5(o,o),A5(P5,r,a),M5(P5,P5);var s=S5.dot(r,P5),l=S5.dot(P5,i),u=(Math.max(S5.len(r),S5.len(a))-s)/l*2;return S5.scaleAndAdd(i,r,i,u),S5.scaleAndAdd(o,a,o,u),n}function z5(e,t){for(var n=new Float32Array(3*e.length),r=0,i=[],o=0;o<e.length;o++)t.dataToPoint(e[o],i),n[r++]=i[0],n[r++]=i[1],n[r++]=i[2];return n}function V5(e){var t=[];return e.each((function(n){var r=e.getItemModel(n),i=r.option instanceof Array?r.option:r.getShallow("coords",!0);if("production"!==process.env.NODE_ENV&&!(i instanceof Array&&i.length>0&&i[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(i)+". Lines must have 2d coords array in data item.");t.push(i)})),{coordsList:t}}function B5(e,t,n){var r=e.getData(),i=e.get("polyline"),o=V5(r);r.setLayout("lineType",i?"polyline":"cubicBezier"),r.each((function(e){var a=o.coordsList[e],s=i?z5(a,t):function(e,t,n){var r=[],i=r[0]=S5.create(),o=r[1]=S5.create(),a=r[2]=S5.create(),s=r[3]=S5.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var l=S5.dist(i,s);return S5.lerp(o,i,s,.3),S5.lerp(a,i,s,.3),S5.scaleAndAdd(o,o,n,Math.min(.1*l,10)),S5.scaleAndAdd(a,a,n,Math.min(.1*l,10)),r}(a,t,n);r.setItemLayout(e,s)}))}function F5(e,t){e.eachSeriesByType("lines3D",(function(e){var t=e.coordinateSystem;"globe"===t.type?function(e,t){var n=e.getData(),r=e.get("polyline");n.setLayout("lineType",r?"polyline":"cubicBezier");var i=V5(n);n.each((function(e){var o=i.coordsList[e],a=r?z5:k5;n.setItemLayout(e,a(o,t))}))}(e,t):"geo3D"===t.type?B5(e,t,[0,1,0]):"mapbox3D"!==t.type&&"maptalks3D"!==t.type||B5(e,t,[0,0,1])}))}var G5=Hg.extend({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){var n=new R_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"globe",globeIndex:0,geo3DIndex:0,zlevel:-10,polyline:!1,effect:{show:!1,period:4,trailWidth:4,trailLength:.2,spotIntensity:6},silent:!0,blendMode:"source-over",lineStyle:{width:1,opacity:.5}}}),H5=p0.vec3;HQ.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");var U5=HQ.Mesh.extend((function(){var e=new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.trail2.vertex"),HQ.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new m0({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}}),{updateData:function(e,t,n){var r=e.hostModel,i=this.geometry,o=r.getModel("effect"),a=o.get("trailWidth")*t.getDevicePixelRatio(),s=o.get("trailLength"),l=r.get("effect.constantSpeed"),u=1e3*r.get("effect.period"),c=null!=l;"production"!==process.env.NODE_ENV&&(this.getScene()||console.error("TrailMesh must been add to scene before updateData")),c?this.material.set("speed",l/1e3):this.material.set("period",u),this.material[c?"define":"undefine"]("vertex","CONSTANT_SPEED");var h=r.get("polyline");i.trailLength=s,this.material.set("trailLength",s),i.resetOffset(),["position","positionPrev","positionNext"].forEach((function(e){i.attributes[e].value=n.attributes[e].value}));["dist","distAll","start","offset","color"].forEach((function(e){i.attributes[e].init(i.vertexCount)})),i.indices=n.indices;var d=[],p=o.get("trailColor"),f=o.get("trailOpacity"),g=null!=p,m=null!=f;this.updateWorldTransform();var v=this.worldTransform.x.len(),y=this.worldTransform.y.len(),_=this.worldTransform.z.len(),x=0,b=0;e.each((function(t){var r=e.getItemLayout(t),o=m?f:O2(e,t),s=P2(e,t);null==o&&(o=1),(d=HQ.parseColor(g?p:s,d))[3]*=o;for(var l=h?n.getPolylineVertexCount(r):n.getCubicCurveVertexCount(r[0],r[1],r[2],r[3]),w=0,S=[],T=[],M=x;M<x+l;M++)i.attributes.position.get(M,S),S[0]*=v,S[1]*=y,S[2]*=_,M>x&&(w+=H5.dist(S,T)),i.attributes.dist.set(M,w),H5.copy(T,S);b=Math.max(b,w);var C=Math.random()*(c?w:u);for(M=x;M<x+l;M++)i.attributes.distAll.set(M,w),i.attributes.start.set(M,C),i.attributes.offset.set(M,(n.attributes.offset.get(M)>0?1:-1)*a/2),i.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",o.get("spotIntensity")),i.dirty()},setAnimationTime:function(e){this.material.set("time",e)}});HQ.Shader.import(N0);var W5=em.extend({type:"lines3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._meshLinesMaterial=new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new HQ.Mesh({geometry:new m0,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new U5},render:function(e,t,n){this.groupGL.add(this._linesMesh);var r=e.coordinateSystem,i=e.getData();if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._updateLines(e,t,n);var o=r.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[o]("fragment","SRGB_DECODE"),this._trailMesh.material[o]("fragment","SRGB_DECODE")}var a=this._trailMesh;if(a.stopAnimation(),e.get("effect.show")){this.groupGL.add(a),a.updateData(i,n,this._linesMesh.geometry),a.__time=a.__time||0;var s=36e5;this._curveEffectsAnimator=a.animate("",{loop:!0}).when(s,{__time:s}).during((function(){a.setAnimationTime(a.__time)})).start()}else this.groupGL.remove(a),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===e.get("blendMode")?HQ.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var e=this._curveEffectsAnimator;e&&(e.isPaused()?e.resume():e.pause())},_updateLines:function(e,t,n){var r=e.getData(),i=e.coordinateSystem,o=this._linesMesh.geometry,a=e.get("polyline");o.expandLine=!0;var s=function(e){return null!=e.radius?e.radius:null!=e.size?Math.max(e.size[0],e.size[1],e.size[2]):100}(i);o.segmentScale=s/20;var l="lineStyle.width".split("."),u=n.getDevicePixelRatio();r.each((function(e){var t=r.getItemModel(e).get(l);null==t&&(t=1),r.setItemVisual(e,"lineWidth",t)})),o.useNativeLine=!1;var c=0,h=0;r.each((function(e){var t=r.getItemLayout(e);a?(c+=o.getPolylineVertexCount(t),h+=o.getPolylineTriangleCount(t)):(c+=o.getCubicCurveVertexCount(t[0],t[1],t[2],t[3]),h+=o.getCubicCurveTriangleCount(t[0],t[1],t[2],t[3]))})),o.setVertexCount(c),o.setTriangleCount(h),o.resetOffset();var d=[];r.each((function(e){var t=r.getItemLayout(e),n=P2(r,e),i=O2(r,e),s=r.getItemVisual(e,"lineWidth")*u;null==i&&(i=1),(d=HQ.parseColor(n,d))[3]*=i,a?o.addPolyline(t,d,s):o.addCubicCurve(t[0],t[1],t[2],t[3],d,s)})),o.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function j5(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}l_((function(e){e.registerChartView(W5),e.registerSeriesModel(G5),e.registerLayout(F5),e.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},(function(){})),e.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},(function(){})),e.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},(function(){}))}));var X5=Hg.extend({type:"series.polygons3D",getRegionModel:function(e){return this.getData().getItemModel(e)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getItemModel(e),r=n.option instanceof Array?n.option:n.getShallow("coords");n.get("multiPolygon")||(r=[r]);for(var i=[],o=0;o<r.length;o++){for(var a=[],s=1;s<r[o].length;s++)a.push(j5(t,r[o][s]));i.push({exterior:j5(t,r[o][0]),interiors:a})}return i},getInitialData:function(e){var t=new R_(["value"],this);return t.hasItemOption=!1,t.initData(e.data,[],(function(e,n,r,i){if(e instanceof Array)return NaN;t.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),t},defaultOption:{show:!0,data:null,multiPolygon:!1,progressiveThreshold:1e3,progressive:1e3,zlevel:-10,label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}});R(X5.prototype,J1);var Y5=em.extend({type:"polygons3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL);var i=this._geo3DBuilderList[0];i||((i=new z2(n)).extrudeY="mapbox3D"!==r.type&&"maptalks3D"!==r.type,this._geo3DBuilderList[0]=i),this._updateShaderDefines(r,i),i.update(e,t,n),this._geo3DBuilderList.length=1,this.groupGL.add(i.rootNode)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(e,t,n,r){var i=this._geo3DBuilderList[this._currentStep],o=t.coordinateSystem;i||((i=new z2(r)).extrudeY="mapbox3D"!==o.type&&"maptalks3D"!==o.type,this._geo3DBuilderList[this._currentStep]=i),i.update(t,n,r,e.start,e.end),this.groupGL.add(i.rootNode),this._updateShaderDefines(o,i),this._currentStep++},_updateShaderDefines:function(e,t){var n=e.viewGL.isLinearSpace()?"define":"undefine";t.rootNode.traverse((function(t){t.material&&(t.material[n]("fragment","SRGB_DECODE"),"mapbox3D"!==e.type&&"maptalks3D"!==e.type||(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1)))}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll(),this._geo3DBuilderList.forEach((function(e){e.dispose()}))}});l_((function(e){e.registerChartView(Y5),e.registerSeriesModel(X5)}));var Z5=Hg.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return Z3(this,e)},getInitialData:function(e,t){var n=e.data;function r(e){return!(isNaN(e.min)||isNaN(e.max)||isNaN(e.step))}function i(e){var t=uo;return Math.max(t(e.min),t(e.max),t(e.step))+1}if(!n)if(e.parametric){var o=e.parametricEquation||{},a=o.u||{},s=o.v||{};["u","v"].forEach((function(e){r(o[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid parametricEquation.%s",e)})),["x","y","z"].forEach((function(e){"function"==typeof o[e]||"production"!==process.env.NODE_ENV&&console.error("parametricEquation.%s needs to be function",e)}));var l=Math.floor((a.max+a.step-a.min)/a.step),u=Math.floor((s.max+s.step-s.min)/s.step);n=new Float32Array(l*u*5);var c=i(a),h=i(s);for(S=0,T=0;T<u;T++)for(M=0;M<l;M++){var d=M*a.step+a.min,p=T*s.step+s.min,f=ao(Math.min(d,a.max),c),g=ao(Math.min(p,s.max),h);C=o.x(f,g),D=o.y(f,g),E=o.z(f,g);n[S++]=C,n[S++]=D,n[S++]=E,n[S++]=f,n[S++]=g}}else{var m=e.equation||{},v=m.x||{},y=m.y||{};if(["x","y"].forEach((function(e){r(m[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid equation.%s",e)})),"function"!=typeof m.z)return void("production"!==process.env.NODE_ENV&&console.error("equation.z needs to be function"));var _=Math.floor((v.max+v.step-v.min)/v.step),x=Math.floor((y.max+y.step-y.min)/y.step);n=new Float32Array(_*x*3);for(var b=i(v),w=i(y),S=0,T=0;T<x;T++)for(var M=0;M<_;M++){var C=M*v.step+v.min,D=T*y.step+y.min,A=ao(Math.min(C,v.max),b),I=ao(Math.min(D,y.max),w),E=m.z(A,I);n[S++]=A,n[S++]=I,n[S++]=E}}var L=["x","y","z"];return e.parametric&&L.push("u","v"),q3(this,L,n)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});R(Z5.prototype,J1);var q5=p0.vec3;function K5(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}var $5=em.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node},render:function(e,t,n){var r=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=r,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var i=e.coordinateSystem,o=e.get("shading"),a=e.getData(),s="ecgl."+o;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=HQ.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),HQ.setMaterialFromModel(o,this._surfaceMesh.material,e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var l=i.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var u=e.get("parametric"),c=e.get("dataShape");c||(c=this._getDataShape(a,u),"production"!==process.env.NODE_ENV&&e.get("data")&&console.warn("dataShape is not provided. Guess it is ",c));var h=e.getModel("wireframe"),d=h.get("lineStyle.width"),p=h.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,c,p);var f=this._surfaceMesh.material;p?(f.define("WIREFRAME_QUAD"),f.set("wireframeLineWidth",d),f.set("wireframeLineColor",HQ.parseColor(h.get("lineStyle.color")))):f.undefine("WIREFRAME_QUAD"),this._initHandler(e,n),this._updateAnimation(e)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new HQ.Mesh({geometry:new HQ.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.sm.depth.vertex"),HQ.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),Object.assign(e.geometry,N2),e},_initHandler:function(e,t){var n=e.getData(),r=this._surfaceMesh,i=e.coordinateSystem;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=function(e,t){for(var n=1/0,i=-1,o=[],a=0;a<e.length;a++){r.geometry.attributes.position.get(e[a],o);var s=q5.dist(t.array,o);s<n&&(n=s,i=e[a])}return i}(e.triangle,e.point);if(a>=0){var s=[];r.geometry.attributes.position.get(a,s);for(var l=i.pointToData(s),u=1/0,c=-1,h=[],d=0;d<n.count();d++){h[0]=n.get("x",d),h[1]=n.get("y",d),h[2]=n.get("z",d);var p=q5.squaredDistance(h,l);p<u&&(c=d,u=p)}c!==o&&t.dispatchAction({type:"grid3DShowAxisPointer",value:l}),o=c,r.dataIndex=c}else r.dataIndex=-1}),this),r.on("mouseout",(function(e){o=-1,r.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateSurfaceMesh:function(e,t,n,r){var i=e.geometry,o=t.getData(),a=o.getLayout("points"),s=0;o.each((function(e){o.hasValue(e)||s++}));var l=s||r,u=i.attributes.position,c=i.attributes.normal,h=i.attributes.texcoord0,d=i.attributes.barycentric,p=i.attributes.color,f=n[0],g=n[1],m="color"!==t.get("shading");if(l){var v=(f-1)*(g-1)*4;u.init(v),r&&d.init(v)}else u.value=new Float32Array(a);p.init(i.vertexCount),h.init(i.vertexCount);var y=[0,3,1,1,3,2],_=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],x=i.indices=new(i.vertexCount>65535?Uint32Array:Uint16Array)((f-1)*(g-1)*6),b=function(e,t,n){n[1]=e*g+t,n[0]=e*g+t+1,n[3]=(e+1)*g+t+1,n[2]=(e+1)*g+t},w=!1;if(l){var S=[],T=[],M=0;m?c.init(i.vertexCount):c.value=null;for(var C=[[],[],[]],D=[],A=[],I=q5.create(),E=function(e,t,n){var r=3*t;return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n},L=new Float32Array(a.length),N=new Float32Array(a.length/3*4),P=0;P<o.count();P++)if(o.hasValue(P)){var O=HQ.parseColor(P2(o,P));null!=(j=O2(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0);for(var R=0;R<4;R++)N[4*P+R]=O[R]}var k=[1e7,1e7,1e7];for(P=0;P<f-1;P++)for(var z=0;z<g-1;z++){var V=4*(P*(g-1)+z);b(P,z,S);var B=!1;for(R=0;R<4;R++)E(a,S[R],T),K5(T)&&(B=!0);for(R=0;R<4;R++)B?u.set(V+R,k):(E(a,S[R],T),u.set(V+R,T)),r&&d.set(V+R,_[R]);for(R=0;R<6;R++)x[M++]=y[R]+V;if(m&&!B)for(R=0;R<2;R++){for(var F=3*R,G=0;G<3;G++){E(a,W=S[y[F]+G],C[G])}q5.sub(D,C[0],C[1]),q5.sub(A,C[1],C[2]),q5.cross(I,D,A);for(G=0;G<3;G++){var H=3*S[y[F]+G];L[H]=L[H]+I[0],L[H+1]=L[H+1]+I[1],L[H+2]=L[H+2]+I[2]}}}if(m)for(P=0;P<L.length/3;P++)E(L,P,I),q5.normalize(I,I),L[3*P]=I[0],L[3*P+1]=I[1],L[3*P+2]=I[2];O=[];var U=[];for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){V=4*(P*(g-1)+z);b(P,z,S);for(R=0;R<4;R++){for(G=0;G<4;G++)O[G]=N[4*S[R]+G];p.set(V+R,O),m&&(E(L,S[R],I),c.set(V+R,I));var W=S[R];U[0]=W%g/(g-1),U[1]=Math.floor(W/g)/(f-1),h.set(V+R,U)}0}}else{for(U=[],P=0;P<o.count();P++){U[0]=P%g/(g-1),U[1]=Math.floor(P/g)/(f-1);var j;O=HQ.parseColor(P2(o,P));null!=(j=O2(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0),p.set(P,O),h.set(P,U)}S=[];var X=0;for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){b(P,z,S);for(R=0;R<6;R++)x[X++]=S[y[R]]}m?i.generateVertexNormals():c.value=null}e.material.get("normalMap")&&i.generateTangents(),i.updateBoundingBox(),i.dirty(),e.material.transparent=w,e.material.depthMask=!w},_getDataShape:function(e,t){for(var n=-1/0,r=0,i=0,o=0,a=!1,s=t?"u":"x",l=e.count(),u=0;u<l;u++){var c=e.get(s,u);c<n&&(o&&o!==i&&"production"!==process.env.NODE_ENV&&(a=!0),o=i,i=0,r++),n=c,i++}if(r&&1!==i||(a=!0),!a)return[r+1,i];for(var h=Math.floor(Math.sqrt(l));h>0;){if(Math.floor(l/h)===l/h)return[h,l/h];h--}return[h=Math.floor(Math.sqrt(l)),h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function J5(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}l_((function(e){e.registerChartView($5),e.registerSeriesModel(Z5),e.registerLayout((function(e,t){e.eachSeriesByType("surface",(function(e){var t=e.coordinateSystem;t&&"cartesian3D"===t.type||"production"!==process.env.NODE_ENV&&console.error("Surface chart only support cartesian3D coordinateSystem");var n=e.getData(),r=new Float32Array(3*n.count()),i=[NaN,NaN,NaN];if(t&&"cartesian3D"===t.type){var o=t.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n.each(o,(function(e,o,a,s){var l;l=n.hasValue(s)?t.dataToPoint([e,o,a]):i,r[3*s]=l[0],r[3*s+1]=l[1],r[3*s+2]=l[2]}))}n.setLayout("points",r)}))}))}));var Q5=Hg.extend({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(e){e=e||{};var t=this.get("coordinateSystem");if(null!=t&&"geo3D"!==t){if("production"!==process.env.NODE_ENV){var n=[];["left","top","width","height","boxWidth","boxDepth","boxHeight","light","viewControl","postEffect","temporalSuperSampling","environment","groundPlane"].forEach((function(t){null!=e[t]&&n.push(t)})),n.length&&console.warn("Property %s in map3D series will be ignored if coordinate system is %s",n.join(", "),t)}this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null}},getInitialData:function(e){e.data=this.getFilledRegions(e.data,e.map);var t=k_(e.data,{coordDimensions:["value"]}),n=new R_(t,this);n.initData(e.data);var r={};return n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,n},formatTooltip:function(e){return Z3(this,e)},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Wh(null,this)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getName(e);if(t.transform)return(r=t.getRegion(n))?r.geometries:[];this._geo||(this._geo=Z2.createGeo3D(this));for(var r=this._geo.getRegion(n),i=[],o=0;o<r.geometries.length;o++){var a=r.geometries[o],s=[],l=J5(t,a.exterior);if(s&&s.length)for(var u=0;u<a.interiors.length;u++)s.push(J5(t,s[u]));i.push({interiors:s,exterior:l})}return i},getFormattedLabel:function(e,t){var n=Y3.getFormattedLabel(this,e,t);return null==n&&(n=this.getData().getName(e)),n},defaultOption:{coordinateSystem:"geo3D",data:null}});R(Q5.prototype,Q1),R(Q5.prototype,i0),R(Q5.prototype,o0),R(Q5.prototype,a0),R(Q5.prototype,J1);var e4=em.extend({type:"map3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new z2(t),this.groupGL=new HQ.Node},render:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),r.viewGL.add(this.groupGL),"geo3D"===r.type){this._sceneHelper||(this._sceneHelper=new _0,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var i=this._control;i||(i=this._control=new h0({zr:n.getZr()}),this._control.init());var o=e.getModel("viewControl");i.setViewGL(r.viewGL),i.setFromViewControlModel(o,0),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"map3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),from:this.uid,map3DId:e.id})})),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),e.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")}))}},afterRender:function(e,t,n,r){var i=r.renderer,o=e.coordinateSystem;o&&"geo3D"===o.type&&(this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n))},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._geo3DBuilder.dispose()}});l_((function(e){q2(e),e.registerChartView(e4),e.registerSeriesModel(Q5),e.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"series",subType:"map3D",query:e},(function(t){t.setView(e)}))}))}));var t4=Hg.extend({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(){return eb(this)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,progressive:1e5,progressiveThreshold:1e5,large:!1,symbol:"circle",symbolSize:10,zoomScale:0,blendMode:"source-over",itemStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}});function n4(e){this.viewGL=e}n4.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(e,t)},n4.prototype.updateTransform=function(e,t){var n=e.coordinateSystem;n.getRoamTransform&&(!function(e,t){var n=t[0],r=t[2],i=t[4],o=t[1],a=t[3],s=t[5],l=n*a-o*r;l&&(l=1/l,e[0]=a*l,e[1]=-o*l,e[2]=-r*l,e[3]=n*l,e[4]=(r*s-a*i)*l,e[5]=(o*i-n*s)*l)}(this._viewTransform,n.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},n4.prototype.dataToPoint=function(e,t,n){n=e.dataToPoint(t,null,n);var r=this._viewTransform;r&&QJ(n,n,r)},n4.prototype.removeTransformInPoint=function(e){return this._viewTransform&&QJ(e,e,this._viewTransform),e},n4.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},n4.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},n4.prototype._updateCamera=function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.top=0,r.bottom=t,r.right=e,r.near=0,r.far=100};var r4=em.extend({type:"scatterGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new n4(this.viewGL)},render:function(e,t,n){if(this.groupGL.removeAll(),this._glViewHelper.reset(e,n),e.getData().count()){var r=this._pointsBuilderList[0];r||(r=this._pointsBuilderList[0]=new b5(!0,n)),this._pointsBuilderList.length=1,this.groupGL.add(r.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),r.update(e,t,n),this.viewGL.setPostEffect(e.getModel("postEffect"),n)}},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new b5(!0,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.setSizeScale(this._sizeScale),i.update(t,n,r,e.start,e.end),r.getZr().refresh(),this._currentStep++}},updateTransform:function(e,t,n){if(e.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(e,n);var r=this._glViewHelper.getZoom(),i=Math.max((e.get("zoomScale")||0)*(r-1)+1,0);this._sizeScale=i,this._pointsBuilderList.forEach((function(e){e.setSizeScale(i)}))}},_removeTransformInPoints:function(e){if(e)for(var t=[],n=0;n<e.length;n+=2)t[0]=e[n],t[1]=e[n+1],this._glViewHelper.removeTransformInPoint(t),e[n]=t[0],e[n+1]=t[1]},dispose:function(){this.groupGL.removeAll(),this._pointsBuilderList.forEach((function(e){e.dispose()}))},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(r4),e.registerSeriesModel(t4),e.registerLayout({seriesType:"scatterGL",reset:function(e){var t,n=e.coordinateSystem,r=e.getData();if(n){var i=n.dimensions.map((function(e){return r.mapDimension(e)})).slice(0,2),o=[];1===i.length?t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),o=e.start;o<e.end;o++){var a=2*(o-e.start),s=r.get(i[0],o),l=n.dataToPoint(s);t[a]=l[0],t[a+1]=l[1]}r.setLayout("points",t)}:2===i.length&&(t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),a=e.start;a<e.end;a++){var s=2*(a-e.start),l=r.get(i[0],a),u=r.get(i[1],a);o[0]=l,o[1]=u,o=n.dataToPoint(o),t[s]=o[0],t[s+1]=o[1]}r.setLayout("points",t)})}return{progress:t}}})}));var i4=Hg.extend({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(e){i4.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(e){i4.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},getInitialData:function(e,t){var n=e.edges||e.links||[],r=e.data||e.nodes||[],i=this;if(r&&n)return function(e,t,n,r,i){for(var o=new kE(r),a=0;a<e.length;a++)o.addNode(wJ(e[a].id,e[a].name,a),a);var s,l=[],u=[],c=0;for(a=0;a<t.length;a++){var h=t[a],d=h.source,p=h.target;o.addEdge(d,p,c)&&(u.push(h),l.push(wJ(h.id,d+" > "+p)),c++)}var f=k_(e,{coordDimensions:["value"]});(s=new R_(f,n)).initData(e);var g=new R_(["value"],n);return g.initData(u,l),i&&i(s,g),TA({mainData:s,struct:o,structAttr:"graph",datas:{node:s,edge:g},datasAttr:{node:"data",edge:"edgeData"}}),o.update(),o}(r,n,this,!0,(function(e,n){e.wrapMethod("getItemModel",(function(e){const t=i._categoriesModels[e.getShallow("category")];return t&&(t.parentModel=e.parentModel,e.parentModel=t),e}));const r=t.getModel([]).getModel;function o(e,t){const n=r.call(this,e,t);return n.resolveParentPath=a,n}function a(e){if(e&&("label"===e[0]||"label"===e[1])){const t=e.slice();return"label"===e[0]?t[0]="edgeLabel":"label"===e[1]&&(t[1]="edgeLabel"),t}return e}n.wrapMethod("getItemModel",(function(e){return e.resolveParentPath=a,e.getModel=o,e}))})).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(e,t,n){if("edge"===n){var r=this.getData(),i=this.getDataParams(e,n),o=r.graph.getEdgeByIndex(e),a=r.getName(o.node1.dataIndex),s=r.getName(o.node2.dataIndex),l=[];return null!=a&&l.push(a),null!=s&&l.push(s),l=dt(l.join(" > ")),i.value&&(l+=" : "+dt(i.value)),l}return i4.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map((function(e){return null!=e.value?e:Object.assign({value:0},e)})),t=new R_(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray((function(e){return t.getItemModel(e,!0)}))},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t<e.length/2;t++){var n=e[2*t],r=e[2*t+1],i=this.getData().getRawDataItem(t);i.x=n,i.y=r}},isAnimationEnabled:function(){return i4.superCall(this,"isAnimationEnabled")&&!("force"===this.get("layout")&&this.get("force.layoutAnimation"))},defaultOption:{zlevel:10,z:2,legendHoverLink:!0,layout:"forceAtlas2",forceAtlas2:{initLayout:null,GPU:!0,steps:1,maxSteps:1e3,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,edgeWeightInfluence:1,edgeWeight:[1,4],nodeWeight:[1,4],preventOverlap:!1,gravityCenter:null},focusNodeAdjacency:!0,focusNodeAdjacencyOn:"mouseover",left:"center",top:"center",symbol:"circle",symbolSize:5,roam:!1,center:null,zoom:1,label:{show:!1,formatter:"{b}",position:"right",distance:5,textStyle:{fontSize:14}},itemStyle:{},lineStyle:{color:"#aaa",width:1,opacity:.5},emphasis:{label:{show:!0}},animation:!1}}),o4=p0.vec2,a4=[[0,0],[1,1]],s4=XK.extend((function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",2,"POSITION"),normal:new XK.Attribute("normal","float",2),offset:new XK.Attribute("offset","float",1),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(o4.dist(e,t)+o4.dist(n,t)+o4.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(a4)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(a4)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=t[0],u=t[1],c=n[0],h=n[1],d=r[0],p=r[1],f=this._getCubicCurveApproxStep(e,t,n,r),g=f*f,m=g*f,v=3*f,y=3*g,_=6*g,x=6*m,b=a-2*l+c,w=s-2*u+h,S=3*(l-c)-a+d,T=3*(u-h)-s+p,M=a,C=s,D=(l-a)*v+b*y+S*m,A=(u-s)*v+w*y+T*m,I=b*_+S*x,E=w*_+T*x,L=S*x,N=T*x,P=0,O=0,R=Math.ceil(1/f),k=new Float32Array(3*(R+1)),z=(k=[],0);for(O=0;O<R+1;O++)k[z++]=M,k[z++]=C,M+=D,C+=A,D+=I,A+=E,I+=L,E+=N,(P+=f)>1&&(M=D>0?Math.min(M,d):Math.max(M,d),C=A>0?Math.min(C,p):Math.max(C,p));this.addPolyline(k,i,o)},addLine:function(e,t,n,r){this.addPolyline([e,t],n,r)},addPolyline:function(){var e=o4.create(),t=o4.create(),n=o4.create(),r=o4.create(),i=[],o=[],a=[];return function(s,l,u,c,h){if(s.length){var d="number"!=typeof s[0];if(null==h&&(h=d?s.length:s.length/2),!(h<2)){null==c&&(c=0),null==u&&(u=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,f=d?"number"!=typeof l[0]:l.length/4===h,g=this.attributes.position,m=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,_=this.indices,x=this._vertexOffset,b=0;b<h;b++){if(d)i=s[b+c],p=f?l[b+c]:l;else{var w=2*b+c;if((i=i||[])[0]=s[w],i[1]=s[w+1],f){var S=4*b+c;(p=p||[])[0]=l[S],p[1]=l[S+1],p[2]=l[S+2],p[3]=l[S+3]}else p=l}if(this.useNativeLine)b>1&&(g.copy(x,x-1),m.copy(x,x-1),x++);else{var T;if(b<h-1){if(d)o4.copy(o,s[b+1]);else{w=2*(b+1)+c;(o=o||[])[0]=s[w],o[1]=s[w+1]}if(b>0){o4.sub(e,i,a),o4.sub(t,o,i),o4.normalize(e,e),o4.normalize(t,t),o4.add(r,e,t),o4.normalize(r,r);var M=u/2*Math.min(1/o4.dot(e,r),2);n[0]=-r[1],n[1]=r[0],T=M}else o4.sub(e,o,i),o4.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2}else o4.sub(e,i,a),o4.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2;y.set(x,n),y.set(x+1,n),v.set(x,T),v.set(x+1,-T),o4.copy(a,i),g.set(x,i),g.set(x+1,i),m.set(x,p),m.set(x+1,p),x+=2}if(this.useNativeLine)m.set(x,p),g.set(x,i),x++;else if(b>0){var C=3*this._faceOffset;(_=this.indices)[C]=x-4,_[C+1]=x-3,_[C+2]=x-2,_[C+3]=x-3,_[C+4]=x-1,_[C+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")}});V(s4.prototype,d0);HQ.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");var l4={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function u4(e){var t={type:HQ.Texture.FLOAT,minFilter:HQ.Texture.NEAREST,magFilter:HQ.Texture.NEAREST};this._positionSourceTex=new HQ.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new HQ.Texture2D(t),this._positionPrevTex=new HQ.Texture2D(t),this._forceTex=new HQ.Texture2D(t),this._forcePrevTex=new HQ.Texture2D(t),this._weightedSumTex=new HQ.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new HQ.Texture2D(t),this._globalSpeedPrevTex=new HQ.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new pJ({fragment:HQ.Shader.source("clay.compositor.output")});var n=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new HQ.Mesh({geometry:new HQ.Geometry({attributes:{node1:new HQ.Geometry.Attribute("node1","float",2),node2:new HQ.Geometry.Attribute("node2","float",2),weight:new HQ.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new HQ.Material({transparent:!0,shader:HQ.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:n,depthMask:!1,depthText:!1}),mode:HQ.Mesh.POINTS}),this._weightedSumMesh=new HQ.Mesh({geometry:new HQ.Geometry({attributes:{node:new HQ.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new HQ.Material({transparent:!0,shader:HQ.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:n,depthMask:!1,depthText:!1}),mode:HQ.Mesh.POINTS}),this._framebuffer=new G$({depthBuffer:!1}),this._dummyCamera=new HQ.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}u4.prototype.updateOption=function(e){for(var t in l4)this[t]=l4[t];var n=this._nodes.length;if(this.jitterTolerence=n>5e4?10:n>5e3?1:.1,this.scaling=n>100?2:10,e)for(var t in l4)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var r=this._positionSourceTex.pixels,i=0;i<this._nodes.length;i++)r[4*i+2]=(this._nodes[i].degree||0)+1},u4.prototype._updateGravityCenter=function(e){var t=this._nodes,n=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var r=[1/0,1/0],i=[-1/0,-1/0],o=0;o<t.length;o++)r[0]=Math.min(t[o].x,r[0]),r[1]=Math.min(t[o].y,r[1]),i[0]=Math.max(t[o].x,i[0]),i[1]=Math.max(t[o].y,i[1]);this._gravityCenter=[.5*(r[0]+i[0]),.5*(r[1]+i[1])]}for(o=0;o<n.length;o++){var a=n[o].node1,s=n[o].node2;t[a].degree=(t[a].degree||0)+1,t[s].degree=(t[s].degree||0)+1}},u4.prototype.initData=function(e,t){this._nodes=e,this._edges=t,this._updateGravityCenter();var n=Math.ceil(Math.sqrt(e.length)),r=n,i=new Float32Array(n*r*4);this._resize(n,r);for(var o=0,a=0;a<e.length;a++){var s=e[a];i[o++]=s.x||0,i[o++]=s.y||0,i[o++]=s.mass||1,i[o++]=s.size||1}this._positionSourceTex.pixels=i;var l=this._edgeForceMesh.geometry,u=t.length;l.attributes.node1.init(2*u),l.attributes.node2.init(2*u),l.attributes.weight.init(2*u);var c=[];for(a=0;a<t.length;a++){var h=l.attributes,d=t[a].weight;null==d&&(d=1),h.node1.set(a,this.getNodeUV(t[a].node1,c)),h.node2.set(a,this.getNodeUV(t[a].node2,c)),h.weight.set(a,d),h.node1.set(a+u,this.getNodeUV(t[a].node2,c)),h.node2.set(a+u,this.getNodeUV(t[a].node1,c)),h.weight.set(a+u,d)}var p=this._weightedSumMesh.geometry;p.attributes.node.init(e.length);for(a=0;a<e.length;a++)p.attributes.node.set(a,this.getNodeUV(a,c));l.dirty(),p.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",e.length),this._nodeRepulsionPass.material.setUniform("textureSize",[n,r]),this._inited=!1,this._frame=0},u4.prototype.getNodes=function(){return this._nodes},u4.prototype.getEdges=function(){return this._edges},u4.prototype.step=function(e){this._inited||(this._initFromSource(e),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(e);var t=this._nodeRepulsionPass;t.setUniform("strongGravityMode",this.strongGravityMode),t.setUniform("gravity",this.gravity),t.setUniform("gravityCenter",this._gravityCenter),t.setUniform("scaling",this.scaling),t.setUniform("preventOverlap",this.preventOverlap),t.setUniform("positionTex",this._positionPrevTex),t.render(e);var n=this._edgeForceMesh;n.material.set("linLogMode",this.linLogMode),n.material.set("edgeWeightInfluence",this.edgeWeightInfluence),n.material.set("preventOverlap",this.preventOverlap),n.material.set("positionTex",this._positionPrevTex),e.gl.enable(e.gl.BLEND),e.renderPass([n],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT),e.gl.enable(e.gl.BLEND);var r=this._weightedSumMesh;r.material.set("positionTex",this._positionPrevTex),r.material.set("forceTex",this._forceTex),r.material.set("forcePrevTex",this._forcePrevTex),e.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var i=this._globalSpeedPass;i.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),i.setUniform("weightedSumTex",this._weightedSumTex),i.setUniform("jitterTolerence",this.jitterTolerence),e.gl.disable(e.gl.BLEND),i.render(e);var o=this._positionPass;this._framebuffer.attach(this._positionTex),o.setUniform("globalSpeedTex",this._globalSpeedTex),o.setUniform("positionTex",this._positionPrevTex),o.setUniform("forceTex",this._forceTex),o.setUniform("forcePrevTex",this._forcePrevTex),o.render(e),this._framebuffer.unbind(e),this._swapTexture()},u4.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1);for(var r=0;r<t;r++)this.step(e);n&&n()},u4.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},u4.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1)||0,t},u4.prototype.getNodePosition=function(e,t){var n=this._positionArr,r=this._positionTex.width,i=this._positionTex.height,o=r*i;n&&n.length===4*o||(n=this._positionArr=new Float32Array(4*o)),this._framebuffer.bind(e),this._framebuffer.attach(this._positionPrevTex),e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,n),this._framebuffer.unbind(e),t||(t=new Float32Array(2*this._nodes.length));for(var a=0;a<this._nodes.length;a++)t[2*a]=n[4*a],t[2*a+1]=n[4*a+1];return t},u4.prototype.getTextureData=function(e,t){var n=this["_"+t+"Tex"],r=n.width,i=n.height;this._framebuffer.bind(e),this._framebuffer.attach(n);var o=new Float32Array(r*i*4);return e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,o),this._framebuffer.unbind(e),o},u4.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},u4.prototype.isFinished=function(e){return this._frame>e},u4.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},u4.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},u4.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach((function(n){this[n].width=e,this[n].height=t,this[n].dirty()}),this)},u4.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)};var c4=function(){var e=function(){return new Float32Array(2)},t=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},n=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},r=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},i=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},a=function(e,t){return e[0]=t[0],e[1]=t[1],e},s=function(e,t,n){return e[0]=t,e[1]=n,e};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var u=l.prototype;function c(){this.position=new Float32Array(2),this.force=e(),this.forcePrev=e(),this.mass=1,this.inDegree=0,this.outDegree=0}function h(e,t){this.source=e,this.target=t,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=e(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}u.beforeUpdate=function(){for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},u.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].afterUpdate()},u.addNode=function(e){if(0===this.nSubRegions){if(null==this.node)return void(this.node=e);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(e),this._updateCenterOfMass(e)},u.findSubRegion=function(e,t){for(var n=0;n<this.nSubRegions;n++){var r=this.subRegions[n];if(r.contain(e,t))return r}},u.contain=function(e,t){return this.bbox[0]<=e&&this.bbox[2]>=e&&this.bbox[1]<=t&&this.bbox[3]>=t},u.setBBox=function(e,t,n,r){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r,this.size=(n-e+r-t)/2},u._newSubRegion=function(){var e=this.subRegions[this.nSubRegions];return e||(e=new l,this.subRegions[this.nSubRegions]=e),this.nSubRegions++,e},u._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),n=this.bbox;if(!t){var r=(n[0]+n[2])/2,i=(n[1]+n[3])/2,o=(n[2]-n[0])/2,a=(n[3]-n[1])/2,s=e.position[0]>=r?1:0,l=e.position[1]>=i?1:0;(t=this._newSubRegion()).setBBox(s*o+n[0],l*a+n[1],(s+1)*o+n[0],(l+1)*a+n[1])}t.addNode(e)},u._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,n=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,n+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=n/this.mass};var p=d.prototype;p.initNodes=function(e,t,n){var r=t.length;this.nodes.length=0;for(var i=void 0!==n,o=0;o<r;o++){var a=new c;a.position[0]=e[2*o],a.position[1]=e[2*o+1],a.mass=t[o],i&&(a.size=n[o]),this.nodes.push(a)}this._massArr=t,this._swingingArr=new Float32Array(r),i&&(this._sizeArr=n)},p.initEdges=function(e,t){var n=e.length/2;this.edges.length=0;for(var r=0;r<n;r++){var i=e[2*r],o=e[2*r+1],a=this.nodes[i],s=this.nodes[o];if(!a||!s)return void console.error("Node not exists, try initNodes before initEdges");a.outDegree++,s.inDegree++;var l=new h(a,s);t&&(l.weight=t[r]),this.edges.push(l)}},p.updateSettings=function(){if(this.repulsionByDegree)for(var e=0;e<this.nodes.length;e++){(t=this.nodes[e]).mass=t.inDegree+t.outDegree+1}else for(e=0;e<this.nodes.length;e++){var t;(t=this.nodes[e]).mass=this._massArr[e]}},p.update=function(){var o=this.nodes.length;if(this.updateSettings(),this.updateBBox(),this.barnesHutOptimize){this.rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this.rootRegion.beforeUpdate();for(var l=0;l<o;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<o;l++){var u=this.nodes[l];a(u.forcePrev,u.force),s(u.force,0,0)}for(l=0;l<o;l++){var c=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,c);else for(var h=l+1;h<o;h++){var d=this.nodes[h];this.applyNodeToNodeRepulsion(c,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(c):this.applyNodeGravity(c))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var p=0,f=0,g=e();for(l=0;l<o;l++){u=this.nodes[l];p+=(v=t(u.force,u.forcePrev))*u.mass,i(g,u.force,u.forcePrev),f+=.5*n(g)*u.mass,this._swingingArr[l]=v}var m=this.jitterTolerence*this.jitterTolerence*f/p;this._globalSpeed>0&&(m=Math.min(m/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=m;for(l=0;l<o;l++){u=this.nodes[l];var v=this._swingingArr[l],y=.1*m/(1+m*Math.sqrt(v)),_=n(u.force);_>0&&(y=Math.min(_*y,10)/_,r(u.position,u.position,u.force,y))}},p.applyRegionToNodeRepulsion=function(){var t=e();return function(e,n){if(e.node)this.applyNodeToNodeRepulsion(e.node,n,!0);else{o(t,n.position,e.centerOfMass);var i=t[0]*t[0]+t[1]*t[1];if(i>this.barnesHutTheta*e.size*e.size){var a=this.scaling*n.mass*e.mass/i;r(n.force,n.force,t,a)}else for(var s=0;s<e.nSubRegions;s++)this.applyRegionToNodeRepulsion(e.subRegions[s],n)}}}(),p.applyNodeToNodeRepulsion=function(){var t=e();return function(e,n,i){if(e!=n){o(t,e.position,n.position);var a=t[0]*t[0]+t[1]*t[1];if(0!==a){var s;if(this.preventOverlap){var l=Math.sqrt(a);if((l=l-e.size-n.size)>0)s=this.scaling*e.mass*n.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*e.mass*n.mass}}else s=this.scaling*e.mass*n.mass/a;r(e.force,e.force,t,s),r(n.force,n.force,t,-s)}}}}(),p.applyEdgeAttraction=function(){var t=e();return function(e){var i=e.source,a=e.target;o(t,i.position,a.position);var s,l,u=n(t);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence),this.preventOverlap&&(u=u-i.size-a.size)<=0||(l=this.linLogMode?-s*Math.log(u+1)/(u+1):-s,r(i.force,i.force,t,l),r(a.force,a.force,t,-l))}}(),p.applyNodeGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position);var i=n(t);r(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),p.applyNodeStrongGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position),r(e.force,e.force,t,this.gravity*e.mass)}}(),p.updateBBox=function(){for(var e=1/0,t=1/0,n=-1/0,r=-1/0,i=0;i<this.nodes.length;i++){var o=this.nodes[i].position;e=Math.min(e,o[0]),t=Math.min(t,o[1]),n=Math.max(n,o[0]),r=Math.max(r,o[1])}this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r},p.getGlobalSpeed=function(){return this._globalSpeed};var f=null;self.onmessage=function(e){switch(e.data.cmd){case"init":(f=new d).initNodes(e.data.nodesPosition,e.data.nodesMass,e.data.nodesSize),f.initEdges(e.data.edges,e.data.edgesWeight);break;case"updateConfig":if(f)for(var t in e.data.config)f[t]=e.data.config[t];break;case"update":var n=e.data.steps;if(f){for(var r=0;r<n;r++)f.update();var i=f.nodes.length,o=new Float32Array(2*i);for(r=0;r<i;r++){var a=f.nodes[r];o[2*r]=a.position[0],o[2*r+1]=a.position[1]}self.postMessage({buffer:o.buffer,globalSpeed:f.getGlobalSpeed()},[o.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:f.getGlobalSpeed()},[s.buffer])}}}}.toString();c4=c4.slice(c4.indexOf("{")+1,c4.lastIndexOf("}"));var h4={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},d4=function(e){for(var t in h4)this[t]=h4[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new RK({type:EK.FLOAT,flipY:!1,minFilter:EK.NEAREST,magFilter:EK.NEAREST})};d4.prototype.initData=function(e,t){var n=new Blob([c4]),r=window.URL.createObjectURL(n);this._worker=new Worker(r),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,o=t.length,a=new Float32Array(2*i),s=new Float32Array(i),l=new Float32Array(i),u=new Float32Array(2*o),c=new Float32Array(o),h=0;h<e.length;h++){var d=e[h];a[2*h]=d.x,a[2*h+1]=d.y,s[h]=null==d.mass?1:d.mass,l[h]=null==d.size?1:d.size}for(h=0;h<t.length;h++){var p=t[h],f=p.node1,g=p.node2;u[2*h]=f,u[2*h+1]=g,c[h]=null==p.weight?1:p.weight}var m=Math.ceil(Math.sqrt(e.length)),v=m,y=new Float32Array(m*v*4),_=this._positionTex;_.width=m,_.height=v,_.pixels=y,this._worker.postMessage({cmd:"init",nodesPosition:a,nodesMass:s,nodesSize:l,edges:u,edgesWeight:c}),this._globalSpeed=1/0},d4.prototype.updateOption=function(e){var t={};for(var n in h4)t[n]=h4[n];var r=this._nodes,i=this._edges,o=r.length;if(t.jitterTolerence=o>5e4?10:o>5e3?1:.1,t.scaling=o>100?2:10,t.barnesHutOptimize=o>1e3,e)for(var n in h4)null!=e[n]&&(t[n]=e[n]);if(!t.gravityCenter){for(var a=[1/0,1/0],s=[-1/0,-1/0],l=0;l<r.length;l++)a[0]=Math.min(r[l].x,a[0]),a[1]=Math.min(r[l].y,a[1]),s[0]=Math.max(r[l].x,s[0]),s[1]=Math.max(r[l].y,s[1]);t.gravityCenter=[.5*(a[0]+s[0]),.5*(a[1]+s[1])]}for(l=0;l<i.length;l++){var u=i[l].node1,c=i[l].node2;r[u].degree=(r[u].degree||0)+1,r[c].degree=(r[c].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:t})},d4.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1),this._frame+=t,this._onupdate=n,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(t)})},d4.prototype._$onupdate=function(e){if(!this._disposed){var t=new Float32Array(e.data.buffer);this._globalSpeed=e.data.globalSpeed,this._positionArr=t,this._updateTexture(t),this._onupdate&&this._onupdate()}},d4.prototype.getNodePositionTexture=function(){return this._positionTex},d4.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1),t},d4.prototype.getNodes=function(){return this._nodes},d4.prototype.getEdges=function(){return this._edges},d4.prototype.isFinished=function(e){return this._frame>e},d4.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var n=0;n<this._positionArr.length;n++)t[n]=this._positionArr[n];return t},d4.prototype._updateTexture=function(e){for(var t=this._positionTex.pixels,n=0,r=0;r<e.length;)t[n++]=e[r++],t[n++]=e[r++],t[n++]=1,t[n++]=1;this._positionTex.dirty()},d4.prototype.dispose=function(e){this._disposed=!0,this._worker=null};var p4=wY.extend((function(){return{zr:null,viewGL:null,minZoom:.2,maxZoom:5,_needsUpdate:!1,_dx:0,_dy:0,_zoom:1}}),(function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._update=this._update.bind(this)}),{init:function(){var e=this.zr;e.on("mousedown",this._mouseDownHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("globalout",this._mouseUpHandler),e.animation.on("frame",this._update)},setTarget:function(e){this._target=e},setZoom:function(e){this._zoom=Math.max(Math.min(e,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(e){this._dx=e[0],this._dy=e[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var e=this._target,t=this._zoom;e.position.x=this._dx,e.position.y=this._dy,e.scale.set(t,t,t),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(e){if(!e.target){var t=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(t,n)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var r=this._convertPos(t,n);this._x=r.x,this._y=r.y}}},_convertPos:function(e,t){var n=this.viewGL.camera,r=this.viewGL.viewport;return{x:(e-r.x)/r.width*(n.right-n.left)+n.left,y:(t-r.y)/r.height*(n.bottom-n.top)+n.top}},_mouseMoveHandler:function(e){var t=this._convertPos(e.offsetX,e.offsetY);this._dx+=t.x-this._x,this._dy+=t.y-this._y,this._x=t.x,this._y=t.y,this._needsUpdate=!0},_mouseUpHandler:function(e){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(e){var t=(e=e.event).wheelDelta||-e.detail;if(0!==t){var n=e.offsetX,r=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(n,r)){var i=t>0?1.1:.9,o=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=o/this._zoom;var a=this._convertPos(n,r),s=(a.x-this._dx)*(i-1),l=(a.y-this._dy)*(i-1);this._dx-=s,this._dy-=l,this._zoom=o,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}),f4=p0.vec2;HQ.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");var g4=1,m4=em.extend({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new b5(!0,t),this._forceEdgesMesh=new HQ.Mesh({material:new HQ.Material({shader:HQ.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new HQ.Geometry({attributes:{node:new HQ.Geometry.Attribute("node","float",2),color:new HQ.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:HQ.Mesh.LINES}),this._edgesMesh=new HQ.Mesh({material:new HQ.Material({shader:HQ.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new s4({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new p4({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,n){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=n,this._initLayout(e,t,n),this._pointsBuilder.update(e,t,n),this._forceLayoutInstance instanceof u4||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,n),this._control.off("update"),this._control.on("update",(function(){n.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)}),this),this._control.setZoom(wJ(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var r=this._pointsBuilder.getPointsMesh();if(r.off("mousemove",this._mousemoveHandler),r.off("mouseout",this._mouseOutHandler,this),n.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?n.getZr().on("click",this._clickHandler):"mouseover"===i?(r.on("mousemove",this._mousemoveHandler,this),r.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1):"production"!==process.env.NODE_ENV&&console.warn("Unkown focusNodeAdjacencyOn value s"+i)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var n=this._forceEdgesMesh.geometry,r=t.getEdgeData(),i=0,o=this._forceLayoutInstance,a=2*r.count();n.attributes.node.init(a),n.attributes.color.init(a),r.each((function(t){var a=e[t];n.attributes.node.set(i,o.getNodeUV(a.node1)),n.attributes.node.set(i+1,o.getNodeUV(a.node2));var s=P2(r,a.dataIndex),l=HQ.parseColor(s);l[3]*=wJ(O2(r,a.dataIndex),1),n.attributes.color.set(i,l),n.attributes.color.set(i+1,l),i+=2})),n.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,n=(e=this._model.getEdgeData(),this._model.getData().getLayout("points"));t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var r=[],i=[],o=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each((function(a){var s=e.graph.getEdgeByIndex(a),l=2*s.node1.dataIndex,u=2*s.node2.dataIndex;r[0]=n[l],r[1]=n[l+1],i[0]=n[u],i[1]=n[u+1];var c=P2(e,s.dataIndex),h=HQ.parseColor(c);h[3]*=wJ(O2(e,s.dataIndex),1);var d=e.getItemModel(s.dataIndex),p=wJ(d.get(o),1)*this._api.getDevicePixelRatio();t.addLine(r,i,h,p);for(var f=0;f<4;f++)this._originalEdgeColors[4*s.dataIndex+f]=h[f];this._edgeIndicesMap[s.dataIndex]=a}),this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),n=[],r=0;r<e.count();r++)this._forceLayoutInstance.getNodeUV(r,n),t.geometry.attributes.position.set(r,n);t.geometry.dirty("position")},_initLayout:function(e,t,n){var r=e.get("layout"),i=e.getGraph(),o=Zd(e.getBoxLayoutParams(),{width:n.getWidth(),height:n.getHeight()});"force"===r&&("production"!==process.env.NODE_ENV&&console.warn("Currently only forceAtlas2 layout supported."),r="forceAtlas2"),this.stopLayout(e,t,n,{beforeLayout:!0});var a=e.getData(),s=e.getData();if("forceAtlas2"===r){var l=e.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],h=[],d=a.getDataExtent("value"),p=s.getDataExtent("value"),f=wJ(l.get("edgeWeight"),1),g=wJ(l.get("nodeWeight"),1);"number"==typeof f&&(f=[f,f]),"number"==typeof g&&(g=[g,g]);var m=0,v={},y=new Float32Array(2*a.count());if(i.eachNode((function(e){var t,n,r=e.dataIndex,i=a.get("value",r);if(a.hasItemOption){var s=a.getItemModel(r);t=s.get("x"),n=s.get("y")}null==t&&(t=o.x+Math.random()*o.width,n=o.y+Math.random()*o.height),y[2*m]=t,y[2*m+1]=n,v[e.id]=m++;var l=io(i,d,g);isNaN(l)&&(l=isNaN(g[0])?1:g[0]),c.push({x:t,y:n,mass:l,size:a.getItemVisual(r,"symbolSize")})})),a.setLayout("points",y),i.eachEdge((function(e){var t=e.dataIndex,n=io(a.get("value",t),p,f);isNaN(n)&&(n=isNaN(f[0])?1:f[0]),h.push({node1:v[e.node1.id],node2:v[e.node2.id],weight:n,dataIndex:t})})),!u){var _=l.get("GPU");this._forceLayoutInstance&&((!_||this._forceLayoutInstance instanceof u4)&&(_||this._forceLayoutInstance instanceof d4)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=_?new u4:new d4}u.initData(c,h),u.updateOption(l.option),this._updateForceEdgesGeometry(u.getEdges(),e),this._updatePositionTexture(),n.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*a.count()),m=0;i.eachNode((function(e){var t,n,r=e.dataIndex;if(a.hasItemOption){var i=a.getItemModel(r);t=i.get("x"),n=i.get("y")}y[m++]=t,y[m++]=n})),a.setLayout("points",y),this._updateAfterLayout(e,t,n)}},_updatePositionTexture:function(){var e=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(e),this._forceEdgesMesh.material.set("positionTex",e)},startLayout:function(e,t,n,r){if(!r||null==r.from||r.from===this.uid){var i=this.viewGL,o=(n=this._api,this._forceLayoutInstance),a=this._model.getData(),s=this._model.getModel("forceAtlas2");if(o){if(this.groupGL.remove(this._edgesMesh),this.groupGL.add(this._forceEdgesMesh),this._forceLayoutInstance){this._updateForceNodesGeometry(e.getData()),this._pointsBuilder.hideLabels();var l=this,u=this._layoutId=g4++,c=s.getShallow("maxSteps"),h=s.getShallow("steps"),d=0,p=Math.max(2*h,20),f=function(t){if(t===l._layoutId)return o.isFinished(c)?(n.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void n.dispatchAction({type:"graphGLFinishLayout",points:a.getLayout("points"),from:l.uid})):void o.update(i.layer.renderer,h,(function(){l._updatePositionTexture(),(d+=h)>=p&&(l._syncNodePosition(e),d=0),n.getZr().refresh(),UQ((function(){f(t)}))}))};UQ((function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(i.layer.renderer),l._forceLayoutInstanceToDispose=null),f(u)})),this._layouting=!0}}else"production"!==process.env.NODE_ENV&&console.error("None layout don't have startLayout action")}},stopLayout:function(e,t,n,r){r&&null!=r.from&&r.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(r&&r.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,n)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,n){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,n),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,n,r){var i=this._model.getData();this._downplayAll();var o=r.dataIndex,a=i.graph,s=[],l=a.getNodeByIndex(o);s.push(l),l.edges.forEach((function(e){e.dataIndex<0||(e.node1!==l&&s.push(e.node1),e.node2!==l&&s.push(e.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(e){this._pointsBuilder.highlight(i,e.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(e){return e.dataIndex})));var u=[];l.edges.forEach((function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),u.push(e))}),this),this._focusNodes=s,this._focusEdges=u},unfocusNodeAdjacency:function(e,t,n,r){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),n=HQ.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),r=wJ(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);n[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],n)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach((function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)}),this),this._focusEdges&&this._focusEdges.forEach((function(e){this._downplayEdge(e.dataIndex)}),this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,n){this._getColor(t,e),e[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var n=0;n<4;n++)t[n]=this._originalEdgeColors[4*e+n];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge((function(t){this._setEdgeFade(t.dataIndex,e)}),this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var n=this.viewGL.camera,r=e.getData().getLayout("points"),i=f4.create(1/0,1/0),o=f4.create(-1/0,-1/0),a=[],s=0;s<r.length;)a[0]=r[s++],a[1]=r[s++],f4.min(i,i,a),f4.max(o,o,a);var l=(o[1]+i[1])/2,u=(o[0]+i[0])/2;if(!(u>n.left&&u<n.right&&l<n.bottom&&l>n.top)){var c=Math.max(o[0]-i[0],10),h=c/t.getWidth()*t.getHeight();c*=1.4,h*=1.4,i[0]-=.2*c,n.left=i[0],n.top=l-h/2,n.bottom=l+h/2,n.right=c+i[0],n.near=0,n.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1,this._pointsBuilder.dispose()},remove:function(){this.groupGL.removeAll(),this._control.dispose()}});function v4(e){return e instanceof Array||(e=[e,e]),e}l_((function(e){function t(){}e.registerChartView(m4),e.registerSeriesModel(i4),e.registerVisual((function(e){const t={};e.eachSeriesByType("graphGL",(function(e){var n=e.getCategoriesData(),r=e.getData(),i={};n.each((function(r){var o=n.getName(r);i["ec-"+o]=r;var a=n.getItemModel(r),s=a.getModel("itemStyle").getItemStyle();s.fill||(s.fill=e.getColorFromPalette(o,t)),n.setItemVisual(r,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let e=0;e<l.length;e++){var u=a.getShallow(l[e],!0);null!=u&&n.setItemVisual(r,l[e],u)}})),n.count()&&r.each((function(e){let t=r.getItemModel(e).getShallow("category");if(null!=t){"string"==typeof t&&(t=i["ec-"+t]);var o=n.getItemVisual(t,"style");z(r.ensureUniqueItemVisual(e,"style"),o);var a=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<a.length;i++)r.setItemVisual(e,a[i],n.getItemVisual(t,a[i]))}}))}))})),e.registerVisual((function(e){e.eachSeriesByType("graphGL",(function(e){var t=e.getGraph(),n=e.getEdgeData(),r=v4(e.get("edgeSymbol")),i=v4(e.get("edgeSymbolSize"));n.setVisual("drawType","stroke"),n.setVisual("fromSymbol",r&&r[0]),n.setVisual("toSymbol",r&&r[1]),n.setVisual("fromSymbolSize",i&&i[0]),n.setVisual("toSymbolSize",i&&i[1]),n.setVisual("style",e.getModel("lineStyle").getLineStyle()),n.each((function(e){var r=n.getItemModel(e),i=t.getEdgeByIndex(e),o=v4(r.getShallow("symbol",!0)),a=v4(r.getShallow("symbolSize",!0)),s=r.getModel("lineStyle").getLineStyle(),l=n.ensureUniqueItemVisual(e,"style");switch(z(l,s),l.stroke){case"source":var u=i.node1.getVisual("style");l.stroke=u&&u.fill;break;case"target":u=i.node2.getVisual("style");l.stroke=u&&u.fill}o[0]&&i.setVisual("fromSymbol",o[0]),o[1]&&i.setVisual("toSymbol",o[1]),a[0]&&i.setVisual("fromSymbolSize",a[0]),a[1]&&i.setVisual("toSymbolSize",a[1])}))}))})),e.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},(function(e,t){t.eachComponent({mainType:"series",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},t),e.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},t),e.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},t),e.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},t)}));var y4=Hg.extend({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(e,t){var n=this.get("coordinateSystem"),r="geo"===n?["lng","lat"]:$y(n)||["x","y"];if("production"!==process.env.NODE_ENV&&r.length>2)throw new Error("flowGL can only be used on 2d coordinate systems.");r.push("vx","vy");var i=k_(this.getSource(),{coordDimensions:r,encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),o=new R_(i,this);return o.initData(this.getSource()),o},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}}),_4=XK.extend((function(){return{dynamic:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(e){var t=this.attributes,n=4*e,r=2*e;this.vertexCount!==n&&t.position.init(n),this.triangleCount!==r&&(this.indices=0===r?null:this.vertexCount>65535?new Uint32Array(3*r):new Uint16Array(3*r))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}});wq.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");var x4=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new RK({type:EK.FLOAT,flipY:!1}),this.particleLife=[5,20],this._particleType="point",this._particleSize=1,this.particleColor=[1,1,1,1],this.particleSpeedScaling=1,this._thisFrameTexture=null,this._particlePass=null,this._spawnTexture=null,this._particleTexture0=null,this._particleTexture1=null,this._particlePointsMesh=null,this._surfaceFrameBuffer=null,this._elapsedTime=0,this._scene=null,this._camera=null,this._lastFrameTexture=null,this._supersampling=1,this._downsampleTextures=[],this._width=512,this._height=512,this.init()};x4.prototype={constructor:x4,init:function(){var e={type:EK.FLOAT,minFilter:EK.NEAREST,magFilter:EK.NEAREST,useMipmap:!1};this._spawnTexture=new RK(e),this._particleTexture0=new RK(e),this._particleTexture1=new RK(e),this._frameBuffer=new G$({depthBuffer:!1}),this._particlePass=new pJ({fragment:wq.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new pJ({fragment:wq.source("clay.compositor.downsample")});var t=new LK({renderOrder:10,material:new jZ({shader:new wq(wq.source("ecgl.vfParticle.renderPoints.vertex"),wq.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:LK.POINTS,geometry:new XK({dynamic:!0,mainAttribute:"texcoord0"})}),n=new LK({renderOrder:10,material:new jZ({shader:new wq(wq.source("ecgl.vfParticle.renderLines.vertex"),wq.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new _4,culling:!1}),r=new LK({material:new jZ({shader:new wq(wq.source("ecgl.color.vertex"),wq.source("ecgl.color.fragment"))}),geometry:new W$});r.material.enableTexture("diffuseMap"),this._particlePointsMesh=t,this._particleLinesMesh=n,this._lastFrameFullQuadMesh=r,this._camera=new uJ,this._thisFrameTexture=new RK,this._lastFrameTexture=new RK},setParticleDensity:function(e,t){for(var n=new Float32Array(4*(e*t)),r=0,i=this.particleLife,o=0;o<e;o++)for(var a=0;a<t;a++,r++){n[4*r]=Math.random(),n[4*r+1]=Math.random(),n[4*r+2]=Math.random();var s=(i[1]-i[0])*Math.random()+i[0];n[4*r+3]=s}"line"===this._particleType?this._setLineGeometry(e,t):this._setPointsGeometry(e,t),this._spawnTexture.width=e,this._spawnTexture.height=t,this._spawnTexture.pixels=n,this._particleTexture0.width=this._particleTexture1.width=e,this._particleTexture0.height=this._particleTexture1.height=t,this._particlePass.setUniform("textureSize",[e,t])},_setPointsGeometry:function(e,t){var n=e*t,r=this._particlePointsMesh.geometry,i=r.attributes;i.texcoord0.init(n);for(var o=0,a=0;a<e;a++)for(var s=0;s<t;s++,o++)i.texcoord0.value[2*o]=a/e,i.texcoord0.value[2*o+1]=s/t;r.dirty()},_setLineGeometry:function(e,t){var n=e*t,r=this._getParticleMesh().geometry;r.setLineCount(n),r.resetOffset();for(var i=0;i<e;i++)for(var o=0;o<t;o++)r.addLine([i/e,o/t]);r.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(e,t,n,r){var i=this._getParticleMesh(),o=this._frameBuffer,a=this._particlePass;r&&this._updateDownsampleTextures(e,t),i.material.set("size",this._particleSize*this._supersampling),i.material.set("color",this.particleColor),a.setUniform("speedScaling",this.particleSpeedScaling),o.attach(this._particleTexture1),a.setUniform("firstFrameTime",r?(this.particleLife[1]+this.particleLife[0])/2:0),a.setUniform("particleTexture",this._particleTexture0),a.setUniform("deltaTime",n),a.setUniform("elapsedTime",this._elapsedTime),a.render(e,o),i.material.set("particleTexture",this._particleTexture1),i.material.set("prevParticleTexture",this._particleTexture0),o.attach(this._thisFrameTexture),o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);var s=this._lastFrameFullQuadMesh;s.material.set("diffuseMap",this._lastFrameTexture),s.material.set("color",[1,1,1,this.motionBlurFactor]),this._camera.update(!0),e.renderPass([s,i],this._camera),o.unbind(e),this._downsample(e),this._swapTexture(),this._elapsedTime+=n},_downsample:function(e){var t=this._downsampleTextures;if(0!==t.length)for(var n=0,r=this._thisFrameTexture,i=t[n];i;)this._frameBuffer.attach(i),this._downsamplePass.setUniform("texture",r),this._downsamplePass.setUniform("textureSize",[r.width,r.height]),this._downsamplePass.render(e,this._frameBuffer),r=i,i=t[++n]},getSurfaceTexture:function(){var e=this._downsampleTextures;return e.length>0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new RK),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=function(e){var t=document.createElement("canvas");t.width=t.height=e;var n=t.getContext("2d");return n.fillStyle="#fff",n.arc(e/2,e/2,e/2,0,2*Math.PI),n.fill(),t}(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var n=this._downsampleTextures,r=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,o=this._width*this._supersampling,a=this._height*this._supersampling,s=0;s<r;s++)n[s]=n[s]||new RK,n[s].width=o/i,n[s].height=a/i,i*=2;for(;s<n.length;s++)n[s].dispose(e);n.length=r},_swapTexture:function(){var e=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=e;e=this._thisFrameTexture;this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=e},dispose:function(e){e.disposeFrameBuffer(this._frameBuffer),e.disposeTexture(this.vectorFieldTexture),e.disposeTexture(this._spawnTexture),e.disposeTexture(this._particleTexture0),e.disposeTexture(this._particleTexture1),e.disposeTexture(this._thisFrameTexture),e.disposeTexture(this._lastFrameTexture),e.disposeGeometry(this._particleLinesMesh.geometry),e.disposeGeometry(this._particlePointsMesh.geometry),e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&e.disposeTexture(this._spriteTexture),this._particlePass.dispose(e),this._downsamplePass.dispose(e),this._downsampleTextures.forEach((function(t){t.dispose(e)}))}};var b4=em.extend({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new V1("orthographic"),this.groupGL=new HQ.Node,this.viewGL.add(this.groupGL),this._particleSurface=new x4;var n=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.color.vertex"),fragment:HQ.Shader.source("ecgl.color.fragment")}),transparent:!0})});n.material.enableTexture("diffuseMap"),this.groupGL.add(n),this._planeMesh=n},render:function(e,t,n){var r=this._particleSurface;r.setParticleType(e.get("particleType")),r.setSupersampling(e.get("supersampling")),this._updateData(e,n),this._updateCamera(n.getWidth(),n.getHeight(),n.getDevicePixelRatio());var i=wJ(e.get("particleDensity"),128);r.setParticleDensity(i,i);var o=this._planeMesh,a=+new Date,s=this,l=!0;o.__percent=0,o.stopAnimation(),o.animate("",{loop:!0}).when(1e5,{__percent:1}).during((function(){var e=+new Date,t=Math.min(e-a,20);a+=t,s._renderer&&(r.update(s._renderer,n,t/1e3,l),o.material.set("diffuseMap",r.getSurfaceTexture())),l=!1})).start();var u=e.getModel("itemStyle"),c=HQ.parseColor(u.get("color"));c[3]*=wJ(u.get("opacity"),1),o.material.set("color",c),r.setColorTextureImage(e.get("colorTexture"),n),r.setParticleSize(e.get("particleSize")),r.particleSpeedScaling=e.get("particleSpeed"),r.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,n){this._updateData(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._renderer=i},_updateData:function(e,t){var n=e.coordinateSystem,r=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]})),i=e.getData(),o=i.getDataExtent(r[0]),a=i.getDataExtent(r[1]),s=e.get("gridWidth"),l=e.get("gridHeight");if(null==s||"auto"===s){var u=(o[1]-o[0])/(a[1]-a[0]);s=Math.round(Math.sqrt(u*i.count()))}null!=l&&"auto"!==l||(l=Math.ceil(i.count()/s));var c=this._particleSurface.vectorFieldTexture,h=c.pixels;if(h&&h.length===l*s*4)for(var d=0;d<h.length;d++)h[d]=0;else h=c.pixels=new Float32Array(s*l*4);var p=0,f=1/0,g=new Float32Array(2*i.count()),m=0,v=[[1/0,1/0],[-1/0,-1/0]];i.each([r[0],r[1],"vx","vy"],(function(e,t,r,i){var o=n.dataToPoint([e,t]);g[m++]=o[0],g[m++]=o[1],v[0][0]=Math.min(o[0],v[0][0]),v[0][1]=Math.min(o[1],v[0][1]),v[1][0]=Math.max(o[0],v[1][0]),v[1][1]=Math.max(o[1],v[1][1]);var a=Math.sqrt(r*r+i*i);p=Math.max(p,a),f=Math.min(f,a)})),i.each(["vx","vy"],(function(e,t,n){var r=Math.round((g[2*n]-v[0][0])/(v[1][0]-v[0][0])*(s-1)),i=4*((l-1-Math.round((g[2*n+1]-v[0][1])/(v[1][1]-v[0][1])*(l-1)))*s+r);h[i]=e/p*.5+.5,h[i+1]=t/p*.5+.5,h[i+3]=1})),c.width=s,c.height=l,"bmap"===e.get("coordinateSystem")&&this._fillEmptyPixels(c),c.dirty(),this._updatePlanePosition(v[0],v[1],e,t),this._updateGradientTexture(i.getVisual("visualMeta"),[f,p])},_fillEmptyPixels:function(e){var t=e.pixels,n=e.width,r=e.height;function i(e,i,o){e=Math.max(Math.min(e,n-1),0);var a=4*((i=Math.max(Math.min(i,r-1),0))*(n-1)+e);return 0!==t[a+3]&&(o[0]=t[a],o[1]=t[a+1],!0)}function o(e,t,n){n[0]=e[0]+t[0],n[1]=e[1]+t[1]}for(var a=[],s=[],l=[],u=[],c=[],h=0,d=0;d<r;d++)for(var p=0;p<n;p++){var f=4*(d*(n-1)+p);0===t[f+3]&&(h=a[0]=a[1]=0,i(p-1,d,s)&&(h++,o(s,a,a)),i(p+1,d,l)&&(h++,o(l,a,a)),i(p,d-1,u)&&(h++,o(u,a,a)),i(p,d+1,c)&&(h++,o(c,a,a)),a[0]/=h,a[1]/=h,t[f]=a[0],t[f+1]=a[1]),t[f+3]=1}},_updateGradientTexture:function(e,t){if(e&&e.length){this._gradientTexture=this._gradientTexture||new HQ.Texture2D({image:document.createElement("canvas")});var n=this._gradientTexture,r=n.image;r.width=200,r.height=1;var i=r.getContext("2d"),o=i.createLinearGradient(0,.5,r.width,.5);e[0].stops.forEach((function(e){var n;t[1]===t[0]?n=0:(n=e.value/t[1],n=Math.min(Math.max(n,0),1)),o.addColorStop(n,e.color)})),i.fillStyle=o,i.fillRect(0,0,r.width,r.height),n.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(e,t,n,r){var i=this._limitInViewportAndFullFill(e,t,n,r);e=i.leftTop,t=i.rightBottom,this._particleSurface.setRegion(i.region),this._planeMesh.position.set((e[0]+t[0])/2,r.getHeight()-(e[1]+t[1])/2,0);var o=t[0]-e[0],a=t[1]-e[1];this._planeMesh.scale.set(o/2,a/2,1),this._particleSurface.resize(Math.max(Math.min(o,2048),1),Math.max(Math.min(a,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(e,t,n,r){var i=[Math.max(e[0],0),Math.max(e[1],0)],o=[Math.min(t[0],r.getWidth()),Math.min(t[1],r.getHeight())];if("bmap"===n.get("coordinateSystem")){var a=n.getData().getDataExtent(n.coordDimToDataDim("lng")[0]);Math.floor(a[1]-a[0])>=359&&(i[0]>0&&(i[0]=0),o[0]<r.getWidth()&&(o[0]=r.getWidth()))}var s=t[0]-e[0],l=t[1]-e[1],u=o[0]-i[0],c=o[1]-i[1];return{leftTop:i,rightBottom:o,region:[(i[0]-e[0])/s,1-c/l-(i[1]-e[1])/l,u/s,c/l]}},_updateCamera:function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.bottom=0,r.top=t,r.right=e,r.near=0,r.far=100,r.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}});l_((function(e){e.registerChartView(b4),e.registerSeriesModel(y4)}));var w4=Hg.extend({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),w4.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),w4.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=$J(this._flatCoords,t.flatCoords),this._flatCoordsOffset=$J(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),n=t.option instanceof Array?t.option:t.getShallow("coords");if("production"!==process.env.NODE_ENV&&!(n instanceof Array&&n.length>0&&n[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(n)+". Lines must have 2d coords array in data item.");return n},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var n=this._flatCoordsOffset[2*e],r=this._flatCoordsOffset[2*e+1],i=0;i<r;i++)t[i]=t[i]||[],t[i][0]=this._flatCoords[n+2*i],t[i][1]=this._flatCoords[n+2*i+1];return r}var o=this._getCoordsFromItemModel(e);for(i=0;i<o.length;i++)t[i]=t[i]||[],t[i][0]=o[i][0],t[i][1]=o[i][1];return o.length},_processFlatCoordsArray:function(e){var t=0;if(this._flatCoords&&(t=this._flatCoords.length),"number"==typeof e[0]){for(var n=e.length,r=new Uint32Array(n),i=new Float64Array(n),o=0,a=0,s=0,l=0;l<n;){s++;var u=e[l++];r[a++]=o+t,r[a++]=u;for(var c=0;c<u;c++){var h=e[l++],d=e[l++];if(i[o++]=h,i[o++]=d,l>n&&"production"!==process.env.NODE_ENV)throw new Error("Invalid data format.")}}return{flatCoordsOffset:new Uint32Array(r.buffer,0,a),flatCoords:i,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:e.length}},getInitialData:function(e,t){var n=new R_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"geo",zlevel:10,progressive:1e4,progressiveThreshold:5e4,blendMode:"source-over",lineStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}}),S4=em.extend({type:"linesGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new n4(this.viewGL),this._nativeLinesShader=HQ.createShader("ecgl.lines3D"),this._meshLinesShader=HQ.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n);var r=this._linesMeshes[0];r||(r=this._linesMeshes[0]=this._createLinesMesh(e)),this._linesMeshes.length=1,this.groupGL.add(r),this._updateLinesMesh(e,r,0,e.getData().count()),this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){var i=this._linesMeshes[this._currentStep];i||(i=this._createLinesMesh(t),this._linesMeshes[this._currentStep]=i),this._updateLinesMesh(t,i,e.start,e.end),this.groupGL.add(i),r.getZr().refresh(),this._currentStep++},updateTransform:function(e,t,n){e.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(e,n)},_createLinesMesh:function(e){return new HQ.Mesh({$ignorePicking:!0,material:new HQ.Material({shader:HQ.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new s4({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:HQ.Mesh.LINES,culling:!1})},_updateLinesMesh:function(e,t,n,r){var i=e.getData();t.material.blend="lighter"===e.get("blendMode")?HQ.additiveBlend:null;var o=e.get("lineStyle.curveness")||0,a=e.get("polyline"),s=t.geometry,l=e.coordinateSystem,u=wJ(e.get("lineStyle.width"),1);u>1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=HQ.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=HQ.Mesh.LINES),n=n||0,r=r||i.count(),s.resetOffset();var c=0,h=0,d=[],p=[],f=[],g=[],m=[],v=.3,y=.7;function _(){p[0]=d[0]*y+g[0]*v-(d[1]-g[1])*o,p[1]=d[1]*y+g[1]*v-(g[0]-d[0])*o,f[0]=d[0]*v+g[0]*y-(d[1]-g[1])*o,f[1]=d[1]*v+g[1]*y-(g[0]-d[0])*o}if(a||0!==o)for(var x=n;x<r;x++)if(a){var b=e.getLineCoordsCount(x);c+=s.getPolylineVertexCount(b),h+=s.getPolylineTriangleCount(b)}else e.getLineCoords(x,m),this._glViewHelper.dataToPoint(l,m[0],d),this._glViewHelper.dataToPoint(l,m[1],g),_(),c+=s.getCubicCurveVertexCount(d,p,f,g),h+=s.getCubicCurveTriangleCount(d,p,f,g);else{var w=r-n;c+=w*s.getLineVertexCount(),h+=w*s.getLineVertexCount()}s.setVertexCount(c),s.setTriangleCount(h);var S=n,T=[];for(x=n;x<r;x++){HQ.parseColor(P2(i,S),T);var M=wJ(O2(i,S),1);T[3]*=M;b=e.getLineCoords(x,m);for(var C=0;C<b;C++)this._glViewHelper.dataToPoint(l,m[C],m[C]);a?s.addPolyline(m,T,u,0,b):0!==o?(d=m[0],g=m[1],_(),s.addCubicCurve(d,p,f,g,T,u)):s.addPolyline(m,T,u,0,2),S++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(S4),e.registerSeriesModel(w4)}));const T4=({className:e="",style:n={},extraOption:r={},lineStyles:i={},pointsStyles:s={},pointsData:l=[],linesData:u=[],globeOption:c={}})=>{const h=t(null),[d,p]=o();return a((()=>{const e=By(h.current);p(e);const t=$X(e.resize,500),n=()=>{t()};return globalThis.addEventListener("resize",n),()=>{globalThis.removeEventListener("resize",n)}}),[]),a((()=>{if(d){const e=[];e.push(Object.assign({type:"lines3D",name:"lines3D",effect:{show:!0,trailWidth:2,trailLength:.15,trailOpacity:1,trailColor:"rgb(30, 30, 60)"},lineStyle:{width:5,color:"rgb(50, 50, 150)",opacity:.3},blendMode:"lighter",data:u},i)),e.push(Object.assign({type:"scatter3D",coordinateSystem:"globe",zlevel:3,rippleEffect:{brushType:"stroke"},label:{fontSize:8,show:!0,position:"right",formatter:"{b}"},itemStyle:{normal:{color:"#f5f802"}},data:l},s)),d.setOption(Object.assign({backgroundColor:"#000",baseColor:"#000",shading:"realistic",globe:Object.assign({environment:"https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg",heightTexture:"https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg",baseTexture:"https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg",shading:"lambert",light:{ambient:{intensity:1},main:{intensity:.1}},viewControl:{autoRotate:!0,distance:2e3}},c),series:e},r));const t=setTimeout((()=>{d.resize()}),500);return()=>{clearTimeout(t)}}}),[d,r,c,i,u,l,s]),yU.jsx(oX,{ref:h,className:e,style:n})};export{T4 as EarthChart,pY as WinChart,aX as WinChartType,pY as default,hU as echarts};
22
+ `;var aX;!function(e){e[e.MINI_AREA=0]="MINI_AREA",e[e.AREA=1]="AREA",e[e.DUAL_LINE_BAR=2]="DUAL_LINE_BAR",e[e.STACK_DUAL_LINE_BAR=3]="STACK_DUAL_LINE_BAR",e[e.COLUMN=4]="COLUMN",e[e.STACK_COLUMN=5]="STACK_COLUMN",e[e.LINE=6]="LINE",e[e.BAR=7]="BAR",e[e.STACK_BAR=8]="STACK_BAR",e[e.FUNNEL=9]="FUNNEL",e[e.PIE=10]="PIE",e[e.CYCLE=11]="CYCLE",e[e.RADAR=12]="RADAR"}(aX||(aX={}));const sX=["#3D84FF","#00DCF0","#FCBC26","#00DB75","#BDB8FF","#40B4FF","#FFA101","#90ABE0","#6EE67A","#6B84FF","#FA6B69"],lX={grid:{top:24,left:0,right:12,bottom:32,containLabel:!0},color:sX,legend:{itemWidth:10,itemHeight:10,bottom:0,type:"scroll",icon:"circle"}};function uX(){return uX=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uX.apply(null,arguments)}function cX(e,t){return cX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},cX(e,t)}function hX(e){return hX=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},hX(e)}function dX(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(dX=function(){return!!e})()}function pX(e){var t="function"==typeof Map?new Map:void 0;return pX=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(dX())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&cX(i,n.prototype),i}(e,arguments,hX(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),cX(n,e)},pX(e)}var fX={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function gX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach((function(e){i=i.replace(/%[a-z]/,e)})),i}var mX=function(e){function t(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,gX.apply(void 0,[fX[t]].concat(i)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,cX(e,t)}(t,e),t}(pX(Error));function vX(e){return Math.round(255*e)}function yX(e,t,n){return vX(e)+","+vX(t)+","+vX(n)}function _X(e,t,n,r){if(void 0===r&&(r=yX),0===t)return r(n,n,n);var i=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*t,a=o*(1-Math.abs(i%2-1)),s=0,l=0,u=0;i>=0&&i<1?(s=o,l=a):i>=1&&i<2?(s=a,l=o):i>=2&&i<3?(l=o,u=a):i>=3&&i<4?(l=a,u=o):i>=4&&i<5?(s=a,u=o):i>=5&&i<6&&(s=o,u=a);var c=n-o/2;return r(s+c,l+c,u+c)}var xX={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",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",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",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",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",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:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var bX=/^#[a-fA-F0-9]{6}$/,wX=/^#[a-fA-F0-9]{8}$/,SX=/^#[a-fA-F0-9]{3}$/,TX=/^#[a-fA-F0-9]{4}$/,MX=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,CX=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,DX=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,AX=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function IX(e){if("string"!=typeof e)throw new mX(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return xX[t]?"#"+xX[t]:e}(e);if(t.match(bX))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(wX)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(SX))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(TX)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var i=MX.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var o=CX.exec(t.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=DX.exec(t);if(a){var s="rgb("+_X(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",l=MX.exec(s);if(!l)throw new mX(4,t,s);return{red:parseInt(""+l[1],10),green:parseInt(""+l[2],10),blue:parseInt(""+l[3],10)}}var u=AX.exec(t.substring(0,50));if(u){var c="rgb("+_X(parseInt(""+u[1],10),parseInt(""+u[2],10)/100,parseInt(""+u[3],10)/100)+")",h=MX.exec(c);if(!h)throw new mX(4,t,c);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10),alpha:parseFloat(""+u[4])>1?parseFloat(""+u[4])/100:parseFloat(""+u[4])}}throw new mX(5)}function EX(e){return function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var l=o-a,u=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:u,lightness:s,alpha:e.alpha}:{hue:t,saturation:u,lightness:s}}(IX(e))}var LX=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function NX(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function PX(e){return NX(Math.round(255*e))}function OX(e,t,n){return LX("#"+PX(e)+PX(t)+PX(n))}function RX(e,t,n){return _X(e,t,n,OX)}function kX(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return LX("#"+NX(e)+NX(t)+NX(n));if("object"==typeof e&&void 0===t&&void 0===n)return LX("#"+NX(e.red)+NX(e.green)+NX(e.blue));throw new mX(6)}function zX(e,t,n,r){if("string"==typeof e&&"number"==typeof t){var i=IX(e);return"rgba("+i.red+","+i.green+","+i.blue+","+t+")"}if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return r>=1?kX(e,t,n):"rgba("+e+","+t+","+n+","+r+")";if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?kX(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new mX(7)}function VX(e){if("object"!=typeof e)throw new mX(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return zX(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return kX(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return"rgba("+_X(e,t,n)+","+r+")";if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?RX(e.hue,e.saturation,e.lightness):"rgba("+_X(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new mX(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return RX(e,t,n);if("object"==typeof e&&void 0===t&&void 0===n)return RX(e.hue,e.saturation,e.lightness);throw new mX(1)}(e);throw new mX(8)}function BX(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):BX(e,t,r)}}function FX(e){return BX(e,e.length,[])}function GX(e,t,n){return Math.max(e,Math.min(t,n))}FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{hue:n.hue+parseFloat(e)}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{lightness:GX(0,1,n.lightness-parseFloat(e))}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{saturation:GX(0,1,n.saturation-parseFloat(e))}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{lightness:GX(0,1,n.lightness+parseFloat(e))}))}));var HX=FX((function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=IX(t),i=uX({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),o=IX(n),a=uX({},o,{alpha:"number"==typeof o.alpha?o.alpha:1}),s=i.alpha-a.alpha,l=2*parseFloat(e)-1,u=((l*s==-1?l:l+s)/(1+l*s)+1)/2,c=1-u;return zX({red:Math.floor(i.red*u+a.red*c),green:Math.floor(i.green*u+a.green*c),blue:Math.floor(i.blue*u+a.blue*c),alpha:i.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})})),UX=HX;function WX(e){return Array.isArray(e)&&e.length>0}FX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(uX({},n,{alpha:GX(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))})),FX((function(e,t){if("transparent"===t)return t;var n=EX(t);return VX(uX({},n,{saturation:GX(0,1,n.saturation+parseFloat(e))}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{hue:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{lightness:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:VX(uX({},EX(t),{saturation:parseFloat(e)}))})),FX((function(e,t){return"transparent"===t?t:UX(parseFloat(e),"rgb(0, 0, 0)",t)})),FX((function(e,t){return"transparent"===t?t:UX(parseFloat(e),"rgb(255, 255, 255)",t)})),FX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(uX({},n,{alpha:GX(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}));const jX=(e,t=2)=>"number"==typeof e?`${Number((100*e).toFixed(t))}%`:"-%";function XX(e){return Array.isArray(e)?[...new Set(e)]:[]}const YX=e=>Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>{const n=Number(t);return e+(Object.is(n,NaN)?0:n)}),0):0,ZX=e=>Array.isArray(e)?e.sort(((e,t)=>t.value-e.value)):e,qX=e=>{let t=e.data;return(e=>Array.isArray(e)&&e.length>0)(t)||(t=e.extraData),{boundaryGap:!0,axisTick:{alignWithLabel:!0},data:XX(null==t?void 0:t.map((e=>e.label))),axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}}},KX=(e,t)=>(e.sort(((e,n)=>t.indexOf(e.label)-t.indexOf(n.label))),e);function $X(e,t){let n=null;return function(...r){clearTimeout(n),n=setTimeout((()=>{e.apply(globalThis,r)}),t)}}const JX=e=>"dark"===e.theme?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)";function QX(e){const t=e.reduce(((e,t)=>{const{label:n,value:r}=t;return e[n]||(e[n]=0),r&&(e[n]+=Number(r)),e}),{});return Object.values(t).map((e=>parseFloat(e.toFixed(2))))}const eY=e=>{const t=(e=>{const{data:t,extraData:n,sort:r}=e;if(t&&r){const a=(i=[...t],"asc"===(o=r)?i.sort(((e,t)=>e.value-t.value)):"desc"===o&&i.sort(((e,t)=>t.value-e.value)),i),s=XX(a.map((e=>e.label))),l=KX(a,s),u=KX([...null!=n?n:[]],s);return Object.assign(Object.assign({},e),{data:l,extraData:u})}var i,o;return e})(e);switch(t.chartType){case aX.MINI_AREA:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),o=e.color;return{color:o,grid:{top:4,left:0,right:0,bottom:0,containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{show:!1},xAxis:{show:!1,boundaryGap:!1,data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label)))},yAxis:{show:!1,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},series:[...i.map(((t,n)=>{var r,i;const a=null!==(r=null==o?void 0:o[n])&&void 0!==r?r:sX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new wc(0,0,0,1,[{offset:0,color:zX(a,.5)},{offset:1,color:"dark"===e.theme?zX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(i=e.data)||void 0===i?void 0:i.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.AREA:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:qX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:[...r.map(((t,n)=>{var r;const i=sX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new wc(0,0,0,1,[{offset:0,color:zX(i,.5)},{offset:1,color:"dark"===e.theme?zX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"},showSymbol:!0}),{data:null===(r=e.data)||void 0===r?void 0:r.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.LINE:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:qX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!1,lineStyle:{width:2},showSymbol:!0,emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))}})(t);case aX.COLUMN:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})}))}})(t);case aX.STACK_COLUMN:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})}))}})(t);case aX.BAR:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:{},yAxis:{data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:[0,500,500,0]}})))})}))}})(t);case aX.STACK_BAR:return(e=>{var t,n,r;const i=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{grid:Object.assign({},e.showStackTotal&&{right:32}),tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll",data:i},xAxis:{},yAxis:{data:XX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:[...i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&!e.showStackTotal&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),Object.assign(Object.assign({name:"总和",type:"bar",stack:"abc",barGap:"-100%",barMaxWidth:8,itemStyle:{normal:{color:"transparent"}},tooltip:{show:!1}},e.showStackTotal&&{label:{normal:{show:!0,position:"right",color:"#000"},formatter:t=>{var n;return String(Number(YX(null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.label===t.name)).map((e=>e.value))).toFixed(2)))}}}),{data:QX(e.data)})]}})(t);case aX.FUNNEL:return(e=>{var t,n;const r=null!==(n=null===(t=ZX(e.data))||void 0===t?void 0:t.map((t=>{var n;return{value:null!==(n=t.value)&&void 0!==n?n:0,name:e.reserveValueWithLabelType?t.label:t.type}})))&&void 0!==n?n:[],i={type:"funnel",minSize:"20%",left:10,top:24,width:"76%",sort:"descending",data:r};return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[Object.assign(Object.assign({},i),{label:{show:!0,position:"outer",formatter:"{c}"}}),Object.assign(Object.assign({},i),{emphasis:{label:{fontSize:20}},label:{show:!0,position:"inner",color:"#fff",formatter:e=>{const t=e.dataIndex;if(0===t)return"100%";const n=r[t-1].value;return jX(e.value/n)}}})]}})(t);case aX.DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=XX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.STACK_DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=XX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},qX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case aX.PIE:return(e=>{var t,n;const r=YX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:"50%",data:null===(n=ZX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:JX(e),position:"outside",formatter:e=>jX(e.value/(r||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}})(t);case aX.CYCLE:return(e=>{var t,n,r,i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x;const b=YX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:["60%","48%"],data:null===(n=ZX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:JX(e),position:"outside",formatter:e=>jX(e.value/(b||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}],graphic:[{type:"text",left:"center",top:null!==(o=null===(i=null===(r=e.cycleCenterConfig)||void 0===r?void 0:r.content)||void 0===i?void 0:i.top)&&void 0!==o?o:76,style:{text:null!==(l=null===(s=null===(a=e.cycleCenterConfig)||void 0===a?void 0:a.content)||void 0===s?void 0:s.value)&&void 0!==l?l:Number(b.toFixed(2)).toString(),fill:"dark"===e.theme?"#fff":"#12161F",fontFamily:"roboto",fontSize:null!==(h=null===(c=null===(u=e.cycleCenterConfig)||void 0===u?void 0:u.content)||void 0===c?void 0:c.fontSize)&&void 0!==h?h:28,fontWeight:"bold"}},{type:"text",left:"center",top:null!==(f=null===(p=null===(d=e.cycleCenterConfig)||void 0===d?void 0:d.title)||void 0===p?void 0:p.top)&&void 0!==f?f:112,style:{text:null!==(v=null===(m=null===(g=e.cycleCenterConfig)||void 0===g?void 0:g.title)||void 0===m?void 0:m.value)&&void 0!==v?v:"总计",fill:"dark"===e.theme?"#fff":"#394252 ",fontSize:null!==(x=null===(_=null===(y=e.cycleCenterConfig)||void 0===y?void 0:y.title)||void 0===_?void 0:_.fontSize)&&void 0!==x?x:14}}]}})(t);case aX.RADAR:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((t=>e.reserveValueWithLabelType?t.label:t.type)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},radar:{shape:"circle",radius:"60%",indicator:XX(null===(n=e.data)||void 0===n?void 0:n.map((t=>e.reserveValueWithLabelType?t.type:t.label))).map((e=>({name:e}))),axisName:{color:"#5d677a"},splitArea:{areaStyle:{color:["transparent"]}},axisLine:{lineStyle:{color:"rgba(226, 229, 235, .3)"}},splitLine:{lineStyle:{color:"#e2e5eb",type:"dashed",dashOffset:1.5}}},series:[{type:"radar",data:r.map(((t,n)=>{var r;return{name:t,value:null===(r=e.data)||void 0===r?void 0:r.filter((n=>e.reserveValueWithLabelType?n.label:n.type===t)).map((e=>e.value)),areaStyle:{color:zX(sX[n],.2)},label:{show:e.reserveValueWithLabelType,formatter:e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.toString()}}}})),emphasis:{lineStyle:{width:4}}}]}})(t);default:return{}}};var tY={color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"rgba(0,0,0,0)",textStyle:{},title:{textStyle:{color:"#272f3d"},subtextStyle:{color:"#394252"}},line:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},radar:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#dfe3eb"},symbolSize:4,symbol:"emptyCircle",smooth:!1,color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#828c9e"},emphasis:{iconStyle:{borderColor:"#394252"}}},legend:{textStyle:{color:"#828b9e"}},tooltip:{axisPointer:{lineStyle:{color:"#ccd1db",width:"1"},crossStyle:{color:"#ccd1db",width:"1"}}},timeline:{lineStyle:{color:"#eef0f5",width:2},itemStyle:{color:"#eef0f5",borderWidth:"1"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},checkpointStyle:{color:"#3379ff",borderColor:"#ffffff"},label:{color:"#b1b9c7"},emphasis:{itemStyle:{color:"#3379ff"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},label:{color:"#b1b9c7"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},nY={color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"transparent",textStyle:{},title:{textStyle:{color:"#ffffff"},subtextStyle:{color:"#ffffff"}},line:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},radar:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#ffffff"},symbolSize:"6",symbol:"emptyCircle",smooth:!0,color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#ffffff"},emphasis:{iconStyle:{borderColor:"#ffffff"}}},legend:{textStyle:{color:"#ffffff"}},tooltip:{axisPointer:{lineStyle:{color:"#ffffff",width:"1"},crossStyle:{color:"#ffffff",width:"1"}}},timeline:{lineStyle:{color:"#ffffff",width:2},itemStyle:{color:"#ffffff",borderWidth:"1"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},checkpointStyle:{color:"#5798ff",borderColor:"#ffffff"},label:{color:"#ffffff"},emphasis:{itemStyle:{color:"#5798ff"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},label:{color:"#ffffff"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},rY=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===iY}(e)}(e)};var iY="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function oY(e,t){return!1!==t.clone&&t.isMergeableObject(e)?cY((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function aY(e,t,n){return e.concat(t).map((function(e){return oY(e,n)}))}function sY(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function lY(e,t){try{return t in e}catch(e){return!1}}function uY(e,t,n){var r={};return n.isMergeableObject(e)&&sY(e).forEach((function(t){r[t]=oY(e[t],n)})),sY(t).forEach((function(i){(function(e,t){return lY(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(lY(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return cY;var n=t.customMerge(e);return"function"==typeof n?n:cY}(i,n)(e[i],t[i],n):r[i]=oY(t[i],n))})),r}function cY(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||aY,n.isMergeableObject=n.isMergeableObject||rY,n.cloneUnlessOtherwiseSpecified=oY;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):uY(e,t,n):oY(t,n)}cY.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return cY(e,n,t)}),{})};var hY=dU(cY);Uy("light",hY(tY,lX)),Uy("dark",hY(nY,lX));const dY={arrayMerge:(e,t)=>t},pY=e=>{const n=t(null),[r,i]=o();return a((()=>{var t;const r=By(n.current,null!==(t=e.theme)&&void 0!==t?t:"light");i(r);const o=$X(r.resize,500),a=()=>{o()};return globalThis.addEventListener("resize",a),()=>{globalThis.removeEventListener("resize",a)}}),[e.theme]),a((()=>{var t;if(r){const n=r.getHeight()-48,i=Object.assign(Object.assign({},e),e.chartType===aX.CYCLE&&!e.cycleCenterConfig&&{cycleCenterConfig:{title:{top:n/2+24},content:{top:n/2-8}}}),{data:o,extraOption:a={},extraSeriesOption:s}=i;WX(o)||r.clear();const l=hY(((e,t)=>(WX(e.series)&&WX(t)&&t.forEach((t=>{e.series=e.series.map((e=>Object.assign(Object.assign({},e),e.name===t.name&&t)))})),e))(eY(i),s),a,dY);r.setOption(l),null===(t=i.onLoad)||void 0===t||t.call(i,r);const u=setTimeout((()=>{r.resize()}),500);return()=>{clearTimeout(u)}}}),[r,e]),yU.jsx(oX,{ref:n,className:e.className,style:e.style})};function fY(e,t,n){"object"==typeof t&&(n=t,t=null);var r,i=this;if(!(e instanceof Function))for(var o in r=[],e)e.hasOwnProperty(o)&&r.push(o);var a=function(t){if(i.apply(this,arguments),e instanceof Function?gY(this,e.call(this,t)):function(e,t,n){for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}}(this,e,r),this.constructor===a)for(var n=a.__initializers__,o=0;o<n.length;o++)n[o].apply(this,arguments)};a.__super__=i,i.__initializers__?a.__initializers__=i.__initializers__.slice():a.__initializers__=[],t&&a.__initializers__.push(t);var s=function(){};return s.prototype=i.prototype,a.prototype=new s,a.prototype.constructor=a,gY(a.prototype,n),a.extend=i.extend,a.derive=i.extend,a}function gY(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}l_([FS,yH]),l_(xw);var mY={extend:fY,derive:fY};function vY(e,t){this.action=e,this.context=t}var yY={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,r=-1,i=arguments;switch(i.length){case 1:for(;++r<n;)t[r].action.call(t[r].context);return;case 2:for(;++r<n;)t[r].action.call(t[r].context,i[1]);return;case 3:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2]);return;case 4:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3]);return;case 5:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3],i[4]);return;default:for(;++r<n;)t[r].action.apply(t[r].context,Array.prototype.slice.call(i,1));return}}},on:function(e,t,n){if(e&&t){var r=this.__handlers__||(this.__handlers__={});if(r[e]){if(this.has(e,t))return}else r[e]=[];var i=new vY(t,n||this);return r[e].push(i),this}},once:function(e,t,n){if(e&&t){var r=this;return this.on(e,(function n(){r.off(e,n),t.apply(this,arguments)}),n)}},before:function(e,t,n){if(e&&t)return e="before"+e,this.on(e,t,n)},after:function(e,t,n){if(e&&t)return e="after"+e,this.on(e,t,n)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var n=this.__handlers__||(this.__handlers__={});if(t){if(n[e]){for(var r=n[e],i=[],o=0;o<r.length;o++)t&&r[o].action!==t&&i.push(r[o]);n[e]=i}return this}n[e]=[]},has:function(e,t){var n=this.__handlers__;if(!n||!n[e])return!1;for(var r=n[e],i=0;i<r.length;i++)if(r[i].action===t)return!0}},_Y=0,xY=Array.prototype.forEach,bY={genGUID:function(){return++_Y},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var n=e.split("/"),r=t.split("/"),i=n[0];"."===i||".."===i;)".."===i&&r.pop(),n.shift(),i=n[0];return r.join("/")+"/"+n.join("/")},extend:function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},defaults:function(e,t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n]);return e},extendWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];null==e[i]&&(e[i]=t[i])}return e},each:function(e,t,n){if(e&&t)if(e.forEach&&e.forEach===xY)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(n,e[o],o,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return!!e&&e.length===+e.length},clone:function(e){if(bY.isObject(e)){if(bY.isArray(e))return e.slice();if(bY.isArrayLike(e)){for(var t=new e.constructor(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return bY.extend({},e)}return e}},wY=function(){this.__uid__=bY.genGUID()};wY.__initializers__=[function(e){bY.extend(this,e)}],bY.extend(wY,mY),bY.extend(wY.prototype,yY);var SY=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],TY=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function MY(e){for(var t={},n={},r=0;r<SY.length;r++){o(SY[r])}for(r=0;r<TY.length;r++){var i=TY[r];n[i]=e.getParameter(e[i])}function o(n){if(e.getExtension){var r=e.getExtension(n);r||(r=e.getExtension("MOZ_"+n)),r||(r=e.getExtension("WEBKIT_"+n)),t[n]=r}}this.getExtension=function(e){return e in t||o(e),t[e]},this.getParameter=function(e){return n[e]}}var CY=256,DY=1024,AY=16384,IY=0,EY=1,LY=2,NY=3,PY=4,OY=5,RY=6,kY=35040,zY=35044,VY=35048,BY=1028,FY=1029,GY=1032,HY=2304,UY=2305,WY=5120,jY=5121,XY=5122,YY=5123,ZY=5124,qY=5125,KY=5126,$Y=6402,JY=6406,QY=6407,eZ=6408,tZ=6409,nZ=6410,rZ=9728,iZ=9729,oZ=9984,aZ=9985,sZ=9986,lZ=9987,uZ=3553,cZ=34067,hZ=10497,dZ=33071,pZ=33648,fZ=36160,gZ=36161,mZ=34041,vZ=36064,yZ=36096,_Z=36128,xZ=33306;var bZ,wZ={get:function(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(t){if(t.lengthComputable){var n=t.loaded/t.total;e.onprogress(n,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(n){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}},SZ={supportWebGL:function(){if(null==bZ)try{var e=document.createElement("canvas");if(!(e.getContext("webgl")||e.getContext("experimental-webgl")))throw new Error}catch(e){bZ=!1}return bZ}};SZ.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,SZ.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,SZ.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,SZ.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,SZ.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,SZ.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,SZ.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var TZ={};"undefined"!=typeof window?TZ=window:"undefined"!=typeof global&&(TZ=global),SZ.requestAnimationFrame=TZ.requestAnimationFrame||TZ.msRequestAnimationFrame||TZ.mozRequestAnimationFrame||TZ.webkitRequestAnimationFrame||function(e){setTimeout(e,16)},SZ.createCanvas=function(){return document.createElement("canvas")},SZ.createImage=function(){return new TZ.Image},SZ.request={get:wZ.get},SZ.addEventListener=function(e,t,n,r){e.addEventListener(t,n,r)},SZ.removeEventListener=function(e,t,n){e.removeEventListener(t,n)};var MZ=function(){this.head=null,this.tail=null,this._length=0};MZ.prototype.insert=function(e){var t=new MZ.Entry(e);return this.insertEntry(t),t},MZ.prototype.insertAt=function(e,t){if(!(e<0)){for(var n=this.head,r=0;n&&r!=e;)n=n.next,r++;if(n){var i=new MZ.Entry(t),o=n.prev;o?(o.next=i,i.prev=o):this.head=i,i.next=n,n.prev=i}else this.insert(t)}},MZ.prototype.insertBeforeEntry=function(e,t){var n=new MZ.Entry(e),r=t.prev;r?(r.next=n,n.prev=r):this.head=n,n.next=t,t.prev=n,this._length++},MZ.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},MZ.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._length--},MZ.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t?(this.remove(t),t.value):void 0}},MZ.prototype.getHead=function(){if(this.head)return this.head.value},MZ.prototype.getTail=function(){if(this.tail)return this.tail.value},MZ.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t.value}},MZ.prototype.indexOf=function(e){for(var t=this.head,n=0;t;){if(t.value===e)return n;t=t.next,n++}},MZ.prototype.length=function(){return this._length},MZ.prototype.isEmpty=function(){return 0===this._length},MZ.prototype.forEach=function(e,t){for(var n=this.head,r=0,i=void 0!==t;n;)i?e.call(t,n.value,r):e(n.value,r),n=n.next,r++},MZ.prototype.clear=function(){this.tail=this.head=null,this._length=0},MZ.Entry=function(e){this.value=e,this.next=null,this.prev=null};var CZ=function(e){this._list=new MZ,this._map={},this._maxSize=e||10};CZ.prototype.setMaxSize=function(e){this._maxSize=e},CZ.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},CZ.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},CZ.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},CZ.prototype.clear=function(){this._list.clear(),this._map={}};var DZ={},AZ={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],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 IZ(e){return(e=Math.round(e))<0?0:e>255?255:e}function EZ(e){return e<0?0:e>1?1:e}function LZ(e){return e.length&&"%"===e.charAt(e.length-1)?IZ(parseFloat(e)/100*255):IZ(parseInt(e,10))}function NZ(e){return e.length&&"%"===e.charAt(e.length-1)?EZ(parseFloat(e)/100):EZ(parseFloat(e))}function PZ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function OZ(e,t,n){return e+(t-e)*n}function RZ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function kZ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var zZ=new CZ(20),VZ=null;function BZ(e,t){VZ&&kZ(VZ,t),VZ=zZ.put(e,VZ||t.slice())}function FZ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=NZ(e[1]),i=NZ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return RZ(t=t||[],IZ(255*PZ(a,o,n+1/3)),IZ(255*PZ(a,o,n)),IZ(255*PZ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}DZ.parse=function(e,t){if(e){t=t||[];var n=zZ.get(e);if(n)return kZ(t,n);var r,i=(e+="").replace(/ /g,"").toLowerCase();if(i in AZ)return kZ(t,AZ[i]),BZ(e,t),t;if("#"===i.charAt(0))return 4===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=4095?(RZ(t,(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1),BZ(e,t),t):void RZ(t,0,0,0,1):7===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=16777215?(RZ(t,(16711680&r)>>16,(65280&r)>>8,255&r,1),BZ(e,t),t):void RZ(t,0,0,0,1):void 0;var o=i.indexOf("("),a=i.indexOf(")");if(-1!==o&&a+1===i.length){var s=i.substr(0,o),l=i.substr(o+1,a-(o+1)).split(","),u=1;switch(s){case"rgba":if(4!==l.length)return void RZ(t,0,0,0,1);u=NZ(l.pop());case"rgb":return 3!==l.length?void RZ(t,0,0,0,1):(RZ(t,LZ(l[0]),LZ(l[1]),LZ(l[2]),u),BZ(e,t),t);case"hsla":return 4!==l.length?void RZ(t,0,0,0,1):(l[3]=NZ(l[3]),FZ(l,t),BZ(e,t),t);case"hsl":return 3!==l.length?void RZ(t,0,0,0,1):(FZ(l,t),BZ(e,t),t);default:return}}RZ(t,0,0,0,1)}},DZ.parseToFloat=function(e,t){if(t=DZ.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},DZ.lift=function(e,t){var n=DZ.parse(e);if(n){for(var r=0;r<3;r++)n[r]=t<0?n[r]*(1-t)|0:(255-n[r])*t+n[r]|0;return DZ.stringify(n,4===n.length?"rgba":"rgb")}},DZ.toHex=function(e){var t=DZ.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},DZ.fastLerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){n=n||[];var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=t[i],s=t[o],l=r-i;return n[0]=IZ(OZ(a[0],s[0],l)),n[1]=IZ(OZ(a[1],s[1],l)),n[2]=IZ(OZ(a[2],s[2],l)),n[3]=EZ(OZ(a[3],s[3],l)),n}},DZ.fastMapToColor=DZ.fastLerp,DZ.lerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=DZ.parse(t[i]),s=DZ.parse(t[o]),l=r-i,u=DZ.stringify([IZ(OZ(a[0],s[0],l)),IZ(OZ(a[1],s[1],l)),IZ(OZ(a[2],s[2],l)),EZ(OZ(a[3],s[3],l))],"rgba");return n?{color:u,leftIndex:i,rightIndex:o,value:r}:u}},DZ.mapToColor=DZ.lerp,DZ.modifyHSL=function(e,t,n,r){if(e=DZ.parse(e))return e=function(e){if(e){var t,n,r=e[0]/255,i=e[1]/255,o=e[2]/255,a=Math.min(r,i,o),s=Math.max(r,i,o),l=s-a,u=(s+a)/2;if(0===l)t=0,n=0;else{n=u<.5?l/(s+a):l/(2-s-a);var c=((s-r)/6+l/2)/l,h=((s-i)/6+l/2)/l,d=((s-o)/6+l/2)/l;r===s?t=d-h:i===s?t=1/3+c-d:o===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var p=[360*t,n,u];return null!=e[3]&&p.push(e[3]),p}}(e),null!=t&&(e[0]=function(e){return(e=Math.round(e))<0?0:e>360?360:e}(t)),null!=n&&(e[1]=NZ(n)),null!=r&&(e[2]=NZ(r)),DZ.stringify(FZ(e),"rgba")},DZ.modifyAlpha=function(e,t){if((e=DZ.parse(e))&&null!=t)return e[3]=EZ(t),DZ.stringify(e,"rgba")},DZ.stringify=function(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}};var GZ=DZ.parseToFloat,HZ={};function UZ(e){var t=Object.keys(e);t.sort();for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e[i];null===o?n.push(i):n.push(i+" "+o.toString())}return n.join("\n")}var WZ,jZ=wY.extend((function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}}),(function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)}),{precision:"highp",setUniform:function(e,t){void 0===t&&console.warn('Uniform value "'+e+'" is undefined');var n=this.uniforms[e];n&&("string"==typeof t&&(t=GZ(t)||t),n.value=t,this.autoUpdateTextureStatus&&"t"===n.type&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var n=e[t];this.setUniform(t,n)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var n in e){var r=e[n];this.setUniform(n,r)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var r=this.uniforms;this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t}),this);var i=this.vertexDefines,o=this.fragmentDefines;if(this.vertexDefines=bY.clone(e.vertexDefines),this.fragmentDefines=bY.clone(e.fragmentDefines),t){for(var a in n)r[a]&&(r[a].value=n[a].value);bY.defaults(this.vertexDefines,i),bY.defaults(this.fragmentDefines,o)}var s={};for(var l in e.textures)s[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=bY.clone(this.vertexDefines),e.fragmentDefines=bY.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,n){var r=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(n=t,t=e,e="both"),n=null!=n?n:null,"vertex"!==e&&"both"!==e||r[t]!==n&&(r[t]=n,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==n&&(i[t]=n,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.enableTexture(e[t]);else{var n=this._textureStatus[e];if(n)n.enabled||(n.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this._programKey=""},disableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.disableTexture(e[t]);else{var n=this._textureStatus[e];if(n)!n.enabled||(n.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this._programKey=""},isTextureEnabled:function(e){var t=this._textureStatus;return!!t[e]&&t[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var n in t)t[n].enabled&&e.push(n);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(e,t,n){n.sort();for(var r=[],i=0;i<n.length;i++){var o=n[i];r.push(o)}var a=UZ(e)+"\n"+UZ(t)+"\n"+r.join("\n");if(HZ[a])return HZ[a];var s=bY.genGUID();return HZ[a]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),XZ=1e-6,YZ=Array,ZZ=Math.random,qZ={};qZ.create=function(){var e=new YZ(2);return e[0]=0,e[1]=0,e},qZ.clone=function(e){var t=new YZ(2);return t[0]=e[0],t[1]=e[1],t},qZ.fromValues=function(e,t){var n=new YZ(2);return n[0]=e,n[1]=t,n},qZ.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},qZ.set=function(e,t,n){return e[0]=t,e[1]=n,e},qZ.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},qZ.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},qZ.sub=qZ.subtract,qZ.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},qZ.mul=qZ.multiply,qZ.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},qZ.div=qZ.divide,qZ.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},qZ.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},qZ.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},qZ.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},qZ.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},qZ.dist=qZ.distance,qZ.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},qZ.sqrDist=qZ.squaredDistance,qZ.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},qZ.len=qZ.length,qZ.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},qZ.sqrLen=qZ.squaredLength,qZ.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},qZ.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},qZ.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},qZ.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},qZ.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},qZ.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},qZ.random=function(e,t){t=t||1;var n=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},qZ.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},qZ.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},qZ.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},qZ.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},qZ.forEach=(WZ=qZ.create(),function(e,t,n,r,i,o){var a,s;for(t||(t=2),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a<s;a+=t)WZ[0]=e[a],WZ[1]=e[a+1],i(WZ,WZ,o),e[a]=WZ[0],e[a+1]=WZ[1];return e});var KZ=function(e,t){e=e||0,t=t||0,this.array=qZ.fromValues(e,t),this._dirty=!0};if(KZ.prototype={constructor:KZ,add:function(e){return qZ.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t){return this.array[0]=e,this.array[1]=t,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this._dirty=!0,this},clone:function(){return new KZ(this.x,this.y)},copy:function(e){return qZ.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return qZ.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return qZ.dist(this.array,e.array)},distance:function(e){return qZ.distance(this.array,e.array)},div:function(e){return qZ.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return qZ.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return qZ.dot(this.array,e.array)},len:function(){return qZ.len(this.array)},length:function(){return qZ.length(this.array)},lerp:function(e,t,n){return qZ.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return qZ.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return qZ.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return qZ.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return qZ.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return qZ.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return qZ.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return qZ.random(this.array,e),this._dirty=!0,this},scale:function(e){return qZ.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return qZ.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return qZ.sqrDist(this.array,e.array)},squaredDistance:function(e){return qZ.squaredDistance(this.array,e.array)},sqrLen:function(){return qZ.sqrLen(this.array)},squaredLength:function(){return qZ.squaredLength(this.array)},sub:function(e){return qZ.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return qZ.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return qZ.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return qZ.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return qZ.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return qZ.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var $Z=KZ.prototype;Object.defineProperty($Z,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty($Z,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}KZ.add=function(e,t,n){return qZ.add(e.array,t.array,n.array),e._dirty=!0,e},KZ.set=function(e,t,n){return qZ.set(e.array,t,n),e._dirty=!0,e},KZ.copy=function(e,t){return qZ.copy(e.array,t.array),e._dirty=!0,e},KZ.cross=function(e,t,n){return qZ.cross(e.array,t.array,n.array),e._dirty=!0,e},KZ.distance=KZ.dist=function(e,t){return qZ.distance(e.array,t.array)},KZ.div=function(e,t,n){return qZ.divide(e.array,t.array,n.array),e._dirty=!0,e},KZ.divide=KZ.div,KZ.dot=function(e,t){return qZ.dot(e.array,t.array)},KZ.len=function(e){return qZ.length(e.array)},KZ.lerp=function(e,t,n,r){return qZ.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},KZ.min=function(e,t,n){return qZ.min(e.array,t.array,n.array),e._dirty=!0,e},KZ.max=function(e,t,n){return qZ.max(e.array,t.array,n.array),e._dirty=!0,e},KZ.mul=function(e,t,n){return qZ.multiply(e.array,t.array,n.array),e._dirty=!0,e},KZ.multiply=KZ.mul,KZ.negate=function(e,t){return qZ.negate(e.array,t.array),e._dirty=!0,e},KZ.normalize=function(e,t){return qZ.normalize(e.array,t.array),e._dirty=!0,e},KZ.random=function(e,t){return qZ.random(e.array,t),e._dirty=!0,e},KZ.scale=function(e,t,n){return qZ.scale(e.array,t.array,n),e._dirty=!0,e},KZ.scaleAndAdd=function(e,t,n,r){return qZ.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},KZ.squaredDistance=KZ.sqrDist=function(e,t){return qZ.sqrDist(e.array,t.array)},KZ.squaredLength=KZ.sqrLen=function(e){return qZ.sqrLen(e.array)},KZ.sub=function(e,t,n){return qZ.subtract(e.array,t.array,n.array),e._dirty=!0,e},KZ.subtract=KZ.sub,KZ.transformMat2=function(e,t,n){return qZ.transformMat2(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat2d=function(e,t,n){return qZ.transformMat2d(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat3=function(e,t,n){return qZ.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},KZ.transformMat4=function(e,t,n){return qZ.transformMat4(e.array,t.array,n.array),e._dirty=!0,e};var JZ={};function QZ(e){for(var t=e.split("\n"),n=0,r=t.length;n<r;n++)t[n]=n+1+": "+t[n];return t.join("\n")}function eq(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),QZ(n)].join("\n")}var tq=new SZ.Float32Array(16),nq=wY.extend({uniformSemantics:{},attributes:{}},(function(){this._locations={},this._textureSlot=0,this._program=null}),{bind:function(e){this._textureSlot=0,e.gl.useProgram(this._program)},hasUniform:function(e){var t=this._locations[e];return null!=t},useTextureSlot:function(e,t,n){t&&(e.gl.activeTexture(e.gl.TEXTURE0+n),t.isRenderable()?t.bind(e):t.unbind(e))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(e){this._textureSlot=e||0},takeCurrentTextureSlot:function(e,t){var n=this._textureSlot;return this.useTextureSlot(e,t,n),this._textureSlot++,n},setUniform:function(e,t,n,r){var i=this._locations[n];if(null==i)return!1;switch(t){case"m4":if(!(r instanceof Float32Array)){for(var o=0;o<r.length;o++)tq[o]=r[o];r=tq}e.uniformMatrix4fv(i,!1,r);break;case"2i":e.uniform2i(i,r[0],r[1]);break;case"2f":e.uniform2f(i,r[0],r[1]);break;case"3i":e.uniform3i(i,r[0],r[1],r[2]);break;case"3f":e.uniform3f(i,r[0],r[1],r[2]);break;case"4i":e.uniform4i(i,r[0],r[1],r[2],r[3]);break;case"4f":e.uniform4f(i,r[0],r[1],r[2],r[3]);break;case"1i":e.uniform1i(i,r);break;case"1f":e.uniform1f(i,r);break;case"1fv":e.uniform1fv(i,r);break;case"1iv":e.uniform1iv(i,r);break;case"2iv":e.uniform2iv(i,r);break;case"2fv":e.uniform2fv(i,r);break;case"3iv":e.uniform3iv(i,r);break;case"3fv":e.uniform3fv(i,r);break;case"4iv":e.uniform4iv(i,r);break;case"4fv":e.uniform4fv(i,r);break;case"m2":case"m2v":e.uniformMatrix2fv(i,!1,r);break;case"m3":case"m3v":e.uniformMatrix3fv(i,!1,r);break;case"m4v":if(Array.isArray(r)&&Array.isArray(r[0])){var a=new SZ.Float32Array(16*r.length),s=0;for(o=0;o<r.length;o++)for(var l=r[o],u=0;u<16;u++)a[s++]=l[u];e.uniformMatrix4fv(i,!1,a)}else e.uniformMatrix4fv(i,!1,r)}return!0},setUniformOfSemantic:function(e,t,n){var r=this.uniformSemantics[t];return!!r&&this.setUniform(e,r.type,r.symbol,n)},enableAttributes:function(e,t,n){var r,i=e.gl,o=this._program,a=this._locations;(r=n?n.__enabledAttributeList:JZ[e.__uid__])||(r=n?n.__enabledAttributeList=[]:JZ[e.__uid__]=[]);for(var s=[],l=0;l<t.length;l++){var u=t[l];if(this.attributes[u]){var c=a[u];if(null==c){if(-1===(c=i.getAttribLocation(o,u))){s[l]=-1;continue}a[u]=c}s[l]=c,r[c]?r[c]=2:r[c]=1}else s[l]=-1}for(l=0;l<r.length;l++)switch(r[l]){case 1:i.enableVertexAttribArray(l),r[l]=3;break;case 2:r[l]=3;break;case 3:i.disableVertexAttribArray(l),r[l]=0}return s},getAttribLocation:function(e,t){var n=this._locations,r=n[t];return null==r&&(r=e.getAttribLocation(this._program,t),n[t]=r),r},buildProgram:function(e,t,n,r){var i=e.createShader(e.VERTEX_SHADER),o=e.createProgram();e.shaderSource(i,n),e.compileShader(i);var a=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(a,r),e.compileShader(a);var s=eq(e,i,n);if(s)return s;if(s=eq(e,a,r))return s;if(e.attachShader(o,i),e.attachShader(o,a),t.attributeSemantics.POSITION)e.bindAttribLocation(o,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(o,0,l[0])}if(e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),this._program=o,this.vertexCode=n,this.fragmentCode=r,!e.getProgramParameter(o,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(o);for(var u=0;u<t.uniforms.length;u++){var c=t.uniforms[u];this._locations[c]=e.getUniformLocation(o,c)}}}),rq=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function iq(e,t,n){var r={};for(var i in n)r[i+"_COUNT"]=n[i];return e.replace(rq,(function(e,n,i,o){var a="";isNaN(n)&&(n=n in t?t[n]:r[n]),isNaN(i)&&(i=i in t?t[i]:r[i]);for(var s=parseInt(n);s<parseInt(i);s++)a+="{"+o.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return a}))}function oq(e,t,n){var r=[];if(t)for(var i in t){var o=t[i];o>0&&r.push("#define "+i.toUpperCase()+"_COUNT "+o)}if(n)for(var a=0;a<n.length;a++){var s=n[a];r.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in e){var l=e[s];null===l?r.push("#define "+s):r.push("#define "+s+" "+l.toString())}return r.join("\n")}function aq(e){this._renderer=e,this._cache={}}aq.prototype.getProgram=function(e,t,n){var r=this._cache,i=e.isSkinnedMesh&&e.isSkinnedMesh(),o=e.isInstancedMesh&&e.isInstancedMesh(),a="s"+t.shader.shaderID+"m"+t.getProgramKey();if(n&&(a+="se"+n.getProgramKey(e.lightGroup)),i&&(a+=",sk"+e.joints.length),o&&(a+=",is"),y=r[a])return y;var s=n?n.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,c=t.getEnabledTextures(),h="";if(i){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),h+="\n"+oq(d)+"\n"}o&&(h+="\n#define INSTANCING\n");var p=h+oq(t.vertexDefines,s,c),f=h+oq(t.fragmentDefines,s,c),g=p+"\n"+t.shader.vertex,m=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(e){return null!=l.getGLExtension(e)}));m.indexOf("EXT_shader_texture_lod")>=0&&(f+="\n#define SUPPORT_TEXTURE_LOD"),m.indexOf("OES_standard_derivatives")>=0&&(f+="\n#define SUPPORT_STANDARD_DERIVATIVES");var v,y,_=function(e){for(var t=[],n=0;n<e.length;n++)t.push("#extension GL_"+e[n]+" : enable");return t.join("\n")}(m)+"\n"+(["precision",v=t.precision,"float"].join(" ")+";\n"+["precision",v,"int"].join(" ")+";\n"+["precision",v,"sampler2D"].join(" ")+";\n\n")+f+"\n"+t.shader.fragment,x=iq(g,t.vertexDefines,s),b=iq(_,t.fragmentDefines,s);(y=new nq).uniformSemantics=t.shader.uniformSemantics,y.attributes=t.shader.attributes;var w=y.buildProgram(u,t.shader,x,b);return y.__error=w,r[a]=y,y};var sq=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,lq=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,uq=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,cq={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function hq(e){for(var t=[],n=0;n<e;n++)t[n]=0;return t}var dq={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return hq(2)},vec3:function(){return hq(3)},vec4:function(){return hq(4)},ivec2:function(){return hq(2)},ivec3:function(){return hq(3)},ivec4:function(){return hq(4)},mat2:function(){return hq(4)},mat3:function(){return hq(9)},mat4:function(){return hq(16)},array:function(){return[]}},pq=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],fq=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],gq=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],mq={vec4:4,vec3:3,vec2:2,float:1},vq={},yq={};function _q(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function xq(){console.error("Wrong uniform/attributes syntax")}function bq(e,t){for(var n=/[,=\(\):]/,r=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),i=[],o=0;o<r.length;o++)r[o].match(n)?i.push(r[o].charAt(0),r[o].slice(1)):i.push(r[o]);var a,s=0,l={},u=null;function c(e){e||xq();var t=e.match(/\[(.*?)\]/);a=e.replace(/\[(.*?)\]/,""),l[a]={},t&&(l[a].isArray=!0,l[a].arraySize=t[1])}c((r=i)[0]);for(o=1;o<r.length;o++){var h=r[o];if(h)if("="!==h)if(":"!==h)if(","!==h)if(")"!==h)if("("!==h)if(h.indexOf("vec")>=0){if(1!==s&&4!==s){xq();break}s=2,u=[]}else if(1!==s)if(4!==s)c(h),s=0;else{var d=h;pq.indexOf(d)>=0||fq.indexOf(d)>=0||gq.indexOf(d)>=0?l[a].semantic=d:"ignore"===d||"unconfigurable"===d?l[a].ignore=!0:l[a].value="bool"===e?"true"===d:parseFloat(d)}else l[a].value="bool"===e?"true"===h:parseFloat(h),u=null;else{if(2!==s){xq();break}if(!(u instanceof Array)){xq();break}u.push(+r[++o])}else l[a].value=new SZ.Float32Array(u),u=null,s=5;else if(2===s){if(!(u instanceof Array)){xq();break}u.push(+r[++o])}else s=5;else s=4;else{if(0!==s&&3!==s){xq();break}s=1}}return l}function wq(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=_q(e),t=_q(t),this._shaderID=function(e,t){var n="vertex:"+e+"fragment:"+t;if(vq[n])return vq[n];var r=bY.genGUID();return vq[n]=r,yq[r]={vertex:e,fragment:t},r}(e,t),this._vertexCode=wq.parseImport(e),this._fragmentCode=wq.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}wq.prototype={constructor:wq,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},_parseImport:function(){this._vertexCode=wq.parseImport(this.vertex),this._fragmentCode=wq.parseImport(this.fragment)},_addSemanticUniform:function(e,t,n){if(pq.indexOf(n)>=0)this.attributeSemantics[n]={symbol:e,type:t};else if(gq.indexOf(n)>=0){var r=!1,i=n;n.match(/TRANSPOSE$/)&&(r=!0,i=n.slice(0,-9)),this.matrixSemantics[n]={symbol:e,type:t,isTranspose:r,semanticNoTranspose:i}}else fq.indexOf(n)>=0&&(this.uniformSemantics[n]={symbol:e,type:t})},_addMaterialUniform:function(e,t,n,r,i,o){o[e]={type:n,value:i?dq.array:r||dq[t],semantic:null}},_parseUniforms:function(){var e={},t=this,n="vertex";function r(e){return null!=e?function(){return e}:null}function i(i,o,a){var s=bq(o,a),l=[];for(var u in s){var c=s[u],h=c.semantic,d=u,p=cq[o],f=r(s[u].value);s[u].isArray&&(d+="["+s[u].arraySize+"]",p+="v"),l.push(d),t._uniformList.push(u),c.ignore||("sampler2D"!==o&&"samplerCube"!==o||(t.textures[u]={shaderType:n,type:o}),h?t._addSemanticUniform(u,p,h):t._addMaterialUniform(u,o,p,f,s[u].isArray,e))}return l.length>0?"uniform "+o+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(sq,i),n="fragment",this._fragmentCode=this._fragmentCode.replace(sq,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(lq,(function(n,r,i){var o=bq(r,i),a=mq[r]||1,s=[];for(var l in o){var u=o[l].semantic;if(e[l]={type:"float",size:a,semantic:u||null},u){if(pq.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:l,type:r}}s.push(l)}return"attribute "+r+" "+s.join(",")+";\n"})),this.attributes=e},_parseDefines:function(){var e=this,t="vertex";function n(n,r,i){var o="vertex"===t?e.vertexDefines:e.fragmentDefines;return o[r]||(o[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(uq,n),t="fragment",this._fragmentCode=this._fragmentCode.replace(uq,n)},clone:function(){var e=yq[this._shaderID];return new wq(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(wq.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(wq.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(wq.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(wq.prototype,"uniforms",{get:function(){return this._uniformList}}));var Sq=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;wq.parseImport=function(e){return e=e.replace(Sq,(function(e,t,n){return(e=wq.source(n))?wq.parseImport(e):(console.error('Shader chunk "'+n+'" not existed in library'),"")}))};var Tq=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;wq.import=function(e){e.replace(Tq,(function(e,t,n,r){if(r=r.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var i,o=n.split("."),a=wq.codes,s=0;s<o.length-1;)a[i=o[s++]]||(a[i]={}),a=a[i];a[i=o[s]]=r}return r}))},wq.codes={},wq.source=function(e){for(var t=e.split("."),n=wq.codes,r=0;n&&r<t.length;){n=n[t[r++]]}return"string"!=typeof n?(console.error('Shader "'+e+'" not existed in library'),""):n};var Mq="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",Cq={create:function(){var e=new YZ(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},clone:function(e){var t=new YZ(16);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(i*A-r*I-o*D)*E,e[2]=(g*S-m*w+v*b)*E,e[3]=(d*w-h*S-p*b)*E,e[4]=(l*C-a*I-u*M)*E,e[5]=(n*I-i*C+o*M)*E,e[6]=(m*x-f*S-v*_)*E,e[7]=(c*S-d*x+p*_)*E,e[8]=(a*A-s*C+u*T)*E,e[9]=(r*C-n*A-o*T)*E,e[10]=(f*w-g*x+v*y)*E,e[11]=(h*x-c*w-p*y)*E,e[12]=(s*M-a*D-l*T)*E,e[13]=(n*D-r*M+i*T)*E,e[14]=(g*_-f*b-m*y)*E,e[15]=(c*b-h*_+d*y)*E,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15];return e[0]=s*(d*v-p*m)-h*(l*v-u*m)+g*(l*p-u*d),e[1]=-(r*(d*v-p*m)-h*(i*v-o*m)+g*(i*p-o*d)),e[2]=r*(l*v-u*m)-s*(i*v-o*m)+g*(i*u-o*l),e[3]=-(r*(l*p-u*d)-s*(i*p-o*d)+h*(i*u-o*l)),e[4]=-(a*(d*v-p*m)-c*(l*v-u*m)+f*(l*p-u*d)),e[5]=n*(d*v-p*m)-c*(i*v-o*m)+f*(i*p-o*d),e[6]=-(n*(l*v-u*m)-a*(i*v-o*m)+f*(i*u-o*l)),e[7]=n*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(h*v-p*g)-c*(s*v-u*g)+f*(s*p-u*h),e[9]=-(n*(h*v-p*g)-c*(r*v-o*g)+f*(r*p-o*h)),e[10]=n*(s*v-u*g)-a*(r*v-o*g)+f*(r*u-o*s),e[11]=-(n*(s*p-u*h)-a*(r*p-o*h)+c*(r*u-o*s)),e[12]=-(a*(h*m-d*g)-c*(s*m-l*g)+f*(s*d-l*h)),e[13]=n*(h*m-d*g)-c*(r*m-i*g)+f*(r*d-i*h),e[14]=-(n*(s*m-l*g)-a*(r*m-i*g)+f*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15];return(t*a-n*o)*(h*m-d*g)-(t*s-r*o)*(c*m-d*f)+(t*l-i*o)*(c*g-h*f)+(n*s-r*a)*(u*m-d*p)-(n*l-i*a)*(u*g-h*p)+(r*l-i*s)*(u*f-c*p)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],g=t[12],m=t[13],v=t[14],y=t[15],_=n[0],x=n[1],b=n[2],w=n[3];return e[0]=_*r+x*s+b*h+w*g,e[1]=_*i+x*l+b*d+w*m,e[2]=_*o+x*u+b*p+w*v,e[3]=_*a+x*c+b*f+w*y,_=n[4],x=n[5],b=n[6],w=n[7],e[4]=_*r+x*s+b*h+w*g,e[5]=_*i+x*l+b*d+w*m,e[6]=_*o+x*u+b*p+w*v,e[7]=_*a+x*c+b*f+w*y,_=n[8],x=n[9],b=n[10],w=n[11],e[8]=_*r+x*s+b*h+w*g,e[9]=_*i+x*l+b*d+w*m,e[10]=_*o+x*u+b*p+w*v,e[11]=_*a+x*c+b*f+w*y,_=n[12],x=n[13],b=n[14],w=n[15],e[12]=_*r+x*s+b*h+w*g,e[13]=_*i+x*l+b*d+w*m,e[14]=_*o+x*u+b*p+w*v,e[15]=_*a+x*c+b*f+w*y,e},multiplyAffine:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[4],s=t[5],l=t[6],u=t[8],c=t[9],h=t[10],d=t[12],p=t[13],f=t[14],g=n[0],m=n[1],v=n[2];return e[0]=g*r+m*a+v*u,e[1]=g*i+m*s+v*c,e[2]=g*o+m*l+v*h,g=n[4],m=n[5],v=n[6],e[4]=g*r+m*a+v*u,e[5]=g*i+m*s+v*c,e[6]=g*o+m*l+v*h,g=n[8],m=n[9],v=n[10],e[8]=g*r+m*a+v*u,e[9]=g*i+m*s+v*c,e[10]=g*o+m*l+v*h,g=n[12],m=n[13],v=n[14],e[12]=g*r+m*a+v*u+d,e[13]=g*i+m*s+v*c+p,e[14]=g*o+m*l+v*h+f,e}};Cq.mul=Cq.multiply,Cq.mulAffine=Cq.multiplyAffine,Cq.translate=function(e,t,n){var r,i,o,a,s,l,u,c,h,d,p,f,g=n[0],m=n[1],v=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*v+t[12],e[13]=t[1]*g+t[5]*m+t[9]*v+t[13],e[14]=t[2]*g+t[6]*m+t[10]*v+t[14],e[15]=t[3]*g+t[7]*m+t[11]*v+t[15]):(r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*g+s*m+h*v+t[12],e[13]=i*g+l*m+d*v+t[13],e[14]=o*g+u*m+p*v+t[14],e[15]=a*g+c*m+f*v+t[15]),e},Cq.scale=function(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Cq.rotate=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x,b,w,S,T,M,C,D,A=r[0],I=r[1],E=r[2],L=Math.sqrt(A*A+I*I+E*E);return Math.abs(L)<XZ?null:(A*=L=1/L,I*=L,E*=L,i=Math.sin(n),a=1-(o=Math.cos(n)),s=t[0],l=t[1],u=t[2],c=t[3],h=t[4],d=t[5],p=t[6],f=t[7],g=t[8],m=t[9],v=t[10],y=t[11],_=A*A*a+o,x=I*A*a+E*i,b=E*A*a-I*i,w=A*I*a-E*i,S=I*I*a+o,T=E*I*a+A*i,M=A*E*a+I*i,C=I*E*a-A*i,D=E*E*a+o,e[0]=s*_+h*x+g*b,e[1]=l*_+d*x+m*b,e[2]=u*_+p*x+v*b,e[3]=c*_+f*x+y*b,e[4]=s*w+h*S+g*T,e[5]=l*w+d*S+m*T,e[6]=u*w+p*S+v*T,e[7]=c*w+f*S+y*T,e[8]=s*M+h*C+g*D,e[9]=l*M+d*C+m*D,e[10]=u*M+p*C+v*D,e[11]=c*M+f*C+y*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Cq.rotateX=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e},Cq.rotateY=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e},Cq.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},Cq.fromRotationTranslation=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,p=i*l,f=i*u,g=o*u,m=a*s,v=a*l,y=a*u;return e[0]=1-(p+g),e[1]=h+y,e[2]=d-v,e[3]=0,e[4]=h-y,e[5]=1-(c+g),e[6]=f+m,e[7]=0,e[8]=d+v,e[9]=f-m,e[10]=1-(c+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},Cq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[1]=c+v,e[2]=d-m,e[3]=0,e[4]=c-v,e[5]=1-u-f,e[6]=p+g,e[7]=0,e[8]=d+m,e[9]=p-g,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Cq.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},Cq.perspective=function(e,t,n,r,i){var o=1/Math.tan(t/2),a=1/(r-i);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*a,e[15]=0,e},Cq.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},Cq.lookAt=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f=t[0],g=t[1],m=t[2],v=r[0],y=r[1],_=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(f-x)<XZ&&Math.abs(g-b)<XZ&&Math.abs(m-w)<XZ?Cq.identity(e):(c=f-x,h=g-b,d=m-w,i=y*(d*=p=1/Math.sqrt(c*c+h*h+d*d))-_*(h*=p),o=_*(c*=p)-v*d,a=v*h-y*c,(p=Math.sqrt(i*i+o*o+a*a))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(p=Math.sqrt(s*s+l*l+u*u))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*f+o*g+a*m),e[13]=-(s*f+l*g+u*m),e[14]=-(c*f+h*g+d*m),e[15]=1,e)},Cq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))};var Dq={create:function(){var e=new YZ(3);return e[0]=0,e[1]=0,e[2]=0,e},clone:function(e){var t=new YZ(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},fromValues:function(e,t,n){var r=new YZ(3);return r[0]=e,r[1]=t,r[2]=n,r},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set:function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}};Dq.sub=Dq.subtract,Dq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e},Dq.mul=Dq.multiply,Dq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},Dq.div=Dq.divide,Dq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},Dq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},Dq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},Dq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},Dq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},Dq.dist=Dq.distance,Dq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},Dq.sqrDist=Dq.squaredDistance,Dq.length=function(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)},Dq.len=Dq.length,Dq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Dq.sqrLen=Dq.squaredLength,Dq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Dq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Dq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o),e},Dq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},Dq.cross=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e},Dq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},Dq.random=function(e,t){t=t||1;var n=2*ZZ()*Math.PI,r=2*ZZ()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},Dq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e},Dq.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},Dq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Dq.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Dq.forEach=function(){var e=Dq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=3),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),Dq.angle=function(e,t){var n=Dq.fromValues(e[0],e[1],e[2]),r=Dq.fromValues(t[0],t[1],t[2]);Dq.normalize(n,n),Dq.normalize(r,r);var i=Dq.dot(n,r);return i>1?0:Math.acos(i)},wq.import(Mq);var Aq=Cq.create,Iq={};function Eq(e){return e.material}function Lq(e,t,n){return t.uniforms[n].value}function Nq(e,t,n,r){return n!==r}function Pq(e){return!0}function Oq(){}var Rq={float:KY,byte:WY,ubyte:jY,short:XY,ushort:YY};function kq(e,t,n){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=n,this.vao=null}function zq(e){var t,n;this.bind=function(e){t||((t=SZ.createCanvas()).width=t.height=1,t.getContext("2d"));var r=e.gl,i=!n;i&&(n=r.createTexture()),r.bindTexture(r.TEXTURE_2D,n),i&&r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var Vq=wY.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=SZ.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new MY(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new aq(this),this._placeholderTexture=new zq}),{resize:function(e,t){var n=this.canvas,r=this.devicePixelRatio;null!=e?(n.style&&(n.style.width=e+"px",n.style.height=t+"px"),n.width=e*r,n.height=t*r,this._width=e,this._height=t):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,r,i){if("object"==typeof e){var o=e;e=o.x,t=o.y,n=o.width,r=o.height,i=o.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,r*i),this.viewport={x:e,y:t,width:n,height:r,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,n,r){var i=this.gl,o=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var a=this.viewport,s=!1,l=a.devicePixelRatio;(a.width!==this._width||a.height!==this._height||l&&l!==this.devicePixelRatio||a.x||a.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(a.x*l,a.y*l,a.width*l,a.height*l)),i.clearColor(o[0],o[1],o[2],o[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(n||e.update(!1),e.updateLights(),t=t||e.getMainCamera()){t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var c=u.opaque,h=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),r?(this.renderPreZ(c,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var p=Aq(),f=Dq.create(),g=0;g<h.length;g++){var m=h[g];Cq.multiplyAffine(p,t.viewMatrix.array,m.worldTransform.array),Dq.transformMat4(f,m.position.array,p),m.__depth=f[2]}this.renderPass(c,t,{getMaterial:function(e){return d||e.material},sortCompare:this.opaqueSortCompare}),this.renderPass(h,t,{getMaterial:function(e){return d||e.material},sortCompare:this.transparentSortCompare}),e.trigger("afterrender",this,e,t,u),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(e,t,n){return t=t||e.material,this._programMgr.getProgram(e,t,n)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Iq[e.__uid__])return;if(Iq[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,n){var r=n&&n.getMaterial||Eq;t=t||null;for(var i=0;i<e.length;i++){var o=e[i],a=r.call(this,o);if(i>0){var s=e[i-1],l=s.joints?s.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===s.material&&o.lightGroup===s.lightGroup){o.__program=s.__program;continue}}var u=this._programMgr.getProgram(o,a,t);this.validateProgram(u),o.__program=u}},renderPass:function(e,t,n){this.trigger("beforerenderpass",this,e,t,n),(n=n||{}).getMaterial=n.getMaterial||Eq,n.getUniform=n.getUniform||Lq,n.isMaterialChanged=n.isMaterialChanged||Nq,n.beforeRender=n.beforeRender||Oq,n.afterRender=n.afterRender||Oq;var r=n.ifRender||Pq;this.updatePrograms(e,this._sceneRendering,n),n.sortCompare&&e.sort(n.sortCompare);var i=this.viewport,o=i.devicePixelRatio,a=[i.x*o,i.y*o,i.width*o,i.height*o],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],u=[a[2],a[3]],c=Date.now();t?(Cq.copy(Bq.VIEW,t.viewMatrix.array),Cq.copy(Bq.PROJECTION,t.projectionMatrix.array),Cq.copy(Bq.VIEWINVERSE,t.worldTransform.array)):(Cq.identity(Bq.VIEW),Cq.identity(Bq.PROJECTION),Cq.identity(Bq.VIEWINVERSE)),Cq.multiply(Bq.VIEWPROJECTION,Bq.PROJECTION,Bq.VIEW),Cq.invert(Bq.PROJECTIONINVERSE,Bq.PROJECTION),Cq.invert(Bq.VIEWPROJECTIONINVERSE,Bq.VIEWPROJECTION);for(var h,d,p,f,g,m,v,y,_,x,b,w,S=this.gl,T=this._sceneRendering,M=null,C=0;C<e.length;C++){var D,A=e[C],I=null!=A.worldTransform;if(r(A)){I&&(D=A.isSkinnedMesh&&A.isSkinnedMesh()?A.offsetMatrix?A.offsetMatrix.array:Bq.IDENTITY:A.worldTransform.array);var E=A.geometry,L=n.getMaterial.call(this,A),N=A.__program,P=L.shader,O=E.__uid__+"-"+N.__uid__,R=O!==x;x=O,I&&(Cq.copy(Bq.WORLD,D),Cq.multiply(Bq.WORLDVIEWPROJECTION,Bq.VIEWPROJECTION,D),Cq.multiplyAffine(Bq.WORLDVIEW,Bq.VIEW,D),(P.matrixSemantics.WORLDINVERSE||P.matrixSemantics.WORLDINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDINVERSE,D),(P.matrixSemantics.WORLDVIEWINVERSE||P.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDVIEWINVERSE,Bq.WORLDVIEW),(P.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||P.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Cq.invert(Bq.WORLDVIEWPROJECTIONINVERSE,Bq.WORLDVIEWPROJECTION)),A.beforeRender&&A.beforeRender(this),n.beforeRender.call(this,A,L,h);var k=N!==d;k?(N.bind(this),N.setUniformOfSemantic(S,"VIEWPORT",a),N.setUniformOfSemantic(S,"WINDOW_SIZE",l),t&&(N.setUniformOfSemantic(S,"NEAR",t.near),N.setUniformOfSemantic(S,"FAR",t.far)),N.setUniformOfSemantic(S,"DEVICEPIXELRATIO",o),N.setUniformOfSemantic(S,"TIME",c),N.setUniformOfSemantic(S,"VIEWPORT_SIZE",u),T&&T.setLightUniforms(N,A.lightGroup,this)):N=d,(k||n.isMaterialChanged(A,p,L,h))&&(L.depthTest!==f&&(L.depthTest?S.enable(S.DEPTH_TEST):S.disable(S.DEPTH_TEST),f=L.depthTest),L.depthMask!==g&&(S.depthMask(L.depthMask),g=L.depthMask),L.transparent!==_&&(L.transparent?S.enable(S.BLEND):S.disable(S.BLEND),_=L.transparent),L.transparent&&(L.blend?L.blend(S):(S.blendEquationSeparate(S.FUNC_ADD,S.FUNC_ADD),S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(A,L,N,p||null,h||null,d||null,n.getUniform),h=L);var z=P.matrixSemanticKeys;if(I)for(var V=0;V<z.length;V++){var B=z[V],F=P.matrixSemantics[B],G=Bq[B];if(F.isTranspose){var H=Bq[F.semanticNoTranspose];Cq.transpose(G,H)}N.setUniform(S,F.type,F.symbol,G)}A.cullFace!==v&&(v=A.cullFace,S.cullFace(v)),A.frontFace!==y&&(y=A.frontFace,S.frontFace(y)),A.culling!==m&&((m=A.culling)?S.enable(S.CULL_FACE):S.disable(S.CULL_FACE)),this._updateSkeleton(A,N,w),R&&(b=this._bindVAO(M,P,E,N)),this._renderObject(A,b,N),n.afterRender(this,A),A.afterRender&&A.afterRender(this),d=N,p=A}}this.trigger("afterrenderpass",this,e,t,n)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,n){var r=this.gl,i=e.skeleton;if(i)if(i.update(),e.joints.length>this.getMaxJointNumber()){var o=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,o,n),t.setUniform(r,"1i","skinMatricesTexture",n),t.setUniform(r,"1f","skinMatricesTextureSize",o.width)}else{var a=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(r,"SKIN_MATRIX",a)}},_renderObject:function(e,t,n){var r=this.gl,i=e.geometry,o=e.mode;null==o&&(o=4);var a=null,s=e.isInstancedMesh&&e.isInstancedMesh();if(!s||(a=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(e,n,a)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint")&&i.indices instanceof Uint32Array?r.UNSIGNED_INT:r.UNSIGNED_SHORT;s?a.drawElementsInstancedANGLE(o,t.indicesBuffer.count,u,0,e.getInstanceCount()):r.drawElements(o,t.indicesBuffer.count,u,0)}else s?a.drawArraysInstancedANGLE(o,0,i.vertexCount,e.getInstanceCount()):r.drawArrays(o,0,i.vertexCount);if(s)for(var c=0;c<l.length;c++)r.disableVertexAttribArray(l[c])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(e,t,n){for(var r=this.gl,i=e.getInstancedAttributesBuffers(this),o=[],a=0;a<i.length;a++){var s=i[a],l=t.getAttribLocation(r,s.symbol);if(!(l<0)){var u=Rq[s.type]||r.FLOAT;r.enableVertexAttribArray(l),r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.vertexAttribPointer(l,s.size,u,!1,0,0),n.vertexAttribDivisorANGLE(l,s.divisor),o.push(l)}}return o},_bindMaterial:function(e,t,n,r,i,o,a){for(var s=this.gl,l=o===n,u=n.currentTextureSlot(),c=t.getEnabledUniforms(),h=t.getTextureUniforms(),d=this._placeholderTexture,p=0;p<h.length;p++){var f=a(e,t,v=h[p]);if("t"===(m=t.uniforms[v].type)&&f)f.__slot=-1;else if("tv"===m)for(var g=0;g<f.length;g++)f[g]&&(f[g].__slot=-1)}d.__slot=-1;for(p=0;p<c.length;p++){var m,v=c[p],y=t.uniforms[v],_=(f=a(e,t,v),"t"===(m=y.type));if(_&&(f&&f.isRenderable()||(f=d)),i&&l){var x=a(r,i,v);if(_&&(x&&x.isRenderable()||(x=d)),x===f){if(_)n.takeCurrentTextureSlot(this,null);else if("tv"===m&&f)for(g=0;g<f.length;g++)n.takeCurrentTextureSlot(this,null);continue}}if(null!=f)if(_)if(f.__slot<0){var b=n.currentTextureSlot();n.setUniform(s,"1i",v,b)&&(n.takeCurrentTextureSlot(this,f),f.__slot=b)}else n.setUniform(s,"1i",v,f.__slot);else if(Array.isArray(f)){if(0===f.length)continue;if("tv"===m){if(!n.hasUniform(v))continue;var w=[];for(g=0;g<f.length;g++){var S=f[g];if(S.__slot<0){b=n.currentTextureSlot();w.push(b),n.takeCurrentTextureSlot(this,S),S.__slot=b}else w.push(S.__slot)}n.setUniform(s,"1iv",v,w)}else n.setUniform(s,y.type,v,f)}else n.setUniform(s,y.type,v,f)}var T=n.currentTextureSlot();return n.resetTextureSlot(u),T},_bindVAO:function(e,t,n,r){var i=!n.dynamic,o=this.gl,a=this.__uid__+"-"+r.__uid__,s=n.__vaoCache[a];if(!s){var l=n.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],c=u.attributeBuffers,h=u.indicesBuffer,d=[],p=[],f=0;f<c.length;f++){var g,m=(w=c[f]).name,v=w.semantic;if(v){var y=t.attributeSemantics[v];g=y&&y.symbol}else g=m;g&&r.attributes[g]&&(d.push(w),p.push(g))}s=new kq(d,p,h),i&&(n.__vaoCache[a]=s)}var _=!0;e&&i&&(null==s.vao?s.vao=e.createVertexArrayOES():_=!1,e.bindVertexArrayOES(s.vao));d=s.availableAttributes,h=s.indicesBuffer;if(_){var x=r.enableAttributes(this,s.availableAttributeSymbols,e&&i&&s);for(f=0;f<d.length;f++){var b=x[f];if(-1!==b){var w,S=(w=d[f]).buffer,T=w.size,M=Rq[w.type]||o.FLOAT;o.bindBuffer(o.ARRAY_BUFFER,S),o.vertexAttribPointer(b,T,M,!1,0,0)}}n.isUseIndices()&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.buffer)}return s},renderPreZ:function(e,t,n){var r=this.gl,i=this._prezMaterial||new jZ({shader:new wq(wq.source("clay.prez.vertex"),wq.source("clay.prez.fragment"))});this._prezMaterial=i,r.colorMask(!1,!1,!1,!1),r.depthMask(!0),this.renderPass(e,n,{ifRender:function(e){return!e.ignorePreZ},isMaterialChanged:function(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)},getUniform:function(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)},getMaterial:function(){return i},sort:this.opaqueSortCompare}),r.colorMask(!0,!0,!0,!0),r.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){e.getParent()&&e.getParent().remove(e);var r={};e.traverse((function(e){var i=e.material;if(e.geometry&&t&&e.geometry.dispose(this),n&&i&&!r[i.__uid__]){for(var o=i.getTextureUniforms(),a=0;a<o.length;a++){var s=o[a],l=i.uniforms[s].value,u=i.uniforms[s].type;if(l)if("t"===u)l.dispose&&l.dispose(this);else if("tv"===u)for(var c=0;c<l.length;c++)l[c]&&l[c].dispose&&l[c].dispose(this)}r[i.__uid__]=!0}e.dispose&&e.dispose(this)}),this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new KZ),t=this._height-t;var r=this.viewport,i=n.array;return i[0]=(e-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(t-r.y)/r.height,i[1]=2*i[1]-1,n}});Vq.opaqueSortCompare=Vq.prototype.opaqueSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.renderOrder-t.renderOrder},Vq.transparentSortCompare=Vq.prototype.transparentSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var Bq={IDENTITY:Aq(),WORLD:Aq(),VIEW:Aq(),PROJECTION:Aq(),WORLDVIEW:Aq(),VIEWPROJECTION:Aq(),WORLDVIEWPROJECTION:Aq(),WORLDINVERSE:Aq(),VIEWINVERSE:Aq(),PROJECTIONINVERSE:Aq(),WORLDVIEWINVERSE:Aq(),VIEWPROJECTIONINVERSE:Aq(),WORLDVIEWPROJECTIONINVERSE:Aq(),WORLDTRANSPOSE:Aq(),VIEWTRANSPOSE:Aq(),PROJECTIONTRANSPOSE:Aq(),WORLDVIEWTRANSPOSE:Aq(),VIEWPROJECTIONTRANSPOSE:Aq(),WORLDVIEWPROJECTIONTRANSPOSE:Aq(),WORLDINVERSETRANSPOSE:Aq(),VIEWINVERSETRANSPOSE:Aq(),PROJECTIONINVERSETRANSPOSE:Aq(),WORLDVIEWINVERSETRANSPOSE:Aq(),VIEWPROJECTIONINVERSETRANSPOSE:Aq(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Aq()};Vq.COLOR_BUFFER_BIT=AY,Vq.DEPTH_BUFFER_BIT=CY,Vq.STENCIL_BUFFER_BIT=DY;var Fq=function(e,t,n){e=e||0,t=t||0,n=n||0,this.array=Dq.fromValues(e,t,n),this._dirty=!0};Fq.prototype={constructor:Fq,add:function(e){return Dq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new Fq(this.x,this.y,this.z)},copy:function(e){return Dq.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return Dq.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return Dq.dist(this.array,e.array)},distance:function(e){return Dq.distance(this.array,e.array)},div:function(e){return Dq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Dq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Dq.dot(this.array,e.array)},len:function(){return Dq.len(this.array)},length:function(){return Dq.length(this.array)},lerp:function(e,t,n){return Dq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Dq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Dq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Dq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Dq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Dq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Dq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Dq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Dq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Dq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Dq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Dq.squaredDistance(this.array,e.array)},sqrLen:function(){return Dq.sqrLen(this.array)},squaredLength:function(){return Dq.squaredLength(this.array)},sub:function(e){return Dq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Dq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return Dq.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Dq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Dq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(0===(e=e.array)[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){Fq.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){Fq.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Gq=Object.defineProperty;if(Gq){var Hq=Fq.prototype;Gq(Hq,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Gq(Hq,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Gq(Hq,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}function Uq(e,t,n){return e<t?t:e>n?n:e}Fq.add=function(e,t,n){return Dq.add(e.array,t.array,n.array),e._dirty=!0,e},Fq.set=function(e,t,n,r){Dq.set(e.array,t,n,r),e._dirty=!0},Fq.copy=function(e,t){return Dq.copy(e.array,t.array),e._dirty=!0,e},Fq.cross=function(e,t,n){return Dq.cross(e.array,t.array,n.array),e._dirty=!0,e},Fq.distance=Fq.dist=function(e,t){return Dq.distance(e.array,t.array)},Fq.div=function(e,t,n){return Dq.divide(e.array,t.array,n.array),e._dirty=!0,e},Fq.divide=Fq.div,Fq.dot=function(e,t){return Dq.dot(e.array,t.array)},Fq.len=function(e){return Dq.length(e.array)},Fq.lerp=function(e,t,n,r){return Dq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},Fq.min=function(e,t,n){return Dq.min(e.array,t.array,n.array),e._dirty=!0,e},Fq.max=function(e,t,n){return Dq.max(e.array,t.array,n.array),e._dirty=!0,e},Fq.mul=function(e,t,n){return Dq.multiply(e.array,t.array,n.array),e._dirty=!0,e},Fq.multiply=Fq.mul,Fq.negate=function(e,t){return Dq.negate(e.array,t.array),e._dirty=!0,e},Fq.normalize=function(e,t){return Dq.normalize(e.array,t.array),e._dirty=!0,e},Fq.random=function(e,t){return Dq.random(e.array,t),e._dirty=!0,e},Fq.scale=function(e,t,n){return Dq.scale(e.array,t.array,n),e._dirty=!0,e},Fq.scaleAndAdd=function(e,t,n,r){return Dq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},Fq.squaredDistance=Fq.sqrDist=function(e,t){return Dq.sqrDist(e.array,t.array)},Fq.squaredLength=Fq.sqrLen=function(e){return Dq.sqrLen(e.array)},Fq.sub=function(e,t,n){return Dq.subtract(e.array,t.array,n.array),e._dirty=!0,e},Fq.subtract=Fq.sub,Fq.transformMat3=function(e,t,n){return Dq.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},Fq.transformMat4=function(e,t,n){return Dq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},Fq.transformQuat=function(e,t,n){return Dq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var Wq=Math.atan2,jq=Math.asin,Xq=Math.abs;Fq.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=t[0],o=t[1],a=t[2],s=t[3],l=i*i,u=o*o,c=a*a,h=s*s;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=Wq(2*(i*s-o*a),h-l-u+c),r[1]=jq(Uq(2*(i*a+o*s),-1,1)),r[2]=Wq(2*(a*s-i*o),h+l-u-c);break;case"YXZ":r[0]=jq(Uq(2*(i*s-o*a),-1,1)),r[1]=Wq(2*(i*a+o*s),h-l-u+c),r[2]=Wq(2*(i*o+a*s),h-l+u-c);break;case"ZXY":r[0]=jq(Uq(2*(i*s+o*a),-1,1)),r[1]=Wq(2*(o*s-a*i),h-l-u+c),r[2]=Wq(2*(a*s-i*o),h-l+u-c);break;case"ZYX":r[0]=Wq(2*(i*s+a*o),h-l-u+c),r[1]=jq(Uq(2*(o*s-i*a),-1,1)),r[2]=Wq(2*(i*o+a*s),h+l-u-c);break;case"YZX":r[0]=Wq(2*(i*s-a*o),h-l+u-c),r[1]=Wq(2*(o*s-i*a),h+l-u-c),r[2]=jq(Uq(2*(i*o+a*s),-1,1));break;case"XZY":r[0]=Wq(2*(i*s+o*a),h-l+u-c),r[1]=Wq(2*(i*a+o*s),h+l-u-c),r[2]=jq(Uq(2*(a*s-i*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},Fq.eulerFromMat3=function(e,t,n){var r=t.array,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7],c=r[2],h=r[5],d=r[8],p=e.array;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":p[1]=jq(Uq(a,-1,1)),Xq(a)<.99999?(p[0]=Wq(-u,d),p[2]=Wq(-o,i)):(p[0]=Wq(h,l),p[2]=0);break;case"YXZ":p[0]=jq(-Uq(u,-1,1)),Xq(u)<.99999?(p[1]=Wq(a,d),p[2]=Wq(s,l)):(p[1]=Wq(-c,i),p[2]=0);break;case"ZXY":p[0]=jq(Uq(h,-1,1)),Xq(h)<.99999?(p[1]=Wq(-c,d),p[2]=Wq(-o,l)):(p[1]=0,p[2]=Wq(s,i));break;case"ZYX":p[1]=jq(-Uq(c,-1,1)),Xq(c)<.99999?(p[0]=Wq(h,d),p[2]=Wq(s,i)):(p[0]=0,p[2]=Wq(-o,l));break;case"YZX":p[2]=jq(Uq(s,-1,1)),Xq(s)<.99999?(p[0]=Wq(-u,l),p[1]=Wq(-c,i)):(p[0]=0,p[1]=Wq(a,d));break;case"XZY":p[2]=jq(-Uq(o,-1,1)),Xq(o)<.99999?(p[0]=Wq(h,l),p[1]=Wq(a,i)):(p[0]=Wq(-u,d),p[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},Object.defineProperties(Fq,{POSITIVE_X:{get:function(){return new Fq(1,0,0)}},NEGATIVE_X:{get:function(){return new Fq(-1,0,0)}},POSITIVE_Y:{get:function(){return new Fq(0,1,0)}},NEGATIVE_Y:{get:function(){return new Fq(0,-1,0)}},POSITIVE_Z:{get:function(){return new Fq(0,0,1)}},NEGATIVE_Z:{get:function(){return new Fq(0,0,-1)}},UP:{get:function(){return new Fq(0,1,0)}},ZERO:{get:function(){return new Fq}}});var Yq,Zq,qq,Kq,$q=1e-5,Jq=function(e,t){this.origin=e||new Fq,this.direction=t||new Fq};Jq.prototype={constructor:Jq,intersectPlane:function(e,t){var n=e.normal.array,r=e.distance,i=this.origin.array,o=this.direction.array,a=Dq.dot(n,o);if(0===a)return null;t||(t=new Fq);var s=(Dq.dot(n,i)-r)/a;return Dq.scaleAndAdd(t.array,i,o,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Dq.dot(e.normal.array,this.direction.array);Dq.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Dq.create();return function(t){Dq.sub(e,t,this.origin.array);var n=Dq.dot(e,this.direction.array);if(n<0)return Dq.distance(this.origin.array,t);var r=Dq.lenSquared(e);return Math.sqrt(r-n*n)}}(),intersectSphere:function(){var e=Dq.create();return function(t,n,r){var i=this.origin.array,o=this.direction.array;t=t.array,Dq.sub(e,t,i);var a=Dq.dot(e,o),s=Dq.squaredLength(e)-a*a,l=n*n;if(!(s>l)){var u=Math.sqrt(l-s),c=a-u,h=a+u;return r||(r=new Fq),c<0?h<0?null:(Dq.scaleAndAdd(r.array,i,o,h),r):(Dq.scaleAndAdd(r.array,i,o,c),r)}}}(),intersectBoundingBox:function(e,t){var n,r,i,o,a,s,l=this.direction.array,u=this.origin.array,c=e.min.array,h=e.max.array,d=1/l[0],p=1/l[1],f=1/l[2];if(d>=0?(n=(c[0]-u[0])*d,r=(h[0]-u[0])*d):(r=(c[0]-u[0])*d,n=(h[0]-u[0])*d),p>=0?(i=(c[1]-u[1])*p,o=(h[1]-u[1])*p):(o=(c[1]-u[1])*p,i=(h[1]-u[1])*p),n>o||i>r)return null;if((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),f>=0?(a=(c[2]-u[2])*f,s=(h[2]-u[2])*f):(s=(c[2]-u[2])*f,a=(h[2]-u[2])*f),n>s||a>r)return null;if((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0)return null;var g=n>=0?n:r;return t||(t=new Fq),Dq.scaleAndAdd(t.array,u,l,g),t},intersectTriangle:(Yq=Dq.create(),Zq=Dq.create(),qq=Dq.create(),Kq=Dq.create(),function(e,t,n,r,i,o){var a=this.direction.array,s=this.origin.array;e=e.array,t=t.array,n=n.array,Dq.sub(Yq,t,e),Dq.sub(Zq,n,e),Dq.cross(Kq,Zq,a);var l=Dq.dot(Yq,Kq);if(r){if(l>-1e-5)return null}else if(l>-1e-5&&l<$q)return null;Dq.sub(qq,s,e);var u=Dq.dot(Kq,qq)/l;if(u<0||u>1)return null;Dq.cross(Kq,Yq,qq);var c=Dq.dot(a,Kq)/l;if(c<0||c>1||u+c>1)return null;Dq.cross(Kq,Yq,Zq);var h=-Dq.dot(qq,Kq)/l;return h<0?null:(i||(i=new Fq),o&&Fq.set(o,1-u-c,u,c),Dq.scaleAndAdd(i.array,s,a,h),i)}),applyTransform:function(e){Fq.add(this.direction,this.direction,this.origin),Fq.transformMat4(this.origin,this.origin,e),Fq.transformMat4(this.direction,this.direction,e),Fq.sub(this.direction,this.direction,this.origin),Fq.normalize(this.direction,this.direction)},copy:function(e){Fq.copy(this.origin,e.origin),Fq.copy(this.direction,e.direction)},clone:function(){var e=new Jq;return e.copy(this),e}};var Qq={create:function(){var e=new YZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},clone:function(e){var t=new YZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues:function(e,t,n,r){var i=new YZ(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set:function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}};Qq.sub=Qq.subtract,Qq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},Qq.mul=Qq.multiply,Qq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},Qq.div=Qq.divide,Qq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},Qq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},Qq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},Qq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},Qq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+o*o)},Qq.dist=Qq.distance,Qq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o},Qq.sqrDist=Qq.squaredDistance,Qq.length=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)},Qq.len=Qq.length,Qq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i},Qq.sqrLen=Qq.squaredLength,Qq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},Qq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},Qq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e[3]=t[3]*a),e},Qq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Qq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},Qq.random=function(e,t){return t=t||1,e[0]=ZZ(),e[1]=ZZ(),e[2]=ZZ(),e[3]=ZZ(),Qq.normalize(e,e),Qq.scale(e,e,t),e},Qq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e},Qq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Qq.forEach=function(){var e=Qq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var eK={create:function(){var e=new YZ(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat4:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone:function(e){var t=new YZ(9);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,d=-c*o+s*l,p=u*o-a*l,f=n*h+r*d+i*p;return f?(f=1/f,e[0]=h*f,e[1]=(-c*r+i*u)*f,e[2]=(s*r-i*a)*f,e[3]=d*f,e[4]=(c*n-i*l)*f,e[5]=(-s*n+i*o)*f,e[6]=p*f,e[7]=(-u*n+r*l)*f,e[8]=(a*n-r*o)*f,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8];return t*(u*o-a*l)+n*(-u*i+a*s)+r*(l*i-o*s)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1],f=n[2],g=n[3],m=n[4],v=n[5],y=n[6],_=n[7],x=n[8];return e[0]=d*r+p*a+f*u,e[1]=d*i+p*s+f*c,e[2]=d*o+p*l+f*h,e[3]=g*r+m*a+v*u,e[4]=g*i+m*s+v*c,e[5]=g*o+m*l+v*h,e[6]=y*r+_*a+x*u,e[7]=y*i+_*s+x*c,e[8]=y*o+_*l+x*h,e}};eK.mul=eK.multiply,eK.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+p*a+u,e[7]=d*i+p*s+c,e[8]=d*o+p*l+h,e},eK.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=Math.sin(n),p=Math.cos(n);return e[0]=p*r+d*a,e[1]=p*i+d*s,e[2]=p*o+d*l,e[3]=p*a-d*r,e[4]=p*s-d*i,e[5]=p*l-d*o,e[6]=u,e[7]=c,e[8]=h,e},eK.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},eK.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},eK.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[3]=c-v,e[6]=d+m,e[1]=c+v,e[4]=1-u-f,e[7]=p-g,e[2]=d-m,e[5]=p+g,e[8]=1-u-h,e},eK.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(l*C-a*I-u*M)*E,e[2]=(a*A-s*C+u*T)*E,e[3]=(i*A-r*I-o*D)*E,e[4]=(n*I-i*C+o*M)*E,e[5]=(r*C-n*A-o*T)*E,e[6]=(g*S-m*w+v*b)*E,e[7]=(m*x-f*S-v*_)*E,e[8]=(f*w-g*x+v*y)*E,e):null},eK.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))};var tK,nK,rK,iK,oK={};oK.create=function(){var e=new YZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},oK.rotationTo=(tK=Dq.create(),nK=Dq.fromValues(1,0,0),rK=Dq.fromValues(0,1,0),function(e,t,n){var r=Dq.dot(t,n);return r<-.999999?(Dq.cross(tK,nK,t),Dq.length(tK)<1e-6&&Dq.cross(tK,rK,t),Dq.normalize(tK,tK),oK.setAxisAngle(e,tK,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Dq.cross(tK,t,n),e[0]=tK[0],e[1]=tK[1],e[2]=tK[2],e[3]=1+r,oK.normalize(e,e))}),oK.setAxes=(iK=eK.create(),function(e,t,n,r){return iK[0]=n[0],iK[3]=n[1],iK[6]=n[2],iK[1]=r[0],iK[4]=r[1],iK[7]=r[2],iK[2]=-t[0],iK[5]=-t[1],iK[8]=-t[2],oK.normalize(e,oK.fromMat3(e,iK))}),oK.clone=Qq.clone,oK.fromValues=Qq.fromValues,oK.copy=Qq.copy,oK.set=Qq.set,oK.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},oK.setAxisAngle=function(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e},oK.add=Qq.add,oK.multiply=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e},oK.mul=oK.multiply,oK.scale=Qq.scale,oK.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},oK.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},oK.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},oK.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},oK.dot=Qq.dot,oK.lerp=Qq.lerp,oK.slerp=function(e,t,n,r){var i,o,a,s,l,u=t[0],c=t[1],h=t[2],d=t[3],p=n[0],f=n[1],g=n[2],m=n[3];return(o=u*p+c*f+h*g+d*m)<0&&(o=-o,p=-p,f=-f,g=-g,m=-m),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*u+l*p,e[1]=s*c+l*f,e[2]=s*h+l*g,e[3]=s*d+l*m,e},oK.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},oK.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},oK.length=Qq.length,oK.len=oK.length,oK.squaredLength=Qq.squaredLength,oK.sqrLen=oK.squaredLength,oK.normalize=Qq.normalize,oK.fromMat3=function(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*o+a]-t[3*a+o])*n,e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e};var aK=function(){this._axisX=new Fq,this._axisY=new Fq,this._axisZ=new Fq,this.array=Cq.create(),this._dirty=!0};aK.prototype={constructor:aK,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Cq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new aK).copy(this)},copy:function(e){return Cq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Cq.determinant(this.array)},fromQuat:function(e){return Cq.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return Cq.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return aK.fromMat2d(this,e),this},frustum:function(e,t,n,r,i,o){return Cq.frustum(this.array,e,t,n,r,i,o),this._dirty=!0,this},identity:function(){return Cq.identity(this.array),this._dirty=!0,this},invert:function(){return Cq.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,n){return Cq.lookAt(this.array,e.array,t.array,n.array),this._dirty=!0,this},mul:function(e){return Cq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Cq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Cq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Cq.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,n,r,i,o){return Cq.ortho(this.array,e,t,n,r,i,o),this._dirty=!0,this},perspective:function(e,t,n,r){return Cq.perspective(this.array,e,t,n,r),this._dirty=!0,this},rotate:function(e,t){return Cq.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return Cq.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return Cq.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return Cq.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Cq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Cq.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return Cq.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:function(){var e=Dq.create(),t=Dq.create(),n=Dq.create(),r=eK.create();return function(i,o,a){var s=this.array;Dq.set(e,s[0],s[1],s[2]),Dq.set(t,s[4],s[5],s[6]),Dq.set(n,s[8],s[9],s[10]);var l=Dq.length(e),u=Dq.length(t),c=Dq.length(n);this.determinant()<0&&(l=-l),i&&i.set(l,u,c),a.set(s[12],s[13],s[14]),eK.fromMat4(r,s),r[0]/=l,r[1]/=l,r[2]/=l,r[3]/=u,r[4]/=u,r[5]/=u,r[6]/=c,r[7]/=c,r[8]/=c,oK.fromMat3(o.array,r),oK.normalize(o.array,o.array),o._dirty=!0,a._dirty=!0}}(),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var sK=Object.defineProperty;if(sK){var lK=aK.prototype;sK(lK,"z",{get:function(){var e=this.array;return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this.array;e=e.array,t[8]=e[0],t[9]=e[1],t[10]=e[2],this._dirty=!0}}),sK(lK,"y",{get:function(){var e=this.array;return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this.array;e=e.array,t[4]=e[0],t[5]=e[1],t[6]=e[2],this._dirty=!0}}),sK(lK,"x",{get:function(){var e=this.array;return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this.array;e=e.array,t[0]=e[0],t[1]=e[1],t[2]=e[2],this._dirty=!0}})}aK.adjoint=function(e,t){return Cq.adjoint(e.array,t.array),e._dirty=!0,e},aK.copy=function(e,t){return Cq.copy(e.array,t.array),e._dirty=!0,e},aK.determinant=function(e){return Cq.determinant(e.array)},aK.identity=function(e){return Cq.identity(e.array),e._dirty=!0,e},aK.ortho=function(e,t,n,r,i,o,a){return Cq.ortho(e.array,t,n,r,i,o,a),e._dirty=!0,e},aK.perspective=function(e,t,n,r,i){return Cq.perspective(e.array,t,n,r,i),e._dirty=!0,e},aK.lookAt=function(e,t,n,r){return Cq.lookAt(e.array,t.array,n.array,r.array),e._dirty=!0,e},aK.invert=function(e,t){return Cq.invert(e.array,t.array),e._dirty=!0,e},aK.mul=function(e,t,n){return Cq.mul(e.array,t.array,n.array),e._dirty=!0,e},aK.multiply=aK.mul,aK.fromQuat=function(e,t){return Cq.fromQuat(e.array,t.array),e._dirty=!0,e},aK.fromRotationTranslation=function(e,t,n){return Cq.fromRotationTranslation(e.array,t.array,n.array),e._dirty=!0,e},aK.fromMat2d=function(e,t){e._dirty=!0;t=t.array;return(e=e.array)[0]=t[0],e[4]=t[2],e[12]=t[4],e[1]=t[1],e[5]=t[3],e[13]=t[5],e},aK.rotate=function(e,t,n,r){return Cq.rotate(e.array,t.array,n,r.array),e._dirty=!0,e},aK.rotateX=function(e,t,n){return Cq.rotateX(e.array,t.array,n),e._dirty=!0,e},aK.rotateY=function(e,t,n){return Cq.rotateY(e.array,t.array,n),e._dirty=!0,e},aK.rotateZ=function(e,t,n){return Cq.rotateZ(e.array,t.array,n),e._dirty=!0,e},aK.scale=function(e,t,n){return Cq.scale(e.array,t.array,n.array),e._dirty=!0,e},aK.transpose=function(e,t){return Cq.transpose(e.array,t.array),e._dirty=!0,e},aK.translate=function(e,t,n){return Cq.translate(e.array,t.array,n.array),e._dirty=!0,e};var uK,cK=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=void 0===r?1:r,this.array=oK.fromValues(e,t,n,r),this._dirty=!0};cK.prototype={constructor:cK,add:function(e){return oK.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return oK.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new cK(this.x,this.y,this.z,this.w)},conjugate:function(){return oK.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return oK.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return oK.dot(this.array,e.array)},fromMat3:function(e){return oK.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:(uK=eK.create(),function(e){return eK.fromMat4(uK,e.array),eK.transpose(uK,uK),oK.fromMat3(this.array,uK),this._dirty=!0,this}),identity:function(){return oK.identity(this.array),this._dirty=!0,this},invert:function(){return oK.invert(this.array,this.array),this._dirty=!0,this},len:function(){return oK.len(this.array)},length:function(){return oK.length(this.array)},lerp:function(e,t,n){return oK.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},mul:function(e){return oK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return oK.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return oK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return oK.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return oK.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return oK.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return oK.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return oK.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return oK.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,n){return oK.setAxes(this.array,e.array,t.array,n.array),this._dirty=!0,this},setAxisAngle:function(e,t){return oK.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,n){return oK.slerp(this.array,e.array,t.array,n),this._dirty=!0,this},sqrLen:function(){return oK.sqrLen(this.array)},squaredLength:function(){return oK.squaredLength(this.array)},fromEuler:function(e,t){return cK.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var hK=Object.defineProperty;if(hK){var dK=cK.prototype;hK(dK,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),hK(dK,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),hK(dK,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),hK(dK,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}cK.add=function(e,t,n){return oK.add(e.array,t.array,n.array),e._dirty=!0,e},cK.set=function(e,t,n,r,i){oK.set(e.array,t,n,r,i),e._dirty=!0},cK.copy=function(e,t){return oK.copy(e.array,t.array),e._dirty=!0,e},cK.calculateW=function(e,t){return oK.calculateW(e.array,t.array),e._dirty=!0,e},cK.conjugate=function(e,t){return oK.conjugate(e.array,t.array),e._dirty=!0,e},cK.identity=function(e){return oK.identity(e.array),e._dirty=!0,e},cK.invert=function(e,t){return oK.invert(e.array,t.array),e._dirty=!0,e},cK.dot=function(e,t){return oK.dot(e.array,t.array)},cK.len=function(e){return oK.length(e.array)},cK.lerp=function(e,t,n,r){return oK.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},cK.slerp=function(e,t,n,r){return oK.slerp(e.array,t.array,n.array,r),e._dirty=!0,e},cK.mul=function(e,t,n){return oK.multiply(e.array,t.array,n.array),e._dirty=!0,e},cK.multiply=cK.mul,cK.rotateX=function(e,t,n){return oK.rotateX(e.array,t.array,n),e._dirty=!0,e},cK.rotateY=function(e,t,n){return oK.rotateY(e.array,t.array,n),e._dirty=!0,e},cK.rotateZ=function(e,t,n){return oK.rotateZ(e.array,t.array,n),e._dirty=!0,e},cK.setAxisAngle=function(e,t,n){return oK.setAxisAngle(e.array,t.array,n),e._dirty=!0,e},cK.normalize=function(e,t){return oK.normalize(e.array,t.array),e._dirty=!0,e},cK.squaredLength=cK.sqrLen=function(e){return oK.sqrLen(e.array)},cK.fromMat3=function(e,t){return oK.fromMat3(e.array,t.array),e._dirty=!0,e},cK.setAxes=function(e,t,n,r){return oK.setAxes(e.array,t.array,n.array,r.array),e._dirty=!0,e},cK.rotationTo=function(e,t,n){return oK.rotationTo(e.array,t.array,n.array),e._dirty=!0,e},cK.fromEuler=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=Math.cos(t[0]/2),o=Math.cos(t[1]/2),a=Math.cos(t[2]/2),s=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2);switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"YXZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"ZXY":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"ZYX":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"YZX":r[0]=s*o*a+i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a-s*l*u;break;case"XZY":r[0]=s*o*a-i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a+s*l*u}};var pK,fK,gK,mK,vK,yK,_K=Dq.set,xK=Dq.copy,bK=function(e,t){this.min=e||new Fq(1/0,1/0,1/0),this.max=t||new Fq(-1/0,-1/0,-1/0),this.vertices=null};bK.prototype={constructor:bK,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,r=t.array,i=n.array;xK(r,e[0]),xK(i,e[0]);for(var o=1;o<e.length;o++){var a=e[o];a[0]<r[0]&&(r[0]=a[0]),a[1]<r[1]&&(r[1]=a[1]),a[2]<r[2]&&(r[2]=a[2]),a[0]>i[0]&&(i[0]=a[0]),a[1]>i[1]&&(i[1]=a[1]),a[2]>i[2]&&(i[2]=a[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return Dq.min(t.array,t.array,e.min.array),Dq.max(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return Dq.max(t.array,t.array,e.min.array),Dq.min(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]<r[0]||n[1]<r[1]||n[2]<r[2])},containBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min.array,n=this.max.array,r=e.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:(pK=Dq.create(),fK=Dq.create(),gK=Dq.create(),mK=Dq.create(),vK=Dq.create(),yK=Dq.create(),function(e,t){var n=e.min.array,r=e.max.array,i=t.array;return pK[0]=i[0]*n[0],pK[1]=i[1]*n[0],pK[2]=i[2]*n[0],fK[0]=i[0]*r[0],fK[1]=i[1]*r[0],fK[2]=i[2]*r[0],gK[0]=i[4]*n[1],gK[1]=i[5]*n[1],gK[2]=i[6]*n[1],mK[0]=i[4]*r[1],mK[1]=i[5]*r[1],mK[2]=i[6]*r[1],vK[0]=i[8]*n[2],vK[1]=i[9]*n[2],vK[2]=i[10]*n[2],yK[0]=i[8]*r[2],yK[1]=i[9]*r[2],yK[2]=i[10]*r[2],n=this.min.array,r=this.max.array,n[0]=Math.min(pK[0],fK[0])+Math.min(gK[0],mK[0])+Math.min(vK[0],yK[0])+i[12],n[1]=Math.min(pK[1],fK[1])+Math.min(gK[1],mK[1])+Math.min(vK[1],yK[1])+i[13],n[2]=Math.min(pK[2],fK[2])+Math.min(gK[2],mK[2])+Math.min(vK[2],yK[2])+i[14],r[0]=Math.max(pK[0],fK[0])+Math.max(gK[0],mK[0])+Math.max(vK[0],yK[0])+i[12],r[1]=Math.max(pK[1],fK[1])+Math.max(gK[1],mK[1])+Math.max(vK[1],yK[1])+i[13],r[2]=Math.max(pK[2],fK[2])+Math.max(gK[2],mK[2])+Math.max(vK[2],yK[2])+i[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(e){var t=this.min.array,n=this.max.array,r=e.array,i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=t[2],c=n[0],h=n[1],d=n[2];if(1===r[15])t[0]=r[0]*i+r[12],t[1]=r[5]*o+r[13],n[2]=r[10]*a+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],t[2]=r[10]*d+r[14];else{var p=-1/a;t[0]=r[0]*i*p,t[1]=r[5]*o*p,n[2]=(r[10]*a+r[14])*p,p=-1/u,n[0]=r[0]*s*p,n[1]=r[5]*l*p,p=-1/d,t[2]=(r[10]*d+r[14])*p}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=Dq.fromValues(0,0,0);this.vertices=e}var n=this.min.array,r=this.max.array;return _K(e[0],n[0],n[1],n[2]),_K(e[1],n[0],r[1],n[2]),_K(e[2],r[0],n[1],n[2]),_K(e[3],r[0],r[1],n[2]),_K(e[4],n[0],n[1],r[2]),_K(e[5],n[0],r[1],r[2]),_K(e[6],r[0],n[1],r[2]),_K(e[7],r[0],r[1],r[2]),this},copy:function(e){var t=this.min,n=this.max;return xK(t.array,e.min.array),xK(n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new bK;return e.copy(this),e}};var wK,SK,TK=0,MK=wY.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+TK++),this.position||(this.position=new Fq),this.rotation||(this.rotation=new cK),this.scale||(this.scale=new Fq(1,1,1)),this.worldTransform=new aK,this.localTransform=new aK,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t<e.length;t++)e[t]._parent=null,this._scene&&e[t].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){for(var t=e._parent;t;){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){for(var t=this._children,n=0;n<t.length;n++)if(t[n].name===e)return t[n]},getDescendantByName:function(e){for(var t=this._children,n=0;n<t.length;n++){var r=t[n];if(r.name===e)return r;var i=r.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(e){for(var t=e.split("/"),n=this,r=0;r<t.length;r++){var i=t[r];if(i){for(var o=!1,a=n._children,s=0;s<a.length;s++){var l=a[s];if(l.name===i){n=l,o=!0;break}}if(!o)return}}return n}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,n=this.name;t._parent&&(n=t.name+"/"+n,t._parent!=e);)t=t._parent;return!t._parent&&e?null:n},traverse:function(e,t){e.call(t,this);for(var n=this._children,r=0,i=n.length;r<i;r++)n[r].traverse(e,t)},eachChild:function(e,t){for(var n=this._children,r=0,i=n.length;r<i;r++){var o=n[r];e.call(t,o,r)}},setLocalTransform:function(e){Cq.copy(this.localTransform.array,e.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){Cq.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:(wK=Cq.create(),function(e){var t=this.localTransform,n=this.worldTransform;this._parent?(Cq.invert(wK,this._parent.worldTransform.array),Cq.multiply(t.array,wK,n.array)):Cq.copy(t.array,n.array);var r=e?null:this.scale;t.decomposeMatrix(r,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var e=this.position,t=this.rotation,n=this.scale;if(this.transformNeedsUpdate()){var r=this.localTransform.array;Cq.fromRotationTranslation(r,t.array,e.array),Cq.scale(r,r,n.array),t._dirty=!1,n._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?Cq.multiplyAffine(t,this._parent.worldTransform.array,e):Cq.copy(t,e)},updateWorldTransform:function(){for(var e=this;e&&e.getParent()&&e.getParent().transformNeedsUpdate();)e=e.getParent();e.update()},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0,(e||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),e=!0,this._needsUpdateWorldTransform=!1);for(var t=this._children,n=0,r=t.length;n<r;n++)t[n].update(e)},getBoundingBox:function(){function e(e){return!e.invisible&&e.geometry}var t=new bK,n=new aK,r=new aK;return function(i,o){return o=o||new bK,this._parent?aK.invert(r,this._parent.worldTransform):aK.identity(r),this.traverse((function(e){e.geometry&&e.geometry.boundingBox&&(t.copy(e.geometry.boundingBox),aK.multiply(n,r,e.worldTransform),t.applyTransform(n),o.union(t))}),this,e),o}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var n=e.array;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e}return new Fq(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var n=0;n<t.length;n++)e.add(t[n].clone());return e},rotateAround:function(){var e=new Fq,t=new aK;return function(n,r,i){e.copy(this.position).subtract(n);var o=this.localTransform;o.identity(),o.translate(n),o.rotate(i,r),t.fromRotationTranslation(this.rotation,e),o.multiply(t),o.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new aK;return function(t,n){e.lookAt(this.position,t,n||this.localTransform.y).invert(),this.setLocalTransform(e),this.target=t}}()}),CK=MK.extend({material:null,geometry:null,mode:PY,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:FY,frontFace:UY,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=MK.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:(SK=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var e=MK.prototype.clone.call(this);e.geometry=this.geometry,e.material=this.material;for(var t=0;t<SK.length;t++){var n=SK[t];e[n]!==this[n]&&(e[n]=this[n])}return e})});CK.POINTS=IY,CK.LINES=EY,CK.LINE_LOOP=LY,CK.LINE_STRIP=NY,CK.TRIANGLES=PY,CK.TRIANGLE_STRIP=OY,CK.TRIANGLE_FAN=RY,CK.BACK=FY,CK.FRONT=BY,CK.FRONT_AND_BACK=GY,CK.CW=HY,CK.CCW=UY;var DK=wY.extend({scene:null,camera:null,renderer:null},(function(){this._ray=new Jq,this._ndc=new KZ}),{pick:function(e,t,n){return this.pickAll(e,t,[],n)[0]||null},pickAll:function(e,t,n,r){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),n=n||[],this._intersectNode(this.scene,n,r||!1),n.sort(this._intersectionCompareFunc),n},_intersectNode:function(e,t,n){e instanceof CK&&e.isRenderable()&&(e.ignorePicking&&!n||!(e.mode===PY&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)||this._intersectRenderable(e,t));for(var r=0;r<e._children.length;r++)this._intersectNode(e._children[r],t,n)},_intersectRenderable:function(){var e=new Fq,t=new Fq,n=new Fq,r=new Jq,i=new aK;return function(o,a){var s=o.isSkinnedMesh();r.copy(this._ray),aK.invert(i,o.worldTransform),s||r.applyTransform(i);var l=o.geometry,u=s?o.skeleton.boundingBox:l.boundingBox;if(!u||r.intersectBoundingBox(u))if(l.pick)l.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,o,a);else if(l.pickByRay)l.pickByRay(r,o,a);else{var c,h,d=o.cullFace===FY&&o.frontFace===UY||o.cullFace===BY&&o.frontFace===HY,p=l.indices,f=l.attributes.position,g=l.attributes.weight,m=l.attributes.joint,v=[];if(f&&f.value&&p){if(s){h=o.skeleton.getSubSkinMatrices(o.__uid__,o.joints);for(var y=0;y<o.joints.length;y++){v[y]=v[y]||[];for(var _=0;_<16;_++)v[y][_]=h[16*y+_]}var x=[],b=[],w=[],S=[],T=[],M=l.attributes.skinnedPosition;M&&M.value||(l.createAttribute("skinnedPosition","f",3),(M=l.attributes.skinnedPosition).init(l.vertexCount));for(y=0;y<l.vertexCount;y++){f.get(y,x),g.get(y,b),m.get(y,w),b[3]=1-b[0]-b[1]-b[2],Dq.set(S,0,0,0);for(_=0;_<4;_++)w[_]>=0&&b[_]>1e-4&&(Dq.transformMat4(T,x,v[w[_]]),Dq.scaleAndAdd(S,S,T,b[_]));M.set(y,S)}}for(y=0;y<p.length;y+=3){var C=p[y],D=p[y+1],A=p[y+2],I=s?l.attributes.skinnedPosition:f;if(I.get(C,e.array),I.get(D,t.array),I.get(A,n.array),c=d?r.intersectTriangle(e,t,n,o.culling):r.intersectTriangle(e,n,t,o.culling)){var E=new Fq;s?Fq.copy(E,c):Fq.transformMat4(E,c,o.worldTransform),a.push(new DK.Intersection(c,E,o,[C,D,A],y/3,Fq.dist(E,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});DK.Intersection=function(e,t,n,r,i,o){this.point=e,this.pointWorld=t,this.target=n,this.triangle=r,this.triangleIndex=i,this.distance=o};var AK="__dt__",IK=function(){this._contextId=0,this._caches=[],this._context={}};IK.prototype={use:function(e,t){var n=this._caches;n[e]||(n[e]={},t&&(n[e]=t())),this._contextId=e,this._context=n[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){var t=AK+(e=e||"");this.put(t,!0)},dirtyAll:function(e){for(var t=AK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!0)},fresh:function(e){var t=AK+(e=e||"");this.put(t,!1)},freshAll:function(e){for(var t=AK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!1)},isDirty:function(e){var t=AK+(e=e||""),n=this._context;return!n.hasOwnProperty(t)||!0===n[t]},deleteContext:function(e){delete this._caches[e],this._context={}},delete:function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(e,t){Object.keys(this._caches).forEach((function(n){e&&e.call(t,n)}))},miss:function(e){return!this._context.hasOwnProperty(e)}},IK.prototype.constructor=IK;var EK=wY.extend({width:512,height:512,type:jY,format:eZ,wrapS:hZ,wrapT:hZ,minFilter:lZ,magFilter:iZ,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},(function(){this._cache=new IK}),{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__uid__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===$Y&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==EK.SRGB||n||(this.format=EK.RGB),this.format!==EK.SRGB_ALPHA||n||(this.format=EK.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?dZ:this.wrapS},getAvailableWrapT:function(){return this.NPOT?dZ:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===oZ||e===sZ?rZ:e===lZ||e===aZ?iZ:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(EK.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(EK.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),EK.BYTE=WY,EK.UNSIGNED_BYTE=jY,EK.SHORT=XY,EK.UNSIGNED_SHORT=YY,EK.INT=ZY,EK.UNSIGNED_INT=qY,EK.FLOAT=KY,EK.HALF_FLOAT=36193,EK.UNSIGNED_INT_24_8_WEBGL=34042,EK.DEPTH_COMPONENT=$Y,EK.DEPTH_STENCIL=mZ,EK.ALPHA=JY,EK.RGB=QY,EK.RGBA=eZ,EK.LUMINANCE=tZ,EK.LUMINANCE_ALPHA=nZ,EK.SRGB=35904,EK.SRGB_ALPHA=35906,EK.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,EK.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,EK.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,EK.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,EK.NEAREST=rZ,EK.LINEAR=iZ,EK.NEAREST_MIPMAP_NEAREST=oZ,EK.LINEAR_MIPMAP_NEAREST=aZ,EK.NEAREST_MIPMAP_LINEAR=sZ,EK.LINEAR_MIPMAP_LINEAR=lZ,EK.REPEAT=hZ,EK.CLAMP_TO_EDGE=dZ,EK.MIRRORED_REPEAT=pZ;var LK=CK.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=CK.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});LK.POINTS=IY,LK.LINES=EY,LK.LINE_LOOP=LY,LK.LINE_STRIP=NY,LK.TRIANGLES=PY,LK.TRIANGLE_STRIP=OY,LK.TRIANGLE_FAN=RY,LK.BACK=FY,LK.FRONT=BY,LK.FRONT_AND_BACK=GY,LK.CW=HY,LK.CCW=UY;var NK={isPowerOfTwo:function(e){return!(e&e-1)},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}},PK=NK.isPowerOfTwo;function OK(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}var RK=EK.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==EK.REPEAT&&this.wrapT!==EK.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var o=e.getGLExtension("EXT_texture_filter_anisotropic");(o&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,o.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=KY));if(this.mipmaps.length)for(var a=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,a,s,n,r,!1),a/=2,s/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r,i),!this.useMipmap||this.NPOT&&!i||t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,n,r,i,o,a,s){if(t.image){var l=t.image;s&&(this._potCanvas=function(e,t){var n=OK(e.width),r=OK(e.height);return(t=t||document.createElement("canvas")).width=n,t.height=r,t.getContext("2d").drawImage(e.image,0,0,n,r),t}(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,n,o,o,a,l)}else o<=EK.COMPRESSED_RGBA_S3TC_DXT5_EXT&&o>=EK.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,r,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,r,i,0,o,a,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return PK(this.width)&&PK(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=SZ.createImage();t&&(n.crossOrigin=t);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r)},n.onerror=function(){r.trigger("error",r)},n.src=e,this.image=n,this}});function kK(e){return{byte:SZ.Int8Array,ubyte:SZ.Uint8Array,short:SZ.Int16Array,ushort:SZ.Uint16Array}[e]||SZ.Float32Array}function zK(e){return"attr_"+e}function VK(e,t,n,r){switch(this.name=e,this.type=t,this.size=n,this.semantic=r||"",this.value=null,n){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var n=this.value;return t[0]=n[2*e],t[1]=n[2*e+1],t},this.set=function(e,t){var n=this.value;n[2*e]=t[0],n[2*e+1]=t[1]},this.copy=function(e,t){var n=this.value;t*=2,n[e*=2]=n[t],n[e+1]=n[t+1]};break;case 3:this.get=function(e,t){var n=3*e,r=this.value;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t},this.set=function(e,t){var n=3*e,r=this.value;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2]},this.copy=function(e,t){var n=this.value;t*=3,n[e*=3]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2]};break;case 4:this.get=function(e,t){var n=this.value,r=4*e;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t},this.set=function(e,t){var n=this.value,r=4*e;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2],n[r+3]=t[3]},this.copy=function(e,t){var n=this.value;t*=4,n[e*=4]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2],n[e+3]=n[t+3]}}}function BK(e,t,n,r,i){this.name=e,this.type=t,this.buffer=n,this.size=r,this.semantic=i,this.symbol="",this.needsRemove=!1}function FK(e){this.buffer=e,this.count=0}Object.defineProperty(RK.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(RK.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),VK.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=kK(this.type);this.value=new t(e*this.size)}},VK.prototype.fromArray=function(e){var t,n=kK(this.type);if(e[0]&&e[0].length){var r=0,i=this.size;t=new n(e.length*i);for(var o=0;o<e.length;o++)for(var a=0;a<i;a++)t[r++]=e[o][a]}else t=new n(e);this.value=t},VK.prototype.clone=function(e){var t=new VK(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};var GK=wY.extend((function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}}),(function(){this._cache=new IK,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}}),{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t<e.length;t++)this.dirtyAttribute(e[t]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(e){this._cache.dirtyAll(zK(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?SZ.Uint32Array:SZ.Uint16Array;if(e[0]&&e[0].length){var r=0;t=new n(3*e.length);for(var i=0;i<e.length;i++)for(var o=0;o<3;o++)t[r++]=e[i][o]}else t=new n(e);this.indices=t},createAttribute:function(e,t,n,r){var i=new VK(e,t,n,r);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,n=t.indexOf(e);return n>=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],r=this.vertexCount,i=0;i<t.length;i++){var o=t[i],a=this.attributes[o];a.value&&a.value.length===r*a.size&&n.push(o)}return this._enabledAttributes=n,n},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var n=t.isDirty("attributes"),r=t.isDirty("indices");if(n||r){this._updateBuffer(e.gl,n,r);for(var i=this.getEnabledAttributes(),o=0;o<i.length;o++)t.fresh(zK(i[o]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,n){var r=this._cache,i=r.get("chunks"),o=!1;i||((i=[])[0]={attributeBuffers:[],indicesBuffer:null},r.put("chunks",i),o=!0);var a=i[0],s=a.attributeBuffers,l=a.indicesBuffer;if(t||o){var u=this.getEnabledAttributes(),c={};if(!o)for(var h=0;h<s.length;h++)c[s[h].name]=s[h];for(var d=0;d<u.length;d++){var p,f,g=u[d],m=this.attributes[g];o||(p=c[g]),f=p?p.buffer:e.createBuffer(),r.isDirty(zK(g))&&(e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,m.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),s[d]=new BK(g,m.type,f,m.size,m.semantic)}for(h=d;h<s.length;h++)e.deleteBuffer(s[h].buffer);s.length=d}this.isUseIndices()&&(n||o)&&(l||(l=new FK(e.createBuffer()),a.indicesBuffer=l),l.count=this.indices.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW))},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});Object.defineProperty&&(Object.defineProperty(GK.prototype,"vertexCount",{enumerable:!1,get:function(){var e=this.attributes[this.mainAttribute];return e||(e=this.attributes[this._attributeList[0]]),e&&e.value?e.value.length/e.size:0}}),Object.defineProperty(GK.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}})),GK.STATIC_DRAW=zY,GK.DYNAMIC_DRAW=VY,GK.STREAM_DRAW=kY,GK.AttributeBuffer=BK,GK.IndicesBuffer=FK,GK.Attribute=VK;var HK=Dq.create,UK=Dq.add,WK=Dq.set,jK=GK.Attribute,XK=GK.extend((function(){return{attributes:{position:new jK("position","float",3,"POSITION"),texcoord0:new jK("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new jK("texcoord1","float",2,"TEXCOORD_1"),normal:new jK("normal","float",3,"NORMAL"),tangent:new jK("tangent","float",4,"TANGENT"),color:new jK("color","float",4,"COLOR"),weight:new jK("weight","float",3,"WEIGHT"),joint:new jK("joint","float",4,"JOINT"),barycentric:new jK("barycentric","float",3,null)},boundingBox:null}}),{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new bK);var t=this.attributes.position.value;if(t&&t.length){var n=e.min,r=e.max,i=n.array,o=r.array;Dq.set(i,t[0],t[1],t[2]),Dq.set(o,t[0],t[1],t[2]);for(var a=3;a<t.length;){var s=t[a++],l=t[a++],u=t[a++];s<i[0]&&(i[0]=s),l<i[1]&&(i[1]=l),u<i[2]&&(i[2]=u),s>o[0]&&(o[0]=s),l>o[1]&&(o[1]=l),u>o[2]&&(o[2]=u)}n._dirty=!0,r._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value;if(r&&r.length===n.length)for(var i=0;i<r.length;i++)r[i]=0;else r=t.normal.value=new SZ.Float32Array(n.length);for(var o,a,s,l=HK(),u=HK(),c=HK(),h=HK(),d=HK(),p=HK(),f=e?e.length:this.vertexCount,g=0;g<f;){e?(o=e[g++],a=e[g++],s=e[g++]):(o=g++,a=g++,s=g++),WK(l,n[3*o],n[3*o+1],n[3*o+2]),WK(u,n[3*a],n[3*a+1],n[3*a+2]),WK(c,n[3*s],n[3*s+1],n[3*s+2]),Dq.sub(h,l,u),Dq.sub(d,u,c),Dq.cross(p,h,d);for(i=0;i<3;i++)r[3*o+i]=r[3*o+i]+p[i],r[3*a+i]=r[3*a+i]+p[i],r[3*s+i]=r[3*s+i]+p[i]}for(i=0;i<r.length;)WK(p,r[i],r[i+1],r[i+2]),Dq.normalize(p,p),r[i++]=p[0],r[i++]=p[1],r[i++]=p[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value,i=HK(),o=HK(),a=HK(),s=HK(),l=HK(),u=HK();r||(r=t.normal.value=new Float32Array(n.length));for(var c,h,d,p=e?e.length:this.vertexCount,f=0;f<p;){e?(c=e[f++],h=e[f++],d=e[f++]):(c=f++,h=f++,d=f++),WK(i,n[3*c],n[3*c+1],n[3*c+2]),WK(o,n[3*h],n[3*h+1],n[3*h+2]),WK(a,n[3*d],n[3*d+1],n[3*d+2]),Dq.sub(s,i,o),Dq.sub(l,o,a),Dq.cross(u,s,l),Dq.normalize(u,u);for(var g=0;g<3;g++)r[3*c+g]=u[g],r[3*h+g]=u[g],r[3*d+g]=u[g]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var e=this.vertexCount,t=this.attributes;t.tangent.value||(t.tangent.value=new Float32Array(4*e));var n=t.texcoord0.value,r=t.position.value,i=t.tangent.value,o=t.normal.value;if(n){for(var a=[],s=[],l=0;l<e;l++)a[l]=[0,0,0],s[l]=[0,0,0];var u,c,h,d=[0,0,0],p=[0,0,0],f=this.indices,g=f?f.length:this.vertexCount;for(l=0;l<g;){f?(u=f[l++],c=f[l++],h=f[l++]):(u=l++,c=l++,h=l++);var m=n[2*u],v=n[2*c],y=n[2*h],_=n[2*u+1],x=n[2*c+1],b=n[2*h+1],w=r[3*u],S=r[3*c],T=r[3*h],M=r[3*u+1],C=r[3*c+1],D=r[3*h+1],A=r[3*u+2],I=S-w,E=T-w,L=C-M,N=D-M,P=r[3*c+2]-A,O=r[3*h+2]-A,R=v-m,k=y-m,z=x-_,V=b-_,B=1/(R*V-z*k);d[0]=(V*I-z*E)*B,d[1]=(V*L-z*N)*B,d[2]=(V*P-z*O)*B,p[0]=(R*E-k*I)*B,p[1]=(R*N-k*L)*B,p[2]=(R*O-k*P)*B,UK(a[u],a[u],d),UK(a[c],a[c],d),UK(a[h],a[h],d),UK(s[u],s[u],p),UK(s[c],s[c],p),UK(s[h],s[h],p)}var F=HK(),G=HK(),H=HK();for(l=0;l<e;l++){H[0]=o[3*l],H[1]=o[3*l+1],H[2]=o[3*l+2];var U=a[l];Dq.scale(F,H,Dq.dot(H,U)),Dq.sub(F,U,F),Dq.normalize(F,F),Dq.cross(G,H,U),i[4*l]=F[0],i[4*l+1]=F[1],i[4*l+2]=F[2],i[4*l+3]=Dq.dot(G,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new SZ.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),r={},i=0;i<n.length;i++){r[l=n[i]]=e[l].value,e[l].init(this.indices.length)}for(var o=0,a=0;a<t.length;a++){var s=t[a];for(i=0;i<n.length;i++)for(var l,u=e[l=n[i]].value,c=e[l].size,h=0;h<c;h++)u[o*c+h]=r[l][s*c+h];t[a]=o,o++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,n=this.indices;if(!t||t.length!==3*n.length){t=e.barycentric.value=new Float32Array(3*n.length);for(var r=0;r<(n?n.length:this.vertexCount/3);)for(var i=0;i<3;i++){t[3*(n?n[r++]:3*r+i)+i]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,n=t.position.value,r=t.normal.value,i=t.tangent.value;e=e.array;var o=Cq.create();Cq.invert(o,e),Cq.transpose(o,o);var a=Dq.transformMat4,s=Dq.forEach;s(n,3,0,null,a,e),r&&s(r,3,0,null,a,o),i&&s(i,4,0,null,a,o),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});XK.STATIC_DRAW=GK.STATIC_DRAW,XK.DYNAMIC_DRAW=GK.DYNAMIC_DRAW,XK.STREAM_DRAW=GK.STREAM_DRAW,XK.AttributeBuffer=GK.AttributeBuffer,XK.IndicesBuffer=GK.IndicesBuffer,XK.Attribute=jK;var YK="uniform vec3 ",ZK="uniform float ",qK="@export clay.header.",KK="@end",$K=":unconfigurable;",JK=[qK+"directional_light",YK+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+$K,YK+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+$K,KK,qK+"ambient_light",YK+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+$K,KK,qK+"ambient_sh_light",YK+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+$K,YK+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+$K,"vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",KK,qK+"ambient_cubemap_light",YK+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+$K,KK,qK+"point_light",YK+"pointLightPosition[POINT_LIGHT_COUNT]"+$K,ZK+"pointLightRange[POINT_LIGHT_COUNT]"+$K,YK+"pointLightColor[POINT_LIGHT_COUNT]"+$K,KK,qK+"spot_light",YK+"spotLightPosition[SPOT_LIGHT_COUNT]"+$K,YK+"spotLightDirection[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightRange[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+$K,ZK+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+$K,YK+"spotLightColor[SPOT_LIGHT_COUNT]"+$K,KK].join("\n");wq.import(JK);var QK,e$,t$,n$,r$=MK.extend((function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}}),{type:"",clone:function(){var e=MK.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}}),i$=function(e,t){this.normal=e||new Fq(0,1,0),this.distance=t||0};i$.prototype={constructor:i$,distanceToPoint:function(e){return Dq.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new Fq);var n=this.distanceToPoint(e);return Dq.scaleAndAdd(t.array,e.array,this.normal.array,-n),t._dirty=!0,t},normalize:function(){var e=1/Dq.len(this.normal.array);Dq.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,n=this.normal.array,r=Dq.dot(t[0].array,n)>this.distance,i=1;i<8;i++)if(Dq.dot(t[i].array,n)>this.distance!=r)return!0},intersectLine:(n$=Dq.create(),function(e,t,n){var r=this.distanceToPoint(e),i=this.distanceToPoint(t);if(r>0&&i>0||r<0&&i<0)return null;var o=this.normal.array,a=this.distance,s=e.array;Dq.sub(n$,t.array,e.array),Dq.normalize(n$,n$);var l=Dq.dot(o,n$);if(0===l)return null;n||(n=new Fq);var u=(Dq.dot(o,s)-a)/l;return Dq.scaleAndAdd(n.array,s,n$,-u),n._dirty=!0,n}),applyTransform:(QK=Cq.create(),e$=Qq.create(),t$=Qq.create(),t$[3]=1,function(e){e=e.array,Dq.scale(t$,this.normal.array,this.distance),Qq.transformMat4(t$,t$,e),this.distance=Dq.dot(t$,this.normal.array),Cq.invert(QK,e),Cq.transpose(QK,QK),e$[3]=0,Dq.copy(e$,this.normal.array),Qq.transformMat4(e$,e$,QK),Dq.copy(this.normal.array,e$)}),copy:function(e){Dq.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new i$;return e.copy(this),e}};var o$,a$=Dq.set,s$=Dq.copy,l$=Dq.transformMat4,u$=Math.min,c$=Math.max,h$=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new i$);this.boundingBox=new bK,this.vertices=[];for(e=0;e<8;e++)this.vertices[e]=Dq.fromValues(0,0,0)};h$.prototype={setFromProjection:function(e){var t=this.planes,n=e.array,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],d=n[9],p=n[10],f=n[11],g=n[12],m=n[13],v=n[14],y=n[15];a$(t[0].normal.array,a-r,c-s,f-h),t[0].distance=-(y-g),t[0].normalize(),a$(t[1].normal.array,a+r,c+s,f+h),t[1].distance=-(y+g),t[1].normalize(),a$(t[2].normal.array,a+i,c+l,f+d),t[2].distance=-(y+m),t[2].normalize(),a$(t[3].normal.array,a-i,c-l,f-d),t[3].distance=-(y-m),t[3].normalize(),a$(t[4].normal.array,a-o,c-u,f-p),t[4].distance=-(y-v),t[4].normalize(),a$(t[5].normal.array,a+o,c+u,f+p),t[5].distance=-(y+v),t[5].normalize();var _=this.boundingBox,x=this.vertices;if(0===y){var b=l/r,w=-v/(p-1),S=-v/(p+1),T=-S/l,M=-w/l;_.min.set(-T*b,-T,S),_.max.set(T*b,T,w),a$(x[0],-T*b,-T,S),a$(x[1],-T*b,T,S),a$(x[2],T*b,-T,S),a$(x[3],T*b,T,S),a$(x[4],-M*b,-M,w),a$(x[5],-M*b,M,w),a$(x[6],M*b,-M,w),a$(x[7],M*b,M,w)}else{var C=(-1-g)/r,D=(1-g)/r,A=(1-m)/l,I=(-1-m)/l,E=(-1-v)/p,L=(1-v)/p;_.min.set(Math.min(C,D),Math.min(I,A),Math.min(L,E)),_.max.set(Math.max(D,C),Math.max(A,I),Math.max(E,L));var N=_.min.array,P=_.max.array;a$(x[0],N[0],N[1],N[2]),a$(x[1],N[0],P[1],N[2]),a$(x[2],P[0],N[1],N[2]),a$(x[3],P[0],P[1],N[2]),a$(x[4],N[0],N[1],P[2]),a$(x[5],N[0],P[1],P[2]),a$(x[6],P[0],N[1],P[2]),a$(x[7],P[0],P[1],P[2])}},getTransformedBoundingBox:(o$=Dq.create(),function(e,t){var n=this.vertices,r=t.array,i=e.min,o=e.max,a=i.array,s=o.array,l=n[0];l$(o$,l,r),s$(a,o$),s$(s,o$);for(var u=1;u<8;u++)l=n[u],l$(o$,l,r),a[0]=u$(o$[0],a[0]),a[1]=u$(o$[1],a[1]),a[2]=u$(o$[2],a[2]),s[0]=c$(o$[0],s[0]),s[1]=c$(o$[1],s[1]),s[2]=c$(o$[2],s[2]);return i._dirty=!0,o._dirty=!0,e})};var d$,p$=MK.extend((function(){return{projectionMatrix:new aK,invProjectionMatrix:new aK,viewMatrix:new aK,frustum:new h$}}),(function(){this.update(!0)}),{update:function(e){MK.prototype.update.call(this,e),aK.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),aK.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){aK.copy(this.viewMatrix,e),aK.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){aK.copy(this.projectionMatrix,e),aK.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(d$=Qq.create(),function(e,t){var n=void 0!==t?t:new Jq,r=e.array[0],i=e.array[1];return Qq.set(d$,r,i,-1,1),Qq.transformMat4(d$,d$,this.invProjectionMatrix.array),Qq.transformMat4(d$,d$,this.worldTransform.array),Dq.scale(n.origin.array,d$,1/d$[3]),Qq.set(d$,r,i,1,1),Qq.transformMat4(d$,d$,this.invProjectionMatrix.array),Qq.transformMat4(d$,d$,this.worldTransform.array),Dq.scale(d$,d$,1/d$[3]),Dq.sub(n.direction.array,d$,n.origin.array),Dq.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n})}),f$=Cq.create(),g$=Cq.create(),m$={};function v$(e){var t=[],n=Object.keys(e);n.sort();for(var r=0;r<n.length;r++){var i=n[r];t.push(i+" "+e[i])}var o=t.join("\n");if(m$[o])return m$[o];var a=bY.genGUID();return m$[o]=a,a}function y$(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}y$.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},y$.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e},y$.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var _$,x$,b$=MK.extend((function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new bK,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new CZ(20)}}),(function(){this._scene=this}),{addToScene:function(e){e instanceof p$?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof r$&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof p$?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof r$&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},n=0;n<e.length;n++){var r=e[n];if(!r.invisible){var i=r.group;t[i]||(t[i]={}),t[i][r.type]=t[i][r.type]||0,t[i][r.type]++}}for(var o in this._lightNumber=t,t)this._lightProgramKeys[o]=v$(t[o]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),n={};return function e(t,r){n[t.__uid__]=r;for(var i=0;i<t._children.length;i++){e(t._children[i],r._children[i])}}(e,t),t.traverse((function(e){e.skeleton&&(e.skeleton=e.skeleton.clone(n)),e.material&&(e.material=e.material.clone())})),t},updateRenderList:function(e,t){var n=e.__uid__,r=this._renderLists.get(n);r||(r=new y$,this._renderLists.put(n,r)),r.startCount(),t&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var i=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,e,i,r,t),r.endCount(),r},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,n,r,i){if(!e.invisible)for(var o=0;o<e._children.length;o++){var a=e._children[o];if(a.isRenderable()){var s=a.isSkinnedMesh()?f$:a.worldTransform.array,l=a.geometry;Cq.multiplyAffine(g$,t.viewMatrix.array,s),(i&&!l.boundingBox||!this.isFrustumCulled(a,t,g$))&&r.add(a,a.material.transparent||n)}a._children.length>0&&this._doUpdateRenderList(a,t,n,r,i)}},isFrustumCulled:(_$=new bK,x$=new aK,function(e,t,n){var r=e.boundingBox;if(r||(r=e.skeleton&&e.skeleton.boundingBox?e.skeleton.boundingBox:e.geometry.boundingBox),!r)return!1;if(x$.array=n,_$.transformFrom(r,x$),e.castShadow&&this.viewBoundingBoxLastFrame.union(_$),e.frustumCulling){if(!_$.intersectBoundingBox(t.frustum.boundingBox))return!0;x$.array=t.projectionMatrix.array,_$.max.array[2]>0&&_$.min.array[2]<0&&(_$.max.array[2]=-1e-20),_$.applyProjection(x$);var i=_$.min.array,o=_$.max.array;if(o[0]<-1||i[0]>1||o[1]<-1||i[1]>1||o[2]<-1||i[2]>1)return!0}return!1}),_updateLightUniforms:function(){var e=this.lights;e.sort(w$);var t=this._lightUniforms;for(var n in t)for(var r in t[n])t[n][r].value.length=0;for(var i=0;i<e.length;i++){var o=e[i];if(!o.invisible){n=o.group;for(var r in o.uniformTemplates){var a=o.uniformTemplates[r],s=a.value(o);if(null!=s){t[n]||(t[n]={}),t[n][r]||(t[n][r]={type:"",value:[]});var l=t[n][r];switch(l.type=a.type+"v",a.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var u=0;u<s.length;u++)l.value.push(s[u]);break;default:console.error("Unkown light uniform type "+a.type)}}}}}},getLightGroups:function(){var e=[];for(var t in this._lightNumber)e.push(t);return e},getNumberChangedLightGroups:function(){var e=[];for(var t in this._lightNumber)this.isLightNumberChanged(t)&&e.push(t);return e},isLightNumberChanged:function(e){var t=this._previousLightNumber,n=this._lightNumber;for(var r in n[e]){if(!t[e])return!0;if(n[e][r]!==t[e][r])return!0}for(var r in t[e]){if(!n[e])return!0;if(n[e][r]!==t[e][r])return!0}return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(e,t,n){for(var r in e){var i=e[r];if("tv"===i.type){if(!t.hasUniform(r))continue;for(var o=[],a=0;a<i.value.length;a++){var s=i.value[a],l=t.takeCurrentTextureSlot(n,s);o.push(l)}t.setUniform(n.gl,"1iv",r,o)}else t.setUniform(n.gl,i.type,r,i.value)}}return function(t,n,r){e(this._lightUniforms[n],t,r),e(this.shadowUniforms,t,r)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function w$(e,t){if(t.castShadow&&!e.castShadow)return!0}var S$=function(e){this.value=e},T$=function(){function e(){this._len=0}return e.prototype.insert=function(e){var t=new S$(e);return this.insertEntry(t),t},e.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e):this.head=this.tail=e,this._len++},e.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._len--},e.prototype.len=function(){return this._len},e.prototype.clear=function(){this.head=this.tail=null,this._len=0},e}(),M$=function(){function e(e){this._list=new T$,this._maxSize=10,this._map={},this._maxSize=e}return e.prototype.put=function(e,t){var n=this._list,r=this._map,i=null;if(null==r[e]){var o=n.len(),a=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var s=n.head;n.remove(s),delete r[s.key],i=s.value,this._lastRemovedEntry=s}a?a.value=t:a=new S$(t),a.key=e,n.insertEntry(a),r[e]=a}return i},e.prototype.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},e.prototype.clear=function(){this._list.clear(),this._map={}},e.prototype.len=function(){return this._list.len()},e}(),C$=NK.isPowerOfTwo,D$=["px","nx","py","ny","pz","nz"],A$=EK.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=KY));if(this.mipmaps.length)for(var o=this.width,a=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(t,l,s,o,a,n,r),o/=2,a/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,n,r,i,o,a){for(var s=0;s<6;s++){var l=D$[s],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,o,a,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,r,i,0,o,a,t.pixels&&t.pixels[l])}},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_CUBE_MAP))},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?C$(this.image.px.width)&&C$(this.image.px.height):C$(this.width)&&C$(this.height)},isRenderable:function(){return this.image.px?I$(this.image.px)&&I$(this.image.nx)&&I$(this.image.py)&&I$(this.image.ny)&&I$(this.image.pz)&&I$(this.image.nz):!(!this.width||!this.height)},load:function(e,t){var n=0,r=this;return bY.each(e,(function(e,i){var o=SZ.createImage();t&&(o.crossOrigin=t),o.onload=function(){0===--n&&(r.dirty(),r.trigger("success",r))},o.onerror=function(){n--},n++,o.src=e,r.image[i]=o})),this}});function I$(e){return e.width>0&&e.height>0}Object.defineProperty(A$.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(A$.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});var E$=p$.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=p$.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),L$="framebuffer",N$="renderbuffer",P$=N$+"_width",O$=N$+"_height",R$=N$+"_attached",k$="depthtexture_attached",z$=fZ,V$=gZ,B$=yZ,F$=vZ,G$=wY.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new IK,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(e){if(e.__currentFrameBuffer){if(e.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}e.__currentFrameBuffer=this;var t=e.gl;t.bindFramebuffer(z$,this._getFrameBufferGL(e)),this._boundRenderer=e;var n=this._cache;n.put("viewport",e.viewport);var r,i,o=!1;for(var a in this._textures){o=!0;var s=this._textures[a];s&&(r=s.texture.width,i=s.texture.height,this._doAttach(e,s.texture,a,s.target))}this._width=r,this._height=i,!o&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?e.setViewport(this.viewport):e.setViewport(0,0,r,i,1);var l=n.get("attached_textures");if(l)for(var a in l)if(!this._textures[a]){var u=l[a];this._doDetach(t,a,u)}if(!n.get(k$)&&this.depthBuffer){n.miss(N$)&&n.put(N$,t.createRenderbuffer());var c=n.get(N$);r===n.get(P$)&&i===n.get(O$)||(t.bindRenderbuffer(V$,c),t.renderbufferStorage(V$,t.DEPTH_COMPONENT16,r,i),n.put(P$,r),n.put(O$,i),t.bindRenderbuffer(V$,null)),n.get(R$)||(t.framebufferRenderbuffer(z$,B$,V$,c),n.put(R$,!0))}},unbind:function(e){e.__currentFrameBuffer=null,e.gl.bindFramebuffer(z$,null),this._boundRenderer=null,this._cache.use(e.__uid__);var t=this._cache.get("viewport");t&&e.setViewport(t),this.updateMipmap(e)},updateMipmap:function(e){var t=e.gl;for(var n in this._textures){var r=this._textures[n];if(r){var i=r.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===EK.LINEAR_MIPMAP_LINEAR){var o="textureCube"===i.textureType?cZ:uZ;t.bindTexture(o,i.getWebGLTexture(e)),t.generateMipmap(o),t.bindTexture(o,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(z$)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(L$)&&t.put(L$,e.gl.createFramebuffer()),t.get(L$)},attach:function(e,t,n){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||F$,n=n||uZ;var r,i=this._boundRenderer;if(i&&i.gl){var o=this._cache;o.use(i.__uid__),r=o.get("attached_textures")}var a=this._textures[t];if(!a||a.target!==n||a.texture!==e||!r||null==r[t]){var s=!0;i&&(s=this._doAttach(i,e,t,n),this.viewport||i.setViewport(0,0,e.width,e.height,1)),s&&(this._textures[t]=this._textures[t]||{},this._textures[t].texture=e,this._textures[t].target=n)}},_doAttach:function(e,t,n,r){var i=e.gl,o=t.getWebGLTexture(e),a=this._cache.get("attached_textures");if(a&&a[n]){var s=a[n];if(s.texture===t&&s.target===r)return}var l=!0;if(((n=+n)===B$||n===xZ)&&(e.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==$Y&&t.format!==mZ&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var u=this._cache.get(N$);u&&(i.framebufferRenderbuffer(z$,B$,V$,null),i.deleteRenderbuffer(u),this._cache.put(N$,!1)),this._cache.put(R$,!1),this._cache.put(k$,!0)}return i.framebufferTexture2D(z$,n,r,o,0),a||(a={},this._cache.put("attached_textures",a)),a[n]=a[n]||{},a[n].texture=t,a[n].target=r,l},_doDetach:function(e,t,n){e.framebufferTexture2D(z$,t,n,null,0);var r=this._cache.get("attached_textures");r&&r[t]&&(r[t]=null),t!==B$&&t!==xZ||this._cache.put(k$,!1)},detach:function(e,t){(this._textures[e]=null,this._boundRenderer)&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,e,t))},dispose:function(e){var t=e.gl,n=this._cache;n.use(e.__uid__);var r=n.get(N$);r&&t.deleteRenderbuffer(r);var i=n.get(L$);i&&t.deleteFramebuffer(i),n.deleteContext(e.__uid__),this._textures={}}});G$.DEPTH_ATTACHMENT=B$,G$.COLOR_ATTACHMENT0=F$,G$.STENCIL_ATTACHMENT=_Z,G$.DEPTH_STENCIL_ATTACHMENT=xZ;var H$=["px","nx","py","ny","pz","nz"],U$=wY.extend((function(){var e={position:new Fq,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new E$({fov:90}),nx:new E$({fov:90}),py:new E$({fov:90}),ny:new E$({fov:90}),pz:new E$({fov:90}),nz:new E$({fov:90})};return t.px.lookAt(Fq.POSITIVE_X,Fq.NEGATIVE_Y),t.nx.lookAt(Fq.NEGATIVE_X,Fq.NEGATIVE_Y),t.py.lookAt(Fq.POSITIVE_Y,Fq.POSITIVE_Z),t.ny.lookAt(Fq.NEGATIVE_Y,Fq.NEGATIVE_Z),t.pz.lookAt(Fq.POSITIVE_Z,Fq.NEGATIVE_Y),t.nz.lookAt(Fq.NEGATIVE_Z,Fq.NEGATIVE_Y),e._frameBuffer=new G$,e}),{getCamera:function(e){return this._cameras[e]},render:function(e,t,n){var r=e.gl;n||t.update();for(var i=this.texture.width,o=2*Math.atan(i/(i-.5))/Math.PI*180,a=0;a<6;a++){var s=H$[a],l=this._cameras[s];if(Fq.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=o,this.shadowMapPass){l.update();var u=t.getBoundingBox();u.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(u),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),W$=XK.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,r=[],i=[],o=[],a=[],s=0;s<=e;s++)for(var l=s/e,u=0;u<=t;u++){var c=u/t;if(r.push([2*c-1,2*l-1,0]),i&&i.push([c,l]),o&&o.push([0,0,1]),u<t&&s<e){var h=u+s*(t+1);a.push([h,h+1,h+t+1]),a.push([h+t+1,h+1,h+t+2])}}n.position.fromArray(r),n.texcoord0.fromArray(i),n.normal.fromArray(o),this.initIndicesFromArray(a),this.boundingBox=new bK,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),j$=new aK,X$=XK.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},(function(){this.build()}),{build:function(){var e={px:Y$("px",this.depthSegments,this.heightSegments),nx:Y$("nx",this.depthSegments,this.heightSegments),py:Y$("py",this.widthSegments,this.depthSegments),ny:Y$("ny",this.widthSegments,this.depthSegments),pz:Y$("pz",this.widthSegments,this.heightSegments),nz:Y$("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],n=0,r=0;for(var i in e)n+=e[i].vertexCount,r+=e[i].indices.length;for(var o=0;o<t.length;o++)this.attributes[t[o]].init(n);this.indices=new SZ.Uint16Array(r);var a=0,s=0;for(var i in e){var l=e[i];for(o=0;o<t.length;o++)for(var u=t[o],c=l.attributes[u].value,h=l.attributes[u].size,d="normal"===u,p=0;p<c.length;p++){var f=c[p];this.inside&&d&&(f=-f),this.attributes[u].value[p+h*s]=f}var g=l.indices.length;for(p=0;p<l.indices.length;p++)this.indices[p+a]=s+l.indices[this.inside?g-p-1:p];a+=l.indices.length,s+=l.vertexCount}this.boundingBox=new bK,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function Y$(e,t,n){j$.identity();var r=new W$({widthSegments:t,heightSegments:n});switch(e){case"px":aK.translate(j$,j$,Fq.POSITIVE_X),aK.rotateY(j$,j$,Math.PI/2);break;case"nx":aK.translate(j$,j$,Fq.NEGATIVE_X),aK.rotateY(j$,j$,-Math.PI/2);break;case"py":aK.translate(j$,j$,Fq.POSITIVE_Y),aK.rotateX(j$,j$,-Math.PI/2);break;case"ny":aK.translate(j$,j$,Fq.NEGATIVE_Y),aK.rotateX(j$,j$,Math.PI/2);break;case"pz":aK.translate(j$,j$,Fq.POSITIVE_Z);break;case"nz":aK.translate(j$,j$,Fq.NEGATIVE_Z),aK.rotateY(j$,j$,Math.PI)}return r.applyTransform(j$),r}wq.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");var Z$=LK.extend((function(){var e=new wq({vertex:wq.source("clay.skybox.vertex"),fragment:wq.source("clay.skybox.fragment")}),t=new jZ({shader:e,depthMask:!1});return{scene:null,geometry:new X$,material:t,environmentMap:null,culling:!1,_dummyCamera:new E$}}),(function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)}),{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){"texture2D"===e.textureType?(this.material.define("EQUIRECTANGULAR"),e.minFilter=EK.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,n){this.renderSkybox(e,n)},renderSkybox:function(e,t){var n=this._dummyCamera;n.aspect=e.getViewportAspect(),n.fov=t.fov||50,n.updateProjectionMatrix(),aK.invert(n.invProjectionMatrix,n.projectionMatrix),n.worldTransform.copy(t.worldTransform),n.viewMatrix.copy(t.viewMatrix),this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],n)}});function q$(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var K$=q$("DXT1"),$$=q$("DXT3"),J$=q$("DXT5"),Q$=function(e,t){var n=new Int32Array(e,0,31);if(542327876!==n[0])return null;if(4&!n(20))return null;var r,i,o=n(21),a=n[4],s=n[3],l=512&n[28],u=131072&n[2];switch(o){case K$:r=8,i=EK.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case $$:r=16,i=EK.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case J$:r=16,i=EK.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var c=n[1]+4,h=l?6:1,d=1;u&&(d=Math.max(1,n[7]));for(var p=[],f=0;f<h;f++){var g=a,m=s;p[f]=new RK({width:g,height:m,format:i});for(var v=[],y=0;y<d;y++){var _=Math.max(4,g)/4*Math.max(4,m)/4*r,x=new Uint8Array(e,c,_);c+=_,g*=.5,m*=.5,v[y]=x}p[f].pixels=v[0],u&&(p[f].mipmaps=v)}if(!t)return p[0];t.width=p[0].width,t.height=p[0].height,t.format=p[0].format,t.pixels=p[0].pixels,t.mipmaps=p[0].mipmaps},eJ=String.fromCharCode;function tJ(e,t,n,r){if(e[3]>0){var i=Math.pow(2,e[3]-128-8+r);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function nJ(e,t,n,r){for(var i,o,a=0,s=0,l=r;l>0;)if(e[s][0]=t[n++],e[s][1]=t[n++],e[s][2]=t[n++],e[s][3]=t[n++],1===e[s][0]&&1===e[s][1]&&1===e[s][2]){for(var u=e[s][3]<<a>>>0;u>0;u--)i=e[s-1],(o=e[s])[0]=i[0],o[1]=i[1],o[2]=i[2],o[3]=i[3],s++,l--;a+=8}else s++,l--,a=0;return n}function rJ(e,t,n,r){if(r<8|r>32767)return nJ(e,t,n,r);if(2!=(i=t[n++]))return nJ(e,t,n-1,r);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var o=0;o<r;){var a=t[n++];if(a>128){a=(127&a)>>>0;for(var s=t[n++];a--;)e[o++][i]=s}else for(;a--;)e[o++][i]=t[n++]}return n}var iJ=function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),i=r.length;if("#?"===function(e,t,n){for(var r="",i=t;i<n;i++)r+=eJ(e[i]);return r}(r,0,2)){for(var o=2;o<i&&("\n"!==eJ(r[o])||"\n"!==eJ(r[o+1]));o++);if(!(o>=i)){o+=2;for(var a="";o<i;o++){var s=eJ(r[o]);if("\n"===s)break;a+=s}var l=a.split(" "),u=parseInt(l[1]),c=parseInt(l[3]);if(c&&u){for(var h=o+1,d=[],p=0;p<c;p++){d[p]=[];for(var f=0;f<4;f++)d[p][f]=0}for(var g=new Float32Array(c*u*4),m=0,v=0;v<u;v++){if(!(h=rJ(d,r,h,c)))return null;for(p=0;p<c;p++)tJ(d[p],g,m,n),m+=4}return t||(t=new RK),t.width=c,t.height=u,t.pixels=g,t.type=EK.FLOAT,t}}}},oJ={loadTexture:function(e,t,n,r){var i;if("function"==typeof t?(r=n=t,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return i=new RK({width:0,height:0,sRGB:!1}),oJ._fetchTexture(e,(function(e){iJ(e,i,t.exposure),i.dirty(),n&&n(i)}),r),i;e.match(/.dds$/)||"dds"===t.fileType?(i=new RK({width:0,height:0}),oJ._fetchTexture(e,(function(e){Q$(e,i),i.dirty(),n&&n(i)}),r)):((i=new RK).load(e),i.success(n),i.error(r))}else"object"==typeof e&&void 0!==e.px&&((i=new A$).load(e),i.success(n),i.error(r));return i},loadPanorama:function(e,t,n,r,i,o){var a=this;"function"==typeof r?(o=i=r,r={}):r=r||{},oJ.loadTexture(t,r,(function(t){t.flipY=r.flipY||!1,a.panoramaToCubeMap(e,t,n,r),t.dispose(e),i&&i(n)}),o)},panoramaToCubeMap:function(e,t,n,r){var i=new U$,o=new Z$({scene:new b$});return o.setEnvironmentMap(t),(r=r||{}).encodeRGBM&&o.material.define("fragment","RGBM_ENCODE"),n.sRGB=t.sRGB,i.texture=n,i.render(e,o.scene),i.texture=null,i.dispose(e),n},heightToNormal:function(e,t){var n=document.createElement("canvas"),r=n.width=e.width,i=n.height=e.height,o=n.getContext("2d");o.drawImage(e,0,0,r,i),t=t||!1;for(var a=o.getImageData(0,0,r,i),s=o.createImageData(r,i),l=0;l<a.data.length;l+=4){if(t){var u=a.data[l],c=a.data[l+1],h=a.data[l+2];if(Math.abs(u-c)+Math.abs(c-h)>20)return console.warn("Given image is not a height map"),e}var d,p,f,g;l%(4*r)==0?(d=a.data[l],f=a.data[l+4]):l%(4*r)==4*(r-1)?(d=a.data[l-4],f=a.data[l]):(d=a.data[l-4],f=a.data[l+4]),l<4*r?(p=a.data[l],g=a.data[l+4*r]):l>r*(i-1)*4?(p=a.data[l-4*r],g=a.data[l]):(p=a.data[l-4*r],g=a.data[l+4*r]),s.data[l]=d-f+127,s.data[l+1]=p-g+127,s.data[l+2]=255,s.data[l+3]=255}return o.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var r=document.createElement("canvas"),i=r.getContext("2d"),o=t||32;n=n||20,r.width=r.height=o,i.drawImage(e,0,0,o,o);for(var a=i.getImageData(0,0,o,o),s=0;s<a.data.length;s+=4){var l=a.data[s],u=a.data[s+1],c=a.data[s+2];if(Math.abs(l-u)+Math.abs(u-c)>n)return!1}return!0},_fetchTexture:function(e,t,n){SZ.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,r){e=e||512,t=t||64,n=n||"black",r=r||"white";var i=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var a=o.getContext("2d");a.fillStyle=r,a.fillRect(0,0,e,e),a.fillStyle=n;for(var s=0;s<i;s++)for(var l=0;l<i;l++){(l%2?s%2:s%2-1)&&a.fillRect(s*t,l*t,t,t)}return new RK({image:o,anisotropic:8})},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,1,1),new RK({image:t})}},aJ=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function sJ(e){return"_on"+e}var lJ=function(e){var t=this;this._texture=new RK({anisotropic:32,flipY:!1,surface:this,dispose:function(e){t.dispose(),RK.prototype.dispose.call(this,e)}}),aJ.forEach((function(e){this[sJ(e)]=function(t){t.triangle&&this._meshes.forEach((function(n){this.dispatchEvent(e,n,t.triangle,t.point)}),this)}}),this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};lJ.prototype={constructor:lJ,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(t instanceof HTMLCanvasElement){var n=this,r=e.getZr(),i=r.__oldRefreshImmediately||r.refreshImmediately;r.refreshImmediately=function(){i.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},r.__oldRefreshImmediately=i}else console.error("ECharts must init on canvas if it is used as texture."),t=document.createElement("canvas");this._texture.image=t,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var e=new Fq,t=new Fq,n=new Fq,r=new KZ,i=new KZ,o=new KZ,a=new KZ,s=new Fq;return function(l,u,c,h){var d=u.geometry,p=d.attributes.position,f=d.attributes.texcoord0,g=Fq.dot,m=Fq.cross;p.get(c[0],e.array),p.get(c[1],t.array),p.get(c[2],n.array),f.get(c[0],r.array),f.get(c[1],i.array),f.get(c[2],o.array),m(s,t,n);var v=g(e,s),y=g(h,s)/v;m(s,n,e);var _=g(h,s)/v;m(s,e,t);var x=g(h,s)/v;KZ.scale(a,r,y),KZ.scaleAndAdd(a,a,i,_),KZ.scaleAndAdd(a,a,o,x);var b=a.x*this._chart.getWidth(),w=a.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(aJ.forEach((function(t){e.on(t,this[sJ(t)],this)}),this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),aJ.forEach((function(t){e.off(t,this[sJ(t)])}),this)},dispose:function(){this._meshes.forEach((function(e){this.detachFromMesh(e)}),this)}};var uJ=p$.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=p$.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});wq.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var cJ=new W$,hJ=new LK({geometry:cJ,frustumCulling:!1}),dJ=new uJ,pJ=wY.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var e=new wq(wq.source("clay.compositor.vertex"),this.fragment),t=new jZ({shader:e});t.enableTexturesAll(),this.material=t}),{setUniform:function(e,t){this.material.setUniform(e,t)},getUniform:function(e){var t=this.material.uniforms[e];if(t)return t.value},attachOutput:function(e,t){this.outputs||(this.outputs={}),t=t||vZ,this.outputs[t]=e},detachOutput:function(e){for(var t in this.outputs)this.outputs[t]===e&&(this.outputs[t]=null)},bind:function(e,t){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&t.attach(r,n)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var n=e.gl;if(t){this.bind(e,t);var r=e.getGLExtension("EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var o in this.outputs)(o=+o)>=n.COLOR_ATTACHMENT0&&o<=n.COLOR_ATTACHMENT0+8&&i.push(o);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var a=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){a|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(a),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){hJ.material=this.material,e.renderPass([hJ],dJ)},dispose:function(e){}}),fJ={},gJ=["px","nx","py","ny","pz","nz"];fJ.prefilterEnvironmentMap=function(e,t,n,r,i){i&&r||(r=fJ.generateNormalDistribution(),i=fJ.integrateBRDF(e,r));var o=(n=n||{}).width||64,a=n.height||64,s=n.type||t.type,l=new A$({width:o,height:a,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(o,a),c=Math.log(u)/Math.log(2)+1,h=new jZ({shader:new wq({vertex:wq.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});h.set("normalDistribution",r),n.encodeRGBM&&h.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&h.define("fragment","RGBM_DECODE");var d,p=new b$;if("texture2D"===t.textureType){var f=new A$({width:o,height:a,type:s===EK.FLOAT?EK.HALF_FLOAT:s});oJ.panoramaToCubeMap(e,t,f,{encodeRGBM:n.decodeRGBM}),t=f}(d=new Z$({scene:p,material:h})).material.set("environmentMap",t);var g=new U$({texture:l});n.encodeRGBM&&(s=l.type=EK.UNSIGNED_BYTE);for(var m=new RK({width:o,height:a,type:s}),v=new G$({depthBuffer:!1}),y=SZ[s===EK.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],_=0;_<c;_++){l.mipmaps[_]={pixels:{}},d.material.set("roughness",_/(c-1));for(var x=m.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<gJ.length;w++){var S=new y(m.width*m.height*4);v.attach(m),v.bind(e);var T=g.getCamera(gJ[w]);T.fov=b,e.render(p,T),e.gl.readPixels(0,0,m.width,m.height,EK.RGBA,s,S),v.unbind(e),l.mipmaps[_].pixels[gJ[w]]=S}m.width/=2,m.height/=2,m.dirty()}return v.dispose(e),m.dispose(e),d.dispose(e),r.dispose(e),{environmentMap:l,brdfLookup:i,normalDistribution:r,maxMipmapLevel:c}},fJ.integrateBRDF=function(e,t){t=t||fJ.generateNormalDistribution();var n=new G$({depthBuffer:!1}),r=new pJ({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),i=new RK({width:512,height:256,type:EK.HALF_FLOAT,wrapS:EK.CLAMP_TO_EDGE,wrapT:EK.CLAMP_TO_EDGE,minFilter:EK.NEAREST,magFilter:EK.NEAREST,useMipmap:!1});return r.setUniform("normalDistribution",t),r.setUniform("viewportSize",[512,256]),r.attachOutput(i),r.render(e,n),n.dispose(e),i},fJ.generateNormalDistribution=function(e,t){for(var n=new RK({width:e=e||256,height:t=t||1024,type:EK.FLOAT,minFilter:EK.NEAREST,magFilter:EK.NEAREST,wrapS:EK.CLAMP_TO_EDGE,wrapT:EK.CLAMP_TO_EDGE,useMipmap:!1}),r=new Float32Array(t*e*4),i=[],o=0;o<e;o++){for(var a=o/e,s=a*a,l=0;l<t;l++){var u=(l<<16|l>>>16)>>>0;u=(((16711935&(u=((252645135&(u=((858993459&(u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0))<<2|(3435973836&u)>>>2)>>>0))<<4|(4042322160&u)>>>4)>>>0))<<8|(4278255360&u)>>>8)>>>0)/4294967296;var c=Math.sqrt((1-u)/(1+(s*s-1)*u));i[l]=c}for(l=0;l<t;l++){var h=4*(l*e+o),d=(c=i[l],Math.sqrt(1-c*c)),p=l/t,f=2*Math.PI*p;r[h]=d*Math.cos(f),r[h+1]=c,r[h+2]=d*Math.sin(f),r[h+3]=1}}return n.pixels=r,n};var mJ=r$.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(e.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=fJ.generateNormalDistribution(),this._brdfLookup=fJ.integrateBRDF(e,this._normalDistribution));var n=this.cubemap;if(!n.__prefiltered){var r=fJ.prefilterEnvironmentMap(e,n,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=r.environmentMap,this.cubemap.__prefiltered=!0,n.dispose(e)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),vJ=r$.extend({castShadow:!1,coefficients:[]},(function(){this._coefficientsTmpArr=new SZ.Float32Array(27)}),{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,n=0;n<e.coefficients.length;n++)t[n]=e.coefficients[n];return t}}}}),yJ={},_J=["px","nx","py","ny","pz","nz"];function xJ(e,t){var n=e[0],r=e[1],i=e[2];return 0===t?1:1===t?n:2===t?r:3===t?i:4===t?n*i:5===t?r*i:6===t?n*r:7===t?3*i*i-1:n*n-r*r}var bJ={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};yJ.projectEnvironmentMap=function(e,t,n){var r;(n=n||{}).lod=n.lod||0;var i=new b$,o=64;"texture2D"===t.textureType||(o=t.image&&t.image.px?t.image.px.width:t.width),r=new Z$({scene:i,environmentMap:t});var a=Math.ceil(o/Math.pow(2,n.lod)),s=Math.ceil(o/Math.pow(2,n.lod)),l=new RK({width:a,height:s}),u=new G$;r.material.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&r.material.define("fragment","RGBM_DECODE"),r.material.set("lod",n.lod);for(var c=new U$({texture:l}),h={},d=0;d<_J.length;d++){h[_J[d]]=new Uint8Array(a*s*4);var p=c.getCamera(_J[d]);p.fov=90,u.attach(l),u.bind(e),e.render(i,p),e.gl.readPixels(0,0,a,s,EK.RGBA,EK.UNSIGNED_BYTE,h[_J[d]]),u.unbind(e)}return r.dispose(e),u.dispose(e),l.dispose(e),function(e,t,n,r){for(var i=new SZ.Float32Array(27),o=Dq.create(),a=Dq.create(),s=Dq.create(),l=0;l<9;l++){for(var u=Dq.create(),c=0;c<_J.length;c++){for(var h=t[_J[c]],d=Dq.create(),p=0,f=0,g=bJ[_J[c]],m=0;m<r;m++)for(var v=0;v<n;v++){o[0]=v/(n-1)*2-1,o[1]=m/(r-1)*2-1,o[2]=-1,Dq.normalize(o,o),s[0]=o[g[0]]*g[3],s[1]=o[g[1]]*g[4],s[2]=o[g[2]]*g[5],a[0]=h[f++]/255,a[1]=h[f++]/255,a[2]=h[f++]/255;var y=h[f++]/255*8.12;a[0]*=y,a[1]*=y,a[2]*=y,Dq.scaleAndAdd(d,d,a,xJ(s,l)*-o[2]),p+=-o[2]}Dq.scaleAndAdd(u,u,d,1/p)}i[3*l]=u[0]/6,i[3*l+1]=u[1]/6,i[3*l+2]=u[2]/6}return i}(0,h,a,s)};var wJ=function(){for(var e=0,t=arguments.length;e<t;e++)if(null!=arguments[e])return arguments[e]},SJ=function(e,t){return null!=t.dataIndexInside?t.dataIndexInside:null!=t.dataIndex?J(t.dataIndex)?j(t.dataIndex,(function(t){return e.indexOfRawIndex(t)})):e.indexOfRawIndex(t.dataIndex):null!=t.name?J(t.name)?j(t.name,(function(t){return e.indexOfName(t)})):e.indexOfName(t.name):void 0},TJ=XK.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,r=this.attributes.texcoord0,i=this.attributes.normal,o=(t+1)*(e+1);n.init(o),r.init(o),i.init(o);var a,s,l,u,c,h,d,p,f,g,m,v=o>65535?Uint32Array:Uint16Array,y=this.indices=new v(t*e*6),_=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,S=this.thetaLength,T=[],M=[],C=0,D=1/(_=this.radius);for(d=0;d<=e;d++)for(h=0;h<=t;h++)u=h/t,c=d/e,a=-_*Math.cos(x+u*b)*Math.sin(w+c*S),s=_*Math.cos(w+c*S),l=_*Math.sin(x+u*b)*Math.sin(w+c*S),T[0]=a,T[1]=s,T[2]=l,M[0]=u,M[1]=c,n.set(C,T),r.set(C,M),T[0]*=D,T[1]*=D,T[2]*=D,i.set(C,T),C++;var A=t+1,I=0;for(d=0;d<e;d++)for(h=0;h<t;h++)f=d*A+h,p=d*A+h+1,m=(d+1)*A+h+1,g=(d+1)*A+h,y[I++]=p,y[I++]=f,y[I++]=m,y[I++]=f,y[I++]=g,y[I++]=m;this.boundingBox=new bK,this.boundingBox.max.set(_,_,_),this.boundingBox.min.set(-_,-_,-_)}}),MJ=r$.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}}),CJ=r$.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Fq,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),DJ=r$.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(e){return e.range}},pointLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.range=this.range,e}}),AJ=r$.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(e){return e.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(e){return e.falloffFactor}},spotLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Fq,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=r$.prototype.clone.call(this);return e.range=this.range,e.umbraAngle=this.umbraAngle,e.penumbraAngle=this.penumbraAngle,e.falloffFactor=this.falloffFactor,e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),IJ=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=r||0,this.array=Qq.fromValues(e,t,n,r),this._dirty=!0};IJ.prototype={constructor:IJ,add:function(e){return Qq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new IJ(this.x,this.y,this.z,this.w)},copy:function(e){return Qq.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return Qq.dist(this.array,e.array)},distance:function(e){return Qq.distance(this.array,e.array)},div:function(e){return Qq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Qq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Qq.dot(this.array,e.array)},len:function(){return Qq.len(this.array)},length:function(){return Qq.length(this.array)},lerp:function(e,t,n){return Qq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Qq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Qq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Qq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Qq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Qq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Qq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Qq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Qq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Qq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Qq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Qq.squaredDistance(this.array,e.array)},sqrLen:function(){return Qq.sqrLen(this.array)},squaredLength:function(){return Qq.squaredLength(this.array)},sub:function(e){return Qq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Qq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Qq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Qq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var EJ=Object.defineProperty;if(EJ){var LJ=IJ.prototype;EJ(LJ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),EJ(LJ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),EJ(LJ,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),EJ(LJ,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}IJ.add=function(e,t,n){return Qq.add(e.array,t.array,n.array),e._dirty=!0,e},IJ.set=function(e,t,n,r,i){Qq.set(e.array,t,n,r,i),e._dirty=!0},IJ.copy=function(e,t){return Qq.copy(e.array,t.array),e._dirty=!0,e},IJ.distance=IJ.dist=function(e,t){return Qq.distance(e.array,t.array)},IJ.div=function(e,t,n){return Qq.divide(e.array,t.array,n.array),e._dirty=!0,e},IJ.divide=IJ.div,IJ.dot=function(e,t){return Qq.dot(e.array,t.array)},IJ.len=function(e){return Qq.length(e.array)},IJ.lerp=function(e,t,n,r){return Qq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},IJ.min=function(e,t,n){return Qq.min(e.array,t.array,n.array),e._dirty=!0,e},IJ.max=function(e,t,n){return Qq.max(e.array,t.array,n.array),e._dirty=!0,e},IJ.mul=function(e,t,n){return Qq.multiply(e.array,t.array,n.array),e._dirty=!0,e},IJ.multiply=IJ.mul,IJ.negate=function(e,t){return Qq.negate(e.array,t.array),e._dirty=!0,e},IJ.normalize=function(e,t){return Qq.normalize(e.array,t.array),e._dirty=!0,e},IJ.random=function(e,t){return Qq.random(e.array,t),e._dirty=!0,e},IJ.scale=function(e,t,n){return Qq.scale(e.array,t.array,n),e._dirty=!0,e},IJ.scaleAndAdd=function(e,t,n,r){return Qq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},IJ.squaredDistance=IJ.sqrDist=function(e,t){return Qq.sqrDist(e.array,t.array)},IJ.squaredLength=IJ.sqrLen=function(e){return Qq.sqrLen(e.array)},IJ.sub=function(e,t,n){return Qq.subtract(e.array,t.array,n.array),e._dirty=!0,e},IJ.subtract=IJ.sub,IJ.transformMat4=function(e,t,n){return Qq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},IJ.transformQuat=function(e,t,n){return Qq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var NJ={create:function(){var e=new YZ(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},clone:function(e){var t=new YZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},transpose:function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(a=1/a,e[0]=o*a,e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null},adjoint:function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},determinant:function(e){return e[0]*e[3]-e[2]*e[1]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*u+o*c,e[3]=i*u+a*c,e}};NJ.mul=NJ.multiply,NJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},NJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1];return e[0]=r*s,e[1]=i*s,e[2]=o*l,e[3]=a*l,e},NJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))},NJ.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]};var PJ=function(){this.array=NJ.create(),this._dirty=!0};PJ.prototype={constructor:PJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new PJ).copy(this)},copy:function(e){return NJ.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return NJ.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return NJ.determinant(this.array)},identity:function(){return NJ.identity(this.array),this._dirty=!0,this},invert:function(){return NJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return NJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return NJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return NJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return NJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return NJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return NJ.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return NJ.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},PJ.adjoint=function(e,t){return NJ.adjoint(e.array,t.array),e._dirty=!0,e},PJ.copy=function(e,t){return NJ.copy(e.array,t.array),e._dirty=!0,e},PJ.determinant=function(e){return NJ.determinant(e.array)},PJ.identity=function(e){return NJ.identity(e.array),e._dirty=!0,e},PJ.invert=function(e,t){return NJ.invert(e.array,t.array),e._dirty=!0,e},PJ.mul=function(e,t,n){return NJ.mul(e.array,t.array,n.array),e._dirty=!0,e},PJ.multiply=PJ.mul,PJ.rotate=function(e,t,n){return NJ.rotate(e.array,t.array,n),e._dirty=!0,e},PJ.scale=function(e,t,n){return NJ.scale(e.array,t.array,n.array),e._dirty=!0,e},PJ.transpose=function(e,t){return NJ.transpose(e.array,t.array),e._dirty=!0,e};var OJ={create:function(){var e=new YZ(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},clone:function(e){var t=new YZ(6);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},copy:function(e,t){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},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(l=1/l,e[0]=o*l,e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},determinant:function(e){return e[0]*e[3]-e[1]*e[2]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1],h=n[2],d=n[3],p=n[4],f=n[5];return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*p+o*f+s,e[5]=i*p+a*f+l,e}};OJ.mul=OJ.multiply,OJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=Math.sin(n),c=Math.cos(n);return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*-u+o*c,e[3]=i*-u+a*c,e[4]=s,e[5]=l,e},OJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r*u,e[1]=i*u,e[2]=o*c,e[3]=a*c,e[4]=s,e[5]=l,e},OJ.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*u+o*c+s,e[5]=i*u+a*c+l,e},OJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)};var RJ=function(){this.array=OJ.create(),this._dirty=!0};RJ.prototype={constructor:RJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new RJ).copy(this)},copy:function(e){return OJ.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return OJ.determinant(this.array)},identity:function(){return OJ.identity(this.array),this._dirty=!0,this},invert:function(){return OJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return OJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return OJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return OJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return OJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return OJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return OJ.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return OJ.translate(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},RJ.copy=function(e,t){return OJ.copy(e.array,t.array),e._dirty=!0,e},RJ.determinant=function(e){return OJ.determinant(e.array)},RJ.identity=function(e){return OJ.identity(e.array),e._dirty=!0,e},RJ.invert=function(e,t){return OJ.invert(e.array,t.array),e._dirty=!0,e},RJ.mul=function(e,t,n){return OJ.mul(e.array,t.array,n.array),e._dirty=!0,e},RJ.multiply=RJ.mul,RJ.rotate=function(e,t,n){return OJ.rotate(e.array,t.array,n),e._dirty=!0,e},RJ.scale=function(e,t,n){return OJ.scale(e.array,t.array,n.array),e._dirty=!0,e},RJ.translate=function(e,t,n){return OJ.translate(e.array,t.array,n.array),e._dirty=!0,e};var kJ=function(){this.array=eK.create(),this._dirty=!0};kJ.prototype={constructor:kJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return eK.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new kJ).copy(this)},copy:function(e){return eK.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return eK.determinant(this.array)},fromMat2d:function(e){return eK.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return eK.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return eK.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return eK.identity(this.array),this._dirty=!0,this},invert:function(){return eK.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return eK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return eK.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return eK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return eK.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return eK.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return eK.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return eK.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return eK.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return eK.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},kJ.adjoint=function(e,t){return eK.adjoint(e.array,t.array),e._dirty=!0,e},kJ.copy=function(e,t){return eK.copy(e.array,t.array),e._dirty=!0,e},kJ.determinant=function(e){return eK.determinant(e.array)},kJ.identity=function(e){return eK.identity(e.array),e._dirty=!0,e},kJ.invert=function(e,t){return eK.invert(e.array,t.array),e},kJ.mul=function(e,t,n){return eK.mul(e.array,t.array,n.array),e._dirty=!0,e},kJ.multiply=kJ.mul,kJ.fromMat2d=function(e,t){return eK.fromMat2d(e.array,t.array),e._dirty=!0,e},kJ.fromMat4=function(e,t){return eK.fromMat4(e.array,t.array),e._dirty=!0,e},kJ.fromQuat=function(e,t){return eK.fromQuat(e.array,t.array),e._dirty=!0,e},kJ.normalFromMat4=function(e,t){return eK.normalFromMat4(e.array,t.array),e._dirty=!0,e},kJ.rotate=function(e,t,n){return eK.rotate(e.array,t.array,n),e._dirty=!0,e},kJ.scale=function(e,t,n){return eK.scale(e.array,t.array,n.array),e._dirty=!0,e},kJ.transpose=function(e,t){return eK.transpose(e.array,t.array),e._dirty=!0,e},kJ.translate=function(e,t,n){return eK.translate(e.array,t.array,n.array),e._dirty=!0,e};var zJ={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quarticIn:function(e){return e*e*e*e},quarticOut:function(e){return 1- --e*e*e*e},quarticInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quinticIn:function(e){return e*e*e*e*e},quinticOut:function(e){return--e*e*e*e*e+1},quinticInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sinusoidalIn:function(e){return 1-Math.cos(e*Math.PI/2)},sinusoidalOut:function(e){return Math.sin(e*Math.PI/2)},sinusoidalInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},exponentialIn:function(e){return 0===e?0:Math.pow(1024,e-1)},exponentialOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},exponentialInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circularIn:function(e){return 1-Math.sqrt(1-e*e)},circularOut:function(e){return Math.sqrt(1- --e*e)},circularInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},elasticOut:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},elasticInOut:function(e){var t,n=.1,r=.4;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=r*Math.asin(1/n)/(2*Math.PI),(e*=2)<1?n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/r)*-.5:n*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/r)*.5+1)},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:function(e){return 1-zJ.bounceOut(1-e)},bounceOut:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},bounceInOut:function(e){return e<.5?.5*zJ.bounceIn(2*e):.5*zJ.bounceOut(2*e-1)+.5}};XJ(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],(function(e,t){return e["[object "+t+"]"]=!0,e}),{}),XJ(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],(function(e,t){return e["[object "+t+"Array]"]=!0,e}),{});var VJ=Array.prototype,BJ=VJ.slice,FJ=VJ.map,GJ=function(){}.constructor,HJ=GJ?GJ.prototype:null;function UJ(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];"undefined"!=typeof console&&console.error.apply(console,e)}function WJ(e){return!!e&&("string"!=typeof e&&"number"==typeof e.length)}function jJ(e,t,n){if(!e)return[];if(!t)return function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return BJ.apply(e,t)}(e);if(e.map&&e.map===FJ)return e.map(t,n);for(var r=[],i=0,o=e.length;i<o;i++)r.push(t.call(n,e[i],i,e));return r}function XJ(e,t,n,r){if(e&&t){for(var i=0,o=e.length;i<o;i++)n=t.call(r,n,e[i],i,e);return n}}function YJ(e){if(!e)return[];if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function ZJ(e){return"function"==typeof e}function qJ(e){return"number"==typeof e}function KJ(e){return null==e?null:"function"==typeof e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function $J(e,t){for(var n=new e.constructor(e.length+t.length),r=0;r<e.length;r++)n[r]=e[r];var i=e.length;for(r=0;r<t.length;r++)n[r+i]=t[r];return n}function JJ(){}function QJ(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}HJ&&ZJ(HJ.bind)&&HJ.call.bind(HJ.bind);var eQ=Math.pow,tQ=Math.sqrt,nQ=tQ(3),rQ=1/3;function iQ(e){return e>-1e-8&&e<1e-8}var oQ=/cubic-bezier\(([0-9,\.e ]+)\)/;function aQ(e){var t=e&&oQ.exec(e);if(t){var n=t[1].split(","),r=+KJ(n[0]),i=+KJ(n[1]),o=+KJ(n[2]),a=+KJ(n[3]);if(isNaN(r+i+o+a))return;var s=[];return function(e){return e<=0?0:e>=1?1:function(e,t,n,r,i,o){var a=r+3*(t-n)-e,s=3*(n-2*t+e),l=3*(t-e),u=e-i,c=s*s-3*a*l,h=s*l-9*a*u,d=l*l-3*s*u,p=0;if(iQ(c)&&iQ(h))iQ(s)?o[0]=0:(T=-l/s)>=0&&T<=1&&(o[p++]=T);else{var f=h*h-4*c*d;if(iQ(f)){var g=h/c,m=-g/2;(T=-s/a+g)>=0&&T<=1&&(o[p++]=T),m>=0&&m<=1&&(o[p++]=m)}else if(f>0){var v=tQ(f),y=c*s+1.5*a*(-h+v),_=c*s+1.5*a*(-h-v);(T=(-s-((y=y<0?-eQ(-y,rQ):eQ(y,rQ))+(_=_<0?-eQ(-_,rQ):eQ(_,rQ))))/(3*a))>=0&&T<=1&&(o[p++]=T)}else{var x=(2*c*s-3*a*h)/(2*tQ(c*c*c)),b=Math.acos(x)/3,w=tQ(c),S=Math.cos(b),T=(-s-2*w*S)/(3*a),M=(m=(-s+w*(S+nQ*Math.sin(b)))/(3*a),(-s+w*(S-nQ*Math.sin(b)))/(3*a));T>=0&&T<=1&&(o[p++]=T),m>=0&&m<=1&&(o[p++]=m),M>=0&&M<=1&&(o[p++]=M)}}return p}(0,r,o,1,e,s)&&function(e,t,n,r,i){var o=1-i;return o*o*(o*e+3*i*t)+i*i*(i*r+3*o*n)}(0,i,a,1,s[0])}}}var sQ=function(){function e(e){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=e.life||1e3,this._delay=e.delay||0,this.loop=e.loop||!1,this.onframe=e.onframe||JJ,this.ondestroy=e.ondestroy||JJ,this.onrestart=e.onrestart||JJ,e.easing&&this.setEasing(e.easing)}return e.prototype.step=function(e,t){if(this._inited||(this._startTime=e+this._delay,this._inited=!0),!this._paused){var n=this._life,r=e-this._startTime-this._pausedTime,i=r/n;i<0&&(i=0),i=Math.min(i,1);var o=this.easingFunc,a=o?o(i):i;if(this.onframe(a),1===i){if(!this.loop)return!0;var s=r%n;this._startTime=e-s,this._pausedTime=0,this.onrestart()}return!1}this._pausedTime+=t},e.prototype.pause=function(){this._paused=!0},e.prototype.resume=function(){this._paused=!1},e.prototype.setEasing=function(e){this.easing=e,this.easingFunc=ZJ(e)?e:zJ[e]||aQ(e)},e}(),lQ={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],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 uQ(e){return(e=Math.round(e))<0?0:e>255?255:e}function cQ(e){return e<0?0:e>1?1:e}function hQ(e){var t=e;return t.length&&"%"===t.charAt(t.length-1)?uQ(parseFloat(t)/100*255):uQ(parseInt(t,10))}function dQ(e){var t=e;return t.length&&"%"===t.charAt(t.length-1)?cQ(parseFloat(t)/100):cQ(parseFloat(t))}function pQ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function fQ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function gQ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var mQ=new M$(20),vQ=null;function yQ(e,t){vQ&&gQ(vQ,t),vQ=mQ.put(e,vQ||t.slice())}function _Q(e,t){if(e){t=t||[];var n=mQ.get(e);if(n)return gQ(t,n);var r=(e+="").replace(/ /g,"").toLowerCase();if(r in lQ)return gQ(t,lQ[r]),yQ(e,t),t;var i,o=r.length;if("#"===r.charAt(0))return 4===o||5===o?(i=parseInt(r.slice(1,4),16))>=0&&i<=4095?(fQ(t,(3840&i)>>4|(3840&i)>>8,240&i|(240&i)>>4,15&i|(15&i)<<4,5===o?parseInt(r.slice(4),16)/15:1),yQ(e,t),t):void fQ(t,0,0,0,1):7===o||9===o?(i=parseInt(r.slice(1,7),16))>=0&&i<=16777215?(fQ(t,(16711680&i)>>16,(65280&i)>>8,255&i,9===o?parseInt(r.slice(7),16)/255:1),yQ(e,t),t):void fQ(t,0,0,0,1):void 0;var a=r.indexOf("("),s=r.indexOf(")");if(-1!==a&&s+1===o){var l=r.substr(0,a),u=r.substr(a+1,s-(a+1)).split(","),c=1;switch(l){case"rgba":if(4!==u.length)return 3===u.length?fQ(t,+u[0],+u[1],+u[2],1):fQ(t,0,0,0,1);c=dQ(u.pop());case"rgb":return u.length>=3?(fQ(t,hQ(u[0]),hQ(u[1]),hQ(u[2]),3===u.length?c:dQ(u[3])),yQ(e,t),t):void fQ(t,0,0,0,1);case"hsla":return 4!==u.length?void fQ(t,0,0,0,1):(u[3]=dQ(u[3]),xQ(u,t),yQ(e,t),t);case"hsl":return 3!==u.length?void fQ(t,0,0,0,1):(xQ(u,t),yQ(e,t),t);default:return}}fQ(t,0,0,0,1)}}function xQ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=dQ(e[1]),i=dQ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return fQ(t=t||[],uQ(255*pQ(a,o,n+1/3)),uQ(255*pQ(a,o,n)),uQ(255*pQ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}var bQ=function(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1},wQ=new function(){this.browser=new bQ,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow="undefined"!=typeof window};"object"==typeof wx&&"function"==typeof wx.getSystemInfoSync?(wQ.wxa=!0,wQ.touchEventsSupported=!0):"undefined"==typeof document&&"undefined"!=typeof self?wQ.worker=!0:!wQ.hasGlobalWindow||"Deno"in window?(wQ.node=!0,wQ.svgSupported=!0):function(e,t){var n=t.browser,r=e.match(/Firefox\/([\d.]+)/),i=e.match(/MSIE\s([\d.]+)/)||e.match(/Trident\/.+?rv:(([\d.]+))/),o=e.match(/Edge?\/([\d.]+)/),a=/micromessenger/i.test(e);r&&(n.firefox=!0,n.version=r[1]);i&&(n.ie=!0,n.version=i[1]);o&&(n.edge=!0,n.version=o[1],n.newEdge=+o[1].split(".")[0]>18);a&&(n.weChat=!0);t.svgSupported="undefined"!=typeof SVGRect,t.touchEventsSupported="ontouchstart"in window&&!n.ie&&!n.edge,t.pointerEventsSupported="onpointerdown"in window&&(n.edge||n.ie&&+n.version>=11),t.domSupported="undefined"!=typeof document;var s=document.documentElement.style;t.transform3dSupported=(n.ie&&"transition"in s||n.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||n.ie&&+n.version>=9}(navigator.userAgent,wQ),wQ.hasGlobalWindow&&ZJ(window.btoa);var SQ=Array.prototype.slice;function TQ(e,t,n){return(t-e)*n+e}function MQ(e,t,n,r){for(var i=t.length,o=0;o<i;o++)e[o]=TQ(t[o],n[o],r);return e}function CQ(e,t,n,r){for(var i=t.length,o=0;o<i;o++)e[o]=t[o]+n[o]*r;return e}function DQ(e,t,n,r){for(var i=t.length,o=i&&t[0].length,a=0;a<i;a++){e[a]||(e[a]=[]);for(var s=0;s<o;s++)e[a][s]=t[a][s]+n[a][s]*r}return e}function AQ(e,t){for(var n=e.length,r=t.length,i=n>r?t:e,o=Math.min(n,r),a=i[o-1]||{color:[0,0,0,0],offset:0},s=o;s<Math.max(n,r);s++)i.push({offset:a.offset,color:a.color.slice()})}function IQ(e,t,n){var r=e,i=t;if(r.push&&i.push){var o=r.length,a=i.length;if(o!==a)if(o>a)r.length=a;else for(var s=o;s<a;s++)r.push(1===n?i[s]:SQ.call(i[s]));var l=r[0]&&r[0].length;for(s=0;s<r.length;s++)if(1===n)isNaN(r[s])&&(r[s]=i[s]);else for(var u=0;u<l;u++)isNaN(r[s][u])&&(r[s][u]=i[s][u])}}function EQ(e){if(WJ(e)){var t=e.length;if(WJ(e[0])){for(var n=[],r=0;r<t;r++)n.push(SQ.call(e[r]));return n}return SQ.call(e)}return e}function LQ(e){return e[0]=Math.floor(e[0])||0,e[1]=Math.floor(e[1])||0,e[2]=Math.floor(e[2])||0,e[3]=null==e[3]?1:e[3],"rgba("+e.join(",")+")"}function NQ(e){return 4===e||5===e}function PQ(e){return 1===e||2===e}var OQ=[0,0,0,0],RQ=function(){function e(e){this.keyframes=[],this.discrete=!1,this._invalid=!1,this._needsSort=!1,this._lastFr=0,this._lastFrP=0,this.propName=e}return e.prototype.isFinished=function(){return this._finished},e.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},e.prototype.needsAnimate=function(){return this.keyframes.length>=1},e.prototype.getAdditiveTrack=function(){return this._additiveTrack},e.prototype.addKeyframe=function(e,t,n){this._needsSort=!0;var r=this.keyframes,i=r.length,o=!1,a=6,s=t;if(WJ(t)){var l=function(e){return WJ(e&&e[0])?2:1}(t);a=l,(1===l&&!qJ(t[0])||2===l&&!qJ(t[0][0]))&&(o=!0)}else if(qJ(t)&&!function(e){return e!=e}(t))a=0;else if(function(e){return"string"==typeof e}(t))if(isNaN(+t)){var u=_Q(t);u&&(s=u,a=3)}else a=0;else if(function(e){return null!=e.colorStops}(t)){var c=function(e,t){if(Object.assign)Object.assign(e,t);else for(var n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=t[n]);return e}({},s);c.colorStops=jJ(t.colorStops,(function(e){return{offset:e.offset,color:_Q(e.color)}})),"linear"===t.type?a=4:function(e){return"radial"===e.type}(t)&&(a=5),s=c}0===i?this.valType=a:a===this.valType&&6!==a||(o=!0),this.discrete=this.discrete||o;var h={time:e,value:s,rawValue:t,percent:0};return n&&(h.easing=n,h.easingFunc=ZJ(n)?n:zJ[n]||aQ(n)),r.push(h),h},e.prototype.prepare=function(e,t){var n=this.keyframes;this._needsSort&&n.sort((function(e,t){return e.time-t.time}));for(var r=this.valType,i=n.length,o=n[i-1],a=this.discrete,s=PQ(r),l=NQ(r),u=0;u<i;u++){var c=n[u],h=c.value,d=o.value;c.percent=c.time/e,a||(s&&u!==i-1?IQ(h,d,r):l&&AQ(h.colorStops,d.colorStops))}if(!a&&5!==r&&t&&this.needsAnimate()&&t.needsAnimate()&&r===t.valType&&!t._finished){this._additiveTrack=t;var p=n[0].value;for(u=0;u<i;u++)0===r?n[u].additiveValue=n[u].value-p:3===r?n[u].additiveValue=CQ([],n[u].value,p,-1):PQ(r)&&(n[u].additiveValue=1===r?CQ([],n[u].value,p,-1):DQ([],n[u].value,p,-1))}},e.prototype.step=function(e,t){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var n,r,i,o=null!=this._additiveTrack,a=o?"additiveValue":"value",s=this.valType,l=this.keyframes,u=l.length,c=this.propName,h=3===s,d=this._lastFr,p=Math.min;if(1===u)r=i=l[0];else{if(t<0)n=0;else if(t<this._lastFrP){for(n=p(d+1,u-1);n>=0&&!(l[n].percent<=t);n--);n=p(n,u-2)}else{for(n=d;n<u&&!(l[n].percent>t);n++);n=p(n-1,u-2)}i=l[n+1],r=l[n]}if(r&&i){this._lastFr=n,this._lastFrP=t;var f=i.percent-r.percent,g=0===f?1:p((t-r.percent)/f,1);i.easingFunc&&(g=i.easingFunc(g));var m=o?this._additiveValue:h?OQ:e[c];if(!PQ(s)&&!h||m||(m=this._additiveValue=[]),this.discrete)e[c]=g<1?r.rawValue:i.rawValue;else if(PQ(s))1===s?MQ(m,r[a],i[a],g):function(e,t,n,r){for(var i=t.length,o=i&&t[0].length,a=0;a<i;a++){e[a]||(e[a]=[]);for(var s=0;s<o;s++)e[a][s]=TQ(t[a][s],n[a][s],r)}}(m,r[a],i[a],g);else if(NQ(s)){var v=r[a],y=i[a],_=4===s;e[c]={type:_?"linear":"radial",x:TQ(v.x,y.x,g),y:TQ(v.y,y.y,g),colorStops:jJ(v.colorStops,(function(e,t){var n=y.colorStops[t];return{offset:TQ(e.offset,n.offset,g),color:LQ(MQ([],e.color,n.color,g))}})),global:y.global},_?(e[c].x2=TQ(v.x2,y.x2,g),e[c].y2=TQ(v.y2,y.y2,g)):e[c].r=TQ(v.r,y.r,g)}else if(h)MQ(m,r[a],i[a],g),o||(e[c]=LQ(m));else{var x=TQ(r[a],i[a],g);o?this._additiveValue=x:e[c]=x}o&&this._addToTarget(e)}}},e.prototype._addToTarget=function(e){var t=this.valType,n=this.propName,r=this._additiveValue;0===t?e[n]=e[n]+r:3===t?(_Q(e[n],OQ),CQ(OQ,OQ,r,1),e[n]=LQ(OQ)):1===t?CQ(e[n],e[n],r,1):2===t&&DQ(e[n],e[n],r,1)},e}(),kQ=function(){function e(e,t,n,r){this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=e,this._loop=t,t&&r?UJ("Can' use additive animation on looped animation."):(this._additiveAnimators=r,this._allowDiscrete=n)}return e.prototype.getMaxTime=function(){return this._maxTime},e.prototype.getDelay=function(){return this._delay},e.prototype.getLoop=function(){return this._loop},e.prototype.getTarget=function(){return this._target},e.prototype.changeTarget=function(e){this._target=e},e.prototype.when=function(e,t,n){return this.whenWithKeys(e,t,YJ(t),n)},e.prototype.whenWithKeys=function(e,t,n,r){for(var i=this._tracks,o=0;o<n.length;o++){var a=n[o],s=i[a];if(!s){s=i[a]=new RQ(a);var l=void 0,u=this._getAdditiveTrack(a);if(u){var c=u.keyframes,h=c[c.length-1];l=h&&h.value,3===u.valType&&l&&(l=LQ(l))}else l=this._target[a];if(null==l)continue;e>0&&s.addKeyframe(0,EQ(l),r),this._trackKeys.push(a)}s.addKeyframe(e,EQ(t[a]),r)}return this._maxTime=Math.max(this._maxTime,e),this},e.prototype.pause=function(){this._clip.pause(),this._paused=!0},e.prototype.resume=function(){this._clip.resume(),this._paused=!1},e.prototype.isPaused=function(){return!!this._paused},e.prototype.duration=function(e){return this._maxTime=e,this._force=!0,this},e.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var e=this._doneCbs;if(e)for(var t=e.length,n=0;n<t;n++)e[n].call(this)},e.prototype._abortedCallback=function(){this._setTracksFinished();var e=this.animation,t=this._abortedCbs;if(e&&e.removeClip(this._clip),this._clip=null,t)for(var n=0;n<t.length;n++)t[n].call(this)},e.prototype._setTracksFinished=function(){for(var e=this._tracks,t=this._trackKeys,n=0;n<t.length;n++)e[t[n]].setFinished()},e.prototype._getAdditiveTrack=function(e){var t,n=this._additiveAnimators;if(n)for(var r=0;r<n.length;r++){var i=n[r].getTrack(e);i&&(t=i)}return t},e.prototype.start=function(e){if(!(this._started>0)){this._started=1;for(var t=this,n=[],r=this._maxTime||0,i=0;i<this._trackKeys.length;i++){var o=this._trackKeys[i],a=this._tracks[o],s=this._getAdditiveTrack(o),l=a.keyframes,u=l.length;if(a.prepare(r,s),a.needsAnimate())if(!this._allowDiscrete&&a.discrete){var c=l[u-1];c&&(t._target[a.propName]=c.rawValue),a.setFinished()}else n.push(a)}if(n.length||this._force){var h=new sQ({life:r,loop:this._loop,delay:this._delay||0,onframe:function(e){t._started=2;var r=t._additiveAnimators;if(r){for(var i=!1,o=0;o<r.length;o++)if(r[o]._clip){i=!0;break}i||(t._additiveAnimators=null)}for(o=0;o<n.length;o++)n[o].step(t._target,e);var a=t._onframeCbs;if(a)for(o=0;o<a.length;o++)a[o](t._target,e)},ondestroy:function(){t._doneCallback()}});this._clip=h,this.animation&&this.animation.addClip(h),e&&h.setEasing(e)}else this._doneCallback();return this}},e.prototype.stop=function(e){if(this._clip){var t=this._clip;e&&t.onframe(1),this._abortedCallback()}},e.prototype.delay=function(e){return this._delay=e,this},e.prototype.during=function(e){return e&&(this._onframeCbs||(this._onframeCbs=[]),this._onframeCbs.push(e)),this},e.prototype.done=function(e){return e&&(this._doneCbs||(this._doneCbs=[]),this._doneCbs.push(e)),this},e.prototype.aborted=function(e){return e&&(this._abortedCbs||(this._abortedCbs=[]),this._abortedCbs.push(e)),this},e.prototype.getClip=function(){return this._clip},e.prototype.getTrack=function(e){return this._tracks[e]},e.prototype.getTracks=function(){var e=this;return jJ(this._trackKeys,(function(t){return e._tracks[t]}))},e.prototype.stopTracks=function(e,t){if(!e.length||!this._clip)return!0;for(var n=this._tracks,r=this._trackKeys,i=0;i<e.length;i++){var o=n[e[i]];o&&!o.isFinished()&&(t?o.step(this._target,1):1===this._started&&o.step(this._target,0),o.setFinished())}var a=!0;for(i=0;i<r.length;i++)if(!n[r[i]].isFinished()){a=!1;break}return a&&this._abortedCallback(),a},e.prototype.saveTo=function(e,t,n){if(e){t=t||this._trackKeys;for(var r=0;r<t.length;r++){var i=t[r],o=this._tracks[i];if(o&&!o.isFinished()){var a=o.keyframes,s=a[n?0:a.length-1];s&&(e[i]=EQ(s.rawValue))}}}},e.prototype.__changeFinalValue=function(e,t){t=t||YJ(e);for(var n=0;n<t.length;n++){var r=t[n],i=this._tracks[r];if(i){var o=i.keyframes;if(o.length>1){var a=o.pop();i.addKeyframe(a.time,e[r]),i.prepare(this._maxTime,i.getAdditiveTrack())}}}},e}(),zQ={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var n;if(e){for(var r=e.split("."),i=this,o=0,a=r.length;o<a;o++)i&&(i=i[r[o]]);i&&(n=i)}else n=this;if(null==n)throw new Error("Target "+e+" not exists");var s=this._animators,l=new kQ(n,t),u=this;return l.during((function(){u.__zr&&u.__zr.refresh()})).done((function(){var e=s.indexOf(l);e>=0&&s.splice(e,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,n=t.length,r=0;r<n;r++)t[r].stop(e);return t.length=0,this},addAnimatorsToZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.addAnimator(this._animators[t])},removeAnimatorsFromZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.removeAnimator(this._animators[t])}},VQ="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";function BQ(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}Object.assign(MK.prototype,zQ),wq.import(VQ),wq.import(Mq),wq.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),wq.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),wq.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),wq.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),wq.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),wq.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var FQ=b$.prototype.addToScene,GQ=b$.prototype.removeFromScene;b$.prototype.addToScene=function(e){if(FQ.call(this,e),this.__zr){var t=this.__zr;e.traverse((function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)}))}},b$.prototype.removeFromScene=function(e){GQ.call(this,e),e.traverse((function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}))},jZ.prototype.setTextureImage=function(e,t,n,r){if(this.shader){var i,o,a=n.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),(o=t)&&"none"!==o&&(i=HQ.loadTexture(t,n,r,(function(t){s.enableTexture(e),a&&a.refresh()})),s.set(e,i)),i}};var HQ={};HQ.Renderer=Vq,HQ.Node=MK,HQ.Mesh=LK,HQ.Shader=wq,HQ.Material=jZ,HQ.Texture=EK,HQ.Texture2D=RK,HQ.Geometry=XK,HQ.SphereGeometry=TJ,HQ.PlaneGeometry=W$,HQ.CubeGeometry=X$,HQ.AmbientLight=MJ,HQ.DirectionalLight=CJ,HQ.PointLight=DJ,HQ.SpotLight=AJ,HQ.PerspectiveCamera=E$,HQ.OrthographicCamera=uJ,HQ.Vector2=KZ,HQ.Vector3=Fq,HQ.Vector4=IJ,HQ.Quaternion=cK,HQ.Matrix2=PJ,HQ.Matrix2d=RJ,HQ.Matrix3=kJ,HQ.Matrix4=aK,HQ.Plane=i$,HQ.Ray=Jq,HQ.BoundingBox=bK,HQ.Frustum=h$;var UQ,WQ=null;function jQ(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function XQ(e){if((e.wrapS===EK.REPEAT||e.wrapT===EK.REPEAT)&&e.image){var t=jQ(e.width),n=jQ(e.height);if(t!==e.width||n!==e.height){var r=document.createElement("canvas");r.width=t,r.height=n,r.getContext("2d").drawImage(e.image,0,0,t,n),e.image=r}}}HQ.loadTexture=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n||{};for(var i=Object.keys(n).sort(),o="",a=0;a<i.length;a++)o+=i[a]+"_"+n[i[a]]+"_";var s,l=t.__textureCache=t.__textureCache||new M$(20);if((s=e).getZr&&s.setOption){var u=e.__textureid__;if(h=l.get(o+u))h.texture.surface.setECharts(e),r&&r(h.texture);else{var c=new lJ(e);c.onupdate=function(){t.getZr().refresh()},h={texture:c.getTexture()};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_ec__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),r&&r(h.texture)}return h.texture}if(BQ(e)){var h;u=e.__textureid__;if(!(h=l.get(o+u))){h={texture:new HQ.Texture2D({image:e})};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_image__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),XQ(h.texture),r&&r(h.texture)}return h.texture}if(h=l.get(o+e))h.callbacks?h.callbacks.push(r):r&&r(h.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){h={callbacks:[r]};var d=oJ.loadTexture(e,{exposure:n.exposure,fileType:"hdr"},(function(){d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null}));h.texture=d,l.put(o+e,h)}else{for(d=new HQ.Texture2D({image:new Image}),a=0;a<i.length;a++)d[i[a]]=n[i[a]];h={texture:d,callbacks:[r]};var p=d.image;p.onload=function(){d.image=p,XQ(d),d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null},p.crossOrigin="Anonymous",p.src=e,d.image=null!==WQ?WQ:WQ=oJ.createBlank("rgba(255,255,255,0)").image,l.put(o+e,h)}return h.texture},HQ.createAmbientCubemap=function(e,t,n,r){var i=(e=e||{}).texture,o=wJ(e.exposure,1),a=new mJ({intensity:wJ(e.specularIntensity,1)}),s=new vJ({intensity:wJ(e.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return a.cubemap=HQ.loadTexture(i,n,{exposure:o},(function(){if(a.cubemap.flipY=!1,"production"!==process.env.NODE_ENV)var e=Date.now();if(a.prefilter(t,32),"production"!==process.env.NODE_ENV){var n=Date.now()-e;console.log("Prefilter environment map: "+n+"ms")}s.coefficients=yJ.projectEnvironmentMap(t,a.cubemap,{lod:1}),r&&r()})),{specular:a,diffuse:s}},HQ.createBlankTexture=oJ.createBlank,HQ.isImage=BQ,HQ.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)},HQ.parseColor=function(e,t){return e instanceof Array?(t||(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],e.length>3?t[3]=e[3]:t[3]=1,t):((t=rr(e||"#000",t)||[0,0,0,0])[0]/=255,t[1]/=255,t[2]/=255,t)},HQ.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,r=-t/180*Math.PI+Math.PI/2,i=[],o=Math.sin(n);return i[0]=o*Math.cos(r),i[1]=-Math.cos(n),i[2]=o*Math.sin(r),i},HQ.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},HQ.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],HQ.createShader=function(e){"ecgl.shadow"===e&&(e="ecgl.displayShadow");var t=wq.source(e+".vertex"),n=wq.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),n||console.error("Fragment shader of '%s' not exits",e);var r=new wq(t,n);return r.name=e,r},HQ.createMaterial=function(e,t){t instanceof Array||(t=[t]);var n=HQ.createShader(e),r=new jZ({shader:n});return t.forEach((function(e){"string"==typeof e&&r.define(e)})),r},HQ.setMaterialFromModel=function(e,t,n,r){t.autoUpdateTextureStatus=!1;var i=n.getModel(e+"Material"),o=i.get("detailTexture"),a=wJ(i.get("textureTiling"),1),s=wJ(i.get("textureOffset"),0);"number"==typeof a&&(a=[a,a]),"number"==typeof s&&(s=[s,s]);var l=a[0]>1||a[1]>1?HQ.Texture.REPEAT:HQ.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===e){var c=i.get("roughness"),h=i.get("metalness");null!=h?isNaN(h)&&(t.setTextureImage("metalnessMap",h,r,u),h=wJ(i.get("metalnessAdjust"),.5)):h=0,null!=c?isNaN(c)&&(t.setTextureImage("roughnessMap",c,r,u),c=wJ(i.get("roughnessAdjust"),.5)):c=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",o,r,u),t.setTextureImage("normalMap",d,r,u),t.set({roughness:c,metalness:h,detailUvRepeat:a,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("hatching"===e){var p=i.get("hatchingTextures")||[];p.length<6&&"production"!==process.env.NODE_ENV&&console.error("Invalid hatchingTextures.");for(var f=0;f<6;f++)t.setTextureImage("hatch"+(f+1),p[f],r,{anisotropic:8,wrapS:HQ.Texture.REPEAT,wrapT:HQ.Texture.REPEAT});t.set({detailUvRepeat:a,detailUvOffset:s})}},HQ.updateVertexAnimation=function(e,t,n,r){var i=r.get("animation"),o=r.get("animationDurationUpdate"),a=r.get("animationEasingUpdate"),s=n.shadowDepthMaterial;if(i&&t&&o>0&&t.geometry.vertexCount===n.geometry.vertexCount){n.material.define("vertex","VERTEX_ANIMATION"),n.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)n.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;n.geometry.dirty(),n.__percent=0,n.material.set("percent",0),n.stopAnimation(),n.animate().when(o,{__percent:1}).during((function(){n.material.set("percent",n.__percent),s&&s.set("percent",n.__percent)})).done((function(){n.ignorePreZ=!1,n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")})).start(a)}else n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")},UQ=wQ.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(e){return setTimeout(e,16)};var YQ=function(e,t){this.id=e,this.zr=t;try{this.renderer=new Vq({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(e){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(e)}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var n=this.dom.style;n.position="absolute",n.left="0",n.top="0",this.views=[],this._picking=new DK({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new ol({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};function ZQ(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}YQ.prototype.setUnpainted=function(){},YQ.prototype.addView=function(e){if(e.layer!==this){var t=this._viewsToDispose.indexOf(e);t>=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var n=this.zr;e.scene.traverse((function(e){e.__zr=n,e.addAnimatorsToZr&&e.addAnimatorsToZr(n)}))}},YQ.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(ZQ,this),e.layer=null,this._viewsToDispose.push(e))}},YQ.prototype.removeViewsAll=function(){this.views.forEach((function(e){e.scene.traverse(ZQ,this),e.layer=null,this._viewsToDispose.push(e)}),this),this.views.length=0},YQ.prototype.resize=function(e,t){this.renderer.resize(e,t)},YQ.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},YQ.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},YQ.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},YQ.prototype.needsRefresh=function(){this.zr.refresh()},YQ.prototype.refresh=function(e){this._backgroundColor=e?HQ.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t<this.views.length;t++)this.views[t].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(t=0;t<this._viewsToDispose.length;t++)this._viewsToDispose[t].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},YQ.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)},YQ.prototype._doRender=function(e){this.clear(),this.renderer.saveViewport();for(var t=0;t<this.views.length;t++)this.views[t].render(this.renderer,e);this.renderer.restoreViewport()},YQ.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var qQ=1;function KQ(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function $Q(e,t){for(var n=0;n<t.length;n++)t[n].__used__||t[n].dispose(e)}function JQ(e,t){e.__used__=e.__used__||0,e.__used__++,1===e.__used__&&t.push(e)}function QQ(e,t,n){var r,i;e.traverse((function(e){if(e.isRenderable()){var o=e.geometry,a=e.material;if(a!==r)for(var s=a.getTextureUniforms(),l=0;l<s.length;l++){var u=s[l],c=a.uniforms[u].value;if(c)if(c instanceof EK)JQ(c,t);else if(c instanceof Array)for(var h=0;h<c.length;h++)c[h]instanceof EK&&JQ(c[h],t)}o!==i&&JQ(o,n),r=a,i=o}}));for(var o=0;o<e.lights.length;o++)e.lights[o].cubemap&&JQ(e.lights[o].cubemap,t)}YQ.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var n=!1,r=0;r<this.views.length;r++)n=this.views[r].needsAccumulate()||n;function i(r){if(t._accumulatingId&&r===t._accumulatingId){for(var o=!0,a=0;a<t.views.length;a++)o=t.views[a].isAccumulateFinished()&&n;o||(t._doRender(!0),e?i(r):UQ((function(){i(r)})))}}n&&(this._accumulatingId=qQ++,e?i(t._accumulatingId):this._accumulatingTimeout=setTimeout((function(){i(t._accumulatingId)}),50))},YQ.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(KQ(this._textureList),KQ(this._geometriesList));for(var n=0;n<this.views.length;n++)QQ(this.views[n].scene,e,t);this._textureList&&($Q(this.renderer,this._textureList),$Q(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t},YQ.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(KQ(this._textureList),KQ(this._geometriesList),$Q(this.renderer,this._textureList),$Q(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)},YQ.prototype.onmousedown=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mousedown",e,t),this._dispatchDataEvent("mousedown",e,t)),this._downX=e.offsetX,this._downY=e.offsetY}},YQ.prototype.onmousemove=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),n=t&&t.target,r=this._hovered;this._hovered=t,r&&n!==r.target&&(r.relatedTarget=n,this._dispatchEvent("mouseout",e,r),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),r&&n===r.target||this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}},YQ.prototype.onmouseup=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mouseup",e,t),this._dispatchDataEvent("mouseup",e,t)),this._upX=e.offsetX,this._upY=e.offsetY}},YQ.prototype.onclick=YQ.prototype.dblclick=function(e){if(!e.target||!e.target.__isGLToZRProxy){var t=this._upX-this._downX,n=this._upY-this._downY;if(!(Math.sqrt(t*t+n*n)>20)){e=e.event;var r=this.pickObject(e.offsetX,e.offsetY);r&&(this._dispatchEvent(e.type,e,r),this._dispatchDataEvent(e.type,e,r));var i=this._clickToSetFocusPoint(e);if(i)i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}},YQ.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,n=t.viewport,r=this.views.length-1;r>=0;r--){var i=this.views[r];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var o=this._picking.pick(e.offsetX,e.offsetY,!0);if(o)return o.view=i,o}}t.viewport=n},YQ.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},YQ.prototype.pickObject=function(e,t){for(var n=[],r=this.renderer,i=r.viewport,o=0;o<this.views.length;o++){var a=this.views[o];a.containPoint(e,t)&&(this._picking.scene=a.scene,this._picking.camera=a.camera,r.viewport=a.viewport,this._picking.pickAll(e,t,n))}return r.viewport=i,n.sort((function(e,t){return e.distance-t.distance})),n[0]},YQ.prototype._dispatchEvent=function(e,t,n){n||(n={});var r=n.target;for(n.cancelBubble=!1,n.event=t,n.type=e,n.offsetX=t.offsetX,n.offsetY=t.offsetY;r&&(r.trigger(e,n),r=r.getParent(),!n.cancelBubble););this._dispatchToView(e,n)},YQ.prototype._dispatchDataEvent=function(e,t,n){var r=n&&n.target,i=r&&r.dataIndex,o=r&&r.seriesIndex,a=r&&r.eventData,s=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l};const c=bl(l);"mousemove"===e&&(null!=i?i!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0):null!=a&&a!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0),this._lastEventData=a,this._lastDataIndex=i,this._lastSeriesIndex=o),c.eventData=a,c.dataIndex=i,c.seriesIndex=o,(null!=a||parseInt(i,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),s&&this.zr.handler.dispatchToElement(u,"mouseover",t))},YQ.prototype._dispatchToView=function(e,t){for(var n=0;n<this.views.length;n++)this.views[n].containPoint(t.offsetX,t.offsetY)&&this.views[n].trigger(e,t)},Object.assign(YQ.prototype,yY);var e0=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function t0(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var n=e[t].normal,r=e[t].emphasis;n&&(e[t]=n),r&&(e.emphasis=e.emphasis||{},e.emphasis[t]=r)}}function n0(e){e&&(e instanceof Array||(e=[e]),W(e,(function(e){if(e.axisLabel){var t=e.axisLabel;Object.assign(t,t.textStyle),t.textStyle=null}})))}function r0(e){this._layers={},this._zr=e}r0.prototype.update=function(e,t){var n=this,r=t.getZr();if(r.getWidth()&&r.getHeight()){for(var i in this._layers)this._layers[i].removeViewsAll();e.eachComponent((function(n,r){if("series"!==n){var i=t.getViewOfComponentModel(r),s=r.coordinateSystem;if(i.__ecgl__){if(s){if(!s.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+r.id);l=s.viewGL}else{if(!r.viewGL)return void console.error("Can't find viewGL of component "+r.id);l=s.viewGL}var l=s.viewGL,u=o(r);u.addView(l),i.afterRender&&i.afterRender(r,e,t,u),a(i.groupGL,r.get("silent"))}}})),e.eachSeries((function(n){var r=t.getViewOfSeriesModel(n),i=n.coordinateSystem;if(r.__ecgl__){if(i&&!i.viewGL&&!r.viewGL)return void console.error("Can't find viewGL of series "+r.id);var s=i&&i.viewGL||r.viewGL,l=o(n);l.addView(s),r.afterRender&&r.afterRender(n,e,t,l),a(r.groupGL,n.get("silent"))}}))}else console.warn("Dom has no width or height");function o(e){var t;r.setSleepAfterStill(0),t=(e.coordinateSystem&&e.coordinateSystem.model,e.get("zlevel"));var i=n._layers,o=i[t];if(!o){if(o=i[t]=new YQ("gl-"+t,r),r.painter.isSingleCanvas()){o.virtual=!0;var a=new Js({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=a,r.add(a)}r.painter.insertLayer(t,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function a(e,t){e&&e.traverse((function(e){e.isRenderable&&e.isRenderable()&&(e.ignorePicking=null!=e.$ignorePicking?e.$ignorePicking:t)}))}},Xy((function(e){var t=e.getZr(),n=t.painter.dispose;t.painter.dispose=function(){"function"==typeof this.eachOtherLayer&&this.eachOtherLayer((function(e){e instanceof YQ&&e.dispose()})),n.call(this)},t.painter.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas)return this._layers[0].dom;var t=document.createElement("canvas"),n=e.pixelRatio||this.dpr;t.width=this.getWidth()*n,t.height=this.getHeight()*n;var r=t.getContext("2d");r.dpr=n,r.clearRect(0,0,t.width,t.height),e.backgroundColor&&(r.fillStyle=e.backgroundColor,r.fillRect(0,0,t.width,t.height));var i,o=this.storage.getDisplayList(!0),a={},s=this;function l(e,t){var n,i=s._zlevelList;null==e&&(e=-1/0);for(var o=0;o<i.length;o++){var a=i[o],l=s._layers[a];if(!l.__builtin__&&a>e&&a<t){n=l;break}}n&&n.renderToCanvas&&(r.save(),n.renderToCanvas(r),r.restore())}for(var u={ctx:r},c=0;c<o.length;c++){var h=o[c];h.zlevel!==i&&(l(i,h.zlevel),i=h.zlevel),this._doPaintEl(h,u,!0,null,a)}return l(i,1/0),t}})),Yy((function(e,t){var n=t.getZr();(n.__egl=n.__egl||new r0(n)).update(e,t)})),Wy((function(e){W(e.series,(function(t){F(e0,t.type)>=0&&(!function(e){t0(e,"itemStyle"),t0(e,"lineStyle"),t0(e,"areaStyle"),t0(e,"label")}(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))})),n0(e.xAxis3D),n0(e.yAxis3D),n0(e.zAxis3D),n0(e.grid3D),t0(e.geo3D)}));var i0={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(e){e=e||{},this.option.viewControl=this.option.viewControl||{},null!=e.alpha&&(this.option.viewControl.alpha=e.alpha),null!=e.beta&&(this.option.viewControl.beta=e.beta),null!=e.distance&&(this.option.viewControl.distance=e.distance),null!=e.center&&(this.option.viewControl.center=e.center)}},o0={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},a0={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}},s0=tp.extend({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});R(s0.prototype,i0),R(s0.prototype,o0),R(s0.prototype,a0);var l0=wJ,u0={left:0,middle:1,right:2};function c0(e){return e instanceof Array||(e=[e,e]),e}var h0=wY.extend((function(){return{zr:null,viewGL:null,_center:new Fq,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new KZ,_panVelocity:new KZ,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}}),(function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach((function(e){this[e]=this[e].bind(this)}),this)}),{init:function(){var e=this.zr;e&&(e.on("mousedown",this._mouseDownHandler),e.on("globalout",this._mouseUpHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("pinch",this._pinchHandler),e.animation.on("frame",this._update),e.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var e=this.zr;e&&(e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("pinch",this._pinchHandler),e.off("globalout",this._mouseUpHandler),e.dom.removeEventListener("contextmenu",this._contextMenuHandler),e.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(e){this._orthoSize=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setViewGL:function(e){this.viewGL=e},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(e,t){var n=(t=t||{}).baseDistance||0,r=t.baseOrthoSize||1,i=e.get("projection");"perspective"!==i&&"orthographic"!==i&&"isometric"!==i&&("production"!==process.env.NODE_ENV&&console.error("Unkown projection type %s, use perspective projection instead.",i),i="perspective"),this._projection=i,this.viewGL.setProjection(i);var o=e.get("distance")+n,a=e.get("orthographicSize")+r;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach((function(t){this[t[0]]=l0(e.get(t[0]),t[1])}),this),this.minDistance+=n,this.maxDistance+=n,this.minOrthographicSize+=r,this.maxOrthographicSize+=r;var s=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach((function(t){l[t]=l0(e.get(t),s&&s.get(t))}));var u=l0(t.alpha,e.get("alpha"))||0,c=l0(t.beta,e.get("beta"))||0,h=l0(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:c,center:h,distance:o,orthographicSize:a,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(o),this.setAlpha(u),this.setBeta(c),this.setCenter(h),this.setOrthographicSize(a)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){"production"!==process.env.NODE_ENV&&(null==u0[this.panMouseButton]&&console.error("Unkown panMouseButton %s. It should be left|middle|right",this.panMouseButton),null==u0[this.rotateMouseButton]&&console.error("Unkown rotateMouseButton %s. It should be left|middle|right",this.rotateMouseButton),"cw"!==this.autoRotateDirection&&"ccw"!==this.autoRotateDirection&&console.error("Unkown autoRotateDirection %s. It should be cw|ccw",this.autoRotateDirection))},animateTo:function(e){var t=this.zr,n=this,r={},i={};return null!=e.distance&&(r.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(r.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(r.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(r).when(e.duration||1e3,i).during((function(){null!=r.alpha&&n.setAlpha(r.alpha),null!=r.beta&&n.setBeta(r.beta),null!=r.distance&&n.setDistance(r.distance),null!=r.center&&n.setCenter(r.center),null!=r.orthographicSize&&n.setOrthographicSize(r.orthographicSize),n._needsUpdate=!0}))).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e<this._animators.length;e++)this._animators[e].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),n=this._orthoSize,r=n/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-r/2,t.right=r/2,t.top=n/2,t.bottom=-n/2},_updatePan:function(e){var t=this._panVelocity,n=this._distance,r=this.getCamera(),i=r.worldTransform.y,o=r.worldTransform.x;this._center.scaleAndAdd(o,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new Fq,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(r),t.y=-Math.cos(n),t.z=i*Math.sin(r),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout((function(){t._rotating=!0}),1e3*e))},_vectorDamping:function(e,t){var n=e.len();(n*=t)<1e-4&&(n=0),e.normalize().scale(n)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),n=Math.atan2(e.x,e.z);this._theta=t,this._phi=-n,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,n=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,n)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===u0[this.rotateMouseButton]?this._mode="rotate":e.event.button===u0[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=c0(this.panSensitivity),n=c0(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*n[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*n[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var n,r=e.offsetX,i=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i))n="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*n*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done((function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)})),e}});Object.defineProperty(h0.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});var d0={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var n in t)e||!t[n].value?t[n].value=[]:t[n].value=Array.prototype.slice.call(t[n].value);e||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var e=this.attributes;for(var t in e)e[t].value&&e[t].value.length>0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},p0={vec2:qZ,vec3:Dq,vec4:Qq,mat2:NJ,mat2d:OJ,mat3:eK,mat4:Cq,quat:oK},f0=p0.vec3,g0=[[0,0],[1,1]],m0=XK.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION"),positionPrev:new XK.Attribute("positionPrev","float",3),positionNext:new XK.Attribute("positionNext","float",3),prevPositionPrev:new XK.Attribute("prevPositionPrev","float",3),prevPosition:new XK.Attribute("prevPosition","float",3),prevPositionNext:new XK.Attribute("prevPositionNext","float",3),offset:new XK.Attribute("offset","float",1),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.positionPrev.init(e),t.positionNext.init(e),t.offset.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(f0.dist(e,t)+f0.dist(n,t)+f0.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(g0)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(g0)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=e[2],u=t[0],c=t[1],h=t[2],d=n[0],p=n[1],f=n[2],g=r[0],m=r[1],v=r[2],y=this._getCubicCurveApproxStep(e,t,n,r),_=y*y,x=_*y,b=3*y,w=3*_,S=6*_,T=6*x,M=a-2*u+d,C=s-2*c+p,D=l-2*h+f,A=3*(u-d)-a+g,I=3*(c-p)-s+m,E=3*(h-f)-l+v,L=a,N=s,P=l,O=(u-a)*b+M*w+A*x,R=(c-s)*b+C*w+I*x,k=(h-l)*b+D*w+E*x,z=M*S+A*T,V=C*S+I*T,B=D*S+E*T,F=A*T,G=I*T,H=E*T,U=0,W=0,j=Math.ceil(1/y),X=new Float32Array(3*(j+1)),Y=(X=[],0);for(W=0;W<j+1;W++)X[Y++]=L,X[Y++]=N,X[Y++]=P,L+=O,N+=R,P+=k,O+=z,R+=V,k+=B,z+=F,V+=G,B+=H,(U+=y)>1&&(L=O>0?Math.min(L,g):Math.max(L,g),N=R>0?Math.min(N,m):Math.max(N,m),P=k>0?Math.min(P,v):Math.max(P,v));return this.addPolyline(X,i,o)},addLine:function(e,t,n,r){return this.addPolyline([e,t],n,r)},addPolyline:function(e,t,n,r,i){if(e.length){var o="number"!=typeof e[0];if(null==i&&(i=o?e.length:e.length/3),!(i<2)){null==r&&(r=0),null==n&&(n=1),this._itemVertexOffsets.push(this._vertexOffset);var a,s,l=(o="number"!=typeof e[0])?"number"!=typeof t[0]:t.length/4===i,u=this.attributes.position,c=this.attributes.positionPrev,h=this.attributes.positionNext,d=this.attributes.color,p=this.attributes.offset,f=this.indices,g=this._vertexOffset;n=Math.max(n,.01);for(var m=r;m<i;m++){if(o)a=e[m],s=l?t[m]:t;else{var v=3*m;if((a=a||[])[0]=e[v],a[1]=e[v+1],a[2]=e[v+2],l){var y=4*m;(s=s||[])[0]=t[y],s[1]=t[y+1],s[2]=t[y+2],s[3]=t[y+3]}else s=t}if(this.useNativeLine?m>1&&(u.copy(g,g-1),d.copy(g,g-1),g++):(m<i-1&&(c.set(g+2,a),c.set(g+3,a)),m>0&&(h.set(g-2,a),h.set(g-1,a)),u.set(g,a),u.set(g+1,a),d.set(g,s),d.set(g+1,s),p.set(g,n/2),p.set(g+1,-n/2),g+=2),this.useNativeLine)d.set(g,s),u.set(g,a),g++;else if(m>0){var _=3*this._triangleOffset;(f=this.indices)[_]=g-4,f[_+1]=g-3,f[_+2]=g-2,f[_+3]=g-3,f[_+4]=g-1,f[_+5]=g-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*i;c.copy(x,x+2),c.copy(x+1,x+3),h.copy(b-1,b-3),h.copy(b-2,b-4)}return this._vertexOffset=g,this._vertexOffset}}},setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});function v0(e,t,n,r,i,o,a){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=r,this.height=i,this.offsetX=t,this.offsetY=n,this.dpr=a,this.gap=o}function y0(e){(e=e||{}).width=e.width||512,e.height=e.height||512,e.devicePixelRatio=e.devicePixelRatio||1,e.gap=null==e.gap?2:e.gap;var t=document.createElement("canvas");t.width=e.width*e.devicePixelRatio,t.height=e.height*e.devicePixelRatio,this._canvas=t,this._texture=new RK({image:t,flipY:!1});var n=this;this._zr=Ji(t);var r=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){r.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new v0(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}function _0(){}V(m0.prototype,d0),v0.prototype={constructor:v0,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,n){var r=e.getBoundingRect();null==t&&(t=r.width),null==n&&(n=r.height),t*=this.dpr,n*=this.dpr,this._fitElement(e,t,n);var i=this._x,o=this._y,a=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(i+t+l>a&&(i=this._x=0,o+=this._rowHeight+l,this._y=o,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,n),o+n+l>s)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+o,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height];return[[i/a+u[0],o/s+u[1]],[(i+t)/a+u[0],(o+n)/s+u[1]]]},_fitElement:function(e,t,n){var r=e.getBoundingRect(),i=t/r.width,o=n/r.height;e.x=-r.x*i,e.y=-r.y*o,e.scaleX=i,e.scaleY=o,e.update()}},y0.prototype={clear:function(){for(var e=0;e<this._textureAtlasNodes.length;e++)this._textureAtlasNodes[e].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var e=4096/this._dpr,t=this._textureAtlasNodes.length,n=t*this._nodeWidth%e,r=Math.floor(t*this._nodeWidth/e)*this._nodeHeight;if(!(r>=e)){var i=(n+this._nodeWidth)*this._dpr,o=(r+this._nodeHeight)*this._dpr;try{this._zr.resize({width:i,height:o})}catch(e){this._canvas.width=i,this._canvas.height=o}var a=new v0(this._zr,n,r,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(a),a}"production"!==process.env.NODE_ENV&&console.error("Too much labels. Some will be ignored.")},add:function(e,t,n){if(this._coords[e.id])return"production"!==process.env.NODE_ENV&&console.warn("Element already been add"),this._coords[e.id];var r=this._getCurrentNode().add(e,t,n);if(!r){var i=this._expand();if(!i)return;r=i.add(e,t,n)}return this._coords[e.id]=r,r},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}},_0.prototype={constructor:_0,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new HQ.DirectionalLight({shadowBias:.005}),this.ambientLight=new HQ.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,n=this.ambientLight,r=e.getModel("light"),i=r.getModel("main"),o=r.getModel("ambient");t.intensity=i.get("intensity"),n.intensity=o.get("intensity"),t.color=HQ.parseColor(i.get("color")).slice(0,3),n.color=HQ.parseColor(o.get("color")).slice(0,3);var a=i.get("alpha")||0,s=i.get("beta")||0;t.position.setArray(HQ.directionFromAlphaBeta(a,s)),t.lookAt(HQ.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=HQ.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,n){var r=t.getModel("light.ambientCubemap"),i=r.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var o=this._cubemapLightsCache[i];if(!o){var a=this;o=this._cubemapLightsCache[i]=HQ.createAmbientCubemap(r.option,e,n,(function(){a._isSkyboxFromAmbientCubemap&&a._skybox.setEnvironmentMap(o.specular.cubemap),n.getZr().refresh()}))}this._lightRoot.add(o.diffuse),this._lightRoot.add(o.specular),this._currentCubemapLights=o}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,t,n){var r=t.get("environment"),i=this;var o=(i._skybox=i._skybox||new Z$,i._skybox);if(r&&"none"!==r)if("auto"===r)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var a=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(a),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof r&&r.colorStops||"string"==typeof r&&rr(r)){this._isSkyboxFromAmbientCubemap=!1;var s=new HQ.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(s);var l=s.image=document.createElement("canvas");l.width=l.height=16,Ov(l.getContext("2d"),new ol({shape:{x:0,y:0,width:16,height:16},style:{fill:r}})),o.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;s=HQ.loadTexture(r,n,{anisotropic:8,flipY:!1});o.setEnvironmentMap(s),o.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var u=t.coordinateSystem;if(this._skybox)if(!u||!u.viewGL||"auto"===r||r.match&&r.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var c=u.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[c]("fragment","SRGB_DECODE")}}};var x0=p0.vec3,b0=XK.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION"),normal:new XK.Attribute("normal","float",3,"NORMAL"),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,n=this.getQuadVertexCount()*e,r=this.getQuadTriangleCount()*e;this.vertexCount!==n&&(t.position.init(n),t.normal.init(n),t.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=x0.create(),t=x0.create(),n=x0.create(),r=[0,3,1,3,2,1];return function(i,o){var a=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;x0.sub(e,i[1],i[0]),x0.sub(t,i[2],i[1]),x0.cross(n,e,t),x0.normalize(n,n);for(var u=0;u<4;u++)a.set(this._vertexOffset+u,i[u]),l.set(this._vertexOffset+u,o),s.set(this._vertexOffset+u,n);var c=3*this._faceOffset;for(u=0;u<6;u++)this.indices[c+u]=r[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});V(b0.prototype,d0);var w0=wJ,S0={x:0,y:2,z:1};function T0(e,t,n){this.rootNode=new HQ.Node;var r=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new HQ.Mesh({geometry:new b0,material:n,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(r),this.faceInfo=e,this.plane=new HQ.Plane,this.linesMesh=r,this.quadsMesh=i}T0.prototype.update=function(e,t,n){var r=e.coordinateSystem,i=[r.getAxis(this.faceInfo[0]),r.getAxis(this.faceInfo[1])],o=this.linesMesh.geometry,a=this.quadsMesh.geometry;o.convertToDynamicArray(!0),a.convertToDynamicArray(!0),this._updateSplitLines(o,i,e,n),this._udpateSplitAreas(a,i,e,n),o.convertToTypedArray(),a.convertToTypedArray();var s=r.getAxis(this.faceInfo[2]);!function(e,t,n,r){var i=[0,0,0],o=r<0?n.getExtentMin():n.getExtentMax();i[S0[n.dim]]=o,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(o),t.normal.set(0,0,0),"x"===n.dim?(e.rotation.rotateY(r*Math.PI/2),t.normal.x=-r):"z"===n.dim?(e.rotation.rotateX(-r*Math.PI/2),t.normal.y=-r):(r>0&&e.rotation.rotateY(Math.PI),t.normal.z=-r)}(this.rootNode,this.plane,s,this.faceInfo[3])},T0.prototype._updateSplitLines=function(e,t,n,r){var i=r.getDevicePixelRatio();t.forEach((function(r,o){var a=r.model,s=t[1-o].getExtent();if(!r.scale.isBlank()){var l=a.getModel("splitLine",n.getModel("splitLine"));if(l.get("show")){var u=l.getModel("lineStyle"),c=u.get("color"),h=w0(u.get("opacity"),1),d=w0(u.get("width"),1);c=J(c)?c:[c];for(var p=r.getTicksCoords({tickModel:l}),f=0,g=0;g<p.length;g++){var m=p[g].coord,v=HQ.parseColor(c[f%c.length]);v[3]*=h;var y=[0,0,0],_=[0,0,0];y[o]=_[o]=m,y[1-o]=s[0],_[1-o]=s[1],e.addLine(y,_,v,d*i),f++}}}}))},T0.prototype._udpateSplitAreas=function(e,t,n,r){t.forEach((function(r,i){var o=r.model,a=t[1-i].getExtent();if(!r.scale.isBlank()){var s=o.getModel("splitArea",n.getModel("splitArea"));if(s.get("show")){var l=s.getModel("areaStyle"),u=l.get("color"),c=w0(l.get("opacity"),1);u=J(u)?u:[u];for(var h=r.getTicksCoords({tickModel:s,clamp:!0}),d=0,p=[0,0,0],f=[0,0,0],g=0;g<h.length;g++){var m=h[g].coord,v=[0,0,0],y=[0,0,0];if(v[i]=y[i]=m,v[1-i]=a[0],y[1-i]=a[1],0!==g){var _=HQ.parseColor(u[d%u.length]);_[3]*=c,e.addQuad([p,v,y,f],_),p=v,f=y,d++}else p=v,f=y}}}}))};var M0=[0,1,2,0,2,3],C0=XK.extend((function(){return{attributes:{position:new XK.Attribute("position","float",3,"POSITION"),texcoord:new XK.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new XK.Attribute("offset","float",2),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=4*e,n=2*e;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==n&&(this.indices=t>65535?new Uint32Array(3*n):new Uint16Array(3*n))},setSpriteAlign:function(e,t,n,r,i){var o,a,s,l;switch(null==n&&(n="left"),null==r&&(r="top"),i=i||0,n){case"left":o=i,s=t[0]+i;break;case"center":case"middle":o=-t[0]/2,s=t[0]/2;break;case"right":o=-t[0]-i,s=-i}switch(r){case"bottom":a=i,l=t[1]+i;break;case"middle":a=-t[1]/2,l=t[1]/2;break;case"top":a=-t[1]-i,l=-i}var u=4*e,c=this.attributes.offset;c.set(u,[o,l]),c.set(u+1,[s,l]),c.set(u+2,[s,a]),c.set(u+3,[o,a])},addSprite:function(e,t,n,r,i,o){var a=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,n,r,i,o);for(var s=0;s<M0.length;s++)this.indices[3*this._faceOffset+s]=M0[s]+a;return this._faceOffset+=2,this._vertexOffset+=4,a/4},setSprite:function(e,t,n,r,i,o,a){for(var s=4*e,l=this.attributes,u=0;u<4;u++)l.position.set(s+u,t);var c=l.texcoord;c.set(s,[r[0][0],r[0][1]]),c.set(s+1,[r[1][0],r[0][1]]),c.set(s+2,[r[1][0],r[1][1]]),c.set(s+3,[r[0][0],r[1][1]]),this.setSpriteAlign(e,n,i,o,a)}});V(C0.prototype,d0);HQ.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");var D0=HQ.Mesh.extend((function(){return{geometry:new C0({dynamic:!0}),material:new HQ.Material({shader:HQ.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}})),A0=wJ,I0={x:0,y:2,z:1};function E0(e,t){var n=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),r=new D0;r.material.depthMask=!1;var i=new HQ.Node;i.add(n),i.add(r),this.rootNode=i,this.dim=e,this.linesMesh=n,this.labelsMesh=r,this.axisLineCoords=null,this.labelElements=[]}var L0={x:"y",y:"x",z:"y"};E0.prototype.update=function(e,t,n){var r=e.coordinateSystem.getAxis(this.dim),i=this.linesMesh.geometry,o=this.labelsMesh.geometry;i.convertToDynamicArray(!0),o.convertToDynamicArray(!0);var a=r.model,s=r.getExtent(),l=n.getDevicePixelRatio(),u=a.getModel("axisLine",e.getModel("axisLine")),c=a.getModel("axisTick",e.getModel("axisTick")),h=a.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var p=u.getModel("lineStyle"),f=[0,0,0];(T=[0,0,0])[M=I0[r.dim]]=s[0],f[M]=s[1],this.axisLineCoords=[T,f];var g=HQ.parseColor(d),m=A0(p.get("width"),1),v=A0(p.get("opacity"),1);g[3]*=v,i.addLine(T,f,g,m*l)}if(c.get("show")){var y=c.getModel("lineStyle"),_=HQ.parseColor(A0(y.get("color"),d));m=A0(y.get("width"),1);_[3]*=A0(y.get("opacity"),1);for(var x=r.getTicksCoords(),b=c.get("length"),w=0;w<x.length;w++){var S=x[w].coord,T=[0,0,0],M=(f=[0,0,0],I0[r.dim]),C=I0[L0[r.dim]];T[M]=f[M]=S,f[C]=b,i.addLine(T,f,_,m*l)}}this.labelElements=[];l=n.getDevicePixelRatio();if(h.get("show")){x=r.getTicksCoords();var D=a.get("data"),A=h.get("margin"),I=r.getViewLabels();for(w=0;w<I.length;w++){var E=I[w].tickValue,L=I[w].formattedLabel,N=I[w].rawLabel,P=(S=r.dataToCoord(E),[0,0,0]);M=I0[r.dim],C=I0[L0[r.dim]];P[M]=P[M]=S,P[C]=A;var O=h;D&&D[E]&&D[E].textStyle&&(O=new Wh(D[E].textStyle,h,a.ecModel));var R=A0(O.get("color"),d),k=new ll({style:wh(O,{text:L,fill:"function"==typeof R?R("category"===r.type?N:"value"===r.type?E+"":E,w):R,verticalAlign:"top",align:"left"})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),this.labelElements.push(k)}}if(a.get("name")){var B=a.getModel("nameTextStyle"),F=(P=[0,0,0],M=I0[r.dim],C=I0[L0[r.dim]],A0(B.get("color"),d)),G=B.get("borderColor");m=B.get("borderWidth");P[M]=P[M]=(s[0]+s[1])/2,P[C]=a.get("nameGap");k=new ll({style:wh(B,{text:a.get("name"),fill:F,stroke:G,lineWidth:m})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),k.__idx=this.labelElements.length,this.nameLabelElement=k}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),i.convertToTypedArray(),o.convertToTypedArray()},E0.prototype.setSpriteAlign=function(e,t,n){for(var r=n.getDevicePixelRatio(),i=this.labelsMesh.geometry,o=0;o<this.labelElements.length;o++){var a=this.labelElements[o].getBoundingRect();i.setSpriteAlign(o,[a.width*r,a.height*r],e,t)}var s=this.nameLabelElement;if(s){a=s.getBoundingRect();i.setSpriteAlign(s.__idx,[a.width*r,a.height*r],e,t),i.dirty()}this.textAlign=e,this.textVerticalAlign=t};var N0="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end",P0=wJ;HQ.Shader.import(N0);var O0={x:0,y:2,z:1},R0=Kg.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var n=new HQ.Material({shader:HQ.createShader("ecgl.color"),depthMask:!1,transparent:!0}),r=new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});n.define("fragment","DOUBLE_SIDED"),n.define("both","VERTEX_COLOR"),this.groupGL=new HQ.Node,this._control=new h0({zr:t.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(e){var t=new T0(e,r,n);return this.groupGL.add(t.rootNode),t}),this),this._axes=["x","y","z"].map((function(e){var t=new E0(e,r);return this.groupGL.add(t.rootNode),t}),this);var i=t.getDevicePixelRatio();this._axisLabelSurface=new y0({width:256,height:256,devicePixelRatio:i}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new HQ.Mesh({geometry:new m0({useNativeLine:!1}),material:r,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new y0({width:128,height:128,devicePixelRatio:i}),this._axisPointerLabelsMesh=new D0({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new HQ.Node,this._sceneHelper=new _0,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,n){this._model=e,this._api=n;var r=e.coordinateSystem;r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach((function(r){r.update(e,t,n)}),this),this._axes.forEach((function(t){t.update(e,this._axisLabelSurface,n)}),this)),i.on("update",this._onCameraChange.bind(this,e,n),this),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},showAxisPointer:function(e,t,n,r){this._doShowAxisPointer(),this._updateAxisPointer(r.value)},hideAxisPointer:function(e,t,n,r){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem.viewGL;e.get("show")&&e.get("axisPointer.show")?t.on("mousemove",this._updateAxisPointerOnMousePosition,this):t.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,n=this._model.coordinateSystem,r=n.viewGL,i=r.castRay(e.offsetX,e.offsetY,new HQ.Ray),o=0;o<this._faces.length;o++){var a=this._faces[o];if(!a.rootNode.invisible){a.plane.normal.dot(r.camera.worldTransform.z)<0&&a.plane.normal.negate();var s=i.intersectPlane(a.plane);if(s){var l=n.getAxis(a.faceInfo[0]),u=n.getAxis(a.faceInfo[1]),c=O0[a.faceInfo[0]],h=O0[a.faceInfo[1]];l.contain(s.array[c])&&u.contain(s.array[h])&&(t=s)}}}if(t){var d=n.pointToData(t.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var n=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new HQ.Vector3;e.update();for(var n=0;n<this._faces.length/2;n++){for(var r=[],i=0;i<2;i++){this._faces[2*n+i].rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),r[i]=t.z}var o=r[0]>r[1]?0:1,a=this._faces[2*n+o],s=this._faces[2*n+1-o];a.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),n=e.getAxis("y"),r=e.getAxis("z"),i=r.getExtentMax(),o=r.getExtentMin(),a=t.getExtentMin(),s=t.getExtentMax(),l=n.getExtentMax(),u=n.getExtentMin(),c=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,p=this._faces,f=p[4].rootNode.invisible?u:l,g=p[2].rootNode.invisible?i:o,m=p[0].rootNode.invisible?a:s,v=p[2].rootNode.invisible?i:o,y=p[0].rootNode.invisible?s:a,_=p[4].rootNode.invisible?u:l;c.rotation.identity(),h.rotation.identity(),d.rotation.identity(),p[4].rootNode.invisible&&(this._axes[0].flipped=!0,c.rotation.rotateX(Math.PI)),p[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),p[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),c.position.set(0,g,f),h.position.set(m,v,0),d.position.set(y,0,_),c.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new HQ.Vector4,new HQ.Vector4],n=new HQ.Vector4;this.groupGL.getWorldPosition(n),n.w=1,n.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),n.x/=n.w,n.y/=n.w,this._axes.forEach((function(r){var i=r.axisLineCoords;r.labelsMesh.geometry;for(var o=0;o<t.length;o++)t[o].setArray(i[o]),t[o].w=1,t[o].transformMat4(r.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[o].x/=t[o].w,t[o].y/=t[o].w;var a,s,l=t[1].x-t[0].x,u=t[1].y-t[0].y,c=(t[1].x+t[0].x)/2,h=(t[1].y+t[0].y)/2;Math.abs(u/l)<.5?(a="center",s=h>n.y?"bottom":"top"):(s="middle",a=c>n.x?"left":"right"),r.setSpriteAlign(a,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,n=t.dataToPoint(e),r=this._axisPointerLineMesh.geometry,i=this._model.getModel("axisPointer"),o=this._api.getDevicePixelRatio();function a(e){return wJ(e.model.get("axisPointer.show"),i.get("show"))}function s(e){var t=e.model.getModel("axisPointer",i).getModel("lineStyle"),n=HQ.parseColor(t.get("color")),r=P0(t.get("width"),1),o=P0(t.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:r}}r.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var u=this._faces[l];if(!u.rootNode.invisible){for(var c=u.faceInfo,h=c[3]<0?t.getAxis(c[2]).getExtentMin():t.getAxis(c[2]).getExtentMax(),d=O0[c[2]],p=0;p<2;p++){var f=c[p],g=c[1-p],m=t.getAxis(f),v=t.getAxis(g);if(a(m)){var y=O0[f],_=O0[g];(w=[0,0,0])[y]=(b=[0,0,0])[y]=n[y],w[d]=b[d]=h,w[_]=v.getExtentMin(),b[_]=v.getExtentMax();var x=s(m);r.addLine(w,b,x.color,x.lineWidth*o)}}if(a(t.getAxis(c[2]))){var b,w=n.slice();(b=n.slice())[d]=h;x=s(t.getAxis(c[2]));r.addLine(w,b,x.color,x.lineWidth*o)}}}r.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,n=this._axisPointerLabelsMesh,r=this._axisPointerLabelsSurface,i=t.coordinateSystem,o=t.getModel("axisPointer");n.geometry.convertToDynamicArray(!0),r.clear();var a={x:"y",y:"x",z:"y"};this._axes.forEach((function(t,s){var l=i.getAxis(t.dim),u=l.model.getModel("axisPointer",o),c=u.getModel("label"),h=u.get("lineStyle.color");if(c.get("show")&&u.get("show")){var d=e[s],p=c.get("formatter"),f=l.scale.getLabel({value:d});if(null!=p)f=p(f,e);else if("interval"===l.scale.type||"log"===l.scale.type){var g=uo(l.scale.getTicks()[0]);f=d.toFixed(g+2)}var m=c.get("color"),v=new ll({style:wh(c,{text:f,fill:m||h,align:"left",verticalAlign:"top"})}),y=r.add(v),_=v.getBoundingRect(),x=this._api.getDevicePixelRatio(),b=t.rootNode.position.toArray();b[O0[a[t.dim]]]+=(t.flipped?-1:1)*c.get("margin"),b[O0[t.dim]]=l.dataToCoord(e[s]),n.geometry.addSprite(b,[_.width*x,_.height*x],y,t.textAlign,t.textVerticalAlign)}}),this),r.getZr().refreshImmediately(),n.material.set("uvScale",r.getCoordsScale()),n.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function k0(e){IM.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}function z0(e,t,n){Ob.call(this,e,t,n)}k0.prototype={constructor:k0,model:null,containPoint:function(e){return this.getAxis("x").contain(e[0])&&this.getAxis("y").contain(e[2])&&this.getAxis("z").contain(e[1])},containData:function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])&&this.getAxis("z").containData(e[2])},dataToPoint:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").dataToCoord(e[0],n),t[2]=this.getAxis("y").dataToCoord(e[1],n),t[1]=this.getAxis("z").dataToCoord(e[2],n),t},pointToData:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").coordToData(e[0],n),t[1]=this.getAxis("y").coordToData(e[2],n),t[2]=this.getAxis("z").coordToData(e[1],n),t}},G(k0,IM),z0.prototype={constructor:z0,getExtentMin:function(){var e=this._extent;return Math.min(e[0],e[1])},getExtentMax:function(){var e=this._extent;return Math.max(e[0],e[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}},G(z0,Ob);var V0=function(){this._pool={},this._allocatedTextures=[]};V0.prototype={constructor:V0,get:function(e){var t=G0(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var n=this._pool[t];if(!n.length){var r=new RK(e);return this._allocatedTextures.push(r),r}return n.pop()},put:function(e){var t=G0(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t<this._allocatedTextures.length;t++)this._allocatedTextures[t].dispose(e);this._pool={},this._allocatedTextures=[]}};var B0={width:512,height:512,type:jY,format:eZ,wrapS:dZ,wrapT:dZ,minFilter:lZ,magFilter:iZ,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},F0=Object.keys(B0);function G0(e){bY.defaultsWithPropList(e,B0,F0),function(e){var t=(n=e.width,r=e.height,!(n&n-1||r&r-1));var n,r;e.format===$Y&&(e.useMipmap=!1);t&&e.useMipmap||(e.minFilter==oZ||e.minFilter==sZ?e.minFilter=rZ:e.minFilter!=lZ&&e.minFilter!=aZ||(e.minFilter=iZ));t||(e.wrapS=dZ,e.wrapT=dZ)}(e);for(var t="",n=0;n<F0.length;n++){t+=e[F0[n]].toString()}return t}var H0=["px","nx","py","ny","pz","nz"];function U0(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)}function W0(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)}wq.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");var j0,X0,Y0,Z0,q0,K0,$0,J0=wY.extend((function(){return{softShadow:J0.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"highp",_lastRenderNotCastShadow:!1,_frameBuffer:new G$,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new V0}}),(function(){this._gaussianPassH=new pJ({fragment:wq.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new pJ({fragment:wq.source("clay.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new pJ({fragment:wq.source("clay.sm.debug_depth")})}),{render:function(e,t,n,r){n||(n=t.getMainCamera()),this.trigger("beforerender",this,e,t,n),this._renderShadowPass(e,t,n,r),this.trigger("afterrender",this,e,t,n)},renderDebug:function(e,t){e.saveClear();var n=e.viewport,r=0,i=t||n.width/4,o=i;for(var a in this.softShadow===J0.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[a];e.setViewport(r,0,i*s.width/s.height,o),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),r+=i*s.width/s.height}e.setViewport(n),e.restoreClear()},_updateReceivers:function(e,t){if(t.receiveShadow?(this._receivers.push(t),t.material.set("shadowEnabled",1),t.material.set("pcfKernel",this.kernelPCF)):t.material.set("shadowEnabled",0),this.softShadow===J0.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var n=this.kernelPCF;n&&n.length?t.material.define("fragment","PCF_KERNEL_SIZE",n.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var n=this;t.traverse((function(t){t.isRenderable()&&n._updateReceivers(e,t)}));for(var r=0;r<t.lights.length;r++){var i=t.lights[r];i.castShadow&&!i.invisible&&this._lightsCastShadow.push(i)}},_renderShadowPass:function(e,t,n,r){for(var i in this._shadowMapNumber)this._shadowMapNumber[i]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var o=e.gl;if(r||t.update(),n&&n.update(),t.updateLights(),this._update(e,t),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,o.enable(o.DEPTH_TEST),o.depthMask(!0),o.disable(o.BLEND),o.clearColor(1,1,1,1);for(var a,s=[],l=[],u=[],c=[],h=[],d=[],p=0;p<this._lightsCastShadow.length;p++){var f=this._lightsCastShadow[p];if("DIRECTIONAL_LIGHT"===f.type){if(a){console.warn("Only one direectional light supported with shadow cascade");continue}if(f.shadowCascade>4){console.warn("Support at most 4 cascade");continue}f.shadowCascade>1&&(a=f),this.renderDirectionalLightShadow(e,t,n,f,h,c,u)}else"SPOT_LIGHT"===f.type?this.renderSpotLightShadow(e,t,f,l,s):"POINT_LIGHT"===f.type&&this.renderPointLightShadow(e,t,f,d);this._shadowMapNumber[f.type]++}for(var g in this._shadowMapNumber){var m=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT";for(p=0;p<this._receivers.length;p++){(y=this._receivers[p].material).fragmentDefines[v]!==m&&(m>0?y.define("fragment",v,m):y.isDefined("fragment",v)&&y.undefine("fragment",v))}}for(p=0;p<this._receivers.length;p++){var y=this._receivers[p].material;a?y.define("fragment","SHADOW_CASCADE",a.shadowCascade):y.undefine("fragment","SHADOW_CASCADE")}var _=t.shadowUniforms;if(u.length>0){var x=u.map(T);if(_.directionalLightShadowMaps={value:u,type:"tv"},_.directionalLightMatrices={value:c,type:"m4v"},_.directionalLightShadowMapSizes={value:x,type:"1fv"},a){var b=h.slice(),w=h.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),c.reverse(),_.shadowCascadeClipsNear={value:b,type:"1fv"},_.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var S=s.map(T);(_=t.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},_.spotLightMatrices={value:l,type:"m4v"},_.spotLightShadowMapSizes={value:S,type:"1fv"}}d.length>0&&(_.pointLightShadowMaps={value:d,type:"tv"})}function T(e){return e.height}},renderDirectionalLightShadow:(j0=new h$,X0=new aK,Y0=new bK,Z0=new aK,q0=new aK,K0=new aK,$0=new aK,function(e,t,n,r,i,o,a){var s=this._getDepthMaterial(r),l={getMaterial:function(e){return e.shadowDepthMaterial||s},isMaterialChanged:W0,getUniform:U0,ifRender:function(e){return e.castShadow},sortCompare:Vq.opaqueSortCompare};if(!t.viewBoundingBoxLastFrame.isFinite()){var u=t.getBoundingBox();t.viewBoundingBoxLastFrame.copy(u).applyTransform(n.viewMatrix)}var c=Math.min(-t.viewBoundingBoxLastFrame.min.z,n.far),h=Math.max(-t.viewBoundingBoxLastFrame.max.z,n.near),d=this._getDirectionalLightCamera(r,t,n),p=K0.array;$0.copy(d.projectionMatrix),Cq.invert(q0.array,d.worldTransform.array),Cq.multiply(q0.array,q0.array,n.worldTransform.array),Cq.multiply(p,$0.array,q0.array);for(var f=[],g=n instanceof E$,m=(n.near+n.far)/(n.near-n.far),v=2*n.near*n.far/(n.near-n.far),y=0;y<=r.shadowCascade;y++){var _=h*Math.pow(c/h,y/r.shadowCascade),x=h+(c-h)*y/r.shadowCascade,b=_*r.cascadeSplitLogFactor+x*(1-r.cascadeSplitLogFactor);f.push(b),i.push(-(-b*m+v)/-b)}var w=this._getTexture(r,r.shadowCascade);a.push(w);var S=e.viewport,T=e.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(e),T.clear(T.COLOR_BUFFER_BIT|T.DEPTH_BUFFER_BIT),y=0;y<r.shadowCascade;y++){var M=f[y],C=f[y+1];g?Cq.perspective(X0.array,n.fov/180*Math.PI,n.aspect,M,C):Cq.ortho(X0.array,n.left,n.right,n.bottom,n.top,M,C),j0.setFromProjection(X0),j0.getTransformedBoundingBox(Y0,q0),Y0.applyProjection($0);var D=Y0.min.array,A=Y0.max.array;D[0]=Math.max(D[0],-1),D[1]=Math.max(D[1],-1),A[0]=Math.min(A[0],1),A[1]=Math.min(A[1],1),Z0.ortho(D[0],A[0],D[1],A[1],1,-1),d.projectionMatrix.multiplyLeft(Z0);var I=r.shadowResolution||512;e.setViewport((r.shadowCascade-y-1)*I,0,I,I,1);var E=t.updateRenderList(d);e.renderPass(E.opaque,d,l),this.softShadow===J0.VSM&&this._gaussianFilter(e,w,w.width);var L=new aK;L.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),o.push(L.array),d.projectionMatrix.copy($0)}this._frameBuffer.unbind(e),e.setViewport(S)}),renderSpotLightShadow:function(e,t,n,r,i){var o=this._getTexture(n),a=this._getSpotLightCamera(n),s=e.gl;this._frameBuffer.attach(o),this._frameBuffer.bind(e),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(n),u={getMaterial:function(e){return e.shadowDepthMaterial||l},isMaterialChanged:W0,getUniform:U0,ifRender:function(e){return e.castShadow},sortCompare:Vq.opaqueSortCompare},c=t.updateRenderList(a);e.renderPass(c.opaque,a,u),this._frameBuffer.unbind(e),this.softShadow===J0.VSM&&this._gaussianFilter(e,o,o.width);var h=new aK;h.copy(a.worldTransform).invert().multiplyLeft(a.projectionMatrix),i.push(o),r.push(h.array)},renderPointLightShadow:function(e,t,n,r){var i=this._getTexture(n),o=e.gl;r.push(i);var a=this._getDepthMaterial(n),s={getMaterial:function(e){return e.shadowDepthMaterial||a},getUniform:U0,sortCompare:Vq.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new bK,c=n.getWorldPosition().array,h=new bK,d=n.range;h.min.setArray(c),h.max.setArray(c);var p=new Fq(d,d,d);h.max.add(p),h.min.sub(p);var f={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};t.traverse((function(e){if(e.isRenderable()&&e.castShadow){var t=e.geometry;if(!t.boundingBox){for(var n=0;n<H0.length;n++)l[H0[n]].push(e);return}if(u.transformFrom(t.boundingBox,e.worldTransform),!u.intersectBoundingBox(h))return;u.updateVertices();for(n=0;n<H0.length;n++)f[H0[n]]=!1;for(n=0;n<8;n++){var r=u.vertices[n],i=r[0]-c[0],o=r[1]-c[1],a=r[2]-c[2],s=Math.abs(i),d=Math.abs(o),p=Math.abs(a);s>d?s>p?f[i>0?"px":"nx"]=!0:f[a>0?"pz":"nz"]=!0:d>p?f[o>0?"py":"ny"]=!0:f[a>0?"pz":"nz"]=!0}for(n=0;n<H0.length;n++)f[H0[n]]&&l[H0[n]].push(e)}}));for(var g=0;g<6;g++){var m=H0[g],v=this._getPointLightCamera(n,m);this._frameBuffer.attach(i,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+g),this._frameBuffer.bind(e),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),e.renderPass(l[m],v,s)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],n="POINT_LIGHT"===e.type;if(!t){var r=n?"clay.sm.distance.":"clay.sm.depth.";t=new jZ({precision:this.precision,shader:new wq(wq.source(r+"vertex"),wq.source(r+"fragment"))}),this._lightMaterials[e.__uid__]=t}return null!=e.shadowSlopeScale&&t.setUniform("slopeScale",e.shadowSlopeScale),null!=e.shadowBias&&t.setUniform("bias",e.shadowBias),this.softShadow===J0.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),n&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,n){var r={width:n,height:n,type:EK.FLOAT},i=this._texturePool.get(r);this._frameBuffer.attach(i),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",n),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",n),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(i)},_getTexture:function(e,t){var n=e.__uid__,r=this._textures[n],i=e.shadowResolution||512;return t=t||1,r||((r="POINT_LIGHT"===e.type?new A$:new RK).width=i*t,r.height=i,this.softShadow===J0.VSM?(r.type=EK.FLOAT,r.anisotropic=4):(r.minFilter=rZ,r.magFilter=rZ,r.useMipmap=!1),this._textures[n]=r),r},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new E$,nx:new E$,py:new E$,ny:new E$,pz:new E$,nz:new E$});var n=this._lightCameras.point[t];switch(n.far=e.range,n.fov=90,n.position.set(0,0,0),t){case"px":n.lookAt(Fq.POSITIVE_X,Fq.NEGATIVE_Y);break;case"nx":n.lookAt(Fq.NEGATIVE_X,Fq.NEGATIVE_Y);break;case"py":n.lookAt(Fq.POSITIVE_Y,Fq.POSITIVE_Z);break;case"ny":n.lookAt(Fq.NEGATIVE_Y,Fq.NEGATIVE_Z);break;case"pz":n.lookAt(Fq.POSITIVE_Z,Fq.NEGATIVE_Y);break;case"nz":n.lookAt(Fq.NEGATIVE_Z,Fq.NEGATIVE_Y)}return e.getWorldPosition(n.position),n.update(),n},_getDirectionalLightCamera:function(){var e=new aK,t=new bK,n=new bK;return function(r,i,o){this._lightCameras.directional||(this._lightCameras.directional=new uJ);var a=this._lightCameras.directional;t.copy(i.viewBoundingBoxLastFrame),t.intersection(o.frustum.boundingBox),a.position.copy(t.min).add(t.max).scale(.5).transformMat4(o.worldTransform),a.rotation.copy(r.rotation),a.scale.copy(r.scale),a.updateWorldTransform(),aK.invert(e,a.worldTransform),aK.multiply(e,e,o.worldTransform),n.copy(t).applyTransform(e);var s=n.min.array,l=n.max.array;return a.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(a.worldTransform),a.near=0,a.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?a.far*=4:a.far+=this.lightFrustumBias,a.left=s[0],a.right=l[0],a.top=l[1],a.bottom=s[1],a.update(!0),a}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new E$);var t=this._lightCameras.spot;return t.fov=2*e.penumbraAngle,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),Cq.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;for(var n in this._frameBuffer&&this._frameBuffer.dispose(t),this._textures)this._textures[n].dispose(t);this._texturePool.clear(e.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var r=0;r<this._receivers.length;r++){var i=this._receivers[r];if(i.material){var o=i.material;o.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),o.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),o.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),o.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});J0.VSM=1,J0.PCF=2;var Q0=wY.extend((function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),{updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n=o.width instanceof Function?o.width.call(this,t):o.width,r=o.height instanceof Function?o.height.call(this,t):o.height,a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),a.width=n,a.height=r,a},setParameter:function(e,t){},getParameter:function(e){},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},render:function(){},getOutput:function(e,t){if(null==t)return t=e,this._outputTextures[t];var n=this.outputs[t];return n?this._rendered?n.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(n.parameters||{})),this._prevOutputTextures[t]):(this.render(e),this._outputTextures[t]):void 0},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.enableTexture(e)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(e){if(!this._rendering){for(var t in this._rendering=!0,this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){for(var e in this._rendered=!1,this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks){if(this._outputReferences[e]>0)this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}}),e1=wY.extend((function(){return{nodes:[]}}),{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t<this.nodes.length;t++)if(this.nodes[t].name===e)return this.nodes[t]},update:function(){for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear();for(e=0;e<this.nodes.length;e++){var t=this.nodes[e];if(t.inputs)for(var n in t.inputs)if(t.inputs[n])if(!t.pass||t.pass.material.isUniformEnabled(n)){var r=t.inputs[n],i=this.findPin(r);i?t.link(n,i.node,i.pin):"string"==typeof r?console.warn("Node "+r+" not exist"):console.warn("Pin of "+r.node+"."+r.pin+" not exist")}else console.warn("Pin "+t.name+"."+n+" not used.")}},findPin:function(e){var t;if(("string"==typeof e||e instanceof Q0)&&(e={node:e}),"string"==typeof e.node)for(var n=0;n<this.nodes.length;n++){var r=this.nodes[n];r.name===e.node&&(t=r)}else t=e.node;if(t){var i=e.pin;if(i||t.outputs&&(i=Object.keys(t.outputs)[0]),t.outputs[i])return{node:t,pin:i}}}}),t1=e1.extend((function(){return{_outputs:[],_texturePool:new V0,_frameBuffer:new G$({depthBuffer:!1})}}),{addNode:function(e){e1.prototype.addNode.call(this,e),e._compositor=this},render:function(e,t){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var n=0;n<this.nodes.length;n++)this.nodes[n].outputs||this._outputs.push(this.nodes[n])}for(n=0;n<this.nodes.length;n++)this.nodes[n].beforeFrame();for(n=0;n<this._outputs.length;n++)this._outputs[n].updateReference();for(n=0;n<this._outputs.length;n++)this._outputs[n].render(e,t);for(n=0;n<this.nodes.length;n++)this.nodes[n].afterFrame()},allocateTexture:function(e){return this._texturePool.get(e)},releaseTexture:function(e){this._texturePool.put(e)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(e){this._texturePool.clear(e)}}),n1=Q0.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},(function(){this.frameBuffer=new G$}),{render:function(e){this._rendering=!0;var t,n=e.gl;if(this.trigger("beforerender"),this.outputs){var r=this.frameBuffer;for(var i in this.outputs){var o=this.updateParameter(i,e),a=this.outputs[i],s=this._compositor.allocateTexture(o);this._outputTextures[i]=s,"string"==typeof(c=a.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),r.attach(s,c)}r.bind(e);var l=e.getGLExtension("EXT_draw_buffers");if(l){var u=[];for(var c in this.outputs)(c=parseInt(c))>=n.COLOR_ATTACHMENT0&&c<=n.COLOR_ATTACHMENT0+8&&u.push(c);l.drawBuffersEXT(u)}e.saveClear(),e.clearBit=CY|AY,t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),r.unbind(e)}else t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",t),this._rendering=!1,this._rendered=!0}}),r1=Q0.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),i1=Q0.extend((function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),(function(){var e=new pJ({fragment:this.shader});this.pass=e}),{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var r in this.inputLinks){var i=(h=this.inputLinks[r]).node.getOutput(e,h.pin);this.pass.setUniform(r,i)}if(this.outputs){this.pass.outputs={};var o={};for(var a in this.outputs){var s=this.updateParameter(a,e);isNaN(s.width)&&this.updateParameter(a,e);var l=this.outputs[a],u=this._compositor.allocateTexture(s);this._outputTextures[a]=u,"string"==typeof(c=l.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),o[c]=u}for(var c in this._compositor.getFrameBuffer().bind(e),o)this._compositor.getFrameBuffer().attach(o[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var r in this.inputLinks){var h;(h=this.inputLinks[r]).node.removeReference(h.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n="function"==typeof o.width?o.width.call(this,t):o.width,r="function"==typeof o.height?o.height.call(this,t):o.height,n=Math.ceil(n),r=Math.ceil(r),a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t),a.width=n,a.height=r,a},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},clear:function(){Q0.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),o1="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",a1="\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end",s1="@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",l1="@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n",u1="@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end",c1="\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end",h1="@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",d1="@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end",p1="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(e){e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),e.import(o1),e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),e.import(a1),e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),e.import(s1),e.import(l1),e.import(u1),e.import(c1),e.import(h1),e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),e.import(d1),e.import(p1)}(wq);var f1=/^#source\((.*?)\)/;function g1(e,t){var n=new t1;t=t||{};var r={textures:{},parameters:{}};for(var i in e.parameters){var o=e.parameters[i];r.parameters[i]=_1(o)}return function(e,t,n,r){if(!e.textures)return void r({});var i={},o=0,a=!1,s=n.textureRootPath;bY.each(e.textures,(function(e,t){var n,l=e.path,u=_1(e.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(e){return bY.relative2absolute(e,s)}))),n=new A$(u);else{if("string"!=typeof l)return;s&&(l=bY.relative2absolute(l,s)),n=new RK(u)}n.load(l),o++,n.once("success",(function(){i[t]=n,0===--o&&(r(i),a=!0)}))})),0!==o||a||r(i)}(e,0,t,(function(i){r.textures=i,function(){for(var i=0;i<e.nodes.length;i++){var o=m1(e.nodes[i],r,t);o&&n.addNode(o)}}()})),n}function m1(e,t,n){var r,i,o,a,s=e.type||"filter";if("filter"===s){var l=e.shader.trim(),u=f1.exec(l);if(u?r=wq.source(u[1].trim()):"#"===l.charAt(0)&&(r=t.shaders[l.substr(1)]),r||(r=l),!r)return}if(e.inputs)for(var c in i={},e.inputs)"string"==typeof e.inputs[c]?i[c]=e.inputs[c]:i[c]={node:e.inputs[c].node,pin:e.inputs[c].pin};if(e.outputs)for(var c in o={},e.outputs){var h=e.outputs[c];o[c]={},null!=h.attachment&&(o[c].attachment=h.attachment),null!=h.keepLastFrame&&(o[c].keepLastFrame=h.keepLastFrame),null!=h.outputLastFrame&&(o[c].outputLastFrame=h.outputLastFrame),h.parameters&&(o[c].parameters=_1(h.parameters))}if(a="scene"===s?new n1({name:e.name,scene:n.scene,camera:n.camera,outputs:o}):"texture"===s?new r1({name:e.name,outputs:o}):new i1({name:e.name,shader:r,inputs:i,outputs:o})){if(e.parameters)for(var c in e.parameters){"string"==typeof(d=e.parameters[c])?"#"===(d=d.trim()).charAt(0)?d=t.textures[d.substr(1)]:a.on("beforerender",x1(c,b1(d))):"function"==typeof d&&a.on("beforerender",d),a.setParameter(c,d)}if(e.defines&&a.pass)for(var c in e.defines){var d=e.defines[c];a.pass.material.define("fragment",c,d)}}return a}function v1(e,t){return e}function y1(e,t){return t}function _1(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach((function(n){var r=e[n];null!=r&&("string"==typeof r&&(r=EK[r]),t[n]=r)}));var n=e.scale||1;return["width","height"].forEach((function(r){if(null!=e[r]){var i=e[r];"string"==typeof i?(i=i.trim(),t[r]=function(e,t,n){return n=n||1,function(e){var r=e.getDevicePixelRatio(),i=e.getWidth()*n,o=e.getHeight()*n;return t(i,o,r)}}(0,b1(i),n)):t[r]=i}})),t.width||(t.width=v1),t.height||(t.height=y1),null!=e.useMipmap&&(t.useMipmap=e.useMipmap),t}function x1(e,t){return function(n){var r=n.getDevicePixelRatio(),i=n.getWidth(),o=n.getHeight(),a=t(i,o,r);this.setParameter(e,a)}}function b1(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var n=new Function("width","height","dpr","return "+t[1]);return n(1,1),n}catch(e){throw new Error("Invalid expression.")}}function w1(e,t){for(var n=0,r=1/t,i=e;i>0;)n+=r*(i%t),i=Math.floor(i/t),r/=t;return n}function S1(e){for(var t=new Uint8Array(e*e*4),n=0,r=new Fq,i=0;i<e;i++)for(var o=0;o<e;o++)r.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),t[n++]=255*(.5*r.x+.5),t[n++]=255*(.5*r.y+.5),t[n++]=0,t[n++]=255;return t}function T1(e){return new RK({pixels:S1(e),wrapS:EK.REPEAT,wrapT:EK.REPEAT,width:e,height:e})}function M1(e,t,n){var r=new Float32Array(3*e);t=t||0;for(var i=0;i<e;i++){var o=w1(i+t,2)*(n?1:2)*Math.PI,a=w1(i+t,3)*Math.PI,s=Math.random(),l=Math.cos(o)*Math.sin(a)*s,u=Math.cos(a)*s,c=Math.sin(o)*Math.sin(a)*s;r[3*i]=l,r[3*i+1]=u,r[3*i+2]=c}return r}function C1(e){e=e||{},this._ssaoPass=new pJ({fragment:wq.source("ecgl.ssao.estimate")}),this._blurPass=new pJ({fragment:wq.source("ecgl.ssao.blur")}),this._framebuffer=new G$({depthBuffer:!1}),this._ssaoTexture=new RK,this._blurTexture=new RK,this._blurTexture2=new RK,this._depthTex=e.depthTexture,this._normalTex=e.normalTexture,this.setNoiseSize(4),this.setKernelSize(e.kernelSize||12),null!=e.radius&&this.setParameter("radius",e.radius),null!=e.power&&this.setParameter("power",e.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}wq.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),C1.prototype.setDepthTexture=function(e){this._depthTex=e},C1.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},C1.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._ssaoPass,a=this._blurPass;o.setUniform("kernel",this._kernels[n%this._kernels.length]),o.setUniform("depthTex",this._depthTex),null!=this._normalTex&&o.setUniform("normalTex",this._normalTex),o.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new aK;aK.transpose(s,t.worldTransform),o.setUniform("projection",t.projectionMatrix.array),o.setUniform("projectionInv",t.invProjectionMatrix.array),o.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,u=this._blurTexture,c=this._blurTexture2;l.width=r/2,l.height=i/2,u.width=r,u.height=i,c.width=r,c.height=i,this._framebuffer.attach(l),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),o.render(e),a.setUniform("textureSize",[r/2,i/2]),a.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),a.setUniform("direction",0),a.setUniform("ssaoTexture",l),a.render(e),this._framebuffer.attach(c),a.setUniform("textureSize",[r,i]),a.setUniform("direction",1),a.setUniform("ssaoTexture",u),a.render(e),this._framebuffer.unbind(e);var h=e.clearColor;e.gl.clearColor(h[0],h[1],h[2],h[3])},C1.prototype.getTargetTexture=function(){return this._blurTexture2},C1.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},C1.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=M1(e,t*e,!!this._normalTex)},C1.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=S1(e),t.width=t.height=e,t.dirty()):(t=T1(e),this._ssaoPass.setUniform("noiseTex",T1(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},C1.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};function D1(e){e=e||{},this._ssrPass=new pJ({fragment:wq.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new pJ({fragment:wq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new pJ({fragment:wq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new pJ({fragment:wq.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",e.normalTexture),this._ssrPass.setUniform("gBufferTexture2",e.depthTexture),this._blurPass1.setUniform("gBufferTexture1",e.normalTexture),this._blurPass1.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.setUniform("gBufferTexture1",e.normalTexture),this._blurPass2.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new RK({type:EK.HALF_FLOAT}),this._texture2=new RK({type:EK.HALF_FLOAT}),this._texture3=new RK({type:EK.HALF_FLOAT}),this._prevTexture=new RK({type:EK.HALF_FLOAT}),this._currentTexture=new RK({type:EK.HALF_FLOAT}),this._frameBuffer=new G$({depthBuffer:!1}),this._normalDistribution=null,this._totalSamples=256,this._samplePerFrame=4,this._ssrPass.material.define("fragment","SAMPLE_PER_FRAME",this._samplePerFrame),this._ssrPass.material.define("fragment","TOTAL_SAMPLES",this._totalSamples),this._downScale=1}wq.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),D1.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var n=e&&t;this._ssrPass.material[n?"enableTexture":"disableTexture"]("specularCubemap")},D1.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._ssrTexture,s=this._texture2,l=this._texture3;a.width=this._prevTexture.width=this._currentTexture.width=i/this._downScale,a.height=this._prevTexture.height=this._currentTexture.height=o/this._downScale,s.width=l.width=i,s.height=l.height=o;var u=this._frameBuffer,c=this._ssrPass,h=this._blurPass1,d=this._blurPass2,p=this._blendPass,f=new aK,g=new aK;aK.transpose(f,t.worldTransform),aK.transpose(g,t.viewMatrix),c.setUniform("sourceTexture",n),c.setUniform("projection",t.projectionMatrix.array),c.setUniform("projectionInv",t.invProjectionMatrix.array),c.setUniform("toViewSpace",f.array),c.setUniform("toWorldSpace",g.array),c.setUniform("nearZ",t.near);var m=r/this._totalSamples*this._samplePerFrame;if(c.setUniform("jitterOffset",m),c.setUniform("sampleOffset",r*this._samplePerFrame),h.setUniform("textureSize",[a.width,a.height]),d.setUniform("textureSize",[i,o]),d.setUniform("sourceTexture",n),h.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(a),u.bind(e),c.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),p.setUniform("texture1",this._prevTexture),p.setUniform("texture2",a),p.material.set({weight1:r>=1?.95:0,weight2:r>=1?.05:1}),p.render(e)),u.attach(s),h.setUniform("texture",this._physicallyCorrect?this._currentTexture:a),h.render(e),u.attach(l),d.setUniform("texture",s),d.render(e),u.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},D1.prototype.getTargetTexture=function(){return this._texture3},D1.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},D1.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=fJ.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},D1.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},D1.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},D1.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)};var A1=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925];function I1(e,t,n,r,i){var o=e.gl;t.setUniform(o,"1i",n,i),o.activeTexture(o.TEXTURE0+i),r.isRenderable()?r.bind(e):r.unbind(e)}function E1(e,t,n,r,i){var o,a,s,l,u=e.gl;return function(i,c,h){if(!l||l.material!==i.material){var d=i.material,p=i.__program,f=d.get("roughness");null==f&&(f=1);var g=d.get("normalMap")||t,m=d.get("roughnessMap"),v=d.get("bumpMap"),y=d.get("uvRepeat"),_=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!v&&d.isTextureEnabled("bumpMap"),S=!!m&&d.isTextureEnabled("roughnessMap"),T=d.isDefined("fragment","DOUBLE_SIDED");v=v||n,m=m||r,h!==c?(c.set("normalMap",g),c.set("bumpMap",v),c.set("roughnessMap",m),c.set("useBumpMap",w),c.set("useRoughnessMap",S),c.set("doubleSide",T),null!=y&&c.set("uvRepeat",y),null!=_&&c.set("uvOffset",_),null!=x&&c.set("detailUvRepeat",x),null!=b&&c.set("detailUvOffset",b),c.set("roughness",f)):(p.setUniform(u,"1f","roughness",f),o!==g&&I1(e,p,"normalMap",g,0),a!==v&&v&&I1(e,p,"bumpMap",v,1),s!==m&&m&&I1(e,p,"roughnessMap",m,2),null!=y&&p.setUniform(u,"2f","uvRepeat",y),null!=_&&p.setUniform(u,"2f","uvOffset",_),null!=x&&p.setUniform(u,"2f","detailUvRepeat",x),null!=b&&p.setUniform(u,"2f","detailUvOffset",b),p.setUniform(u,"1i","useBumpMap",+w),p.setUniform(u,"1i","useRoughnessMap",+S),p.setUniform(u,"1i","doubleSide",+T)),o=g,a=v,s=m,l=i}}}function L1(e){this._depthTex=new RK({format:EK.DEPTH_COMPONENT,type:EK.UNSIGNED_INT}),this._normalTex=new RK({type:EK.HALF_FLOAT}),this._framebuffer=new G$,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,G$.DEPTH_ATTACHMENT),this._normalMaterial=new jZ({shader:new wq(wq.source("ecgl.normal.vertex"),wq.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=oJ.createBlank("#000"),this._defaultBumpMap=oJ.createBlank("#000"),this._defaultRoughessMap=oJ.createBlank("#000"),this._debugPass=new pJ({fragment:wq.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}function N1(e){e=e||{},this._edgePass=new pJ({fragment:wq.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new RK({type:EK.HALF_FLOAT}),this._frameBuffer=new G$,this._frameBuffer.attach(this._targetTexture)}wq.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),L1.prototype.getDepthTexture=function(){return this._depthTex},L1.prototype.getNormalTexture=function(){return this._normalTex},L1.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._depthTex,a=this._normalTex,s=this._normalMaterial;o.width=r,o.height=i,a.width=r,a.height=i;var l=t.getRenderList(n).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,n,{getMaterial:function(){return s},ifRender:function(e){return e.renderNormal},beforeRender:E1(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},L1.prototype.renderDebug=function(e){this._debugPass.render(e)},L1.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},N1.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._targetTexture;a.width=i,a.height=o;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,o]),this._edgePass.setUniform("texture",n),this._edgePass.render(e),s.unbind(e)},N1.prototype.getTargetTexture=function(){return this._targetTexture},N1.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},N1.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};var P1={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]};function O1(e,t){return{color:{parameters:{width:e,height:t}}}}wq.import(o1),wq.import(a1),wq.import(s1),wq.import(l1),wq.import(u1),wq.import(c1),wq.import(h1),wq.import(d1),wq.import(p1),wq.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),wq.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");var R1=["composite","FXAA"];function k1(){this._width,this._height,this._dpr,this._sourceTexture=new RK({type:EK.HALF_FLOAT}),this._depthTexture=new RK({format:EK.DEPTH_COMPONENT,type:EK.UNSIGNED_INT}),this._framebuffer=new G$,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,G$.DEPTH_ATTACHMENT),this._normalPass=new L1,this._compositor=g1(P1);var e=this._compositor.getNodeByName("source");e.texture=this._sourceTexture;var t=this._compositor.getNodeByName("coc");this._sourceNode=e,this._cocNode=t,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map((function(e){return this._compositor.getNodeByName(e)}),this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=R1.map((function(e){return this._compositor.getNodeByName(e)}),this);var n={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new C1(n),this._ssrPass=new D1(n),this._edgePass=new N1(n)}function z1(e){for(var t=[],n=0;n<30;n++)t.push([w1(n,2),w1(n,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new RK,this._sourceFb=new G$,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new RK,this._outputTex=new RK;var r=this._blendPass=new pJ({fragment:wq.source("clay.compositor.blend")});r.material.disableTexturesAll(),r.material.enableTexture(["texture1","texture2"]),this._blendFb=new G$({depthBuffer:!1}),this._outputPass=new pJ({fragment:wq.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}function V1(e){e=e||"perspective",this.layer=null,this.scene=new b$,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new k1,this._temporalSS=new z1,this._shadowMapPass=new J0;for(var t=[],n=0,r=0;r<30;r++){for(var i=[],o=0;o<6;o++)i.push(4*w1(n,2)-2),i.push(4*w1(n,3)-2),n++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",(function(e,t,n){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,n)}),this)}k1.prototype.resize=function(e,t,n){e*=n=n||1,t*=n;var r=this._sourceTexture,i=this._depthTexture;r.width=e,r.height=t,i.width=e,i.height=t;var o={getWidth:function(){return e},getHeight:function(){return t},getDevicePixelRatio:function(){return n}};function a(e,t){if("function"==typeof e[t]){var n=e[t].__original||e[t];e[t]=function(e){return n.call(this,o)},e[t].__original=n}}this._compositor.nodes.forEach((function(e){for(var t in e.outputs){var n=e.outputs[t].parameters;n&&(a(n,"width"),a(n,"height"))}for(var r in e.parameters)a(e.parameters,r)})),this._width=e,this._height=t,this._dpr=n},k1.prototype.getWidth=function(){return this._width},k1.prototype.getHeight=function(){return this._height},k1.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},k1.prototype._getPrevNode=function(e){for(var t=R1.indexOf(e.name)-1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t-=1,n=this._finalNodesChain[t];return n},k1.prototype._getNextNode=function(e){for(var t=R1.indexOf(e.name)+1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t+=1,n=this._finalNodesChain[t];return n},k1.prototype._addChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(e.inputs.texture=t.name,n?(e.outputs=O1(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},k1.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(n?(t.outputs=O1(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},k1.prototype.updateNormal=function(e,t,n,r){this._ifRenderNormalPass()&&this._normalPass.update(e,t,n)},k1.prototype.updateSSAO=function(e,t,n,r){this._ssaoPass.update(e,n,r)},k1.prototype.enableSSAO=function(){this._enableSSAO=!0},k1.prototype.disableSSAO=function(){this._enableSSAO=!1},k1.prototype.enableSSR=function(){this._enableSSR=!0},k1.prototype.disableSSR=function(){this._enableSSR=!1},k1.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},k1.prototype.getSourceFrameBuffer=function(){return this._framebuffer},k1.prototype.getSourceTexture=function(){return this._sourceTexture},k1.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},k1.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},k1.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},k1.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},k1.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},k1.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},k1.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},k1.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},k1.prototype.enableEdge=function(){this._enableEdge=!0},k1.prototype.disableEdge=function(){this._enableEdge=!1},k1.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)},k1.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var n={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",n);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown SSAO parameter "+e)}},k1.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].setParameter("blurRadius",t);break;case"quality":var r={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=r;for(n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].pass.material.define("POISSON_KERNEL_SIZE",r);this._dofBlurKernel=new Float32Array(2*r);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown DOF parameter "+e)}},k1.prototype.setSSRParameter=function(e,t){if(null!=t)switch(e){case"quality":var n={low:10,medium:15,high:30,ultra:80}[t]||20,r={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",n),this._ssrPass.setParameter("pixelStride",r);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-t,1),0));break;case"physical":this.setPhysicallyCorrectSSR(t);break;default:console.warn("Unkown SSR parameter "+e)}},k1.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)},k1.prototype.setEdgeColor=function(e){var t=HQ.parseColor(e);this._edgePass.setParameter("edgeColor",t)},k1.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))},k1.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:HQ.Texture.NEAREST,magFilter:HQ.Texture.NEAREST,flipY:!1})},k1.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)},k1.prototype.isSSREnabled=function(){return this._enableSSR},k1.prototype.composite=function(e,t,n,r,i){var o=this._sourceTexture,a=o;this._enableEdge&&(this._edgePass.update(e,n,o,i),o=a=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,n,o,i),a=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=a,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,u=i%Math.floor(A1.length/2/l),c=0;c<2*l;c++)s[c]=A1[c+u*l*2];for(c=0;c<this._dofBlurNodes.length;c++)this._dofBlurNodes[c].setParameter("percent",i/30),this._dofBlurNodes[c].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",n.near),this._cocNode.setParameter("zFar",n.far),this._compositor.render(e,r)},k1.prototype.dispose=function(e){this._sourceTexture.dispose(e),this._depthTexture.dispose(e),this._framebuffer.dispose(e),this._compositor.dispose(e),this._normalPass.dispose(e),this._ssaoPass.dispose(e)},z1.prototype={constructor:z1,jitterProjection:function(e,t){var n=e.viewport,r=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*r,o=n.height*r,a=this._haltonSequence[this._frame%this._haltonSequence.length],s=new aK;s.array[12]=(2*a[0]-1)/i,s.array[13]=(2*a[1]-1)/o,aK.mul(t.projectionMatrix,s,t.projectionMatrix),aK.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,n){var r=this._blendPass;0===this._frame?(r.setUniform("weight1",0),r.setUniform("weight2",1)):(r.setUniform("weight1",.9),r.setUniform("weight2",.1)),r.setUniform("texture1",this._prevFrameTex),r.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),r.render(e),this._blendFb.unbind(e),n||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},V1.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof E$||(this.camera=new E$,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof uJ||(this.camera=new uJ,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},V1.prototype.setViewport=function(e,t,n,r,i){this.camera instanceof E$&&(this.camera.aspect=n/r),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=n,this.viewport.height=r,this.viewport.devicePixelRatio=i,this._compositor.resize(n*i,r*i),this._temporalSS.resize(n*i,r*i)},V1.prototype.containPoint=function(e,t){var n=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var B1=new KZ;function F1(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=e.get("boxWidth"),i=e.get("boxHeight"),o=e.get("boxDepth");"production"!==process.env.NODE_ENV&&["x","y","z"].forEach((function(t){if(!this.getAxis(t))throw new Error("Grid"+e.id+" don't have "+t+"Axis")}),this),this.getAxis("x").setExtent(-r/2,r/2),this.getAxis("y").setExtent(o/2,-o/2),this.getAxis("z").setExtent(-i/2,i/2),this.size=[r,i,o]}function G1(e,t){var n={};e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData();["x","y","z"].forEach((function(e){t.mapDimensionsAll(e,!0).forEach((function(r){!function(e,t){n[e]=n[e]||[1/0,-1/0],n[e][0]=Math.min(t[0],n[e][0]),n[e][1]=Math.max(t[1],n[e][1])}(e,t.getDataExtent(r,!0))}))}))}}),this),["xAxis3D","yAxis3D","zAxis3D"].forEach((function(t){e.eachComponent(t,(function(e){var r=t.charAt(0),i=e.getReferringComponents("grid3D").models[0],o=i.coordinateSystem;if(o===this){var a=o.getAxis(r);if(a)"production"!==process.env.NODE_ENV&&console.warn("Can't have two %s in one grid3D",t);else{(a=new z0(r,nb(n[r]||[1/0,-1/0],e))).type=e.get("type");var s="category"===a.type;a.onBand=s&&e.get("boundaryGap"),a.inverse=e.get("inverse"),e.axis=a,a.model=e,a.getLabelModel=function(){return e.getModel("axisLabel",i.getModel("axisLabel"))},a.getTickModel=function(){return e.getModel("axisTick",i.getModel("axisTick"))},o.addAxis(a)}}}),this)}),this),this.resize(this.model,t)}V1.prototype.castRay=function(e,t,n){var r=this.layer.renderer,i=r.viewport;return r.viewport=this.viewport,r.screenToNDC(e,t,B1),this.camera.castRay(B1,n),r.viewport=i,n},V1.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t<e.transparent.length;t++){var n=e.transparent[t].geometry;n.needsSortVerticesProgressively&&n.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),n.needsSortTrianglesProgressively&&n.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},V1.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++},V1.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},V1.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"===e&&(e=this._enablePostEffect),e},V1.prototype.hasDOF=function(){return this._enableDOF},V1.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},V1.prototype._doRender=function(e,t,n){var r=this.scene,i=this.camera;n=n||0,this._updateTransparent(e,r,i,n),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,r,i,!0)),this._updateShadowPCFKernel(n);var o,a=e.clearColor;(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,r,i,this._temporalSS.getFrame())),this._updateSSAO(e,r,i,this._temporalSS.getFrame()),this._enablePostEffect)?((o=this._compositor.getSourceFrameBuffer()).bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(r,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,r,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,r,i,null,0))):this.needsTemporalSS()&&t?((o=this._temporalSS.getSourceFrameBuffer()).bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(r,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),e.render(r,i,!0,!0))},V1.prototype._updateTransparent=function(e,t,n,r){for(var i=new Fq,o=new aK,a=n.getWorldPosition(),s=t.getRenderList(n).transparent,l=0;l<s.length;l++){var u=s[l],c=u.geometry;aK.invert(o,u.worldTransform),Fq.transformMat4(i,a,o),c.needsSortTriangles&&c.needsSortTriangles()&&c.doSortTriangles(i,r),c.needsSortVertices&&c.needsSortVertices()&&c.doSortVertices(i,r)}},V1.prototype._updateSSAO=function(e,t,n){var r=this._enableSSAO&&this._enablePostEffect;r&&this._compositor.updateSSAO(e,t,n,this._temporalSS.getFrame());for(var i=t.getRenderList(n),o=0;o<i.opaque.length;o++){var a=i.opaque[o];a.renderNormal&&a.material[r?"enableTexture":"disableTexture"]("ssaoMap"),r&&a.material.set("ssaoMap",this._compositor.getSSAOTexture())}},V1.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],n=this.scene.getRenderList(this.camera).opaque,r=0;r<n.length;r++)n[r].receiveShadow&&(n[r].material.set("pcfKernel",t),n[r].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))},V1.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)},V1.prototype.setPostEffect=function(e,t){var n=this._compositor;this._enablePostEffect=e.get("enable");var r=e.getModel("bloom"),i=e.getModel("edge"),o=e.getModel("DOF",e.getModel("depthOfField")),a=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),s=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");r.get("enable")?n.enableBloom():n.disableBloom(),o.get("enable")?n.enableDOF():n.disableDOF(),s.get("enable")?n.enableSSR():n.disableSSR(),u.get("enable")?n.enableColorCorrection():n.disableColorCorrection(),i.get("enable")?n.enableEdge():n.disableEdge(),l.get("enable")?n.enableFXAA():n.disableFXAA(),this._enableDOF=o.get("enable"),this._enableSSAO=a.get("enable"),this._enableSSAO?n.enableSSAO():n.disableSSAO(),n.setBloomIntensity(r.get("intensity")),n.setEdgeColor(i.get("color")),n.setColorLookupTexture(u.get("lookupTexture"),t),n.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach((function(e){n.setSSAOParameter(e,a.get(e))})),["quality","maxRoughness","physical"].forEach((function(e){n.setSSRParameter(e,s.get(e))})),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach((function(e){n.setDOFParameter(e,o.get(e))})),["brightness","contrast","saturation"].forEach((function(e){n.setColorCorrection(e,u.get(e))}))},V1.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect){if(e>this.camera.far||e<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",e),!0}},V1.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")},V1.prototype.isLinearSpace=function(){return this._enablePostEffect},V1.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),n=0;n<t.length;n++)e.add(t[n]);e!==this.scene&&this.scene.add(e),this.rootNode=e}},V1.prototype.add=function(e){this.rootNode.add(e)},V1.prototype.remove=function(e){this.rootNode.remove(e)},V1.prototype.removeAll=function(e){this.rootNode.removeAll(e)},Object.assign(V1.prototype,yY);var H1={dimensions:k0.prototype.dimensions,create:function(e,t){var n=[];e.eachComponent("grid3D",(function(e){e.__viewGL=e.__viewGL||new V1;var t=new k0;t.model=e,t.viewGL=e.__viewGL,e.coordinateSystem=t,n.push(t),t.resize=F1,t.update=G1}));var r=["xAxis3D","yAxis3D","zAxis3D"];return e.eachSeries((function(t){if("cartesian3D"===t.get("coordinateSystem")){if(null==(i=t.getReferringComponents("grid3D").models[0])){var n=function(e,t){return r.map((function(n){var r=e.getReferringComponents(n).models[0];if(null==r&&(r=t.getComponent(n)),"production"!==process.env.NODE_ENV&&!r)throw new Error(n+' "'+wJ(e.get(n+"Index"),e.get(n+"Id"),0)+'" not found');return r}))}(t,e),i=n[0].getCoordSysModel();n.forEach((function(e){var t=e.getCoordSysModel();if("production"!==process.env.NODE_ENV){if(!t)throw new Error('grid3D "'+wJ(e.get("gridIndex"),e.get("gridId"),0)+'" not found');if(t!==i)throw new Error("xAxis3D, yAxis3D, zAxis3D must use the same grid")}}))}var o=i.coordinateSystem;t.coordinateSystem=o}})),n}},U1=tp.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});rb(U1);var W1={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},j1=R({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},W1),X1=R({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},W1),Y1=V({scale:!0,min:"dataMin",max:"dataMax"},X1),Z1=V({logBase:10},X1);Z1.scale=!0;var q1={categoryAxis3D:j1,valueAxis3D:X1,timeAxis3D:Y1,logAxis3D:Z1},K1=["value","category","time","log"];function $1(e,t){return t.type||(t.data?"category":"value")}l_((function(e){e.registerComponentModel(s0),e.registerComponentView(R0),e.registerCoordinateSystem("grid3D",H1),["x","y","z"].forEach((function(t){!function(e,t,n,r,i){K1.forEach((function(o){var a=n.extend({type:t+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){R(e,n.getTheme().get(o+"Axis3D")),R(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=Z_.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:R(O(q1[o+"Axis3D"]),i||{},!0)});e.registerComponentModel(a)})),e.registerSubTypeDefaulter(t+"Axis3D",$(r,t))}(e,t,U1,$1,{name:t.toUpperCase()});const n=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(n)})),e.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"grid3D",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},(function(e,t){})),e.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},(function(e,t){}))}));var J1={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}},Q1={getFilledRegions:function(e,t){var n,r=(e||[]).slice();if("string"==typeof t?n=(t=i_(t))&&t.geoJson:t&&t.features&&(n=t),!n)return"production"!==process.env.NODE_ENV&&(console.error("Map "+t+" not exists. You can download map file on http://echarts.baidu.com/download-map.html"),n.features||console.error("Invalid GeoJSON for map3D")),[];for(var i={},o=n.features,a=0;a<r.length;a++)i[r[a].name]=r[a];for(a=0;a<o.length;a++){var s=o[a].properties.name;i[s]||r.push({name:s})}return r},defaultOption:{show:!0,zlevel:-10,map:"",left:0,top:0,width:"100%",height:"100%",boxWidth:100,boxHeight:10,boxDepth:"auto",regionHeight:3,environment:"auto",groundPlane:{show:!1,color:"#aaa"},shading:"lambert",light:{main:{alpha:40,beta:30}},viewControl:{alpha:40,beta:0,distance:100,orthographicSize:60,minAlpha:5,minBeta:-80,maxBeta:80},label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}},e2=tp.extend({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=k_(e.data||[],{coordDimensions:["value"],encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),n=new R_(t,this);n.initData(e.regions);var r={};n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,this._data=n},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Wh(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),n=this.coordinateSystem.getRegion(t);return n?n.geometries:[]},getFormattedLabel:function(e,t){var n=this._data.getName(e),r=this.getRegionModel(e),i=r.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=r.get(["label","formatter"]));var o={name:n};if("function"==typeof i)return o.status=t,i(o);if("string"==typeof i){var a=o.seriesName;return i.replace("{a}",null!=a?a:"")}return n},defaultOption:{regions:[]}});function t2(e,t,n){n=n||2;var r,i,o,a,s,l,u,c=t&&t.length,h=c?t[0]*n:e.length,d=n2(e,0,h,n,!0),p=[];if(!d)return p;if(c&&(d=function(e,t,n,r){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=n2(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(d2(a));for(s.sort(u2),i=0;i<s.length;i++)c2(s[i],n),n=r2(n,n.next);return n}(e,t,d,n)),e.length>80*n){r=o=e[0],i=a=e[1];for(var f=n;f<h;f+=n)(s=e[f])<r&&(r=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=Math.max(o-r,a-i)}return i2(d,p,n,r,i,u),p}function n2(e,t,n,r,i){var o,a;if(i===S2(e,t,n,r)>0)for(o=t;o<n;o+=r)a=x2(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=x2(o,e[o],e[o+1],a);return a&&m2(a,a.next)&&(b2(a),a=a.next),a}function r2(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m2(r,r.next)&&0!==g2(r.prev,r,r.next))r=r.next;else{if(b2(r),(r=t=r.prev)===r.next)return null;n=!0}}while(n||r!==t);return t}function i2(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=h2(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<u&&(s++,r=r.nextZ);t++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?a2(e,r,i,o):o2(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),b2(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?i2(e=s2(e,t,n),t,n,r,i,o,2):2===a&&l2(e,t,n,r,i,o):i2(r2(e),t,n,r,i,o,1);break}}}function o2(e){var t=e.prev,n=e,r=e.next;if(g2(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(p2(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&g2(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function a2(e,t,n,r){var i=e.prev,o=e,a=e.next;if(g2(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,h=h2(s,l,t,n,r),d=h2(u,c,t,n,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&p2(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&g2(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&p2(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&g2(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function s2(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!m2(i,o)&&v2(i,r,r.next,o)&&y2(i,o)&&y2(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),b2(r),b2(r.next),r=e=o),r=r.next}while(r!==e);return r}function l2(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&f2(a,s)){var l=_2(a,s);return a=r2(a,a.next),l=r2(l,l.next),i2(a,t,n,r,i,o),void i2(l,t,n,r,i,o)}s=s.next}a=a.next}while(a!==e)}function u2(e,t){return e.x-t.x}function c2(e,t){if(t=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n.prev;var l,u=n,c=n.x,h=n.y,d=1/0;r=n.next;for(;r!==u;)i>=r.x&&r.x>=c&&i!==r.x&&p2(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&((l=Math.abs(o-r.y)/(i-r.x))<d||l===d&&r.x>n.x)&&y2(r,e)&&(n=r,d=l),r=r.next;return n}(e,t),t){var n=_2(t,e);r2(n,n.next)}}function h2(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d2(e){var t=e,n=e;do{t.x<n.x&&(n=t),t=t.next}while(t!==e);return n}function p2(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function f2(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&v2(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&y2(e,t)&&y2(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)}function g2(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m2(e,t){return e.x===t.x&&e.y===t.y}function v2(e,t,n,r){return!!(m2(e,t)&&m2(n,r)||m2(e,r)&&m2(n,t))||g2(e,t,n)>0!=g2(e,t,r)>0&&g2(n,r,e)>0!=g2(n,r,t)>0}function y2(e,t){return g2(e.prev,e,e.next)<0?g2(e,t,e.next)>=0&&g2(e,e.prev,t)>=0:g2(e,t,e.prev)<0||g2(e,e.next,t)<0}function _2(e,t){var n=new w2(e.i,e.x,e.y),r=new w2(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function x2(e,t,n,r){var i=new w2(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function b2(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function w2(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S2(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}function T2(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function M2(e,t,n,r,i){var o=n,a=e[t];T2(e,t,r);for(var s=n;s<r;s++)i(e[s],a)<0&&(T2(e,s,o),o++);return T2(e,r,o),o}function C2(e,t,n,r){if(n<r){var i=M2(e,Math.floor((n+r)/2),n,r,t);C2(e,t,n,i-1),C2(e,t,i+1,r)}}function D2(){this._parts=[]}R(e2.prototype,Q1),R(e2.prototype,i0),R(e2.prototype,o0),R(e2.prototype,a0),R(e2.prototype,J1),t2.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(S2(e,0,o,n));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*n,c=s<l-1?t[s+1]*n:e.length;a-=Math.abs(S2(e,u,c,n))}var h=0;for(s=0;s<r.length;s+=3){var d=r[s]*n,p=r[s+1]*n,f=r[s+2]*n;h+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},D2.prototype.step=function(e,t,n){var r=e.length;if(0===n){this._parts=[],this._sorted=!1;var i=Math.floor(r/2);this._parts.push({pivot:i,left:0,right:r-1}),this._currentSortPartIdx=0}if(!this._sorted){var o=this._parts;if(0===o.length)return this._sorted=!0,!0;if(o.length<512){for(var a=0;a<o.length;a++)o[a].pivot=M2(e,o[a].pivot,o[a].left,o[a].right,t);var s=[];for(a=0;a<o.length;a++){var l=o[a].left;(u=o[a].pivot-1)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u});var u;l=o[a].pivot+1;(u=o[a].right)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u})}o=this._parts=s}else for(a=0;a<Math.floor(o.length/10);a++){var c=o.length-1-this._currentSortPartIdx;if(C2(e,t,o[c].left,o[c].right),this._currentSortPartIdx++,this._currentSortPartIdx===o.length)return this._sorted=!0,!0}return!1}},D2.sort=C2;var A2=p0.vec3,I2=A2.create(),E2=A2.create(),L2=A2.create(),N2={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var n=this.indices;if(0===t){var r=this.attributes.position;e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new n.constructor(n.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,o=0,a=0;a<n.length;){r.get(n[a++],I2),r.get(n[a++],E2),r.get(n[a++],L2);var s=A2.sqrDist(I2,e),l=A2.sqrDist(E2,e),u=A2.sqrDist(L2,e),c=Math.min(s,l);c=Math.min(c,u),3===a?(i=c,c=0):c-=i,this._triangleZList[o++]=c}}var h=this._sortedTriangleIndices;for(a=0;a<h.length;a++)h[a]=a;if(this.triangleCount<2e4)0===t&&this._simpleSort(!0);else for(a=0;a<3;a++)this._progressiveQuickSort(3*t+a);var d=this._indicesTmp,p=this._triangleZListTmp,f=this._triangleZList;for(a=0;a<this.triangleCount;a++){var g=3*h[a],m=3*a;d[m++]=n[g++],d[m++]=n[g++],d[m]=n[g],p[a]=f[h[a]]}var v=this._indicesTmp;this._indicesTmp=this.indices,this.indices=v;v=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=v,this.dirtyIndices()},_simpleSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):D2.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;this._quickSort=this._quickSort||new D2,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}};function P2(e,t){const n=e.getItemVisual(t,"style");if(n){return n[e.getVisual("drawType")]}}function O2(e,t){const n=e.getItemVisual(t,"style");return n&&n.opacity}function R2(e,t,n){this._labelsMesh=new D0,this._labelTextureSurface=new y0({width:512,height:512,devicePixelRatio:n.getDevicePixelRatio(),onupdate:function(){n.getZr().refresh()}}),this._api=n,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}R2.prototype.getLabelPosition=function(e,t,n){return[0,0,0]},R2.prototype.getLabelDistance=function(e,t,n){return 0},R2.prototype.getMesh=function(){return this._labelsMesh},R2.prototype.updateData=function(e,t,n){null==t&&(t=0),null==n&&(n=e.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===n-t||(this._labelsVisibilitiesBits=new Uint8Array(n-t));for(var r=["label","show"],i=["emphasis","label","show"],o=t;o<n;o++){var a=e.getItemModel(o),s=a.get(r),l=a.get(i);null==l&&(l=s);var u=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[o-t]=u}this._start=t,this._end=n,this._data=e},R2.prototype.updateLabels=function(e){if(this._data){for(var t=(e=e||[]).length>0,n={},r=0;r<e.length;r++)n[e[r]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var i=["label"],o=["emphasis","label"],a=this._data.hostModel,s=this._data,l=a.getModel(i),u=a.getModel(o,l),c={left:"right",right:"left",top:"center",bottom:"center"},h={left:"middle",right:"middle",top:"bottom",bottom:"top"},d=this._start;d<this._end;d++){var p=!1;if(t&&n[d]&&(p=!0),this._labelsVisibilitiesBits[d-this._start]&(p?2:1)){var f=s.getItemModel(d).getModel(p?o:i,p?u:l),g=f.get("distance")||0,m=f.get("position"),v=this._api.getDevicePixelRatio(),y=a.getFormattedLabel(d,p?"emphasis":"normal");if(null==y||""===y)return;var _=new ll({style:wh(f,{text:y,fill:f.get("color")||P2(s,d)||"#000",align:"left",verticalAlign:"top",opacity:wJ(f.get("opacity"),O2(s,d),1)})}),x=_.getBoundingRect();x.height*=1.2;var b=this._labelTextureSurface.add(_),w=c[m]||"center",S=h[m]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(d,m,g),[x.width*v,x.height*v],b,w,S,this.getLabelDistance(d,m,g)*v)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}},R2.prototype.dispose=function(){this._labelTextureSurface.dispose()};var k2=p0.vec3;function z2(e){this.rootNode=new HQ.Node,this._triangulationResults={},this._shadersMap=HQ.COMMON_SHADERS.filter((function(e){return"shadow"!==e})).reduce((function(e,t){return e[t]=HQ.createShader("ecgl."+t),e}),{}),this._linesShader=HQ.createShader("ecgl.meshLines3D");var t={};HQ.COMMON_SHADERS.forEach((function(e){t[e]=new HQ.Material({shader:HQ.createShader("ecgl."+e)})})),this._groundMaterials=t,this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new R2(512,512,e),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=e}HQ.Shader.import(N0),z2.prototype={constructor:z2,extrudeY:!0,update:function(e,t,n,r,i){var o=e.getData();null==r&&(r=0),null==i&&(i=o.count()),this._startIndex=r,this._endIndex=i-1,this._triangulation(e,r,i);var a=this._getShader(e.get("shading"));this._prepareMesh(e,a,n,r,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,n,r,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,n);var l=this;this._labelsBuilder.updateData(o,r,i),this._labelsBuilder.getLabelPosition=function(e,t,n){var r=o.getName(e),i=n;if("geo3D"===s.type){var a=s.getRegion(r);return a?(c=a.getCenter(),s.dataToPoint([c[0],c[1],i])):[NaN,NaN,NaN]}var u=l._triangulationResults[e-l._startIndex],c=l.extrudeY?[(u.max[0]+u.min[0])/2,u.max[1]+i,(u.max[2]+u.min[2])/2]:[(u.max[0]+u.min[0])/2,(u.max[1]+u.min[1])/2,u.max[2]+i]},this._data=o,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this;var t=function(){var t=new HQ.Mesh({name:"Polygon",material:new HQ.Material({shader:e._shadersMap.lambert}),geometry:new HQ.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(t.geometry,N2),t}(),n=new HQ.Mesh({material:new HQ.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new m0({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(n),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=n,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+e),t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,n,r,i){for(var o=0,a=0,s=0,l=0,u=r;u<i;u++){var c=this._getRegionPolygonInfo(u),h=this._getRegionLinesInfo(u,e,this._linesMesh.geometry);o+=c.vertexCount,a+=c.triangleCount,s+=h.vertexCount,l+=h.triangleCount}var d=this._polygonMesh,p=d.geometry;["position","normal","texcoord0","color"].forEach((function(e){p.attributes[e].init(o)})),p.indices=o>65535?new Uint32Array(3*a):new Uint16Array(3*a),d.material.shader!==t&&d.material.attachShader(t,!0),HQ.setMaterialFromModel(t.__shading,d.material,e,n),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(o),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-r))},_updateRegionMesh:function(e,t,n,r){for(var i=e.getData(),o=0,a=0,s=!1,l=this._polygonMesh,u=this._linesMesh,c=n;c<r;c++){var h=e.getRegionModel(c),d=h.getModel("itemStyle"),p=wJ(P2(i,c),d.get("color"),"#fff"),f=wJ(O2(i,c),d.get("opacity"),1),g=HQ.parseColor(p),m=HQ.parseColor(d.get("borderColor"));g[3]*=f,m[3]*=f;var v=g[3]<.99;l.material.set("color",[1,1,1,1]),s=s||v;for(var y=wJ(h.get("height",!0),e.get("regionHeight")),_=this._updatePolygonGeometry(e,l.geometry,c,y,o,a,g),x=o;x<_.vertexOffset;x++)this._dataIndexOfVertex[x]=c;this._vertexRangeOfDataIndex[2*(c-n)]=o,this._vertexRangeOfDataIndex[2*(c-n)+1]=_.vertexOffset,o=_.vertexOffset,a=_.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=t.getDevicePixelRatio(),this._updateLinesGeometry(u.geometry,e,c,y,b,e.coordinateSystem.transform)),u.invisible=!w,u.material.set({color:m})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?HQ.Mesh.CCW:HQ.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=e.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var n=HQ.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),r=wJ(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",n),i.material.set("wireframeLineWidth",r)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,n){var r=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!r.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),o=this._groundMaterials[i];o||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+i),o=this._groundMaterials.lambert),HQ.setMaterialFromModel(i,o,r,n),o.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=o,this._groundMesh.material.set("color",HQ.parseColor(r.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,n){this._triangulationResults=[];for(var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],o=e.coordinateSystem,a=t;a<n;a++){for(var s=[],l=e.getRegionPolygonCoords(a),u=0;u<l.length;u++){var c=l[u].exterior,h=l[u].interiors,d=[],p=[];if(!(c.length<3)){for(var f=0,g=0;g<c.length;g++){var m=c[g];d[f++]=m[0],d[f++]=m[1]}for(g=0;g<h.length;g++)if(!(h[g].length<3)){for(var v=d.length/2,y=0;y<h[g].length;y++){m=h[g][y];d.push(m[0]),d.push(m[1])}p.push(v)}var _=t2(d,p),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],S=[-1/0,-1/0,-1/0],T=0;for(g=0;g<d.length;)k2.set(b,d[g++],0,d[g++]),o&&o.transform&&k2.transformMat4(b,b,o.transform),k2.min(w,w,b),k2.max(S,S,b),x[T++]=b[0],x[T++]=b[1],x[T++]=b[2];k2.min(r,r,w),k2.max(i,i,S),s.push({points:x,indices:_,min:w,max:S})}}this._triangulationResults.push(s)}this._geoBoundingBox=[r,i]},_getRegionPolygonInfo:function(e){for(var t=this._triangulationResults[e-this._startIndex],n=0,r=0,i=0;i<t.length;i++)n+=t[i].points.length/3,r+=t[i].indices.length/3;return{vertexCount:2*n+4*n,triangleCount:2*r+2*n}},_updatePolygonGeometry:function(e,t,n,r,i,o,a){var s=e.get("projectUVOnGround"),l=t.attributes.position,u=t.attributes.normal,c=t.attributes.texcoord0,h=t.attributes.color,d=this._triangulationResults[n-this._startIndex],p=h.value&&a,f=t.indices,g=this.extrudeY?1:2,m=this.extrudeY?2:1,v=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],y=k2.mul([],this._geoBoundingBox[0],v),_=k2.mul([],this._geoBoundingBox[1],v),x=Math.max(_[0]-y[0],_[2]-y[2]);function b(e,t,n){var r=i;!function(e,t){for(var n=e.points,r=n.length,o=[],s=[],u=0;u<r;u+=3)o[0]=n[u],o[g]=t,o[m]=n[u+2],s[0]=(n[u]*v[0]-y[0])/x,s[1]=(n[u+2]*v[m]-y[2])/x,l.set(i,o),p&&h.set(i,a),c.set(i++,s)}(e,t);for(var s=e.indices.length,u=0;u<s;u++)f[3*o+u]=e.indices[u]+r;o+=e.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],S=k2.negate([],w),T=0;T<d.length;T++){var M=i,C=d[T];b(C,0),b(C,r);for(var D=C.points.length/3,A=0;A<D;A++)u.set(M+A,S),u.set(M+A+D,w);var I=[0,3,1,1,3,2],E=[[],[],[],[]],L=[],N=[],P=[],O=[],R=0;for(A=0;A<D;A++){for(var k=(A+1)%D,z=(C.points[3*k]-C.points[3*A])*v[0],V=(C.points[3*k+2]-C.points[3*A+2])*v[m],B=Math.sqrt(z*z+V*V),F=0;F<4;F++){var G=0===F||3===F,H=3*(G?A:k);E[F][0]=C.points[H],E[F][g]=F>1?r:0,E[F][m]=C.points[H+2],l.set(i+F,E[F]),s?(O[0]=(C.points[H]*v[0]-y[0])/x,O[1]=(C.points[H+2]*v[m]-y[m])/x):(O[0]=(G?R:R+B)/x,O[1]=(E[F][g]*v[g]-y[g])/x),c.set(i+F,O)}k2.sub(L,E[1],E[0]),k2.sub(N,E[3],E[0]),k2.cross(P,L,N),k2.normalize(P,P);for(F=0;F<4;F++)u.set(i+F,P),p&&h.set(i+F,a);for(F=0;F<6;F++)f[3*o+F]=I[F]+i;i+=4,o+=2,R+=B}}return t.dirty(),{vertexOffset:i,triangleOffset:o}},_getRegionLinesInfo:function(e,t,n){var r=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach((function(e){var t=e.exterior,o=e.interiors;r+=n.getPolylineVertexCount(t),i+=n.getPolylineTriangleCount(t);for(var a=0;a<o.length;a++)r+=n.getPolylineVertexCount(o[a]),i+=n.getPolylineTriangleCount(o[a])}),this);return{vertexCount:r,triangleCount:i}},_updateLinesGeometry:function(e,t,n,r,i,o){function a(e){for(var t=new Float64Array(3*e.length),n=0,i=[],a=0;a<e.length;a++)i[0]=e[a][0],i[1]=r+.1,i[2]=e[a][1],o&&k2.transformMat4(i,i,o),t[n++]=i[0],t[n++]=i[1],t[n++]=i[2];return t}var s=[1,1,1,1];t.getRegionPolygonCoords(n).forEach((function(t){var n=t.exterior,r=t.interiors;e.addPolyline(a(n),s,i);for(var o=0;o<r.length;o++)e.addPolyline(a(r[o]),s,i)}))},highlight:function(e){var t=this._data;if(t){var n=t.getItemModel(e).getModel(["emphasis","itemStyle"]),r=n.get("color"),i=wJ(n.get("opacity"),O2(t,e),1);if(null==r)r=or(P2(t,e),-.4);null==i&&(i=O2(t,e));var o=HQ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},downplay:function(e){var t=this._data;if(t){var n=t.getItemModel(e),r=wJ(P2(t,e),n.get(["itemStyle","color"]),"#fff"),i=wJ(O2(t,e),n.get(["itemStyle","opacity"]),1),o=HQ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},dispose:function(){this._labelsBuilder.dispose()},_setColorOfDataIndex:function(e,t,n){if(!(t<this._startIndex&&t>this._endIndex)){t-=this._startIndex;for(var r=this._vertexRangeOfDataIndex[2*t];r<this._vertexRangeOfDataIndex[2*t+1];r++)this._polygonMesh.geometry.attributes.color.set(r,n);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var V2=Kg.extend({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new z2(t),this.groupGL=new HQ.Node,this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new h0({zr:t.getZr()}),this._control.init()},render:function(e,t,n){this.groupGL.add(this._geo3DBuilder.rootNode);var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")})),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})})),i.update()}},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},dispose:function(){this._control.dispose(),this._geo3DBuilder.dispose()}}),B2={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var F2=p0.vec3,G2=p0.mat4,H2=[mD,function(e,t){if("world"===e){var n=B2[t.name];if(n){var r=[n[0],n[1]];t.setCenter(r)}}}];function U2(e,t,n,r,i){this.name=e,this.map=t,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(n,r,i),this.transform=G2.identity(new Float64Array(16)),this.invTransform=G2.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}function W2(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=this.getGeoBoundingRect(),i=r.width/r.height*(e.get("aspectScale")||.75),o=e.get("boxWidth"),a=e.get("boxDepth"),s=e.get("boxHeight");null==s&&(s=5),isNaN(o)&&isNaN(a)&&(o=100),isNaN(a)?a=o/i:isNaN(o)&&(o=a/i),this.setSize(o,s,a),this.regionHeight=e.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function j2(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this&&"series.map3D"!==e.type){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),n&&isFinite(n[1]-n[0])){var r=nb(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Ob("altitude",r),this.resize(this.model,t)}}if(U2.prototype={constructor:U2,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(e,t,n){var r=vb||vb;try{this.regions=e?r(e):[]}catch(e){throw"Invalid geoJson format\n"+e}t=t||{},n=n||{};for(var i=this.regions,o={},a=0;a<i.length;a++){var s=i[a].name;s=n[s]||s,i[a].name=s,o[s]=i[a],this.addGeoCoord(s,i[a].getCenter());var l=t[s];l&&i[a].transformTo(l.left,l.top,l.width,l.height)}this._regionsMap=o,this._geoRect=null,H2.forEach((function(e){e(this)}),this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var e,t=this.regions,n=0;n<t.length;n++){var r=t[n].getBoundingRect();(e=e||r.clone()).union(r)}return this._geoRect=e||new jt(0,0,0,0)},addGeoCoord:function(e,t){this._nameCoordMap[e]=t},getRegion:function(e){return this._regionsMap[e]},getRegionByCoord:function(e){for(var t=this.regions,n=0;n<t.length;n++)if(t[n].contain(e))return t[n]},setSize:function(e,t,n){this.size=[e,t,n];var r=this.getGeoBoundingRect(),i=e/r.width,o=-n/r.height,a=-e/2-r.x*i,s=n/2-r.y*o,l=this.extrudeY?[a,0,s]:[a,s,0],u=this.extrudeY?[i,1,o]:[i,o,1],c=this.transform;G2.identity(c),G2.translate(c,c,l),G2.scale(c,c,u),G2.invert(this.invTransform,c)},dataToPoint:function(e,t){t=t||[];var n=this.extrudeY?1:2,r=this.extrudeY?2:1,i=e[2];return isNaN(i)&&(i=0),t[0]=e[0],t[r]=e[1],this.altitudeAxis?t[n]=this.altitudeAxis.dataToCoord(i):t[n]=0,t[n]+=this.regionHeight,F2.transformMat4(t,t,this.transform),t},pointToData:function(e,t){}},"production"!==process.env.NODE_ENV)var X2=function(e){console.error("Map "+e+" not exists. You can download map file on http://echarts.baidu.com/download-map.html")};var Y2=0,Z2={dimensions:U2.prototype.dimensions,create:function(e,t){var n=[];if(!i_)throw new Error("geo3D component depends on geo component");function r(e,r){var i=Z2.createGeo3D(e);e.__viewGL=e.__viewGL||new V1,i.viewGL=e.__viewGL,e.coordinateSystem=i,i.model=e,n.push(i),i.resize=W2,i.resize(e,t),i.update=j2}return e.eachComponent("geo3D",(function(e,t){r(e)})),e.eachSeriesByType("map3D",(function(e,t){var n=e.get("coordinateSystem");null==n&&(n="geo3D"),"geo3D"===n&&r(e)})),e.eachSeries((function(t){if("geo3D"===t.get("coordinateSystem")){if("series.map3D"===t.type)return;var n=t.getReferringComponents("geo3D").models[0];if(n||(n=e.getComponent("geo3D")),!n)throw new Error('geo "'+wJ(t.get("geo3DIndex"),t.get("geo3DId"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n},createGeo3D:function(e){var t,n=e.get("map");if("string"==typeof n?(t=n,n=i_(n)):n&&n.features&&(n={geoJson:n}),"production"!==process.env.NODE_ENV&&(n||X2(n),!n.geoJson.features))throw new Error("Invalid GeoJSON for map3D");return null==t&&(t="GEO_ANONYMOUS_"+Y2++),new U2(t+Y2++,t,n&&n.geoJson,n&&n.specialAreas,e.get("nameMap"))}};function q2(e){e.registerComponentModel(e2),e.registerComponentView(V2),e.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"geo3D",query:e},(function(t){t.setView(e)}))})),e.registerCoordinateSystem("geo3D",Z2)}function K2(e,t){e.id=e.id||e.name||t+""}l_(q2);var $2=tp.extend({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){$2.superApply(this,"init",arguments),W(this.option.layers,(function(e,t){R(e,this.defaultLayerOption),K2(e,t)}),this)},mergeOption:function(e){var t=this.option.layers;function n(e){return X(e,(function(e,t,n){return K2(t,n),e[t.id]=t,e}),{})}if(this.option.layers=null,$2.superApply(this,"mergeOption",arguments),t&&t.length){var r=n(e.layers),i=n(t);for(var o in r)i[o]?R(i[o],r[o],!0):t.push(e.layers[o]);this.option.layers=t}W(this.option.layers,(function(e){R(e,this.defaultLayerOption)}),this)},optionUpdated:function(){this.updateDisplacementHash()},defaultLayerOption:{show:!0,type:"overlay"},defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",baseColor:"#fff",baseTexture:"",heightTexture:"",displacementTexture:"",displacementScale:0,displacementQuality:"medium",globeRadius:100,globeOuterRadius:150,shading:"lambert",light:{main:{time:""}},atmosphere:{show:!1,offset:5,color:"#ffffff",glowPower:6,innerGlowPower:2},viewControl:{autoRotate:!0,panSensitivity:0,targetCoord:null},layers:[]},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var e=this.getDisplacementTexture(),t=this.get("displacementScale");return e&&"none"!==e||(t=0),t},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});R($2.prototype,i0),R($2.prototype,o0),R($2.prototype,a0),R($2.prototype,J1);var J2=Math.PI,Q2=Math.sin,e3=Math.cos,t3=Math.tan,n3=Math.asin,r3=Math.atan2,i3=J2/180;var o3=23.4397*i3;function a3(e,t){return r3(Q2(e)*e3(o3)-t3(t)*Q2(o3),e3(e))}function s3(e,t,n){return r3(Q2(e),e3(e)*Q2(t)-t3(n)*e3(t))}function l3(e,t,n){return n3(Q2(t)*Q2(n)+e3(t)*e3(n)*e3(e))}function u3(e){var t,n,r=function(e){return i3*(357.5291+.98560028*e)}(e),i=function(e){return e+i3*(1.9148*Q2(e)+.02*Q2(2*e)+3e-4*Q2(3*e))+102.9372*i3+J2}(r);return{dec:(t=i,n=0,n3(Q2(n)*e3(o3)+e3(n)*Q2(o3)*Q2(t))),ra:a3(i,0)}}var c3={};c3.getPosition=function(e,t,n){var r=i3*-n,i=i3*t,o=function(e){return function(e){return e.valueOf()/864e5-.5+2440588}(e)-2451545}(e),a=u3(o),s=function(e,t){return i3*(280.16+360.9856235*e)-t}(o,r)-a.ra;return{azimuth:s3(s,i,a.dec),altitude:l3(s,i,a.dec)}};HQ.Shader.import(VQ),HQ.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");var h3=Kg.extend({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new HQ.Node,this._sphereGeometry=new HQ.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new HQ.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new HQ.PlaneGeometry,this._earthMesh=new HQ.Mesh({renderNormal:!0}),this._atmosphereMesh=new HQ.Mesh,this._atmosphereGeometry=new HQ.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.atmosphere.vertex"),HQ.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=HQ.Mesh.CW,this._lightRoot=new HQ.Node,this._sceneHelper=new _0,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new h0({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,n){var r=e.coordinateSystem,i=e.get("shading");r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL),this._sceneHelper.setScene(r.viewGL.scene),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var a="ecgl."+i;o.material&&o.material.shader.name===a||(o.material=HQ.createMaterial(a)),HQ.setMaterialFromModel(i,o.material,e,n),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach((function(e){var t=o.material.get(e);t&&(t.flipY=!1)})),o.material.set("color",HQ.parseColor(e.get("baseColor")));var s=.99*r.radius;if(o.scale.set(s,s,s),e.get("atmosphere.show")){o.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:e.get("atmosphere.glowPower")||6,glowColor:e.get("atmosphere.color")||"#ffffff"}),o.material.setUniforms({glowPower:e.get("atmosphere.innerGlowPower")||2,glowColor:e.get("atmosphere.color")||"#ffffff"});var l=e.get("atmosphere.offset")||5;this._atmosphereMesh.scale.set(s+l,s+l,s+l)}else o.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var u=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),n,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(o);var c=o.material.setTextureImage("bumpMap",e.get("heightTexture"),n,{flipY:!1,anisotropic:8});c&&c.surface&&c.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,n),this._displaceVertices(e,n),this._updateViewControl(e,n),this._updateLayers(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},_updateLayers:function(e,t){var n=e.coordinateSystem,r=e.get("layers"),i=n.radius,o=[],a=[],s=[],l=[];W(r,(function(e){var r=new Wh(e),u=r.get("type"),c=HQ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var h=r.get("blendTo"),d=wJ(r.get("intensity"),1);"emission"===h?(s.push(c),l.push(d)):(o.push(c),a.push(d))}else{var p=r.get("id"),f=this._layerMeshes[p];f||(f=this._layerMeshes[p]=new HQ.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===r.get("shading")?(f.material=f.__lambertMaterial||new HQ.Material({autoUpdateTextureStatus:!1,shader:HQ.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),f.__lambertMaterial=f.material):(f.material=f.__colorMaterial||new HQ.Material({autoUpdateTextureStatus:!1,shader:HQ.createShader("ecgl.color"),transparent:!0,depthMask:!1}),f.__colorMaterial=f.material),f.material.enableTexture("diffuseMap");var g=r.get("distance"),m=i+(null==g?n.radius/100:g);f.scale.set(m,m,m),i=m;var v=this._blankTexture||(this._blankTexture=HQ.createBlankTexture("rgba(255, 255, 255, 0)"));f.material.set("diffuseMap",v),HQ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8},(function(e){e.surface&&e.surface.attachToMesh(f),f.material.set("diffuseMap",e),t.getZr().refresh()})),r.get("show")?this.groupGL.add(f):this.groupGL.remove(f)}}),this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",s.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",a),u.set("layerEmissiveMap",s),u.set("layerEmissionIntensity",l);var c=e.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var h=HQ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),d=wJ(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",d),u.set("wireframeLineColor",h)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){var n=e.coordinateSystem,r=e.getModel("viewControl");n.viewGL.camera;var i=this;var o=this._control;o.setViewGL(n.viewGL);var a,s,l=r.get("targetCoord");null!=l&&(s=l[0]+90,a=l[1]),o.setFromViewControlModel(r,{baseDistance:n.radius,alpha:a,beta:s}),o.off("update"),o.on("update",(function(){t.dispatchAction({type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:i.uid,globeId:e.id})}))},_displaceVertices:function(e,t){var n=e.get("displacementQuality"),r=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||n!==this._displacementQuality||r!==this._showDebugWireframe){this._displacementQuality=n,this._showDebugWireframe=r;var o=this._sphereGeometry,a={low:100,medium:200,high:400,ultra:800}[n]||200,s=a/2;(o.widthSegments!==a||r)&&(o.widthSegments=a,o.heightSegments=s,o.build()),this._doDisplaceVertices(o,i),r&&o.generateBarycentric()}},_doDisplaceVertices:function(e,t){var n=e.attributes.position.value,r=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===n.length||((i=new Float32Array(n.length)).set(n),e.__originalPosition=i);for(var o=t.displacementWidth,a=t.displacementHeight,s=t.displacementData,l=0;l<e.vertexCount;l++){var u=3*l,c=2*l,h=i[u+1],d=i[u+2],p=i[u+3],f=r[c++],g=r[c++],m=Math.round(f*(o-1)),v=Math.round(g*(a-1)),y=s?s[v*o+m]:0;n[u+1]=h+h*y,n[u+2]=d+d*y,n[u+3]=p+p*y}e.generateVertexNormals(),e.dirty(),e.updateBoundingBox()},_updateLight:function(e,t){var n=this._earthMesh;this._sceneHelper.updateLight(e);var r=this._sceneHelper.mainLight,i=e.get("light.main.time")||new Date,o=c3.getPosition(yo(i),0,0),a=Math.cos(o.altitude);r.position.y=-a*Math.cos(o.azimuth),r.position.x=Math.sin(o.altitude),r.position.z=a*Math.sin(o.azimuth),r.lookAt(n.getWorldPosition())},dispose:function(e,t){this.groupGL.removeAll(),this._control.dispose()}}),d3=p0.vec3;function p3(e){this.radius=e,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}function f3(e,t){var n=Zd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio()),this.radius=e.get("globeRadius");var r=e.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,r-this.radius)}function g3(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),n&&isFinite(n[1]-n[0])){var r=nb(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Ob("altitude",r),this.resize(this.model,t)}}p3.prototype={constructor:p3,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},_getDisplacementScale:function(e,t){var n=(e+180)/360*(this.displacementWidth-1),r=(90-t)/180*(this.displacementHeight-1),i=Math.round(n)+Math.round(r)*this.displacementWidth;return this.displacementData[i]},dataToPoint:function(e,t){var n=e[0],r=e[1],i=e[2]||0,o=this.radius;this.displacementData&&(o*=1+this._getDisplacementScale(n,r)),this.altitudeAxis&&(o+=this.altitudeAxis.dataToCoord(i)),n=n*Math.PI/180,r=r*Math.PI/180;var a=Math.cos(r)*o;return(t=t||[])[0]=-a*Math.cos(n+Math.PI),t[1]=Math.sin(r)*o,t[2]=a*Math.sin(n+Math.PI),t},pointToData:function(e,t){var n=e[0],r=e[1],i=e[2],o=d3.len(e);n/=o,r/=o,i/=o;var a=Math.asin(r),s=Math.atan2(i,-n);s<0&&(s=2*Math.PI+s);var l=180*a/Math.PI,u=180*s/Math.PI-180;return(t=t||[])[0]=u,t[1]=l,t[2]=o-this.radius,this.altitudeAxis&&(t[2]=this.altitudeAxis.coordToData(t[2])),t}};var m3={dimensions:p3.prototype.dimensions,create:function(e,t){var n=[];return e.eachComponent("globe",(function(e){e.__viewGL=e.__viewGL||new V1;var r=new p3;r.viewGL=e.__viewGL,e.coordinateSystem=r,r.model=e,n.push(r),r.resize=f3,r.resize(e,t),r.update=g3})),e.eachSeries((function(t){if("globe"===t.get("coordinateSystem")){var n=t.getReferringComponents("globe").models[0];if(n||(n=e.getComponent("globe")),!n)throw new Error('globe "'+wJ(t.get("globe3DIndex"),t.get("globe3DId"),0)+'" not found');var r=n.coordinateSystem;t.coordinateSystem=r}})),e.eachComponent("globe",(function(e,n){var r=e.coordinateSystem,i=e.getDisplacementTexture(),o=e.getDisplacemenScale();if(e.isDisplacementChanged()){if(e.hasDisplacement()){var a=!0;HQ.loadTexture(i,t,(function(n){var r=function(e,t){var n=document.createElement("canvas"),r=n.getContext("2d"),i=e.width,o=e.height;n.width=i,n.height=o,r.drawImage(e,0,0,i,o);for(var a=r.getImageData(0,0,i,o).data,s=new Float32Array(a.length/4),l=0;l<a.length/4;l++){var u=a[4*l];s[l]=u/255*t}return{data:s,width:i,height:o}}(n.image,o);e.setDisplacementData(r.data,r.width,r.height),a||t.dispatchAction({type:"globeUpdateDisplacment"})})),a=!1}else r.setDisplacementData(null,0,0);r.setDisplacementData(e.displacementData,e.displacementWidth,e.displacementHeight)}})),n}};l_((function(e){e.registerComponentModel($2),e.registerComponentView(h3),e.registerCoordinateSystem("globe",m3),e.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"globe",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},(function(e,t){}))}));var v3=["zoom","center","pitch","bearing"],y3=tp.extend({type:"mapbox3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,style:"mapbox://styles/mapbox/light-v9",center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMapboxCameraOption:function(){var e=this;return v3.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMapboxCameraOption:function(e){null!=e&&v3.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(e){this._mapbox=e}});function _3(e,t){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!mapboxgl)throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");this._mapbox=new mapboxgl.Map({container:this.dom}),this._initEvents()}R(y3.prototype,o0),R(y3.prototype,a0),_3.prototype.setUnpainted=function(){},_3.prototype.resize=function(){this._mapbox.resize()},_3.prototype.getMapbox=function(){return this._mapbox},_3.prototype.clear=function(){},_3.prototype.refresh=function(){this._mapbox.resize()};var x3=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];_3.prototype._initEvents=function(){var e=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},x3.forEach((function(t){this._handlers[t]=function(t){var n={};for(var r in t)n[r]=t[r];n.bubbles=!1;var i=new t.constructor(t.type,n);e.dispatchEvent(i)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},_3.prototype.dispose=function(){x3.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this)};var b3="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";HQ.Shader.import(b3);var w3=Kg.extend({type:"mapbox3D",__ecgl__:!0,init:function(e,t){var n=t.getZr();this._zrLayer=new _3("mapbox3D",n),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMapbox(),i=this._dispatchInteractAction.bind(this,t,r);["zoom","rotate","drag","pitch","rotate","move"].forEach((function(e){r.on(e,i)})),this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.displayShadow.vertex"),fragment:HQ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(e,t,n){var r=this._zrLayer.getMapbox(),i=e.get("style"),o=JSON.stringify(i);o!==this._oldStyleStr&&i&&r.setStyle(i),this._oldStyleStr=o,r.setCenter(e.get("center")),r.setZoom(e.get("zoom")),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMapbox(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._mapbox3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){e.dispatchAction({type:"mapbox3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var e=this._mapbox3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new HQ.Plane(new HQ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new HQ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new HQ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}}),S3=p0.mat4,T3=512,M3=.6435011087932844,C3=Math.PI,D3=.1;function A3(){this.width=0,this.height=0,this.altitudeScale=1,this.boxHeight="auto",this.altitudeExtent,this.bearing=0,this.pitch=0,this.center=[0,0],this._origin,this.zoom=0,this._initialZoom,this.maxPitch=60,this.zoomOffset=0}function I3(){A3.apply(this,arguments)}function E3(e,t,n){function r(e,t){var n=t.getWidth(),r=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,n,r,i),this.width=n,this.height=r,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function i(e,t){if("auto"!==this.model.get("boxHeight")){var n=[1/0,-1/0];e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt")[0];if(r){var i=t.getDataExtent(r,!0);n[0]=Math.min(n[0],i[0]),n[1]=Math.max(n[1],i[1])}}}),this),n&&isFinite(n[1]-n[0])&&(this.altitudeExtent=n)}}return{dimensions:t.prototype.dimensions,create:function(o,a){var s=[];return o.eachComponent(e,(function(e){var n=e.__viewGL;n||(n=e.__viewGL=new V1).setRootNode(new HQ.Node);var o=new t;o.viewGL=e.__viewGL,o.resize=r,o.resize(e,a),s.push(o),e.coordinateSystem=o,o.model=e,o.update=i})),o.eachSeries((function(t){if(t.get("coordinateSystem")===e){var n=t.getReferringComponents(e).models[0];if(n||(n=o.getComponent(e)),!n)throw new Error(e+' "'+wJ(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n&&n(s,o,a),s}}}A3.prototype={constructor:A3,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(e){this.bearing=e.bearing,this.pitch=e.pitch,this.center=e.center,this.zoom=e.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,T3)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var e=.5/Math.tan(M3/2)*this.height*D3,t=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,n=M3/2,r=Math.PI/2+t,i=Math.sin(n)*e/Math.sin(Math.PI-r-n),o=1.1*(Math.cos(Math.PI/2-t)*i+e);this.pitch>50&&(o=1e3);var a=[];S3.perspective(a,M3,this.width/this.height,1,o),this.viewGL.camera.projectionMatrix.setArray(a),this.viewGL.camera.decomposeProjectionMatrix();a=S3.identity([]);var s=this.dataToPoint(this.center);S3.scale(a,a,[1,-1,1]),S3.translate(a,a,[0,0,-e]),S3.rotateX(a,a,t),S3.rotateZ(a,a,-this.bearing/180*Math.PI),S3.translate(a,a,[-s[0]*this.getScale()*D3,-s[1]*this.getScale()*D3,0]),this.viewGL.camera.viewMatrix.array=a;var l=[];S3.invert(l,a),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var u,c=T3*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var h=this.altitudeExtent[1]-this.altitudeExtent[0];u=this.boxHeight/h*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else u=c/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*D3;this.viewGL.rootNode.scale.set(this.getScale()*D3,this.getScale()*D3,u)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,this.getScale()*T3,t)},projectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1]*C3/180,o=t*(r*C3/180+C3)/(2*C3),a=t*(C3-Math.log(Math.tan(C3/4+.5*i)))/(2*C3);return(n=n||[])[0]=o,n[1]=a,n},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,this.getScale()*T3,t)},unprojectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1],o=r/t*(2*C3)-C3,a=2*(Math.atan(Math.exp(C3-i/t*(2*C3)))-C3/4);return(n=n||[])[0]=180*o/C3,n[1]=180*a/C3,n},dataToPoint:function(e,t){return(t=this.projectOnTileWithScale(e,T3,t))[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},I3.prototype=new A3,I3.prototype.constructor=I3,I3.prototype.type="mapbox3D";var L3=E3("mapbox3D",I3,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMapboxCameraOption())}))}));l_((function(e){e.registerComponentModel(y3),e.registerComponentView(w3),e.registerCoordinateSystem("mapbox3D",L3),e.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"mapbox3D",query:e},(function(t){t.setMapboxCameraOption(e)}))}))}));var N3=["zoom","center","pitch","bearing"],P3=tp.extend({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return N3.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMaptalksCameraOption:function(e){null!=e&&N3.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});function O3(e,t,n,r){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:n,zoom:r,doubleClickZoom:!1,fog:!1}),this._initEvents()}R(P3.prototype,o0),R(P3.prototype,a0),O3.prototype.setUnpainted=function(){},O3.prototype.resize=function(){this._maptalks.checkSize()},O3.prototype.getMaptalks=function(){return this._maptalks},O3.prototype.clear=function(){},O3.prototype.refresh=function(){this._maptalks.checkSize()};var R3=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];O3.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},R3.forEach((function(t){this._handlers[t]=function(n){var r={};for(var i in n)r[i]=n[i];r.bubbles=!1;var o=new n.constructor(n.type,r);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(o):e.firstElementChild.dispatchEvent(o)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},O3.prototype.dispose=function(){R3.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this),this._maptalks.remove()},HQ.Shader.import(b3);var k3=Kg.extend({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.displayShadow.vertex"),fragment:HQ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var n=t.getZr();this._zrLayer=new O3("maptalks3D",n,e.get("center"),e.get("zoom")),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new HQ.Node,this._sceneHelper=new _0(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,r);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach((function(e){r.on(e,i)}))},render:function(e,t,n){this._zrLayer||this._initMaptalksLayer(e,n);var r=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),o=r.getBaseLayer();i!==this._oldUrlTemplate&&(o?o.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(o=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),r.setBaseLayer(o))),this._oldUrlTemplate=i,r.setCenter(e.get("center")),r.setZoom(e.get("zoom"),{animation:!1}),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMaptalks(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){var r;e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:(r=t.getResolution(),19-Math.log(r/z3)/Math.LN2+1),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new HQ.Plane(new HQ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new HQ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new HQ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}});const z3=12756274*Math.PI/(256*Math.pow(2,20));function V3(){A3.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}V3.prototype=new A3,V3.prototype.constructor=V3,V3.prototype.type="maptalks3D";var B3=E3("maptalks3D",V3,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMaptalksCameraOption())}))}));l_((function(e){e.registerComponentModel(P3),e.registerComponentView(k3),e.registerCoordinateSystem("maptalks3D",B3),e.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"maptalks3D",query:e},(function(t){t.setMaptalksCameraOption(e)}))}))}));var F3=p0.vec3,G3=tb.isDimensionStacked;function H3(e,t,n){for(var r=e.getDataExtent(t),i=e.getDataExtent(n),o=r[1]-r[0]||r[0],a=i[1]-i[0]||i[0],s=new Uint8Array(2500),l=0;l<e.count();l++){var u=e.get(t,l),c=e.get(n,l),h=Math.floor((u-r[0])/o*49),d=50*Math.floor((c-i[0])/a*49)+h;s[d]=s[d]||1}var p=0;for(l=0;l<s.length;l++)s[l]&&p++;return p/s.length}var U3=p0.vec3,W3=tb.isDimensionStacked;function j3(e,t){var n=W3(e,t[2]);return{dimension:n?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:n}}function X3(e){e.registerLayout((function(e,t){e.eachSeriesByType("bar3D",(function(e){var t=e.coordinateSystem,n=t&&t.type;if("globe"===n)!function(e,t){var n=e.getData(),r=e.get("minHeight")||0,i=e.get("barSize"),o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==i){var a=t.radius*Math.PI,s=H3(n,o[0],o[1]);i=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(i)||(i=[i,i]);var l=j3(n,o);n.each(o,(function(e,o,a,s){var u=n.get(l.dimension,s),c=l.isStacked?u-a:t.altitudeAxis.scale.getExtent()[0],h=Math.max(t.altitudeAxis.dataToCoord(a),r),d=t.dataToPoint([e,o,c]),p=t.dataToPoint([e,o,u]),f=U3.sub([],p,d);U3.normalize(f,f);var g=[i[0],h,i[1]];n.setItemLayout(s,[d,f,g])})),n.setLayout("orient",Fq.UP.array)}(e,t);else if("cartesian3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize");if(null==r){var i,o,a=t.size,s=t.getAxis("x"),l=t.getAxis("y");i="category"===s.type?.7*s.getBandWidth():.6*Math.round(a[0]/Math.sqrt(n.count())),o="category"===l.type?.7*l.getBandWidth():.6*Math.round(a[1]/Math.sqrt(n.count())),r=[i,o]}else J(r)||(r=[r,r]);var u=t.getAxis("z").scale.getExtent(),c=function(e){var t=e[0],n=e[1];return!(t>0&&n>0||t<0&&n<0)}(u),h=["x","y","z"].map((function(t){return e.coordDimToDataDim(t)[0]})),d=G3(n,h[2]),p=d?n.getCalculationInfo("stackResultDimension"):h[2];n.each(h,(function(e,i,o,a){var s=n.get(p,a),l=d?s-o:c?0:u[0],h=t.dataToPoint([e,i,l]),f=t.dataToPoint([e,i,s]),g=F3.dist(h,f),m=[0,f[1]<h[1]?-1:1,0];0===Math.abs(g)&&(g=.1);var v=[r[0],g,r[1]];n.setItemLayout(a,[h,m,v])})),n.setLayout("orient",[1,0,0])}(e,t);else if("geo3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize"),i=e.get("minHeight")||0,o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==r){var a=Math.min(t.size[0],t.size[2]),s=H3(n,o[0],o[1]);r=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(r)||(r=[r,r]);var l=[0,1,0],u=j3(n,o);n.each(o,(function(e,o,a,s){var c=n.get(u.dimension,s),h=u.isStacked?c-a:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(a),i),p=t.dataToPoint([e,o,h]),f=[r[0],d,r[1]];n.setItemLayout(s,[p,l,f])})),n.setLayout("orient",[1,0,0])}(e,t);else if("mapbox3D"===n||"maptalks3D"===n)!function(e,t){var n=e.getData(),r=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],o=e.coordDimToDataDim("alt")[0],a=e.get("barSize"),s=e.get("minHeight")||0;if(null==a){var l=n.getDataExtent(r),u=n.getDataExtent(i),c=t.dataToPoint([l[0],u[0]]),h=t.dataToPoint([l[1],u[1]]),d=Math.min(Math.abs(c[0]-h[0]),Math.abs(c[1]-h[1]))||1,p=H3(n,r,i);a=[d/Math.sqrt(n.count()/p),d/Math.sqrt(n.count()/p)]}else J(a)||(a=[a,a]),a[0]/=t.getScale()/16,a[1]/=t.getScale()/16;var f=[0,0,1],g=[r,i,o],m=j3(n,g);n.each(g,(function(e,r,i,o){var l=n.get(m.dimension,o),u=m.isStacked?l-i:0,c=t.dataToPoint([e,r,u]),h=t.dataToPoint([e,r,l]),d=Math.max(h[2]-c[2],s),p=[a[0],d,a[1]];n.setItemLayout(o,[c,f,p])})),n.setLayout("orient",[1,0,0])}(e,t);else if("production"!==process.env.NODE_ENV)throw t?new Error("bar3D doesn't support coordinate system "+t.type):new Error("bar3D doesn't have coordinate system.")}))}))}var Y3={};function Z3(e,t,n){var r=e.getData(),i=e.getRawValue(t),o=J(i)?function(e){var i=[],o=function(e,t){var n=[];return W(e.dimensions,(function(r){var i=e.getDimensionInfo(r),o=i.otherDims[t];null!=o&&!1!==o&&(n[o]=i.name)})),n}(r,"tooltip");function a(e,t){var o=r.getDimensionInfo(t);if(o&&!1!==o.otherDims.tooltip){var a=o.type,s="- "+(o.tooltipName||o.name)+": "+("ordinal"===a?e+"":"time"===a?n?"":Fd("yyyy/MM/dd hh:mm:ss",e):Nd(e));s&&i.push(dt(s))}}return o.length?W(o,(function(e){a(r.get(e,t),e)})):W(e,a),"<br/>"+i.join("<br/>")}(i):dt(Nd(i)),a=r.getName(t),s=P2(r,t);re(s)&&s.colorStops&&(s=(s.colorStops[0]||{}).color);var l=Bd(s=s||"transparent"),u=e.name;return"\0-"===u&&(u=""),u=u?dt(u)+(n?": ":"<br/>"):"",n?l+u+o:u+l+(a?dt(a)+": "+o:o)}function q3(e,t,n){n=n||e.getSource();var r=t||$y(e.get("coordinateSystem"))||["x","y","z"],i=k_(n,{dimensionsDefine:n.dimensionsDefine||e.get("dimensions"),encodeDefine:n.encodeDefine||e.get("encode"),coordDimensions:r.map((function(t){var n=e.getReferringComponents(t+"Axis3D").models[0];return{type:n&&"category"===n.get("type")?"ordinal":"float",name:t}}))});"cartesian3D"===e.get("coordinateSystem")&&i.forEach((function(t){if(r.indexOf(t.coordDim)>=0){var n=e.getReferringComponents(t.coordDim+"Axis3D").models[0];n&&"category"===n.get("type")&&(t.ordinalMeta=n.getOrdinalMeta())}}));var o=tb.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),a=new R_(i,e);return a.setCalculationInfo(o),a.initData(n),a}Y3.getFormattedLabel=function(e,t,n,r,i){n=n||"normal";var o=e.getData(r).getItemModel(t),a=e.getDataParams(t,r);null!=i&&a.value instanceof Array&&(a.value=a.value[i]);var s,l=o.get("normal"===n?["label","formatter"]:["emphasis","label","formatter"]);return null==l&&(l=o.get(["label","formatter"])),"function"==typeof l?(a.status=n,s=l(a)):"string"==typeof l&&(s=Vd(l,a)),s},Y3.normalizeToArray=function(e){return e instanceof Array?e:null==e?[]:[e]};var K3=Hg.extend({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(e,t){return q3(this)},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);return null==i&&(i=this.getData().get("z",e)),i},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",globeIndex:0,grid3DIndex:0,zlevel:-10,bevelSize:0,bevelSmoothness:2,onGridPlane:"xy",shading:"color",minHeight:0,itemStyle:{opacity:1},label:{show:!1,distance:2,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},emphasis:{label:{show:!0}},animationDurationUpdate:500}});R(K3.prototype,J1);var $3,J3,Q3,e5,t5,n5,r5,i5,o5=p0.vec3,a5=p0.mat3,s5=XK.extend((function(){return{attributes:{position:new XK.Attribute("position","float",3,"POSITION"),normal:new XK.Attribute("normal","float",3,"NORMAL"),color:new XK.Attribute("color","float",4,"COLOR"),prevPosition:new XK.Attribute("prevPosition","float",3),prevNormal:new XK.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,n=this.getBarVertexCount()*e,r=this.getBarTriangleCount()*e;this.vertexCount!==n&&(this.attributes.position.init(n),t?this.attributes.normal.init(n):this.attributes.normal.value=null,this.attributes.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r),this._dataIndices=new Uint32Array(n))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var n=this.getBarVertexCount(),r=n*(e+1),i=n*e;i<r;i++)this.attributes.color.set(i,t);this.dirtyAttribute("color")},getDataIndexOfVertex:function(e){return this._dataIndices?this._dataIndices[e]:null},addBar:function(){for(var e=o5.create,t=o5.scaleAndAdd,n=e(),r=e(),i=e(),o=e(),a=e(),s=e(),l=e(),u=[],c=[],h=0;h<8;h++)u[h]=e();var d=[[0,1,5,4],[2,3,7,6],[4,5,6,7],[3,2,1,0],[0,4,7,3],[1,2,6,5]],p=[0,1,2,0,2,3],f=[];for(h=0;h<d.length;h++)for(var g=d[h],m=0;m<2;m++){for(var v=[],y=0;y<3;y++)v.push(g[p[3*m+y]]);f.push(v)}return function(e,h,g,m,v,y){var _=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(e,h,g,m,this.bevelSize,this.bevelSegments,v);else{o5.copy(i,h),o5.normalize(i,i),o5.cross(o,g,i),o5.normalize(o,o),o5.cross(r,i,o),o5.normalize(o,o),o5.negate(a,r),o5.negate(s,i),o5.negate(l,o),t(u[0],e,r,m[0]/2),t(u[0],u[0],o,m[2]/2),t(u[1],e,r,m[0]/2),t(u[1],u[1],l,m[2]/2),t(u[2],e,a,m[0]/2),t(u[2],u[2],l,m[2]/2),t(u[3],e,a,m[0]/2),t(u[3],u[3],o,m[2]/2),t(n,e,i,m[1]),t(u[4],n,r,m[0]/2),t(u[4],u[4],o,m[2]/2),t(u[5],n,r,m[0]/2),t(u[5],u[5],l,m[2]/2),t(u[6],n,a,m[0]/2),t(u[6],u[6],l,m[2]/2),t(u[7],n,a,m[0]/2),t(u[7],u[7],o,m[2]/2);var x=this.attributes;if(this.enableNormal){c[0]=r,c[1]=a,c[2]=i,c[3]=s,c[4]=o,c[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var S=3*this._triangleOffset,T=0;T<6;T++)this.indices[S++]=b+p[T];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=c[w];for(T=0;T<4;T++){var C=d[w][T];x.position.set(this._vertexOffset,u[C]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,v)}}}else{for(w=0;w<f.length;w++){for(S=3*this._triangleOffset,T=0;T<3;T++)this.indices[S+T]=f[w][T]+this._vertexOffset;this._triangleOffset++}for(w=0;w<u.length;w++)x.position.set(this._vertexOffset,u[w]),x.color.set(this._vertexOffset++,v)}}var D=this._vertexOffset;for(w=_;w<D;w++)this._dataIndices[w]=y}}(),_addBevelBar:($3=o5.create(),J3=o5.create(),Q3=o5.create(),e5=a5.create(),t5=[],n5=[1,-1,-1,1],r5=[1,1,-1,-1],i5=[2,0],function(e,t,n,r,i,o,a){o5.copy(J3,t),o5.normalize(J3,J3),o5.cross(Q3,n,J3),o5.normalize(Q3,Q3),o5.cross($3,J3,Q3),o5.normalize(Q3,Q3),e5[0]=$3[0],e5[1]=$3[1],e5[2]=$3[2],e5[3]=J3[0],e5[4]=J3[1],e5[5]=J3[2],e5[6]=Q3[0],e5[7]=Q3[1],e5[8]=Q3[2],i=Math.min(r[0],r[2])/2*i;for(var s=0;s<3;s++)t5[s]=Math.max(r[s]-2*i,0);var l=(r[0]-t5[0])/2,u=(r[1]-t5[1])/2,c=(r[2]-t5[2])/2,h=[],d=[],p=this._vertexOffset,f=[];for(s=0;s<2;s++){f[s]=f[s]=[];for(var g=0;g<=o;g++)for(var m=0;m<4;m++){(0===g&&0===s||1===s&&g===o)&&f[s].push(p);for(var v=0;v<=o;v++){var y=v/o*Math.PI/2+Math.PI/2*m,_=g/o*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(y)*Math.sin(_),d[1]=u*Math.cos(_),d[2]=c*Math.sin(y)*Math.sin(_),h[0]=d[0]+n5[m]*t5[0]/2,h[1]=d[1]+u+i5[s]*t5[1]/2,h[2]=d[2]+r5[m]*t5[2]/2,Math.abs(l-u)<1e-6&&Math.abs(u-c)<1e-6||(d[0]/=l*l,d[1]/=u*u,d[2]/=c*c),o5.normalize(d,d),o5.transformMat3(h,h,e5),o5.transformMat3(d,d,e5),o5.add(h,h,e),this.attributes.position.set(p,h),this.enableNormal&&this.attributes.normal.set(p,d),this.attributes.color.set(p,a),p++}}}var x=4*o+3,b=2*o+1,w=x+1;for(m=0;m<b;m++)for(s=0;s<=x;s++){var S=m*w+s+this._vertexOffset,T=m*w+(s+1)%w+this._vertexOffset,M=(m+1)*w+(s+1)%w+this._vertexOffset,C=(m+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,S,T]),this.setTriangleIndices(this._triangleOffset++,[M,C,S])}this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][2],f[0][1]]),this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][3],f[0][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][1],f[1][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][2],f[1][3]]),this._vertexOffset=p})});V(s5.prototype,d0),V(s5.prototype,N2);var l5=p0.vec3,u5=em.extend({type:"bar3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._api=t,this._labelsBuilder=new R2(256,256,t);var n=this;this._labelsBuilder.getLabelPosition=function(e,t,r){if(n._data){var i=n._data.getItemLayout(e),o=i[0],a=i[1],s=i[2][1];return l5.scaleAndAdd([],o,a,r+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(e,t,n){var r=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=r,this._barMesh||(this._barMesh=new HQ.Mesh({geometry:new s5,shadowDepthMaterial:new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.sm.depth.vertex"),HQ.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===e.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var i=e.coordinateSystem;if(this._doRender(e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[o]("fragment","SRGB_DECODE")}this._data=e.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(e)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,e)},_doRender:function(e,t){var n=e.getData(),r=e.get("shading"),i="color"!==r,o=this,a=this._barMesh,s="ecgl."+r;a.material&&a.material.shader.name===s||(a.material=HQ.createMaterial(s,["VERTEX_COLOR"])),HQ.setMaterialFromModel(r,a.material,e,t),a.geometry.enableNormal=i,a.geometry.resetOffset();var l=e.get("bevelSize"),u=e.get("bevelSmoothness");a.geometry.bevelSegments=u,a.geometry.bevelSize=l;var c=[],h=new Float32Array(4*n.count()),d=0,p=0,f=!1;n.each((function(e){if(n.hasValue(e)){var t=P2(n,e),r=O2(n,e);null==r&&(r=1),HQ.parseColor(t,c),c[3]*=r,h[d++]=c[0],h[d++]=c[1],h[d++]=c[2],h[d++]=c[3],c[3]>0&&(p++,c[3]<.99&&(f=!0))}})),a.geometry.setBarCount(p);var g=n.getLayout("orient"),m=this._barIndexOfData=new Int32Array(n.count());p=0;n.each((function(e){if(n.hasValue(e)){var t=n.getItemLayout(e),r=t[0],i=t[1],a=t[2],s=4*e;c[0]=h[s++],c[1]=h[s++],c[2]=h[s++],c[3]=h[s++],c[3]>0&&(o._barMesh.geometry.addBar(r,i,g,a,c,e),m[e]=p++)}else m[e]=-1})),a.geometry.dirty(),a.geometry.updateBoundingBox();var v=a.material;v.transparent=f,v.depthMask=!f,a.geometry.sortTriangles=f,this._initHandler(e,t)},_initHandler:function(e,t){var n=e.getData(),r=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=r.geometry.getDataIndexOfVertex(e.triangle[0]);a!==o&&(this._downplay(o),this._highlight(a),this._labelsBuilder.updateLabels([a]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",a),n.get("y",a),n.get("z",a,!0)]})),o=a,r.dataIndex=a}),this),r.on("mouseout",(function(e){this._downplay(o),this._labelsBuilder.updateLabels(),o=-1,r.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_highlight:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),i=r.get("color"),o=r.get("opacity");if(null==i)i=or(P2(t,e),-.4);null==o&&(o=O2(t,e));var a=HQ.parseColor(i);a[3]*=o,this._barMesh.geometry.setColor(n,a),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=P2(t,e),i=O2(t,e),o=HQ.parseColor(r);o[3]*=i,this._barMesh.geometry.setColor(n,o),this._api.getZr().refresh()}}},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=SJ(o,i),s=this;null!=a?W(Y3.normalizeToArray(a),(function(t){"highlight"===e?this._highlight(t):this._downplay(t)}),this):o.each((function(t){"highlight"===e?s._highlight(t):s._downplay(t)}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this._labelsBuilder.dispose(),this.groupGL.removeAll()}});l_((function(e){e.registerChartView(u5),e.registerSeriesModel(K3),X3(e),e.registerProcessor((function(e,t){e.eachSeriesByType("bar3d",(function(e){var t=e.getData();t.filterSelf((function(e){return t.hasValue(e)}))}))}))}));var c5=Hg.extend({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){return q3(this)},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}});function h5(e,t,n,r,i,o,a){if(0===i)return!1;var s=i,l=0;if(a>t+s&&a>r+s||a<t-s&&a<r-s||o>e+s&&o>n+s||o<e-s&&o<n-s)return!1;if(e===n)return Math.abs(o-e)<=s/2;var u=(l=(t-r)/(e-n))*o-a+(e*r-n*t)/(e-n);return u*u/(l*l+1)<=s/2*s/2}var d5=p0.vec3;HQ.Shader.import(N0);var p5=em.extend({type:"line3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._api=t},render:function(e,t,n){var r=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=r,this._line3DMesh||(this._line3DMesh=new HQ.Mesh({geometry:new m0({useNativeLine:!1,sortTriangles:!0}),material:new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var i=e.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[o]("fragment","SRGB_DECODE")}this._doRender(e,n),this._data=e.getData(),this._camera=i.viewGL.camera,this.updateCamera(),this._updateAnimation(e)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(e,t){var n=e.getData(),r=this._line3DMesh;r.geometry.resetOffset();var i=n.getLayout("points"),o=[],a=new Float32Array(i.length/3*4),s=0,l=!1;n.each((function(e){var t=P2(n,e),r=O2(n,e);null==r&&(r=1),HQ.parseColor(t,o),o[3]*=r,a[s++]=o[0],a[s++]=o[1],a[s++]=o[2],a[s++]=o[3],o[3]<.99&&(l=!0)})),r.geometry.setVertexCount(r.geometry.getPolylineVertexCount(i)),r.geometry.setTriangleCount(r.geometry.getPolylineTriangleCount(i)),r.geometry.addPolyline(i,a,wJ(e.get("lineStyle.width"),1)),r.geometry.dirty(),r.geometry.updateBoundingBox();var u=r.material;u.transparent=l,u.depthMask=!l;var c=e.getModel("debug.wireframe");c.get("show")?(r.geometry.createAttribute("barycentric","float",3),r.geometry.generateBarycentric(),r.material.set("both","WIREFRAME_TRIANGLE"),r.material.set("wireframeLineColor",HQ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)")),r.material.set("wireframeLineWidth",wJ(c.get("lineStyle.width"),1))):r.material.set("both","WIREFRAME_TRIANGLE"),this._points=i,this._initHandler(e,t)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,e)},_initHandler:function(e,t){var n=e.getData(),r=e.coordinateSystem,i=this._line3DMesh,o=-1;i.seriesIndex=e.seriesIndex,i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(e){var a=r.pointToData(e.point.array),s=n.indicesOfNearest("x",a[0])[0];s!==o&&(t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",s),n.get("y",s),n.get("z",s)]}),i.dataIndex=s),o=s}),this),i.on("mouseout",(function(e){o=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateNDCPosition:function(){var e=new aK,t=this._camera;aK.multiply(e,t.projectionMatrix,t.viewMatrix);var n=this._positionNDC,r=this._points,i=r.length/3;n&&n.length/2===i||(n=this._positionNDC=new Float32Array(2*i));for(var o=[],a=0;a<i;a++){var s=3*a,l=2*a;o[0]=r[s],o[1]=r[s+1],o[2]=r[s+2],o[3]=1,d5.transformMat4(o,o,e.array),n[l]=o[0]/o[3],n[l+1]=o[1]/o[3]}},_pick:function(e,t,n,r,i,o){var a=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,u=.5*n.viewport.width,c=.5*n.viewport.height;e=(e+1)*u,t=(t+1)*c;for(var h=1;h<a.length/2;h++){var d=(a[2*(h-1)]+1)*u,p=(a[2*(h-1)+1]+1)*c,f=(a[2*h]+1)*u,g=(a[2*h+1]+1)*c;if(h5(d,p,f,g,s,e,t))l=(d-e)*(d-e)+(p-t)*(p-t)<(f-e)*(f-e)+(g-t)*(g-t)?h-1:h}if(l>=0){var m=3*l,v=new Fq(this._points[m],this._points[m+1],this._points[m+2]);o.push({dataIndex:l,point:v,pointWorld:v.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(v)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(p5),e.registerSeriesModel(c5),e.registerLayout((function(e,t){e.eachSeriesByType("line3D",(function(e){var t=e.getData(),n=e.coordinateSystem;if(n){if("cartesian3D"!==n.type)return void("production"!==process.env.NODE_ENV&&console.error("line3D needs cartesian3D coordinateSystem"));var r=new Float32Array(3*t.count()),i=[],o=[],a=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n&&t.each(a,(function(e,t,a,s){i[0]=e,i[1]=t,i[2]=a,n.dataToPoint(i,o),r[3*s]=o[0],r[3*s+1]=o[1],r[3*s+2]=o[2]})),t.setLayout("points",r)}}))}))}));var f5=Hg.extend({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(e,t){return q3(this)},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},formatTooltip:function(e){return Z3(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,progressive:1e5,progressiveThreshold:1e5,grid3DIndex:0,globeIndex:0,symbol:"circle",symbolSize:10,blendMode:"source-over",label:{show:!1,position:"right",distance:5,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},itemStyle:{opacity:.8},emphasis:{label:{show:!0}},animationDurationUpdate:500}});function g5(e,t,n){(t=t||document.createElement("canvas")).width=e,t.height=e;var r=t.getContext("2d");return n&&n(r),t}var m5={getMarginByStyle:function(e){var t=e.minMargin||0,n=0;e.stroke&&"none"!==e.stroke&&(n=null==e.lineWidth?1:e.lineWidth);var r=e.shadowBlur||0,i=e.shadowOffsetX||0,o=e.shadowOffsetY||0,a={};return a.left=Math.max(n/2,-i+r,t),a.right=Math.max(n/2,i+r,t),a.top=Math.max(n/2,-o+r,t),a.bottom=Math.max(n/2,o+r,t),a},createSymbolSprite:function(e,t,n,r){var i=function(e,t,n,r){J(t)||(t=[t,t]);var i=m5.getMarginByStyle(n,r),o=t[0]+i.left+i.right,a=t[1]+i.top+i.bottom,s=dv(e,0,0,t[0],t[1]),l=Math.max(o,a);s.x=i.left,s.y=i.top,o>a?s.y+=(l-a)/2:s.x+=(l-o)/2;var u=s.getBoundingRect();return s.x-=u.x,s.y-=u.y,s.setStyle(n),s.update(),s.__size=l,s}(e,t,n),o=m5.getMarginByStyle(n);return{image:g5(i.__size,r,(function(e){Ov(e,i)})),margin:o}},createSDFFromCanvas:function(e,t,n,r){return g5(t,r,(function(t){var r=e.getContext("2d").getImageData(0,0,e.width,e.height);t.putImageData(function(e,t,n){var r=t.width,i=t.height,o=e.canvas.width,a=e.canvas.height,s=r/o,l=i/a;function u(e){return e<128?1:-1}function c(e,o){var a=1/0;e=Math.floor(e*s);for(var c=(o=Math.floor(o*l))*r+e,h=u(t.data[4*c]),d=Math.max(o-n,0);d<Math.min(o+n,i);d++)for(var p=Math.max(e-n,0);p<Math.min(e+n,r);p++){c=d*r+p;var f=p-e,g=d-o;if(h!==u(t.data[4*c])){var m=f*f+g*g;m<a&&(a=m)}}return h*Math.sqrt(a)}for(var h=e.createImageData(o,a),d=0;d<a;d++)for(var p=0;p<o;p++){var f=c(p,d)/n*.5+.5,g=4*(d*o+p);h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255}return h}(t,r,n),0,0)}))},createSimpleSprite:function(e,t){return g5(e,t,(function(t){var n=e/2;t.beginPath(),t.arc(n,n,60,0,2*Math.PI,!1),t.closePath();var r=t.createRadialGradient(n,n,0,n,n,n);r.addColorStop(0,"rgba(255, 255, 255, 1)"),r.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),r.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=r,t.fill()}))}},v5=p0.vec3,y5={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(e,t){var n=this.indices,r=v5.create();if(!n){n=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i<n.length;i++)n[i]=i}if(0===t){var o,a=this.attributes.position,s=(e=e.array,0);this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount));for(i=0;i<this.vertexCount;i++){a.get(i,r);var l=v5.sqrDist(r,e);isNaN(l)&&(l=1e7,s++),0===i?(o=l,l=0):l-=o,this._zList[i]=l}this._noneCount=s}if(this.vertexCount<2e4)0===t&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){var t=this._zList,n=this.indices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):D2.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._zList,n=this.indices;this._quickSort=this._quickSort||new D2,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}},_5=p0.vec4;HQ.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");var x5=HQ.Mesh.extend((function(){var e=new HQ.Geometry({dynamic:!0,attributes:{color:new HQ.Geometry.Attribute("color","float",4,"COLOR"),position:new HQ.Geometry.Attribute("position","float",3,"POSITION"),size:new HQ.Geometry.Attribute("size","float",1),prevPosition:new HQ.Geometry.Attribute("prevPosition","float",3),prevSize:new HQ.Geometry.Attribute("prevSize","float",1)}});Object.assign(e,y5);var t=new HQ.Material({shader:HQ.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});t.enableTexture("sprite"),t.define("both","VERTEX_COLOR"),t.define("both","VERTEX_SIZE");var n=new HQ.Texture2D({image:document.createElement("canvas"),flipY:!1});return t.set("sprite",n),e.pick=this._pick.bind(this),{geometry:e,material:t,mode:HQ.Mesh.POINTS,sizeScale:1}}),{_pick:function(e,t,n,r,i,o){var a=this._positionNDC;if(a)for(var s=n.viewport,l=2/s.width,u=2/s.height,c=this.geometry.vertexCount-1;c>=0;c--){var h,d=a[2*(h=this.geometry.indices?this.geometry.indices[c]:c)],p=a[2*h+1],f=this.geometry.attributes.size.get(h)/this.sizeScale/2;if(e>d-f*l&&e<d+f*l&&t>p-f*u&&t<p+f*u){var g=new HQ.Vector3,m=new HQ.Vector3;this.geometry.attributes.position.get(h,g.array),HQ.Vector3.transformMat4(m,g,this.worldTransform),o.push({vertexIndex:h,point:g,pointWorld:m,target:this,distance:m.distance(r.getWorldPosition())})}}},updateNDCPosition:function(e,t,n){var r=this._positionNDC,i=this.geometry;r&&r.length/2===i.vertexCount||(r=this._positionNDC=new Float32Array(2*i.vertexCount));for(var o=_5.create(),a=0;a<i.vertexCount;a++)i.attributes.position.get(a,o),o[3]=1,_5.transformMat4(o,o,e.array),_5.scale(o,o,1/o[3]),r[2*a]=o[0],r[2*a+1]=o[1]}});function b5(e,t){this.rootNode=new HQ.Node,this.is2D=e,this._labelsBuilder=new R2(256,256,t),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=t,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}b5.prototype={constructor:b5,highlightOnMouseover:!0,update:function(e,t,n,r,i){var o=this._prevMesh;this._prevMesh=this._mesh,this._mesh=o;var a=e.getData();if(null==r&&(r=0),null==i&&(i=a.count()),this._startDataIndex=r,this._endDataIndex=i-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new x5({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,u=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var c=this._getSymbolInfo(e,r,i),h=n.getDevicePixelRatio(),d=e.getModel("itemStyle").getItemStyle(),p=e.get("large"),f=1;c.maxSize>2?(f=this._updateSymbolSprite(e,d,c,h),s.enableTexture("sprite")):s.disableTexture("sprite"),u.position.init(i-r);var g=[];if(p){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var m=function(e){const t=e.getVisual("style");if(t)return t[e.getVisual("drawType")]}(a),v=function(e){return e.getVisual("style").opacity}(a);HQ.parseColor(m,g),g[3]*=v,s.set({color:g,u_Size:c.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),u.size.init(i-r),u.color.init(i-r),this._originalOpacity=new Float32Array(i-r);for(var y=a.getLayout("points"),_=u.position.value,x=0;x<i-r;x++){var b=3*x,w=2*x;if(this.is2D?(_[b]=y[w],_[b+1]=y[w+1],_[b+2]=-10):(_[b]=y[b],_[b+1]=y[b+1],_[b+2]=y[b+2]),!p){m=P2(a,x),v=O2(a,x);HQ.parseColor(m,g),g[3]*=v,u.color.set(x,g),g[3];var S=a.getItemVisual(x,"symbolSize");S=S instanceof Array?Math.max(S[0],S[1]):S,isNaN(S)&&(S=0),u.size.value[x]=S*f*this._sizeScale,this._originalOpacity[x]=g[3]}}this._mesh.sizeScale=f,l.updateBoundingBox(),l.dirty(),this._updateMaterial(e,d);var T=e.coordinateSystem;T&&T.viewGL&&s[T.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");p||this._updateLabelBuilder(e,r,i),this._updateHandler(e,t,n),this._updateAnimation(e),this._api=n},getPointsMesh:function(){return this._mesh},updateLabels:function(e){this._labelsBuilder.updateLabels(e)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},dispose:function(){this._labelsBuilder.dispose()},_updateSymbolSprite:function(e,t,n,r){n.maxSize=Math.min(2*n.maxSize,200);var i,o,a=[];return n.aspect>1?(a[0]=n.maxSize,a[1]=n.maxSize/n.aspect):(a[1]=n.maxSize,a[0]=n.maxSize*n.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===n.type&&(i=this._symbolSize,o=a,i&&o&&i[0]===o[0]&&i[1]===o[1])&&this._lineWidth===t.lineWidth||(m5.createSymbolSprite(n.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),m5.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=n.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/n.maxSize*r},_updateMaterial:function(e,t){var n="lighter"===e.get("blendMode")?HQ.additiveBlend:null,r=this._mesh.material;r.blend=n,r.set("lineWidth",t.lineWidth/20);var i=HQ.parseColor(t.stroke);r.set("strokeColor",i),r.transparent=!0,r.depthMask=!1,r.depthTest=!this.is2D,r.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,n){var r=e.getData(),i=this._mesh.geometry,o=i.attributes.position.value,a=(t=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(r,t,n),this._labelsBuilder.getLabelPosition=function(e,n,r){var i=3*(e-t);return[o[i],o[i+1],o[i+2]]},this._labelsBuilder.getLabelDistance=function(e,n,r){return i.attributes.size.get(e-t)/a/2+r},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,n){var r,i=e.getData(),o=this._mesh,a=this,s=-1,l=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;l&&(r=e.coordinateSystem.model),o.seriesIndex=e.seriesIndex,o.off("mousemove"),o.off("mouseout"),o.on("mousemove",(function(t){var u=t.vertexIndex+a._startDataIndex;u!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,u),this._labelsBuilder.updateLabels([u])),l&&n.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],u),i.get(e.coordDimToDataDim("y")[0],u),i.get(e.coordDimToDataDim("z")[0],u)],grid3DIndex:r.componentIndex})),o.dataIndex=u,s=u}),this),o.on("mouseout",(function(e){var t=e.vertexIndex+a._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,o.dataIndex=-1,l&&n.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:r.componentIndex})}),this)},updateLayout:function(e,t,n){var r=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,o=r.getLayout("points");if(this.is2D)for(var a=0;a<o.length/2;a++){var s=3*a,l=2*a;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=-10}else for(a=0;a<o.length;a++)i[a]=o[a];this._mesh.geometry.dirty(),n.getZr().refresh()}},updateView:function(e){if(this._mesh){var t=new aK;aK.mul(t,e.viewMatrix,this._mesh.worldTransform),aK.mul(t,e.projectionMatrix,t),this._mesh.updateNDCPosition(t,this.is2D,this._api)}},highlight:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),r=n.get("color"),i=n.get("opacity");if(null==r)r=or(P2(e,t),-.4);null==i&&(i=O2(e,t));var o=HQ.parseColor(r);o[3]*=i,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,o),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=P2(e,t),r=O2(e,t),i=HQ.parseColor(n);i[3]*=r,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,i),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(e){if(this._originalOpacity){for(var t=this._mesh.geometry,n=0;n<t.vertexCount;n++){var r=this._originalOpacity[n]*e;t.attributes.color.value[4*n+3]=r}t.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(e){this._mesh&&this._setPositionTextureToMesh(this._mesh,e),this._positionTexture=e},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(e){if(e!==this._sizeScale){if(this._mesh){var t=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",t/this._sizeScale*e);var n=this._mesh.geometry.attributes;if(n.size.value)for(var r=0;r<n.size.value.length;r++)n.size.value[r]=n.size.value[r]/this._sizeScale*e}this._sizeScale=e}},_setPositionTextureToMesh:function(e,t){t&&e.material.set("positionTexture",t),e.material[t?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(e,t,n){if(e.get("large"))return(h=wJ(e.get("symbolSize"),1))instanceof Array?(l=Math.max(h[0],h[1]),r=h[0]/h[1]):(l=h,r=1),{maxSize:h,type:e.get("symbol"),aspect:r};for(var r,i=e.getData(),o=!1,a=i.getItemVisual(0,"symbol")||"circle",s=!1,l=0,u=t;u<n;u++){var c,h=i.getItemVisual(u,"symbolSize"),d=i.getItemVisual(u,"symbol");if(h instanceof Array)c=h[0]/h[1],l=Math.max(Math.max(h[0],h[1]),l);else{if(isNaN(h))continue;c=1,l=Math.max(h,l)}"production"!==process.env.NODE_ENV&&(null!=r&&Math.abs(c-r)>.05&&(o=!0),d!==a&&(s=!0)),a=d,r=c}return"production"!==process.env.NODE_ENV&&(o&&console.warn("Different symbol width / height ratio will be ignored."),s&&console.warn("Different symbol type will be ignored.")),{maxSize:l,type:a,aspect:r}}};var w5=em.extend({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(e,t,n){if(this.groupGL.removeAll(),e.getData().count()){var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new b5(!1,n)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),i.update(e,t,n),i.updateView(r.viewGL.camera)}else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system")}},incrementalPrepareRender:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL)r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system");this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new b5(!1,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),i.update(t,n,r,e.start,e.end),i.updateView(t.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach((function(e){e.updateView(this._camera)}),this)},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=SJ(o,i),s="highlight"===e;null!=a?W(Y3.normalizeToArray(a),(function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}),this):o.each((function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}))},dispose:function(){this._pointsBuilderList.forEach((function(e){e.dispose()})),this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(w5),e.registerSeriesModel(f5),e.registerLayout({seriesType:"scatter3D",reset:function(e){var t=e.coordinateSystem;if(t){var n=t.dimensions;if(n.length<3)return void("production"!==process.env.NODE_ENV&&console.error("scatter3D needs 3D coordinateSystem"));var r=n.map((function(t){return e.coordDimToDataDim(t)[0]})),i=[],o=[];return{progress:function(e,n){for(var a=new Float32Array(3*(e.end-e.start)),s=e.start;s<e.end;s++){var l=3*(s-e.start);i[0]=n.get(r[0],s),i[1]=n.get(r[1],s),i[2]=n.get(r[2],s),t.dataToPoint(i,o),a[l]=o[0],a[l+1]=o[1],a[l+2]=o[2]}n.setLayout("points",a)}}}}})}));var S5=p0.vec3,T5=p0.vec2,M5=S5.normalize,C5=S5.cross,D5=S5.sub,A5=S5.add,I5=S5.create,E5=I5(),L5=I5(),N5=I5(),P5=I5(),O5=[],R5=[];function k5(e,t){T5.copy(O5,e[0]),T5.copy(R5,e[1]);var n=[],r=n[0]=I5(),i=n[1]=I5(),o=n[2]=I5(),a=n[3]=I5();t.dataToPoint(O5,r),t.dataToPoint(R5,a),M5(E5,r),D5(L5,a,r),M5(L5,L5),C5(N5,L5,E5),M5(N5,N5),C5(L5,E5,N5),A5(i,E5,L5),M5(i,i),M5(E5,a),D5(L5,r,a),M5(L5,L5),C5(N5,L5,E5),M5(N5,N5),C5(L5,E5,N5),A5(o,E5,L5),M5(o,o),A5(P5,r,a),M5(P5,P5);var s=S5.dot(r,P5),l=S5.dot(P5,i),u=(Math.max(S5.len(r),S5.len(a))-s)/l*2;return S5.scaleAndAdd(i,r,i,u),S5.scaleAndAdd(o,a,o,u),n}function z5(e,t){for(var n=new Float32Array(3*e.length),r=0,i=[],o=0;o<e.length;o++)t.dataToPoint(e[o],i),n[r++]=i[0],n[r++]=i[1],n[r++]=i[2];return n}function V5(e){var t=[];return e.each((function(n){var r=e.getItemModel(n),i=r.option instanceof Array?r.option:r.getShallow("coords",!0);if("production"!==process.env.NODE_ENV&&!(i instanceof Array&&i.length>0&&i[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(i)+". Lines must have 2d coords array in data item.");t.push(i)})),{coordsList:t}}function B5(e,t,n){var r=e.getData(),i=e.get("polyline"),o=V5(r);r.setLayout("lineType",i?"polyline":"cubicBezier"),r.each((function(e){var a=o.coordsList[e],s=i?z5(a,t):function(e,t,n){var r=[],i=r[0]=S5.create(),o=r[1]=S5.create(),a=r[2]=S5.create(),s=r[3]=S5.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var l=S5.dist(i,s);return S5.lerp(o,i,s,.3),S5.lerp(a,i,s,.3),S5.scaleAndAdd(o,o,n,Math.min(.1*l,10)),S5.scaleAndAdd(a,a,n,Math.min(.1*l,10)),r}(a,t,n);r.setItemLayout(e,s)}))}function F5(e,t){e.eachSeriesByType("lines3D",(function(e){var t=e.coordinateSystem;"globe"===t.type?function(e,t){var n=e.getData(),r=e.get("polyline");n.setLayout("lineType",r?"polyline":"cubicBezier");var i=V5(n);n.each((function(e){var o=i.coordsList[e],a=r?z5:k5;n.setItemLayout(e,a(o,t))}))}(e,t):"geo3D"===t.type?B5(e,t,[0,1,0]):"mapbox3D"!==t.type&&"maptalks3D"!==t.type||B5(e,t,[0,0,1])}))}var G5=Hg.extend({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){var n=new R_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"globe",globeIndex:0,geo3DIndex:0,zlevel:-10,polyline:!1,effect:{show:!1,period:4,trailWidth:4,trailLength:.2,spotIntensity:6},silent:!0,blendMode:"source-over",lineStyle:{width:1,opacity:.5}}}),H5=p0.vec3;HQ.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");var U5=HQ.Mesh.extend((function(){var e=new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.trail2.vertex"),HQ.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new m0({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}}),{updateData:function(e,t,n){var r=e.hostModel,i=this.geometry,o=r.getModel("effect"),a=o.get("trailWidth")*t.getDevicePixelRatio(),s=o.get("trailLength"),l=r.get("effect.constantSpeed"),u=1e3*r.get("effect.period"),c=null!=l;"production"!==process.env.NODE_ENV&&(this.getScene()||console.error("TrailMesh must been add to scene before updateData")),c?this.material.set("speed",l/1e3):this.material.set("period",u),this.material[c?"define":"undefine"]("vertex","CONSTANT_SPEED");var h=r.get("polyline");i.trailLength=s,this.material.set("trailLength",s),i.resetOffset(),["position","positionPrev","positionNext"].forEach((function(e){i.attributes[e].value=n.attributes[e].value}));["dist","distAll","start","offset","color"].forEach((function(e){i.attributes[e].init(i.vertexCount)})),i.indices=n.indices;var d=[],p=o.get("trailColor"),f=o.get("trailOpacity"),g=null!=p,m=null!=f;this.updateWorldTransform();var v=this.worldTransform.x.len(),y=this.worldTransform.y.len(),_=this.worldTransform.z.len(),x=0,b=0;e.each((function(t){var r=e.getItemLayout(t),o=m?f:O2(e,t),s=P2(e,t);null==o&&(o=1),(d=HQ.parseColor(g?p:s,d))[3]*=o;for(var l=h?n.getPolylineVertexCount(r):n.getCubicCurveVertexCount(r[0],r[1],r[2],r[3]),w=0,S=[],T=[],M=x;M<x+l;M++)i.attributes.position.get(M,S),S[0]*=v,S[1]*=y,S[2]*=_,M>x&&(w+=H5.dist(S,T)),i.attributes.dist.set(M,w),H5.copy(T,S);b=Math.max(b,w);var C=Math.random()*(c?w:u);for(M=x;M<x+l;M++)i.attributes.distAll.set(M,w),i.attributes.start.set(M,C),i.attributes.offset.set(M,(n.attributes.offset.get(M)>0?1:-1)*a/2),i.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",o.get("spotIntensity")),i.dirty()},setAnimationTime:function(e){this.material.set("time",e)}});HQ.Shader.import(N0);var W5=em.extend({type:"lines3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._meshLinesMaterial=new HQ.Material({shader:HQ.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new HQ.Mesh({geometry:new m0,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new U5},render:function(e,t,n){this.groupGL.add(this._linesMesh);var r=e.coordinateSystem,i=e.getData();if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._updateLines(e,t,n);var o=r.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[o]("fragment","SRGB_DECODE"),this._trailMesh.material[o]("fragment","SRGB_DECODE")}var a=this._trailMesh;if(a.stopAnimation(),e.get("effect.show")){this.groupGL.add(a),a.updateData(i,n,this._linesMesh.geometry),a.__time=a.__time||0;var s=36e5;this._curveEffectsAnimator=a.animate("",{loop:!0}).when(s,{__time:s}).during((function(){a.setAnimationTime(a.__time)})).start()}else this.groupGL.remove(a),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===e.get("blendMode")?HQ.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var e=this._curveEffectsAnimator;e&&(e.isPaused()?e.resume():e.pause())},_updateLines:function(e,t,n){var r=e.getData(),i=e.coordinateSystem,o=this._linesMesh.geometry,a=e.get("polyline");o.expandLine=!0;var s=function(e){return null!=e.radius?e.radius:null!=e.size?Math.max(e.size[0],e.size[1],e.size[2]):100}(i);o.segmentScale=s/20;var l="lineStyle.width".split("."),u=n.getDevicePixelRatio();r.each((function(e){var t=r.getItemModel(e).get(l);null==t&&(t=1),r.setItemVisual(e,"lineWidth",t)})),o.useNativeLine=!1;var c=0,h=0;r.each((function(e){var t=r.getItemLayout(e);a?(c+=o.getPolylineVertexCount(t),h+=o.getPolylineTriangleCount(t)):(c+=o.getCubicCurveVertexCount(t[0],t[1],t[2],t[3]),h+=o.getCubicCurveTriangleCount(t[0],t[1],t[2],t[3]))})),o.setVertexCount(c),o.setTriangleCount(h),o.resetOffset();var d=[];r.each((function(e){var t=r.getItemLayout(e),n=P2(r,e),i=O2(r,e),s=r.getItemVisual(e,"lineWidth")*u;null==i&&(i=1),(d=HQ.parseColor(n,d))[3]*=i,a?o.addPolyline(t,d,s):o.addCubicCurve(t[0],t[1],t[2],t[3],d,s)})),o.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function j5(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}l_((function(e){e.registerChartView(W5),e.registerSeriesModel(G5),e.registerLayout(F5),e.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},(function(){})),e.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},(function(){})),e.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},(function(){}))}));var X5=Hg.extend({type:"series.polygons3D",getRegionModel:function(e){return this.getData().getItemModel(e)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getItemModel(e),r=n.option instanceof Array?n.option:n.getShallow("coords");n.get("multiPolygon")||(r=[r]);for(var i=[],o=0;o<r.length;o++){for(var a=[],s=1;s<r[o].length;s++)a.push(j5(t,r[o][s]));i.push({exterior:j5(t,r[o][0]),interiors:a})}return i},getInitialData:function(e){var t=new R_(["value"],this);return t.hasItemOption=!1,t.initData(e.data,[],(function(e,n,r,i){if(e instanceof Array)return NaN;t.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),t},defaultOption:{show:!0,data:null,multiPolygon:!1,progressiveThreshold:1e3,progressive:1e3,zlevel:-10,label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}});R(X5.prototype,J1);var Y5=em.extend({type:"polygons3D",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL);var i=this._geo3DBuilderList[0];i||((i=new z2(n)).extrudeY="mapbox3D"!==r.type&&"maptalks3D"!==r.type,this._geo3DBuilderList[0]=i),this._updateShaderDefines(r,i),i.update(e,t,n),this._geo3DBuilderList.length=1,this.groupGL.add(i.rootNode)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(e,t,n,r){var i=this._geo3DBuilderList[this._currentStep],o=t.coordinateSystem;i||((i=new z2(r)).extrudeY="mapbox3D"!==o.type&&"maptalks3D"!==o.type,this._geo3DBuilderList[this._currentStep]=i),i.update(t,n,r,e.start,e.end),this.groupGL.add(i.rootNode),this._updateShaderDefines(o,i),this._currentStep++},_updateShaderDefines:function(e,t){var n=e.viewGL.isLinearSpace()?"define":"undefine";t.rootNode.traverse((function(t){t.material&&(t.material[n]("fragment","SRGB_DECODE"),"mapbox3D"!==e.type&&"maptalks3D"!==e.type||(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1)))}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll(),this._geo3DBuilderList.forEach((function(e){e.dispose()}))}});l_((function(e){e.registerChartView(Y5),e.registerSeriesModel(X5)}));var Z5=Hg.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return Z3(this,e)},getInitialData:function(e,t){var n=e.data;function r(e){return!(isNaN(e.min)||isNaN(e.max)||isNaN(e.step))}function i(e){var t=uo;return Math.max(t(e.min),t(e.max),t(e.step))+1}if(!n)if(e.parametric){var o=e.parametricEquation||{},a=o.u||{},s=o.v||{};["u","v"].forEach((function(e){r(o[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid parametricEquation.%s",e)})),["x","y","z"].forEach((function(e){"function"==typeof o[e]||"production"!==process.env.NODE_ENV&&console.error("parametricEquation.%s needs to be function",e)}));var l=Math.floor((a.max+a.step-a.min)/a.step),u=Math.floor((s.max+s.step-s.min)/s.step);n=new Float32Array(l*u*5);var c=i(a),h=i(s);for(S=0,T=0;T<u;T++)for(M=0;M<l;M++){var d=M*a.step+a.min,p=T*s.step+s.min,f=ao(Math.min(d,a.max),c),g=ao(Math.min(p,s.max),h);C=o.x(f,g),D=o.y(f,g),E=o.z(f,g);n[S++]=C,n[S++]=D,n[S++]=E,n[S++]=f,n[S++]=g}}else{var m=e.equation||{},v=m.x||{},y=m.y||{};if(["x","y"].forEach((function(e){r(m[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid equation.%s",e)})),"function"!=typeof m.z)return void("production"!==process.env.NODE_ENV&&console.error("equation.z needs to be function"));var _=Math.floor((v.max+v.step-v.min)/v.step),x=Math.floor((y.max+y.step-y.min)/y.step);n=new Float32Array(_*x*3);for(var b=i(v),w=i(y),S=0,T=0;T<x;T++)for(var M=0;M<_;M++){var C=M*v.step+v.min,D=T*y.step+y.min,A=ao(Math.min(C,v.max),b),I=ao(Math.min(D,y.max),w),E=m.z(A,I);n[S++]=A,n[S++]=I,n[S++]=E}}var L=["x","y","z"];return e.parametric&&L.push("u","v"),q3(this,L,n)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});R(Z5.prototype,J1);var q5=p0.vec3;function K5(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}var $5=em.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node},render:function(e,t,n){var r=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=r,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var i=e.coordinateSystem,o=e.get("shading"),a=e.getData(),s="ecgl."+o;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=HQ.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),HQ.setMaterialFromModel(o,this._surfaceMesh.material,e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var l=i.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var u=e.get("parametric"),c=e.get("dataShape");c||(c=this._getDataShape(a,u),"production"!==process.env.NODE_ENV&&e.get("data")&&console.warn("dataShape is not provided. Guess it is ",c));var h=e.getModel("wireframe"),d=h.get("lineStyle.width"),p=h.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,c,p);var f=this._surfaceMesh.material;p?(f.define("WIREFRAME_QUAD"),f.set("wireframeLineWidth",d),f.set("wireframeLineColor",HQ.parseColor(h.get("lineStyle.color")))):f.undefine("WIREFRAME_QUAD"),this._initHandler(e,n),this._updateAnimation(e)},_updateAnimation:function(e){HQ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new HQ.Mesh({geometry:new HQ.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new HQ.Material({shader:new HQ.Shader(HQ.Shader.source("ecgl.sm.depth.vertex"),HQ.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),Object.assign(e.geometry,N2),e},_initHandler:function(e,t){var n=e.getData(),r=this._surfaceMesh,i=e.coordinateSystem;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=function(e,t){for(var n=1/0,i=-1,o=[],a=0;a<e.length;a++){r.geometry.attributes.position.get(e[a],o);var s=q5.dist(t.array,o);s<n&&(n=s,i=e[a])}return i}(e.triangle,e.point);if(a>=0){var s=[];r.geometry.attributes.position.get(a,s);for(var l=i.pointToData(s),u=1/0,c=-1,h=[],d=0;d<n.count();d++){h[0]=n.get("x",d),h[1]=n.get("y",d),h[2]=n.get("z",d);var p=q5.squaredDistance(h,l);p<u&&(c=d,u=p)}c!==o&&t.dispatchAction({type:"grid3DShowAxisPointer",value:l}),o=c,r.dataIndex=c}else r.dataIndex=-1}),this),r.on("mouseout",(function(e){o=-1,r.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateSurfaceMesh:function(e,t,n,r){var i=e.geometry,o=t.getData(),a=o.getLayout("points"),s=0;o.each((function(e){o.hasValue(e)||s++}));var l=s||r,u=i.attributes.position,c=i.attributes.normal,h=i.attributes.texcoord0,d=i.attributes.barycentric,p=i.attributes.color,f=n[0],g=n[1],m="color"!==t.get("shading");if(l){var v=(f-1)*(g-1)*4;u.init(v),r&&d.init(v)}else u.value=new Float32Array(a);p.init(i.vertexCount),h.init(i.vertexCount);var y=[0,3,1,1,3,2],_=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],x=i.indices=new(i.vertexCount>65535?Uint32Array:Uint16Array)((f-1)*(g-1)*6),b=function(e,t,n){n[1]=e*g+t,n[0]=e*g+t+1,n[3]=(e+1)*g+t+1,n[2]=(e+1)*g+t},w=!1;if(l){var S=[],T=[],M=0;m?c.init(i.vertexCount):c.value=null;for(var C=[[],[],[]],D=[],A=[],I=q5.create(),E=function(e,t,n){var r=3*t;return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n},L=new Float32Array(a.length),N=new Float32Array(a.length/3*4),P=0;P<o.count();P++)if(o.hasValue(P)){var O=HQ.parseColor(P2(o,P));null!=(j=O2(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0);for(var R=0;R<4;R++)N[4*P+R]=O[R]}var k=[1e7,1e7,1e7];for(P=0;P<f-1;P++)for(var z=0;z<g-1;z++){var V=4*(P*(g-1)+z);b(P,z,S);var B=!1;for(R=0;R<4;R++)E(a,S[R],T),K5(T)&&(B=!0);for(R=0;R<4;R++)B?u.set(V+R,k):(E(a,S[R],T),u.set(V+R,T)),r&&d.set(V+R,_[R]);for(R=0;R<6;R++)x[M++]=y[R]+V;if(m&&!B)for(R=0;R<2;R++){for(var F=3*R,G=0;G<3;G++){E(a,W=S[y[F]+G],C[G])}q5.sub(D,C[0],C[1]),q5.sub(A,C[1],C[2]),q5.cross(I,D,A);for(G=0;G<3;G++){var H=3*S[y[F]+G];L[H]=L[H]+I[0],L[H+1]=L[H+1]+I[1],L[H+2]=L[H+2]+I[2]}}}if(m)for(P=0;P<L.length/3;P++)E(L,P,I),q5.normalize(I,I),L[3*P]=I[0],L[3*P+1]=I[1],L[3*P+2]=I[2];O=[];var U=[];for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){V=4*(P*(g-1)+z);b(P,z,S);for(R=0;R<4;R++){for(G=0;G<4;G++)O[G]=N[4*S[R]+G];p.set(V+R,O),m&&(E(L,S[R],I),c.set(V+R,I));var W=S[R];U[0]=W%g/(g-1),U[1]=Math.floor(W/g)/(f-1),h.set(V+R,U)}0}}else{for(U=[],P=0;P<o.count();P++){U[0]=P%g/(g-1),U[1]=Math.floor(P/g)/(f-1);var j;O=HQ.parseColor(P2(o,P));null!=(j=O2(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0),p.set(P,O),h.set(P,U)}S=[];var X=0;for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){b(P,z,S);for(R=0;R<6;R++)x[X++]=S[y[R]]}m?i.generateVertexNormals():c.value=null}e.material.get("normalMap")&&i.generateTangents(),i.updateBoundingBox(),i.dirty(),e.material.transparent=w,e.material.depthMask=!w},_getDataShape:function(e,t){for(var n=-1/0,r=0,i=0,o=0,a=!1,s=t?"u":"x",l=e.count(),u=0;u<l;u++){var c=e.get(s,u);c<n&&(o&&o!==i&&"production"!==process.env.NODE_ENV&&(a=!0),o=i,i=0,r++),n=c,i++}if(r&&1!==i||(a=!0),!a)return[r+1,i];for(var h=Math.floor(Math.sqrt(l));h>0;){if(Math.floor(l/h)===l/h)return[h,l/h];h--}return[h=Math.floor(Math.sqrt(l)),h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function J5(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}l_((function(e){e.registerChartView($5),e.registerSeriesModel(Z5),e.registerLayout((function(e,t){e.eachSeriesByType("surface",(function(e){var t=e.coordinateSystem;t&&"cartesian3D"===t.type||"production"!==process.env.NODE_ENV&&console.error("Surface chart only support cartesian3D coordinateSystem");var n=e.getData(),r=new Float32Array(3*n.count()),i=[NaN,NaN,NaN];if(t&&"cartesian3D"===t.type){var o=t.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n.each(o,(function(e,o,a,s){var l;l=n.hasValue(s)?t.dataToPoint([e,o,a]):i,r[3*s]=l[0],r[3*s+1]=l[1],r[3*s+2]=l[2]}))}n.setLayout("points",r)}))}))}));var Q5=Hg.extend({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(e){e=e||{};var t=this.get("coordinateSystem");if(null!=t&&"geo3D"!==t){if("production"!==process.env.NODE_ENV){var n=[];["left","top","width","height","boxWidth","boxDepth","boxHeight","light","viewControl","postEffect","temporalSuperSampling","environment","groundPlane"].forEach((function(t){null!=e[t]&&n.push(t)})),n.length&&console.warn("Property %s in map3D series will be ignored if coordinate system is %s",n.join(", "),t)}this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null}},getInitialData:function(e){e.data=this.getFilledRegions(e.data,e.map);var t=k_(e.data,{coordDimensions:["value"]}),n=new R_(t,this);n.initData(e.data);var r={};return n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,n},formatTooltip:function(e){return Z3(this,e)},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Wh(null,this)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getName(e);if(t.transform)return(r=t.getRegion(n))?r.geometries:[];this._geo||(this._geo=Z2.createGeo3D(this));for(var r=this._geo.getRegion(n),i=[],o=0;o<r.geometries.length;o++){var a=r.geometries[o],s=[],l=J5(t,a.exterior);if(s&&s.length)for(var u=0;u<a.interiors.length;u++)s.push(J5(t,s[u]));i.push({interiors:s,exterior:l})}return i},getFormattedLabel:function(e,t){var n=Y3.getFormattedLabel(this,e,t);return null==n&&(n=this.getData().getName(e)),n},defaultOption:{coordinateSystem:"geo3D",data:null}});R(Q5.prototype,Q1),R(Q5.prototype,i0),R(Q5.prototype,o0),R(Q5.prototype,a0),R(Q5.prototype,J1);var e4=em.extend({type:"map3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new z2(t),this.groupGL=new HQ.Node},render:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),r.viewGL.add(this.groupGL),"geo3D"===r.type){this._sceneHelper||(this._sceneHelper=new _0,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var i=this._control;i||(i=this._control=new h0({zr:n.getZr()}),this._control.init());var o=e.getModel("viewControl");i.setViewGL(r.viewGL),i.setFromViewControlModel(o,0),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"map3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),from:this.uid,map3DId:e.id})})),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),e.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")}))}},afterRender:function(e,t,n,r){var i=r.renderer,o=e.coordinateSystem;o&&"geo3D"===o.type&&(this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n))},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._geo3DBuilder.dispose()}});l_((function(e){q2(e),e.registerChartView(e4),e.registerSeriesModel(Q5),e.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"series",subType:"map3D",query:e},(function(t){t.setView(e)}))}))}));var t4=Hg.extend({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(){return eb(this)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,progressive:1e5,progressiveThreshold:1e5,large:!1,symbol:"circle",symbolSize:10,zoomScale:0,blendMode:"source-over",itemStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}});function n4(e){this.viewGL=e}n4.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(e,t)},n4.prototype.updateTransform=function(e,t){var n=e.coordinateSystem;n.getRoamTransform&&(!function(e,t){var n=t[0],r=t[2],i=t[4],o=t[1],a=t[3],s=t[5],l=n*a-o*r;l&&(l=1/l,e[0]=a*l,e[1]=-o*l,e[2]=-r*l,e[3]=n*l,e[4]=(r*s-a*i)*l,e[5]=(o*i-n*s)*l)}(this._viewTransform,n.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},n4.prototype.dataToPoint=function(e,t,n){n=e.dataToPoint(t,null,n);var r=this._viewTransform;r&&QJ(n,n,r)},n4.prototype.removeTransformInPoint=function(e){return this._viewTransform&&QJ(e,e,this._viewTransform),e},n4.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},n4.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},n4.prototype._updateCamera=function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.top=0,r.bottom=t,r.right=e,r.near=0,r.far=100};var r4=em.extend({type:"scatterGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new n4(this.viewGL)},render:function(e,t,n){if(this.groupGL.removeAll(),this._glViewHelper.reset(e,n),e.getData().count()){var r=this._pointsBuilderList[0];r||(r=this._pointsBuilderList[0]=new b5(!0,n)),this._pointsBuilderList.length=1,this.groupGL.add(r.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),r.update(e,t,n),this.viewGL.setPostEffect(e.getModel("postEffect"),n)}},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new b5(!0,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.setSizeScale(this._sizeScale),i.update(t,n,r,e.start,e.end),r.getZr().refresh(),this._currentStep++}},updateTransform:function(e,t,n){if(e.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(e,n);var r=this._glViewHelper.getZoom(),i=Math.max((e.get("zoomScale")||0)*(r-1)+1,0);this._sizeScale=i,this._pointsBuilderList.forEach((function(e){e.setSizeScale(i)}))}},_removeTransformInPoints:function(e){if(e)for(var t=[],n=0;n<e.length;n+=2)t[0]=e[n],t[1]=e[n+1],this._glViewHelper.removeTransformInPoint(t),e[n]=t[0],e[n+1]=t[1]},dispose:function(){this.groupGL.removeAll(),this._pointsBuilderList.forEach((function(e){e.dispose()}))},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(r4),e.registerSeriesModel(t4),e.registerLayout({seriesType:"scatterGL",reset:function(e){var t,n=e.coordinateSystem,r=e.getData();if(n){var i=n.dimensions.map((function(e){return r.mapDimension(e)})).slice(0,2),o=[];1===i.length?t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),o=e.start;o<e.end;o++){var a=2*(o-e.start),s=r.get(i[0],o),l=n.dataToPoint(s);t[a]=l[0],t[a+1]=l[1]}r.setLayout("points",t)}:2===i.length&&(t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),a=e.start;a<e.end;a++){var s=2*(a-e.start),l=r.get(i[0],a),u=r.get(i[1],a);o[0]=l,o[1]=u,o=n.dataToPoint(o),t[s]=o[0],t[s+1]=o[1]}r.setLayout("points",t)})}return{progress:t}}})}));var i4=Hg.extend({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(e){i4.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(e){i4.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(e,t,n,r){var i=Y3.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},getInitialData:function(e,t){var n=e.edges||e.links||[],r=e.data||e.nodes||[],i=this;if(r&&n)return function(e,t,n,r,i){for(var o=new kE(r),a=0;a<e.length;a++)o.addNode(wJ(e[a].id,e[a].name,a),a);var s,l=[],u=[],c=0;for(a=0;a<t.length;a++){var h=t[a],d=h.source,p=h.target;o.addEdge(d,p,c)&&(u.push(h),l.push(wJ(h.id,d+" > "+p)),c++)}var f=k_(e,{coordDimensions:["value"]});(s=new R_(f,n)).initData(e);var g=new R_(["value"],n);return g.initData(u,l),i&&i(s,g),TA({mainData:s,struct:o,structAttr:"graph",datas:{node:s,edge:g},datasAttr:{node:"data",edge:"edgeData"}}),o.update(),o}(r,n,this,!0,(function(e,n){e.wrapMethod("getItemModel",(function(e){const t=i._categoriesModels[e.getShallow("category")];return t&&(t.parentModel=e.parentModel,e.parentModel=t),e}));const r=t.getModel([]).getModel;function o(e,t){const n=r.call(this,e,t);return n.resolveParentPath=a,n}function a(e){if(e&&("label"===e[0]||"label"===e[1])){const t=e.slice();return"label"===e[0]?t[0]="edgeLabel":"label"===e[1]&&(t[1]="edgeLabel"),t}return e}n.wrapMethod("getItemModel",(function(e){return e.resolveParentPath=a,e.getModel=o,e}))})).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(e,t,n){if("edge"===n){var r=this.getData(),i=this.getDataParams(e,n),o=r.graph.getEdgeByIndex(e),a=r.getName(o.node1.dataIndex),s=r.getName(o.node2.dataIndex),l=[];return null!=a&&l.push(a),null!=s&&l.push(s),l=dt(l.join(" > ")),i.value&&(l+=" : "+dt(i.value)),l}return i4.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map((function(e){return null!=e.value?e:Object.assign({value:0},e)})),t=new R_(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray((function(e){return t.getItemModel(e,!0)}))},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t<e.length/2;t++){var n=e[2*t],r=e[2*t+1],i=this.getData().getRawDataItem(t);i.x=n,i.y=r}},isAnimationEnabled:function(){return i4.superCall(this,"isAnimationEnabled")&&!("force"===this.get("layout")&&this.get("force.layoutAnimation"))},defaultOption:{zlevel:10,z:2,legendHoverLink:!0,layout:"forceAtlas2",forceAtlas2:{initLayout:null,GPU:!0,steps:1,maxSteps:1e3,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,edgeWeightInfluence:1,edgeWeight:[1,4],nodeWeight:[1,4],preventOverlap:!1,gravityCenter:null},focusNodeAdjacency:!0,focusNodeAdjacencyOn:"mouseover",left:"center",top:"center",symbol:"circle",symbolSize:5,roam:!1,center:null,zoom:1,label:{show:!1,formatter:"{b}",position:"right",distance:5,textStyle:{fontSize:14}},itemStyle:{},lineStyle:{color:"#aaa",width:1,opacity:.5},emphasis:{label:{show:!0}},animation:!1}}),o4=p0.vec2,a4=[[0,0],[1,1]],s4=XK.extend((function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new XK.Attribute("position","float",2,"POSITION"),normal:new XK.Attribute("normal","float",2),offset:new XK.Attribute("offset","float",1),color:new XK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(o4.dist(e,t)+o4.dist(n,t)+o4.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(a4)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(a4)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=t[0],u=t[1],c=n[0],h=n[1],d=r[0],p=r[1],f=this._getCubicCurveApproxStep(e,t,n,r),g=f*f,m=g*f,v=3*f,y=3*g,_=6*g,x=6*m,b=a-2*l+c,w=s-2*u+h,S=3*(l-c)-a+d,T=3*(u-h)-s+p,M=a,C=s,D=(l-a)*v+b*y+S*m,A=(u-s)*v+w*y+T*m,I=b*_+S*x,E=w*_+T*x,L=S*x,N=T*x,P=0,O=0,R=Math.ceil(1/f),k=new Float32Array(3*(R+1)),z=(k=[],0);for(O=0;O<R+1;O++)k[z++]=M,k[z++]=C,M+=D,C+=A,D+=I,A+=E,I+=L,E+=N,(P+=f)>1&&(M=D>0?Math.min(M,d):Math.max(M,d),C=A>0?Math.min(C,p):Math.max(C,p));this.addPolyline(k,i,o)},addLine:function(e,t,n,r){this.addPolyline([e,t],n,r)},addPolyline:function(){var e=o4.create(),t=o4.create(),n=o4.create(),r=o4.create(),i=[],o=[],a=[];return function(s,l,u,c,h){if(s.length){var d="number"!=typeof s[0];if(null==h&&(h=d?s.length:s.length/2),!(h<2)){null==c&&(c=0),null==u&&(u=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,f=d?"number"!=typeof l[0]:l.length/4===h,g=this.attributes.position,m=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,_=this.indices,x=this._vertexOffset,b=0;b<h;b++){if(d)i=s[b+c],p=f?l[b+c]:l;else{var w=2*b+c;if((i=i||[])[0]=s[w],i[1]=s[w+1],f){var S=4*b+c;(p=p||[])[0]=l[S],p[1]=l[S+1],p[2]=l[S+2],p[3]=l[S+3]}else p=l}if(this.useNativeLine)b>1&&(g.copy(x,x-1),m.copy(x,x-1),x++);else{var T;if(b<h-1){if(d)o4.copy(o,s[b+1]);else{w=2*(b+1)+c;(o=o||[])[0]=s[w],o[1]=s[w+1]}if(b>0){o4.sub(e,i,a),o4.sub(t,o,i),o4.normalize(e,e),o4.normalize(t,t),o4.add(r,e,t),o4.normalize(r,r);var M=u/2*Math.min(1/o4.dot(e,r),2);n[0]=-r[1],n[1]=r[0],T=M}else o4.sub(e,o,i),o4.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2}else o4.sub(e,i,a),o4.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2;y.set(x,n),y.set(x+1,n),v.set(x,T),v.set(x+1,-T),o4.copy(a,i),g.set(x,i),g.set(x+1,i),m.set(x,p),m.set(x+1,p),x+=2}if(this.useNativeLine)m.set(x,p),g.set(x,i),x++;else if(b>0){var C=3*this._faceOffset;(_=this.indices)[C]=x-4,_[C+1]=x-3,_[C+2]=x-2,_[C+3]=x-3,_[C+4]=x-1,_[C+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")}});V(s4.prototype,d0);HQ.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");var l4={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function u4(e){var t={type:HQ.Texture.FLOAT,minFilter:HQ.Texture.NEAREST,magFilter:HQ.Texture.NEAREST};this._positionSourceTex=new HQ.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new HQ.Texture2D(t),this._positionPrevTex=new HQ.Texture2D(t),this._forceTex=new HQ.Texture2D(t),this._forcePrevTex=new HQ.Texture2D(t),this._weightedSumTex=new HQ.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new HQ.Texture2D(t),this._globalSpeedPrevTex=new HQ.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new pJ({fragment:HQ.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new pJ({fragment:HQ.Shader.source("clay.compositor.output")});var n=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new HQ.Mesh({geometry:new HQ.Geometry({attributes:{node1:new HQ.Geometry.Attribute("node1","float",2),node2:new HQ.Geometry.Attribute("node2","float",2),weight:new HQ.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new HQ.Material({transparent:!0,shader:HQ.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:n,depthMask:!1,depthText:!1}),mode:HQ.Mesh.POINTS}),this._weightedSumMesh=new HQ.Mesh({geometry:new HQ.Geometry({attributes:{node:new HQ.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new HQ.Material({transparent:!0,shader:HQ.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:n,depthMask:!1,depthText:!1}),mode:HQ.Mesh.POINTS}),this._framebuffer=new G$({depthBuffer:!1}),this._dummyCamera=new HQ.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}u4.prototype.updateOption=function(e){for(var t in l4)this[t]=l4[t];var n=this._nodes.length;if(this.jitterTolerence=n>5e4?10:n>5e3?1:.1,this.scaling=n>100?2:10,e)for(var t in l4)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var r=this._positionSourceTex.pixels,i=0;i<this._nodes.length;i++)r[4*i+2]=(this._nodes[i].degree||0)+1},u4.prototype._updateGravityCenter=function(e){var t=this._nodes,n=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var r=[1/0,1/0],i=[-1/0,-1/0],o=0;o<t.length;o++)r[0]=Math.min(t[o].x,r[0]),r[1]=Math.min(t[o].y,r[1]),i[0]=Math.max(t[o].x,i[0]),i[1]=Math.max(t[o].y,i[1]);this._gravityCenter=[.5*(r[0]+i[0]),.5*(r[1]+i[1])]}for(o=0;o<n.length;o++){var a=n[o].node1,s=n[o].node2;t[a].degree=(t[a].degree||0)+1,t[s].degree=(t[s].degree||0)+1}},u4.prototype.initData=function(e,t){this._nodes=e,this._edges=t,this._updateGravityCenter();var n=Math.ceil(Math.sqrt(e.length)),r=n,i=new Float32Array(n*r*4);this._resize(n,r);for(var o=0,a=0;a<e.length;a++){var s=e[a];i[o++]=s.x||0,i[o++]=s.y||0,i[o++]=s.mass||1,i[o++]=s.size||1}this._positionSourceTex.pixels=i;var l=this._edgeForceMesh.geometry,u=t.length;l.attributes.node1.init(2*u),l.attributes.node2.init(2*u),l.attributes.weight.init(2*u);var c=[];for(a=0;a<t.length;a++){var h=l.attributes,d=t[a].weight;null==d&&(d=1),h.node1.set(a,this.getNodeUV(t[a].node1,c)),h.node2.set(a,this.getNodeUV(t[a].node2,c)),h.weight.set(a,d),h.node1.set(a+u,this.getNodeUV(t[a].node2,c)),h.node2.set(a+u,this.getNodeUV(t[a].node1,c)),h.weight.set(a+u,d)}var p=this._weightedSumMesh.geometry;p.attributes.node.init(e.length);for(a=0;a<e.length;a++)p.attributes.node.set(a,this.getNodeUV(a,c));l.dirty(),p.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",e.length),this._nodeRepulsionPass.material.setUniform("textureSize",[n,r]),this._inited=!1,this._frame=0},u4.prototype.getNodes=function(){return this._nodes},u4.prototype.getEdges=function(){return this._edges},u4.prototype.step=function(e){this._inited||(this._initFromSource(e),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(e);var t=this._nodeRepulsionPass;t.setUniform("strongGravityMode",this.strongGravityMode),t.setUniform("gravity",this.gravity),t.setUniform("gravityCenter",this._gravityCenter),t.setUniform("scaling",this.scaling),t.setUniform("preventOverlap",this.preventOverlap),t.setUniform("positionTex",this._positionPrevTex),t.render(e);var n=this._edgeForceMesh;n.material.set("linLogMode",this.linLogMode),n.material.set("edgeWeightInfluence",this.edgeWeightInfluence),n.material.set("preventOverlap",this.preventOverlap),n.material.set("positionTex",this._positionPrevTex),e.gl.enable(e.gl.BLEND),e.renderPass([n],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT),e.gl.enable(e.gl.BLEND);var r=this._weightedSumMesh;r.material.set("positionTex",this._positionPrevTex),r.material.set("forceTex",this._forceTex),r.material.set("forcePrevTex",this._forcePrevTex),e.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var i=this._globalSpeedPass;i.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),i.setUniform("weightedSumTex",this._weightedSumTex),i.setUniform("jitterTolerence",this.jitterTolerence),e.gl.disable(e.gl.BLEND),i.render(e);var o=this._positionPass;this._framebuffer.attach(this._positionTex),o.setUniform("globalSpeedTex",this._globalSpeedTex),o.setUniform("positionTex",this._positionPrevTex),o.setUniform("forceTex",this._forceTex),o.setUniform("forcePrevTex",this._forcePrevTex),o.render(e),this._framebuffer.unbind(e),this._swapTexture()},u4.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1);for(var r=0;r<t;r++)this.step(e);n&&n()},u4.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},u4.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1)||0,t},u4.prototype.getNodePosition=function(e,t){var n=this._positionArr,r=this._positionTex.width,i=this._positionTex.height,o=r*i;n&&n.length===4*o||(n=this._positionArr=new Float32Array(4*o)),this._framebuffer.bind(e),this._framebuffer.attach(this._positionPrevTex),e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,n),this._framebuffer.unbind(e),t||(t=new Float32Array(2*this._nodes.length));for(var a=0;a<this._nodes.length;a++)t[2*a]=n[4*a],t[2*a+1]=n[4*a+1];return t},u4.prototype.getTextureData=function(e,t){var n=this["_"+t+"Tex"],r=n.width,i=n.height;this._framebuffer.bind(e),this._framebuffer.attach(n);var o=new Float32Array(r*i*4);return e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,o),this._framebuffer.unbind(e),o},u4.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},u4.prototype.isFinished=function(e){return this._frame>e},u4.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},u4.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},u4.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach((function(n){this[n].width=e,this[n].height=t,this[n].dirty()}),this)},u4.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)};var c4=function(){var e=function(){return new Float32Array(2)},t=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},n=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},r=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},i=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},a=function(e,t){return e[0]=t[0],e[1]=t[1],e},s=function(e,t,n){return e[0]=t,e[1]=n,e};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var u=l.prototype;function c(){this.position=new Float32Array(2),this.force=e(),this.forcePrev=e(),this.mass=1,this.inDegree=0,this.outDegree=0}function h(e,t){this.source=e,this.target=t,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=e(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}u.beforeUpdate=function(){for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},u.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].afterUpdate()},u.addNode=function(e){if(0===this.nSubRegions){if(null==this.node)return void(this.node=e);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(e),this._updateCenterOfMass(e)},u.findSubRegion=function(e,t){for(var n=0;n<this.nSubRegions;n++){var r=this.subRegions[n];if(r.contain(e,t))return r}},u.contain=function(e,t){return this.bbox[0]<=e&&this.bbox[2]>=e&&this.bbox[1]<=t&&this.bbox[3]>=t},u.setBBox=function(e,t,n,r){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r,this.size=(n-e+r-t)/2},u._newSubRegion=function(){var e=this.subRegions[this.nSubRegions];return e||(e=new l,this.subRegions[this.nSubRegions]=e),this.nSubRegions++,e},u._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),n=this.bbox;if(!t){var r=(n[0]+n[2])/2,i=(n[1]+n[3])/2,o=(n[2]-n[0])/2,a=(n[3]-n[1])/2,s=e.position[0]>=r?1:0,l=e.position[1]>=i?1:0;(t=this._newSubRegion()).setBBox(s*o+n[0],l*a+n[1],(s+1)*o+n[0],(l+1)*a+n[1])}t.addNode(e)},u._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,n=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,n+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=n/this.mass};var p=d.prototype;p.initNodes=function(e,t,n){var r=t.length;this.nodes.length=0;for(var i=void 0!==n,o=0;o<r;o++){var a=new c;a.position[0]=e[2*o],a.position[1]=e[2*o+1],a.mass=t[o],i&&(a.size=n[o]),this.nodes.push(a)}this._massArr=t,this._swingingArr=new Float32Array(r),i&&(this._sizeArr=n)},p.initEdges=function(e,t){var n=e.length/2;this.edges.length=0;for(var r=0;r<n;r++){var i=e[2*r],o=e[2*r+1],a=this.nodes[i],s=this.nodes[o];if(!a||!s)return void console.error("Node not exists, try initNodes before initEdges");a.outDegree++,s.inDegree++;var l=new h(a,s);t&&(l.weight=t[r]),this.edges.push(l)}},p.updateSettings=function(){if(this.repulsionByDegree)for(var e=0;e<this.nodes.length;e++){(t=this.nodes[e]).mass=t.inDegree+t.outDegree+1}else for(e=0;e<this.nodes.length;e++){var t;(t=this.nodes[e]).mass=this._massArr[e]}},p.update=function(){var o=this.nodes.length;if(this.updateSettings(),this.updateBBox(),this.barnesHutOptimize){this.rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this.rootRegion.beforeUpdate();for(var l=0;l<o;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<o;l++){var u=this.nodes[l];a(u.forcePrev,u.force),s(u.force,0,0)}for(l=0;l<o;l++){var c=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,c);else for(var h=l+1;h<o;h++){var d=this.nodes[h];this.applyNodeToNodeRepulsion(c,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(c):this.applyNodeGravity(c))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var p=0,f=0,g=e();for(l=0;l<o;l++){u=this.nodes[l];p+=(v=t(u.force,u.forcePrev))*u.mass,i(g,u.force,u.forcePrev),f+=.5*n(g)*u.mass,this._swingingArr[l]=v}var m=this.jitterTolerence*this.jitterTolerence*f/p;this._globalSpeed>0&&(m=Math.min(m/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=m;for(l=0;l<o;l++){u=this.nodes[l];var v=this._swingingArr[l],y=.1*m/(1+m*Math.sqrt(v)),_=n(u.force);_>0&&(y=Math.min(_*y,10)/_,r(u.position,u.position,u.force,y))}},p.applyRegionToNodeRepulsion=function(){var t=e();return function(e,n){if(e.node)this.applyNodeToNodeRepulsion(e.node,n,!0);else{o(t,n.position,e.centerOfMass);var i=t[0]*t[0]+t[1]*t[1];if(i>this.barnesHutTheta*e.size*e.size){var a=this.scaling*n.mass*e.mass/i;r(n.force,n.force,t,a)}else for(var s=0;s<e.nSubRegions;s++)this.applyRegionToNodeRepulsion(e.subRegions[s],n)}}}(),p.applyNodeToNodeRepulsion=function(){var t=e();return function(e,n,i){if(e!=n){o(t,e.position,n.position);var a=t[0]*t[0]+t[1]*t[1];if(0!==a){var s;if(this.preventOverlap){var l=Math.sqrt(a);if((l=l-e.size-n.size)>0)s=this.scaling*e.mass*n.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*e.mass*n.mass}}else s=this.scaling*e.mass*n.mass/a;r(e.force,e.force,t,s),r(n.force,n.force,t,-s)}}}}(),p.applyEdgeAttraction=function(){var t=e();return function(e){var i=e.source,a=e.target;o(t,i.position,a.position);var s,l,u=n(t);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence),this.preventOverlap&&(u=u-i.size-a.size)<=0||(l=this.linLogMode?-s*Math.log(u+1)/(u+1):-s,r(i.force,i.force,t,l),r(a.force,a.force,t,-l))}}(),p.applyNodeGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position);var i=n(t);r(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),p.applyNodeStrongGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position),r(e.force,e.force,t,this.gravity*e.mass)}}(),p.updateBBox=function(){for(var e=1/0,t=1/0,n=-1/0,r=-1/0,i=0;i<this.nodes.length;i++){var o=this.nodes[i].position;e=Math.min(e,o[0]),t=Math.min(t,o[1]),n=Math.max(n,o[0]),r=Math.max(r,o[1])}this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r},p.getGlobalSpeed=function(){return this._globalSpeed};var f=null;self.onmessage=function(e){switch(e.data.cmd){case"init":(f=new d).initNodes(e.data.nodesPosition,e.data.nodesMass,e.data.nodesSize),f.initEdges(e.data.edges,e.data.edgesWeight);break;case"updateConfig":if(f)for(var t in e.data.config)f[t]=e.data.config[t];break;case"update":var n=e.data.steps;if(f){for(var r=0;r<n;r++)f.update();var i=f.nodes.length,o=new Float32Array(2*i);for(r=0;r<i;r++){var a=f.nodes[r];o[2*r]=a.position[0],o[2*r+1]=a.position[1]}self.postMessage({buffer:o.buffer,globalSpeed:f.getGlobalSpeed()},[o.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:f.getGlobalSpeed()},[s.buffer])}}}}.toString();c4=c4.slice(c4.indexOf("{")+1,c4.lastIndexOf("}"));var h4={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},d4=function(e){for(var t in h4)this[t]=h4[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new RK({type:EK.FLOAT,flipY:!1,minFilter:EK.NEAREST,magFilter:EK.NEAREST})};d4.prototype.initData=function(e,t){var n=new Blob([c4]),r=window.URL.createObjectURL(n);this._worker=new Worker(r),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,o=t.length,a=new Float32Array(2*i),s=new Float32Array(i),l=new Float32Array(i),u=new Float32Array(2*o),c=new Float32Array(o),h=0;h<e.length;h++){var d=e[h];a[2*h]=d.x,a[2*h+1]=d.y,s[h]=null==d.mass?1:d.mass,l[h]=null==d.size?1:d.size}for(h=0;h<t.length;h++){var p=t[h],f=p.node1,g=p.node2;u[2*h]=f,u[2*h+1]=g,c[h]=null==p.weight?1:p.weight}var m=Math.ceil(Math.sqrt(e.length)),v=m,y=new Float32Array(m*v*4),_=this._positionTex;_.width=m,_.height=v,_.pixels=y,this._worker.postMessage({cmd:"init",nodesPosition:a,nodesMass:s,nodesSize:l,edges:u,edgesWeight:c}),this._globalSpeed=1/0},d4.prototype.updateOption=function(e){var t={};for(var n in h4)t[n]=h4[n];var r=this._nodes,i=this._edges,o=r.length;if(t.jitterTolerence=o>5e4?10:o>5e3?1:.1,t.scaling=o>100?2:10,t.barnesHutOptimize=o>1e3,e)for(var n in h4)null!=e[n]&&(t[n]=e[n]);if(!t.gravityCenter){for(var a=[1/0,1/0],s=[-1/0,-1/0],l=0;l<r.length;l++)a[0]=Math.min(r[l].x,a[0]),a[1]=Math.min(r[l].y,a[1]),s[0]=Math.max(r[l].x,s[0]),s[1]=Math.max(r[l].y,s[1]);t.gravityCenter=[.5*(a[0]+s[0]),.5*(a[1]+s[1])]}for(l=0;l<i.length;l++){var u=i[l].node1,c=i[l].node2;r[u].degree=(r[u].degree||0)+1,r[c].degree=(r[c].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:t})},d4.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1),this._frame+=t,this._onupdate=n,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(t)})},d4.prototype._$onupdate=function(e){if(!this._disposed){var t=new Float32Array(e.data.buffer);this._globalSpeed=e.data.globalSpeed,this._positionArr=t,this._updateTexture(t),this._onupdate&&this._onupdate()}},d4.prototype.getNodePositionTexture=function(){return this._positionTex},d4.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1),t},d4.prototype.getNodes=function(){return this._nodes},d4.prototype.getEdges=function(){return this._edges},d4.prototype.isFinished=function(e){return this._frame>e},d4.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var n=0;n<this._positionArr.length;n++)t[n]=this._positionArr[n];return t},d4.prototype._updateTexture=function(e){for(var t=this._positionTex.pixels,n=0,r=0;r<e.length;)t[n++]=e[r++],t[n++]=e[r++],t[n++]=1,t[n++]=1;this._positionTex.dirty()},d4.prototype.dispose=function(e){this._disposed=!0,this._worker=null};var p4=wY.extend((function(){return{zr:null,viewGL:null,minZoom:.2,maxZoom:5,_needsUpdate:!1,_dx:0,_dy:0,_zoom:1}}),(function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._update=this._update.bind(this)}),{init:function(){var e=this.zr;e.on("mousedown",this._mouseDownHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("globalout",this._mouseUpHandler),e.animation.on("frame",this._update)},setTarget:function(e){this._target=e},setZoom:function(e){this._zoom=Math.max(Math.min(e,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(e){this._dx=e[0],this._dy=e[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var e=this._target,t=this._zoom;e.position.x=this._dx,e.position.y=this._dy,e.scale.set(t,t,t),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(e){if(!e.target){var t=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(t,n)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var r=this._convertPos(t,n);this._x=r.x,this._y=r.y}}},_convertPos:function(e,t){var n=this.viewGL.camera,r=this.viewGL.viewport;return{x:(e-r.x)/r.width*(n.right-n.left)+n.left,y:(t-r.y)/r.height*(n.bottom-n.top)+n.top}},_mouseMoveHandler:function(e){var t=this._convertPos(e.offsetX,e.offsetY);this._dx+=t.x-this._x,this._dy+=t.y-this._y,this._x=t.x,this._y=t.y,this._needsUpdate=!0},_mouseUpHandler:function(e){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(e){var t=(e=e.event).wheelDelta||-e.detail;if(0!==t){var n=e.offsetX,r=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(n,r)){var i=t>0?1.1:.9,o=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=o/this._zoom;var a=this._convertPos(n,r),s=(a.x-this._dx)*(i-1),l=(a.y-this._dy)*(i-1);this._dx-=s,this._dy-=l,this._zoom=o,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}),f4=p0.vec2;HQ.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");var g4=1,m4=em.extend({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new b5(!0,t),this._forceEdgesMesh=new HQ.Mesh({material:new HQ.Material({shader:HQ.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new HQ.Geometry({attributes:{node:new HQ.Geometry.Attribute("node","float",2),color:new HQ.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:HQ.Mesh.LINES}),this._edgesMesh=new HQ.Mesh({material:new HQ.Material({shader:HQ.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new s4({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new p4({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,n){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=n,this._initLayout(e,t,n),this._pointsBuilder.update(e,t,n),this._forceLayoutInstance instanceof u4||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,n),this._control.off("update"),this._control.on("update",(function(){n.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)}),this),this._control.setZoom(wJ(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var r=this._pointsBuilder.getPointsMesh();if(r.off("mousemove",this._mousemoveHandler),r.off("mouseout",this._mouseOutHandler,this),n.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?n.getZr().on("click",this._clickHandler):"mouseover"===i?(r.on("mousemove",this._mousemoveHandler,this),r.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1):"production"!==process.env.NODE_ENV&&console.warn("Unkown focusNodeAdjacencyOn value s"+i)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var n=this._forceEdgesMesh.geometry,r=t.getEdgeData(),i=0,o=this._forceLayoutInstance,a=2*r.count();n.attributes.node.init(a),n.attributes.color.init(a),r.each((function(t){var a=e[t];n.attributes.node.set(i,o.getNodeUV(a.node1)),n.attributes.node.set(i+1,o.getNodeUV(a.node2));var s=P2(r,a.dataIndex),l=HQ.parseColor(s);l[3]*=wJ(O2(r,a.dataIndex),1),n.attributes.color.set(i,l),n.attributes.color.set(i+1,l),i+=2})),n.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,n=(e=this._model.getEdgeData(),this._model.getData().getLayout("points"));t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var r=[],i=[],o=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each((function(a){var s=e.graph.getEdgeByIndex(a),l=2*s.node1.dataIndex,u=2*s.node2.dataIndex;r[0]=n[l],r[1]=n[l+1],i[0]=n[u],i[1]=n[u+1];var c=P2(e,s.dataIndex),h=HQ.parseColor(c);h[3]*=wJ(O2(e,s.dataIndex),1);var d=e.getItemModel(s.dataIndex),p=wJ(d.get(o),1)*this._api.getDevicePixelRatio();t.addLine(r,i,h,p);for(var f=0;f<4;f++)this._originalEdgeColors[4*s.dataIndex+f]=h[f];this._edgeIndicesMap[s.dataIndex]=a}),this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),n=[],r=0;r<e.count();r++)this._forceLayoutInstance.getNodeUV(r,n),t.geometry.attributes.position.set(r,n);t.geometry.dirty("position")},_initLayout:function(e,t,n){var r=e.get("layout"),i=e.getGraph(),o=Zd(e.getBoxLayoutParams(),{width:n.getWidth(),height:n.getHeight()});"force"===r&&("production"!==process.env.NODE_ENV&&console.warn("Currently only forceAtlas2 layout supported."),r="forceAtlas2"),this.stopLayout(e,t,n,{beforeLayout:!0});var a=e.getData(),s=e.getData();if("forceAtlas2"===r){var l=e.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],h=[],d=a.getDataExtent("value"),p=s.getDataExtent("value"),f=wJ(l.get("edgeWeight"),1),g=wJ(l.get("nodeWeight"),1);"number"==typeof f&&(f=[f,f]),"number"==typeof g&&(g=[g,g]);var m=0,v={},y=new Float32Array(2*a.count());if(i.eachNode((function(e){var t,n,r=e.dataIndex,i=a.get("value",r);if(a.hasItemOption){var s=a.getItemModel(r);t=s.get("x"),n=s.get("y")}null==t&&(t=o.x+Math.random()*o.width,n=o.y+Math.random()*o.height),y[2*m]=t,y[2*m+1]=n,v[e.id]=m++;var l=io(i,d,g);isNaN(l)&&(l=isNaN(g[0])?1:g[0]),c.push({x:t,y:n,mass:l,size:a.getItemVisual(r,"symbolSize")})})),a.setLayout("points",y),i.eachEdge((function(e){var t=e.dataIndex,n=io(a.get("value",t),p,f);isNaN(n)&&(n=isNaN(f[0])?1:f[0]),h.push({node1:v[e.node1.id],node2:v[e.node2.id],weight:n,dataIndex:t})})),!u){var _=l.get("GPU");this._forceLayoutInstance&&((!_||this._forceLayoutInstance instanceof u4)&&(_||this._forceLayoutInstance instanceof d4)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=_?new u4:new d4}u.initData(c,h),u.updateOption(l.option),this._updateForceEdgesGeometry(u.getEdges(),e),this._updatePositionTexture(),n.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*a.count()),m=0;i.eachNode((function(e){var t,n,r=e.dataIndex;if(a.hasItemOption){var i=a.getItemModel(r);t=i.get("x"),n=i.get("y")}y[m++]=t,y[m++]=n})),a.setLayout("points",y),this._updateAfterLayout(e,t,n)}},_updatePositionTexture:function(){var e=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(e),this._forceEdgesMesh.material.set("positionTex",e)},startLayout:function(e,t,n,r){if(!r||null==r.from||r.from===this.uid){var i=this.viewGL,o=(n=this._api,this._forceLayoutInstance),a=this._model.getData(),s=this._model.getModel("forceAtlas2");if(o){if(this.groupGL.remove(this._edgesMesh),this.groupGL.add(this._forceEdgesMesh),this._forceLayoutInstance){this._updateForceNodesGeometry(e.getData()),this._pointsBuilder.hideLabels();var l=this,u=this._layoutId=g4++,c=s.getShallow("maxSteps"),h=s.getShallow("steps"),d=0,p=Math.max(2*h,20),f=function(t){if(t===l._layoutId)return o.isFinished(c)?(n.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void n.dispatchAction({type:"graphGLFinishLayout",points:a.getLayout("points"),from:l.uid})):void o.update(i.layer.renderer,h,(function(){l._updatePositionTexture(),(d+=h)>=p&&(l._syncNodePosition(e),d=0),n.getZr().refresh(),UQ((function(){f(t)}))}))};UQ((function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(i.layer.renderer),l._forceLayoutInstanceToDispose=null),f(u)})),this._layouting=!0}}else"production"!==process.env.NODE_ENV&&console.error("None layout don't have startLayout action")}},stopLayout:function(e,t,n,r){r&&null!=r.from&&r.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(r&&r.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,n)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,n){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,n),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,n,r){var i=this._model.getData();this._downplayAll();var o=r.dataIndex,a=i.graph,s=[],l=a.getNodeByIndex(o);s.push(l),l.edges.forEach((function(e){e.dataIndex<0||(e.node1!==l&&s.push(e.node1),e.node2!==l&&s.push(e.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(e){this._pointsBuilder.highlight(i,e.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(e){return e.dataIndex})));var u=[];l.edges.forEach((function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),u.push(e))}),this),this._focusNodes=s,this._focusEdges=u},unfocusNodeAdjacency:function(e,t,n,r){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),n=HQ.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),r=wJ(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);n[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],n)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach((function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)}),this),this._focusEdges&&this._focusEdges.forEach((function(e){this._downplayEdge(e.dataIndex)}),this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,n){this._getColor(t,e),e[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var n=0;n<4;n++)t[n]=this._originalEdgeColors[4*e+n];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge((function(t){this._setEdgeFade(t.dataIndex,e)}),this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var n=this.viewGL.camera,r=e.getData().getLayout("points"),i=f4.create(1/0,1/0),o=f4.create(-1/0,-1/0),a=[],s=0;s<r.length;)a[0]=r[s++],a[1]=r[s++],f4.min(i,i,a),f4.max(o,o,a);var l=(o[1]+i[1])/2,u=(o[0]+i[0])/2;if(!(u>n.left&&u<n.right&&l<n.bottom&&l>n.top)){var c=Math.max(o[0]-i[0],10),h=c/t.getWidth()*t.getHeight();c*=1.4,h*=1.4,i[0]-=.2*c,n.left=i[0],n.top=l-h/2,n.bottom=l+h/2,n.right=c+i[0],n.near=0,n.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1,this._pointsBuilder.dispose()},remove:function(){this.groupGL.removeAll(),this._control.dispose()}});function v4(e){return e instanceof Array||(e=[e,e]),e}l_((function(e){function t(){}e.registerChartView(m4),e.registerSeriesModel(i4),e.registerVisual((function(e){const t={};e.eachSeriesByType("graphGL",(function(e){var n=e.getCategoriesData(),r=e.getData(),i={};n.each((function(r){var o=n.getName(r);i["ec-"+o]=r;var a=n.getItemModel(r),s=a.getModel("itemStyle").getItemStyle();s.fill||(s.fill=e.getColorFromPalette(o,t)),n.setItemVisual(r,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let e=0;e<l.length;e++){var u=a.getShallow(l[e],!0);null!=u&&n.setItemVisual(r,l[e],u)}})),n.count()&&r.each((function(e){let t=r.getItemModel(e).getShallow("category");if(null!=t){"string"==typeof t&&(t=i["ec-"+t]);var o=n.getItemVisual(t,"style");z(r.ensureUniqueItemVisual(e,"style"),o);var a=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<a.length;i++)r.setItemVisual(e,a[i],n.getItemVisual(t,a[i]))}}))}))})),e.registerVisual((function(e){e.eachSeriesByType("graphGL",(function(e){var t=e.getGraph(),n=e.getEdgeData(),r=v4(e.get("edgeSymbol")),i=v4(e.get("edgeSymbolSize"));n.setVisual("drawType","stroke"),n.setVisual("fromSymbol",r&&r[0]),n.setVisual("toSymbol",r&&r[1]),n.setVisual("fromSymbolSize",i&&i[0]),n.setVisual("toSymbolSize",i&&i[1]),n.setVisual("style",e.getModel("lineStyle").getLineStyle()),n.each((function(e){var r=n.getItemModel(e),i=t.getEdgeByIndex(e),o=v4(r.getShallow("symbol",!0)),a=v4(r.getShallow("symbolSize",!0)),s=r.getModel("lineStyle").getLineStyle(),l=n.ensureUniqueItemVisual(e,"style");switch(z(l,s),l.stroke){case"source":var u=i.node1.getVisual("style");l.stroke=u&&u.fill;break;case"target":u=i.node2.getVisual("style");l.stroke=u&&u.fill}o[0]&&i.setVisual("fromSymbol",o[0]),o[1]&&i.setVisual("toSymbol",o[1]),a[0]&&i.setVisual("fromSymbolSize",a[0]),a[1]&&i.setVisual("toSymbolSize",a[1])}))}))})),e.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},(function(e,t){t.eachComponent({mainType:"series",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},t),e.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},t),e.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},t),e.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},t)}));var y4=Hg.extend({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(e,t){var n=this.get("coordinateSystem"),r="geo"===n?["lng","lat"]:$y(n)||["x","y"];if("production"!==process.env.NODE_ENV&&r.length>2)throw new Error("flowGL can only be used on 2d coordinate systems.");r.push("vx","vy");var i=k_(this.getSource(),{coordDimensions:r,encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),o=new R_(i,this);return o.initData(this.getSource()),o},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}}),_4=XK.extend((function(){return{dynamic:!0,attributes:{position:new XK.Attribute("position","float",3,"POSITION")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(e){var t=this.attributes,n=4*e,r=2*e;this.vertexCount!==n&&t.position.init(n),this.triangleCount!==r&&(this.indices=0===r?null:this.vertexCount>65535?new Uint32Array(3*r):new Uint16Array(3*r))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}});wq.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");var x4=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new RK({type:EK.FLOAT,flipY:!1}),this.particleLife=[5,20],this._particleType="point",this._particleSize=1,this.particleColor=[1,1,1,1],this.particleSpeedScaling=1,this._thisFrameTexture=null,this._particlePass=null,this._spawnTexture=null,this._particleTexture0=null,this._particleTexture1=null,this._particlePointsMesh=null,this._surfaceFrameBuffer=null,this._elapsedTime=0,this._scene=null,this._camera=null,this._lastFrameTexture=null,this._supersampling=1,this._downsampleTextures=[],this._width=512,this._height=512,this.init()};x4.prototype={constructor:x4,init:function(){var e={type:EK.FLOAT,minFilter:EK.NEAREST,magFilter:EK.NEAREST,useMipmap:!1};this._spawnTexture=new RK(e),this._particleTexture0=new RK(e),this._particleTexture1=new RK(e),this._frameBuffer=new G$({depthBuffer:!1}),this._particlePass=new pJ({fragment:wq.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new pJ({fragment:wq.source("clay.compositor.downsample")});var t=new LK({renderOrder:10,material:new jZ({shader:new wq(wq.source("ecgl.vfParticle.renderPoints.vertex"),wq.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:LK.POINTS,geometry:new XK({dynamic:!0,mainAttribute:"texcoord0"})}),n=new LK({renderOrder:10,material:new jZ({shader:new wq(wq.source("ecgl.vfParticle.renderLines.vertex"),wq.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new _4,culling:!1}),r=new LK({material:new jZ({shader:new wq(wq.source("ecgl.color.vertex"),wq.source("ecgl.color.fragment"))}),geometry:new W$});r.material.enableTexture("diffuseMap"),this._particlePointsMesh=t,this._particleLinesMesh=n,this._lastFrameFullQuadMesh=r,this._camera=new uJ,this._thisFrameTexture=new RK,this._lastFrameTexture=new RK},setParticleDensity:function(e,t){for(var n=new Float32Array(4*(e*t)),r=0,i=this.particleLife,o=0;o<e;o++)for(var a=0;a<t;a++,r++){n[4*r]=Math.random(),n[4*r+1]=Math.random(),n[4*r+2]=Math.random();var s=(i[1]-i[0])*Math.random()+i[0];n[4*r+3]=s}"line"===this._particleType?this._setLineGeometry(e,t):this._setPointsGeometry(e,t),this._spawnTexture.width=e,this._spawnTexture.height=t,this._spawnTexture.pixels=n,this._particleTexture0.width=this._particleTexture1.width=e,this._particleTexture0.height=this._particleTexture1.height=t,this._particlePass.setUniform("textureSize",[e,t])},_setPointsGeometry:function(e,t){var n=e*t,r=this._particlePointsMesh.geometry,i=r.attributes;i.texcoord0.init(n);for(var o=0,a=0;a<e;a++)for(var s=0;s<t;s++,o++)i.texcoord0.value[2*o]=a/e,i.texcoord0.value[2*o+1]=s/t;r.dirty()},_setLineGeometry:function(e,t){var n=e*t,r=this._getParticleMesh().geometry;r.setLineCount(n),r.resetOffset();for(var i=0;i<e;i++)for(var o=0;o<t;o++)r.addLine([i/e,o/t]);r.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(e,t,n,r){var i=this._getParticleMesh(),o=this._frameBuffer,a=this._particlePass;r&&this._updateDownsampleTextures(e,t),i.material.set("size",this._particleSize*this._supersampling),i.material.set("color",this.particleColor),a.setUniform("speedScaling",this.particleSpeedScaling),o.attach(this._particleTexture1),a.setUniform("firstFrameTime",r?(this.particleLife[1]+this.particleLife[0])/2:0),a.setUniform("particleTexture",this._particleTexture0),a.setUniform("deltaTime",n),a.setUniform("elapsedTime",this._elapsedTime),a.render(e,o),i.material.set("particleTexture",this._particleTexture1),i.material.set("prevParticleTexture",this._particleTexture0),o.attach(this._thisFrameTexture),o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);var s=this._lastFrameFullQuadMesh;s.material.set("diffuseMap",this._lastFrameTexture),s.material.set("color",[1,1,1,this.motionBlurFactor]),this._camera.update(!0),e.renderPass([s,i],this._camera),o.unbind(e),this._downsample(e),this._swapTexture(),this._elapsedTime+=n},_downsample:function(e){var t=this._downsampleTextures;if(0!==t.length)for(var n=0,r=this._thisFrameTexture,i=t[n];i;)this._frameBuffer.attach(i),this._downsamplePass.setUniform("texture",r),this._downsamplePass.setUniform("textureSize",[r.width,r.height]),this._downsamplePass.render(e,this._frameBuffer),r=i,i=t[++n]},getSurfaceTexture:function(){var e=this._downsampleTextures;return e.length>0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new RK),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=function(e){var t=document.createElement("canvas");t.width=t.height=e;var n=t.getContext("2d");return n.fillStyle="#fff",n.arc(e/2,e/2,e/2,0,2*Math.PI),n.fill(),t}(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var n=this._downsampleTextures,r=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,o=this._width*this._supersampling,a=this._height*this._supersampling,s=0;s<r;s++)n[s]=n[s]||new RK,n[s].width=o/i,n[s].height=a/i,i*=2;for(;s<n.length;s++)n[s].dispose(e);n.length=r},_swapTexture:function(){var e=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=e;e=this._thisFrameTexture;this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=e},dispose:function(e){e.disposeFrameBuffer(this._frameBuffer),e.disposeTexture(this.vectorFieldTexture),e.disposeTexture(this._spawnTexture),e.disposeTexture(this._particleTexture0),e.disposeTexture(this._particleTexture1),e.disposeTexture(this._thisFrameTexture),e.disposeTexture(this._lastFrameTexture),e.disposeGeometry(this._particleLinesMesh.geometry),e.disposeGeometry(this._particlePointsMesh.geometry),e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&e.disposeTexture(this._spriteTexture),this._particlePass.dispose(e),this._downsamplePass.dispose(e),this._downsampleTextures.forEach((function(t){t.dispose(e)}))}};var b4=em.extend({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new V1("orthographic"),this.groupGL=new HQ.Node,this.viewGL.add(this.groupGL),this._particleSurface=new x4;var n=new HQ.Mesh({geometry:new HQ.PlaneGeometry,material:new HQ.Material({shader:new HQ.Shader({vertex:HQ.Shader.source("ecgl.color.vertex"),fragment:HQ.Shader.source("ecgl.color.fragment")}),transparent:!0})});n.material.enableTexture("diffuseMap"),this.groupGL.add(n),this._planeMesh=n},render:function(e,t,n){var r=this._particleSurface;r.setParticleType(e.get("particleType")),r.setSupersampling(e.get("supersampling")),this._updateData(e,n),this._updateCamera(n.getWidth(),n.getHeight(),n.getDevicePixelRatio());var i=wJ(e.get("particleDensity"),128);r.setParticleDensity(i,i);var o=this._planeMesh,a=+new Date,s=this,l=!0;o.__percent=0,o.stopAnimation(),o.animate("",{loop:!0}).when(1e5,{__percent:1}).during((function(){var e=+new Date,t=Math.min(e-a,20);a+=t,s._renderer&&(r.update(s._renderer,n,t/1e3,l),o.material.set("diffuseMap",r.getSurfaceTexture())),l=!1})).start();var u=e.getModel("itemStyle"),c=HQ.parseColor(u.get("color"));c[3]*=wJ(u.get("opacity"),1),o.material.set("color",c),r.setColorTextureImage(e.get("colorTexture"),n),r.setParticleSize(e.get("particleSize")),r.particleSpeedScaling=e.get("particleSpeed"),r.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,n){this._updateData(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._renderer=i},_updateData:function(e,t){var n=e.coordinateSystem,r=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]})),i=e.getData(),o=i.getDataExtent(r[0]),a=i.getDataExtent(r[1]),s=e.get("gridWidth"),l=e.get("gridHeight");if(null==s||"auto"===s){var u=(o[1]-o[0])/(a[1]-a[0]);s=Math.round(Math.sqrt(u*i.count()))}null!=l&&"auto"!==l||(l=Math.ceil(i.count()/s));var c=this._particleSurface.vectorFieldTexture,h=c.pixels;if(h&&h.length===l*s*4)for(var d=0;d<h.length;d++)h[d]=0;else h=c.pixels=new Float32Array(s*l*4);var p=0,f=1/0,g=new Float32Array(2*i.count()),m=0,v=[[1/0,1/0],[-1/0,-1/0]];i.each([r[0],r[1],"vx","vy"],(function(e,t,r,i){var o=n.dataToPoint([e,t]);g[m++]=o[0],g[m++]=o[1],v[0][0]=Math.min(o[0],v[0][0]),v[0][1]=Math.min(o[1],v[0][1]),v[1][0]=Math.max(o[0],v[1][0]),v[1][1]=Math.max(o[1],v[1][1]);var a=Math.sqrt(r*r+i*i);p=Math.max(p,a),f=Math.min(f,a)})),i.each(["vx","vy"],(function(e,t,n){var r=Math.round((g[2*n]-v[0][0])/(v[1][0]-v[0][0])*(s-1)),i=4*((l-1-Math.round((g[2*n+1]-v[0][1])/(v[1][1]-v[0][1])*(l-1)))*s+r);h[i]=e/p*.5+.5,h[i+1]=t/p*.5+.5,h[i+3]=1})),c.width=s,c.height=l,"bmap"===e.get("coordinateSystem")&&this._fillEmptyPixels(c),c.dirty(),this._updatePlanePosition(v[0],v[1],e,t),this._updateGradientTexture(i.getVisual("visualMeta"),[f,p])},_fillEmptyPixels:function(e){var t=e.pixels,n=e.width,r=e.height;function i(e,i,o){e=Math.max(Math.min(e,n-1),0);var a=4*((i=Math.max(Math.min(i,r-1),0))*(n-1)+e);return 0!==t[a+3]&&(o[0]=t[a],o[1]=t[a+1],!0)}function o(e,t,n){n[0]=e[0]+t[0],n[1]=e[1]+t[1]}for(var a=[],s=[],l=[],u=[],c=[],h=0,d=0;d<r;d++)for(var p=0;p<n;p++){var f=4*(d*(n-1)+p);0===t[f+3]&&(h=a[0]=a[1]=0,i(p-1,d,s)&&(h++,o(s,a,a)),i(p+1,d,l)&&(h++,o(l,a,a)),i(p,d-1,u)&&(h++,o(u,a,a)),i(p,d+1,c)&&(h++,o(c,a,a)),a[0]/=h,a[1]/=h,t[f]=a[0],t[f+1]=a[1]),t[f+3]=1}},_updateGradientTexture:function(e,t){if(e&&e.length){this._gradientTexture=this._gradientTexture||new HQ.Texture2D({image:document.createElement("canvas")});var n=this._gradientTexture,r=n.image;r.width=200,r.height=1;var i=r.getContext("2d"),o=i.createLinearGradient(0,.5,r.width,.5);e[0].stops.forEach((function(e){var n;t[1]===t[0]?n=0:(n=e.value/t[1],n=Math.min(Math.max(n,0),1)),o.addColorStop(n,e.color)})),i.fillStyle=o,i.fillRect(0,0,r.width,r.height),n.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(e,t,n,r){var i=this._limitInViewportAndFullFill(e,t,n,r);e=i.leftTop,t=i.rightBottom,this._particleSurface.setRegion(i.region),this._planeMesh.position.set((e[0]+t[0])/2,r.getHeight()-(e[1]+t[1])/2,0);var o=t[0]-e[0],a=t[1]-e[1];this._planeMesh.scale.set(o/2,a/2,1),this._particleSurface.resize(Math.max(Math.min(o,2048),1),Math.max(Math.min(a,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(e,t,n,r){var i=[Math.max(e[0],0),Math.max(e[1],0)],o=[Math.min(t[0],r.getWidth()),Math.min(t[1],r.getHeight())];if("bmap"===n.get("coordinateSystem")){var a=n.getData().getDataExtent(n.coordDimToDataDim("lng")[0]);Math.floor(a[1]-a[0])>=359&&(i[0]>0&&(i[0]=0),o[0]<r.getWidth()&&(o[0]=r.getWidth()))}var s=t[0]-e[0],l=t[1]-e[1],u=o[0]-i[0],c=o[1]-i[1];return{leftTop:i,rightBottom:o,region:[(i[0]-e[0])/s,1-c/l-(i[1]-e[1])/l,u/s,c/l]}},_updateCamera:function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.bottom=0,r.top=t,r.right=e,r.near=0,r.far=100,r.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}});l_((function(e){e.registerChartView(b4),e.registerSeriesModel(y4)}));var w4=Hg.extend({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),w4.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),w4.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=$J(this._flatCoords,t.flatCoords),this._flatCoordsOffset=$J(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),n=t.option instanceof Array?t.option:t.getShallow("coords");if("production"!==process.env.NODE_ENV&&!(n instanceof Array&&n.length>0&&n[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(n)+". Lines must have 2d coords array in data item.");return n},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var n=this._flatCoordsOffset[2*e],r=this._flatCoordsOffset[2*e+1],i=0;i<r;i++)t[i]=t[i]||[],t[i][0]=this._flatCoords[n+2*i],t[i][1]=this._flatCoords[n+2*i+1];return r}var o=this._getCoordsFromItemModel(e);for(i=0;i<o.length;i++)t[i]=t[i]||[],t[i][0]=o[i][0],t[i][1]=o[i][1];return o.length},_processFlatCoordsArray:function(e){var t=0;if(this._flatCoords&&(t=this._flatCoords.length),"number"==typeof e[0]){for(var n=e.length,r=new Uint32Array(n),i=new Float64Array(n),o=0,a=0,s=0,l=0;l<n;){s++;var u=e[l++];r[a++]=o+t,r[a++]=u;for(var c=0;c<u;c++){var h=e[l++],d=e[l++];if(i[o++]=h,i[o++]=d,l>n&&"production"!==process.env.NODE_ENV)throw new Error("Invalid data format.")}}return{flatCoordsOffset:new Uint32Array(r.buffer,0,a),flatCoords:i,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:e.length}},getInitialData:function(e,t){var n=new R_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"geo",zlevel:10,progressive:1e4,progressiveThreshold:5e4,blendMode:"source-over",lineStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}}),S4=em.extend({type:"linesGL",__ecgl__:!0,init:function(e,t){this.groupGL=new HQ.Node,this.viewGL=new V1("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new n4(this.viewGL),this._nativeLinesShader=HQ.createShader("ecgl.lines3D"),this._meshLinesShader=HQ.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n);var r=this._linesMeshes[0];r||(r=this._linesMeshes[0]=this._createLinesMesh(e)),this._linesMeshes.length=1,this.groupGL.add(r),this._updateLinesMesh(e,r,0,e.getData().count()),this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){var i=this._linesMeshes[this._currentStep];i||(i=this._createLinesMesh(t),this._linesMeshes[this._currentStep]=i),this._updateLinesMesh(t,i,e.start,e.end),this.groupGL.add(i),r.getZr().refresh(),this._currentStep++},updateTransform:function(e,t,n){e.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(e,n)},_createLinesMesh:function(e){return new HQ.Mesh({$ignorePicking:!0,material:new HQ.Material({shader:HQ.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new s4({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:HQ.Mesh.LINES,culling:!1})},_updateLinesMesh:function(e,t,n,r){var i=e.getData();t.material.blend="lighter"===e.get("blendMode")?HQ.additiveBlend:null;var o=e.get("lineStyle.curveness")||0,a=e.get("polyline"),s=t.geometry,l=e.coordinateSystem,u=wJ(e.get("lineStyle.width"),1);u>1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=HQ.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=HQ.Mesh.LINES),n=n||0,r=r||i.count(),s.resetOffset();var c=0,h=0,d=[],p=[],f=[],g=[],m=[],v=.3,y=.7;function _(){p[0]=d[0]*y+g[0]*v-(d[1]-g[1])*o,p[1]=d[1]*y+g[1]*v-(g[0]-d[0])*o,f[0]=d[0]*v+g[0]*y-(d[1]-g[1])*o,f[1]=d[1]*v+g[1]*y-(g[0]-d[0])*o}if(a||0!==o)for(var x=n;x<r;x++)if(a){var b=e.getLineCoordsCount(x);c+=s.getPolylineVertexCount(b),h+=s.getPolylineTriangleCount(b)}else e.getLineCoords(x,m),this._glViewHelper.dataToPoint(l,m[0],d),this._glViewHelper.dataToPoint(l,m[1],g),_(),c+=s.getCubicCurveVertexCount(d,p,f,g),h+=s.getCubicCurveTriangleCount(d,p,f,g);else{var w=r-n;c+=w*s.getLineVertexCount(),h+=w*s.getLineVertexCount()}s.setVertexCount(c),s.setTriangleCount(h);var S=n,T=[];for(x=n;x<r;x++){HQ.parseColor(P2(i,S),T);var M=wJ(O2(i,S),1);T[3]*=M;b=e.getLineCoords(x,m);for(var C=0;C<b;C++)this._glViewHelper.dataToPoint(l,m[C],m[C]);a?s.addPolyline(m,T,u,0,b):0!==o?(d=m[0],g=m[1],_(),s.addCubicCurve(d,p,f,g,T,u)):s.addPolyline(m,T,u,0,2),S++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});l_((function(e){e.registerChartView(S4),e.registerSeriesModel(w4)}));const T4=({className:e="",style:n={},extraOption:r={},lineStyles:i={},pointsStyles:s={},pointsData:l=[],linesData:u=[],globeOption:c={}})=>{const h=t(null),[d,p]=o();return a((()=>{const e=By(h.current);p(e);const t=$X(e.resize,500),n=()=>{t()};return globalThis.addEventListener("resize",n),()=>{globalThis.removeEventListener("resize",n)}}),[]),a((()=>{if(d){const e=[];e.push(Object.assign({type:"lines3D",name:"lines3D",effect:{show:!0,trailWidth:2,trailLength:.15,trailOpacity:1,trailColor:"rgb(30, 30, 60)"},lineStyle:{width:5,color:"rgb(50, 50, 150)",opacity:.3},blendMode:"lighter",data:u},i)),e.push(Object.assign({type:"scatter3D",coordinateSystem:"globe",zlevel:3,rippleEffect:{brushType:"stroke"},label:{fontSize:8,show:!0,position:"right",formatter:"{b}"},itemStyle:{normal:{color:"#f5f802"}},data:l},s)),d.setOption(Object.assign({backgroundColor:"#000",baseColor:"#000",shading:"realistic",globe:Object.assign({environment:"https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg",heightTexture:"https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg",baseTexture:"https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg",shading:"lambert",light:{ambient:{intensity:1},main:{intensity:.1}},viewControl:{autoRotate:!0,distance:2e3}},c),series:e},r));const t=setTimeout((()=>{d.resize()}),500);return()=>{clearTimeout(t)}}}),[d,r,c,i,u,l,s]),yU.jsx(oX,{ref:h,className:e,style:n})};export{T4 as EarthChart,pY as WinChart,aX as WinChartType,pY as default,hU as echarts};