var mapsindoors=(()=>{var yM=Object.create;var gl=Object.defineProperty;var _M=Object.getOwnPropertyDescriptor;var vM=Object.getOwnPropertyNames;var xM=Object.getPrototypeOf,bM=Object.prototype.hasOwnProperty;var MM=(i,e,t)=>e in i?gl(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var SM=(i,e)=>()=>(i&&(e=i(i=0)),e);var On=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),xy=(i,e)=>{for(var t in e)gl(i,t,{get:e[t],enumerable:!0})},by=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vM(e))!bM.call(i,s)&&s!==t&&gl(i,s,{get:()=>e[s],enumerable:!(n=_M(e,s))||n.enumerable});return i};var ln=(i,e,t)=>(t=i!=null?yM(xM(i)):{},by(e||!i||!i.__esModule?gl(t,"default",{value:i,enumerable:!0}):t,i)),wM=i=>by(gl({},"__esModule",{value:!0}),i);var cn=(i,e,t)=>(MM(i,typeof e!="symbol"?e+"":e,t),t),md=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var g=(i,e,t)=>(md(i,e,"read from private field"),t?t.call(i):e.get(i)),U=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},W=(i,e,t,n)=>(md(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var te=(i,e,t)=>(md(i,e,"access private method"),t);var $,T=SM(()=>{$=["https://api.mapsindoors.com"]});var gd=On(ph=>{"use strict";T();Object.defineProperty(ph,"__esModule",{value:!0});ph.storageFactory=void 0;function EM(i){var e={};function t(){try{var c="__some_random_key_you_are_not_going_to_use__";return i().setItem(c,c),i().removeItem(c),!0}catch{return!1}}function n(){t()?i().clear():e={}}function s(c){return t()?i().getItem(c):e.hasOwnProperty(c)?e[c]:null}function r(c){return t()?i().key(c):Object.keys(e)[c]||null}function o(c){t()?i().removeItem(c):delete e[c]}function a(c,h){t()?i().setItem(c,h):e[c]=String(h)}function l(){return t()?i().length:Object.keys(e).length}return{getItem:s,setItem:a,removeItem:o,clear:n,key:r,get length(){return l()}}}ph.storageFactory=EM});var ii=On((D2,yd)=>{"use strict";T();var Bo=typeof Reflect=="object"?Reflect:null,My=Bo&&typeof Bo.apply=="function"?Bo.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},mh;Bo&&typeof Bo.ownKeys=="function"?mh=Bo.ownKeys:Object.getOwnPropertySymbols?mh=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:mh=function(e){return Object.getOwnPropertyNames(e)};function TM(i){console&&console.warn&&console.warn(i)}var wy=Number.isNaN||function(e){return e!==e};function gt(){gt.init.call(this)}yd.exports=gt;yd.exports.once=LM;gt.EventEmitter=gt;gt.prototype._events=void 0;gt.prototype._eventsCount=0;gt.prototype._maxListeners=void 0;var Sy=10;function gh(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(gt,"defaultMaxListeners",{enumerable:!0,get:function(){return Sy},set:function(i){if(typeof i!="number"||i<0||wy(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Sy=i}});gt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};gt.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||wy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ay(i){return i._maxListeners===void 0?gt.defaultMaxListeners:i._maxListeners}gt.prototype.getMaxListeners=function(){return Ay(this)};gt.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var s=e==="error",r=this._events;if(r!==void 0)s=s&&r.error===void 0;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=r[e];if(l===void 0)return!1;if(typeof l=="function")My(l,this,t);else for(var c=l.length,h=Cy(l,c),n=0;n<c;++n)My(h[n],this,t);return!0};function Ey(i,e,t,n){var s,r,o;if(gh(t),r=i._events,r===void 0?(r=i._events=Object.create(null),i._eventsCount=0):(r.newListener!==void 0&&(i.emit("newListener",e,t.listener?t.listener:t),r=i._events),o=r[e]),o===void 0)o=r[e]=t,++i._eventsCount;else if(typeof o=="function"?o=r[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),s=Ay(i),s>0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,TM(a)}return i}gt.prototype.addListener=function(e,t){return Ey(this,e,t,!1)};gt.prototype.on=gt.prototype.addListener;gt.prototype.prependListener=function(e,t){return Ey(this,e,t,!0)};function IM(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ty(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},s=IM.bind(n);return s.listener=t,n.wrapFn=s,s}gt.prototype.once=function(e,t){return gh(t),this.on(e,Ty(this,e,t)),this};gt.prototype.prependOnceListener=function(e,t){return gh(t),this.prependListener(e,Ty(this,e,t)),this};gt.prototype.removeListener=function(e,t){var n,s,r,o,a;if(gh(t),s=this._events,s===void 0)return this;if(n=s[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,r=o;break}if(r<0)return this;r===0?n.shift():RM(n,r),n.length===1&&(s[e]=n[0]),s.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};gt.prototype.off=gt.prototype.removeListener;gt.prototype.removeAllListeners=function(e){var t,n,s;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var r=Object.keys(n),o;for(s=0;s<r.length;++s)o=r[s],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this};function Iy(i,e,t){var n=i._events;if(n===void 0)return[];var s=n[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?CM(s):Cy(s,s.length)}gt.prototype.listeners=function(e){return Iy(this,e,!0)};gt.prototype.rawListeners=function(e){return Iy(this,e,!1)};gt.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):Ry.call(i,e)};gt.prototype.listenerCount=Ry;function Ry(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}gt.prototype.eventNames=function(){return this._eventsCount>0?mh(this._events):[]};function Cy(i,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=i[n];return t}function RM(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function CM(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}function LM(i,e){return new Promise(function(t,n){function s(o){i.removeListener(e,r),n(o)}function r(){typeof i.removeListener=="function"&&i.removeListener("error",s),t([].slice.call(arguments))}Ly(i,e,r,{once:!0}),e!=="error"&&PM(i,s,{once:!0})})}function PM(i,e,t){typeof i.on=="function"&&Ly(i,"error",e,t)}function Ly(i,e,t,n){if(typeof i.on=="function")n.once?i.once(e,t):i.on(e,t);else if(typeof i.addEventListener=="function")i.addEventListener(e,function s(r){n.once&&i.removeEventListener(e,s),t(r)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var c_=On((Al,Qd)=>{T();(function(e,t){typeof Al=="object"&&typeof Qd=="object"?Qd.exports=t():typeof define=="function"&&define.amd?define(t):typeof Al=="object"?Al=t():e.Paho=t()})(Al,function(){var e=function(t){var n="@VERSION@-@BUILDLEVEL@",s=t.localStorage||function(){var _={};return{setItem:function(M,I){_[M]=I},getItem:function(M){return _[M]},removeItem:function(M){delete _[M]}}}(),r={CONNECT:1,CONNACK:2,PUBLISH:3,PUBACK:4,PUBREC:5,PUBREL:6,PUBCOMP:7,SUBSCRIBE:8,SUBACK:9,UNSUBSCRIBE:10,UNSUBACK:11,PINGREQ:12,PINGRESP:13,DISCONNECT:14},o=function(_,M){for(var I in _)if(_.hasOwnProperty(I))if(M.hasOwnProperty(I)){if(typeof _[I]!==M[I])throw new Error(h(l.INVALID_TYPE,[typeof _[I],I]))}else{var O="Unknown property, "+I+". Valid properties are:";for(var B in M)M.hasOwnProperty(B)&&(O=O+" "+B);throw new Error(O)}},a=function(_,M){return function(){return _.apply(M,arguments)}},l={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."},BUFFER_FULL:{code:18,text:"AMQJS0018E Message buffer is full, maximum buffer size: {0}."}},c={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},h=function(_,M){var I=_.text;if(M){for(var O,B,D=0;D<M.length;D++)if(O="{"+D+"}",B=I.indexOf(O),B>0){var X=I.substring(0,B),q=I.substring(B+O.length);I=X+M[D]+q}}return I},u=[0,6,77,81,73,115,100,112,3],f=[0,4,77,81,84,84,4],d=function(_,M){this.type=_;for(var I in M)M.hasOwnProperty(I)&&(this[I]=M[I])};d.prototype.encode=function(){var _=(this.type&15)<<4,M=0,I=[],O=0,B;switch(this.messageIdentifier!==void 0&&(M+=2),this.type){case r.CONNECT:switch(this.mqttVersion){case 3:M+=u.length+3;break;case 4:M+=f.length+3;break}M+=x(this.clientId)+2,this.willMessage!==void 0&&(M+=x(this.willMessage.destinationName)+2,B=this.willMessage.payloadBytes,B instanceof Uint8Array||(B=new Uint8Array(X)),M+=B.byteLength+2),this.userName!==void 0&&(M+=x(this.userName)+2),this.password!==void 0&&(M+=x(this.password)+2);break;case r.SUBSCRIBE:_|=2;for(var D=0;D<this.topics.length;D++)I[D]=x(this.topics[D]),M+=I[D]+2;M+=this.requestedQos.length;break;case r.UNSUBSCRIBE:_|=2;for(var D=0;D<this.topics.length;D++)I[D]=x(this.topics[D]),M+=I[D]+2;break;case r.PUBREL:_|=2;break;case r.PUBLISH:this.payloadMessage.duplicate&&(_|=8),_=_|=this.payloadMessage.qos<<1,this.payloadMessage.retained&&(_|=1),O=x(this.payloadMessage.destinationName),M+=O+2;var X=this.payloadMessage.payloadBytes;M+=X.byteLength,X instanceof ArrayBuffer?X=new Uint8Array(X):X instanceof Uint8Array||(X=new Uint8Array(X.buffer));break;case r.DISCONNECT:break;default:break}var q=A(M),Q=q.length+1,ae=new ArrayBuffer(M+Q),ee=new Uint8Array(ae);if(ee[0]=_,ee.set(q,1),this.type==r.PUBLISH)Q=p(this.payloadMessage.destinationName,O,ee,Q);else if(this.type==r.CONNECT){switch(this.mqttVersion){case 3:ee.set(u,Q),Q+=u.length;break;case 4:ee.set(f,Q),Q+=f.length;break}var H=0;this.cleanSession&&(H=2),this.willMessage!==void 0&&(H|=4,H|=this.willMessage.qos<<3,this.willMessage.retained&&(H|=32)),this.userName!==void 0&&(H|=128),this.password!==void 0&&(H|=64),ee[Q++]=H,Q=v(this.keepAliveInterval,ee,Q)}switch(this.messageIdentifier!==void 0&&(Q=v(this.messageIdentifier,ee,Q)),this.type){case r.CONNECT:Q=p(this.clientId,x(this.clientId),ee,Q),this.willMessage!==void 0&&(Q=p(this.willMessage.destinationName,x(this.willMessage.destinationName),ee,Q),Q=v(B.byteLength,ee,Q),ee.set(B,Q),Q+=B.byteLength),this.userName!==void 0&&(Q=p(this.userName,x(this.userName),ee,Q)),this.password!==void 0&&(Q=p(this.password,x(this.password),ee,Q));break;case r.PUBLISH:ee.set(X,Q);break;case r.SUBSCRIBE:for(var D=0;D<this.topics.length;D++)Q=p(this.topics[D],I[D],ee,Q),ee[Q++]=this.requestedQos[D];break;case r.UNSUBSCRIBE:for(var D=0;D<this.topics.length;D++)Q=p(this.topics[D],I[D],ee,Q);break;default:}return ae};function y(_,M){var I=M,O=_[M],B=O>>4,D=O&=15;M+=1;var X,q=0,Q=1;do{if(M==_.length)return[null,I];X=_[M++],q+=(X&127)*Q,Q*=128}while((X&128)!==0);var ae=M+q;if(ae>_.length)return[null,I];var ee=new d(B);switch(B){case r.CONNACK:var H=_[M++];H&1&&(ee.sessionPresent=!0),ee.returnCode=_[M++];break;case r.PUBLISH:var be=D>>1&3,Y=m(_,M);M+=2;var oe=N(_,M,Y);M+=Y,be>0&&(ee.messageIdentifier=m(_,M),M+=2);var he=new b(_.subarray(M,ae));(D&1)==1&&(he.retained=!0),(D&8)==8&&(he.duplicate=!0),he.qos=be,he.destinationName=oe,ee.payloadMessage=he;break;case r.PUBACK:case r.PUBREC:case r.PUBREL:case r.PUBCOMP:case r.UNSUBACK:ee.messageIdentifier=m(_,M);break;case r.SUBACK:ee.messageIdentifier=m(_,M),M+=2,ee.returnCode=_.subarray(M,ae);break;default:break}return[ee,ae]}function v(_,M,I){return M[I++]=_>>8,M[I++]=_%256,I}function p(_,M,I,O){return O=v(M,I,O),S(_,I,O),O+M}function m(_,M){return 256*_[M]+_[M+1]}function A(_){var M=new Array(1),I=0;do{var O=_%128;_=_>>7,_>0&&(O|=128),M[I++]=O}while(_>0&&I<4);return M}function x(_){for(var M=0,I=0;I<_.length;I++){var O=_.charCodeAt(I);O>2047?(55296<=O&&O<=56319&&(I++,M++),M+=3):O>127?M+=2:M++}return M}function S(_,M,I){for(var O=I,B=0;B<_.length;B++){var D=_.charCodeAt(B);if(55296<=D&&D<=56319){var X=_.charCodeAt(++B);if(isNaN(X))throw new Error(h(l.MALFORMED_UNICODE,[D,X]));D=(D-55296<<10)+(X-56320)+65536}D<=127?M[O++]=D:D<=2047?(M[O++]=D>>6&31|192,M[O++]=D&63|128):D<=65535?(M[O++]=D>>12&15|224,M[O++]=D>>6&63|128,M[O++]=D&63|128):(M[O++]=D>>18&7|240,M[O++]=D>>12&63|128,M[O++]=D>>6&63|128,M[O++]=D&63|128)}return M}function N(_,M,I){for(var O="",B,D=M;D<M+I;){var X=_[D++];if(X<128)B=X;else{var q=_[D++]-128;if(q<0)throw new Error(h(l.MALFORMED_UTF,[X.toString(16),q.toString(16),""]));if(X<224)B=64*(X-192)+q;else{var Q=_[D++]-128;if(Q<0)throw new Error(h(l.MALFORMED_UTF,[X.toString(16),q.toString(16),Q.toString(16)]));if(X<240)B=4096*(X-224)+64*q+Q;else{var ae=_[D++]-128;if(ae<0)throw new Error(h(l.MALFORMED_UTF,[X.toString(16),q.toString(16),Q.toString(16),ae.toString(16)]));if(X<248)B=262144*(X-240)+4096*q+64*Q+ae;else throw new Error(h(l.MALFORMED_UTF,[X.toString(16),q.toString(16),Q.toString(16),ae.toString(16)]))}}}B>65535&&(B-=65536,O+=String.fromCharCode(55296+(B>>10)),B=56320+(B&1023)),O+=String.fromCharCode(B)}return O}var P=function(_,M){this._client=_,this._keepAliveInterval=M*1e3,this.isReset=!1;var I=new d(r.PINGREQ).encode(),O=function(D){return function(){return B.apply(D)}},B=function(){this.isReset?(this.isReset=!1,this._client._trace("Pinger.doPing","send PINGREQ"),this._client.socket.send(I),this.timeout=setTimeout(O(this),this._keepAliveInterval)):(this._client._trace("Pinger.doPing","Timed out"),this._client._disconnected(l.PING_TIMEOUT.code,h(l.PING_TIMEOUT)))};this.reset=function(){this.isReset=!0,clearTimeout(this.timeout),this._keepAliveInterval>0&&(this.timeout=setTimeout(O(this),this._keepAliveInterval))},this.cancel=function(){clearTimeout(this.timeout)}},C=function(_,M,I,O){M||(M=30);var B=function(D,X,q){return function(){return D.apply(X,q)}};this.timeout=setTimeout(B(I,_,O),M*1e3),this.cancel=function(){clearTimeout(this.timeout)}},R=function(_,M,I,O,B){if(!("WebSocket"in t&&t.WebSocket!==null))throw new Error(h(l.UNSUPPORTED,["WebSocket"]));if(!("ArrayBuffer"in t&&t.ArrayBuffer!==null))throw new Error(h(l.UNSUPPORTED,["ArrayBuffer"]));this._trace("Paho.Client",_,M,I,O,B),this.host=M,this.port=I,this.path=O,this.uri=_,this.clientId=B,this._wsuri=null,this._localKey=M+":"+I+(O!="/mqtt"?":"+O:"")+":"+B+":",this._msg_queue=[],this._buffered_msg_queue=[],this._sentMessages={},this._receivedMessages={},this._notify_msg_sent={},this._message_identifier=1,this._sequence=0;for(var D in s)(D.indexOf("Sent:"+this._localKey)===0||D.indexOf("Received:"+this._localKey)===0)&&this.restore(D)};R.prototype.host=null,R.prototype.port=null,R.prototype.path=null,R.prototype.uri=null,R.prototype.clientId=null,R.prototype.socket=null,R.prototype.connected=!1,R.prototype.maxMessageIdentifier=65536,R.prototype.connectOptions=null,R.prototype.hostIndex=null,R.prototype.onConnected=null,R.prototype.onConnectionLost=null,R.prototype.onMessageDelivered=null,R.prototype.onMessageArrived=null,R.prototype.traceFunction=null,R.prototype._msg_queue=null,R.prototype._buffered_msg_queue=null,R.prototype._connectTimeout=null,R.prototype.sendPinger=null,R.prototype.receivePinger=null,R.prototype._reconnectInterval=1,R.prototype._reconnecting=!1,R.prototype._reconnectTimeout=null,R.prototype.disconnectedPublishing=!1,R.prototype.disconnectedBufferSize=5e3,R.prototype.receiveBuffer=null,R.prototype._traceBuffer=null,R.prototype._MAX_TRACE_ENTRIES=100,R.prototype.connect=function(_){var M=this._traceMask(_,"password");if(this._trace("Client.connect",M,this.socket,this.connected),this.connected)throw new Error(h(l.INVALID_STATE,["already connected"]));if(this.socket)throw new Error(h(l.INVALID_STATE,["already connected"]));this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),this.connectOptions=_,this._reconnectInterval=1,this._reconnecting=!1,_.uris?(this.hostIndex=0,this._doConnect(_.uris[0])):this._doConnect(this.uri)},R.prototype.subscribe=function(_,M){if(this._trace("Client.subscribe",_,M),!this.connected)throw new Error(h(l.INVALID_STATE,["not connected"]));var I=new d(r.SUBSCRIBE);I.topics=_.constructor===Array?_:[_],M.qos===void 0&&(M.qos=0),I.requestedQos=[];for(var O=0;O<I.topics.length;O++)I.requestedQos[O]=M.qos;M.onSuccess&&(I.onSuccess=function(B){M.onSuccess({invocationContext:M.invocationContext,grantedQos:B})}),M.onFailure&&(I.onFailure=function(B){M.onFailure({invocationContext:M.invocationContext,errorCode:B,errorMessage:h(B)})}),M.timeout&&(I.timeOut=new C(this,M.timeout,M.onFailure,[{invocationContext:M.invocationContext,errorCode:l.SUBSCRIBE_TIMEOUT.code,errorMessage:h(l.SUBSCRIBE_TIMEOUT)}])),this._requires_ack(I),this._schedule_message(I)},R.prototype.unsubscribe=function(_,M){if(this._trace("Client.unsubscribe",_,M),!this.connected)throw new Error(h(l.INVALID_STATE,["not connected"]));var I=new d(r.UNSUBSCRIBE);I.topics=_.constructor===Array?_:[_],M.onSuccess&&(I.callback=function(){M.onSuccess({invocationContext:M.invocationContext})}),M.timeout&&(I.timeOut=new C(this,M.timeout,M.onFailure,[{invocationContext:M.invocationContext,errorCode:l.UNSUBSCRIBE_TIMEOUT.code,errorMessage:h(l.UNSUBSCRIBE_TIMEOUT)}])),this._requires_ack(I),this._schedule_message(I)},R.prototype.send=function(_){this._trace("Client.send",_);var M=new d(r.PUBLISH);if(M.payloadMessage=_,this.connected)_.qos>0?this._requires_ack(M):this.onMessageDelivered&&(this._notify_msg_sent[M]=this.onMessageDelivered(M.payloadMessage)),this._schedule_message(M);else if(this._reconnecting&&this.disconnectedPublishing){var I=Object.keys(this._sentMessages).length+this._buffered_msg_queue.length;if(I>this.disconnectedBufferSize)throw new Error(h(l.BUFFER_FULL,[this.disconnectedBufferSize]));_.qos>0?this._requires_ack(M):(M.sequence=++this._sequence,this._buffered_msg_queue.unshift(M))}else throw new Error(h(l.INVALID_STATE,["not connected"]))},R.prototype.disconnect=function(){if(this._trace("Client.disconnect"),this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),!this.socket)throw new Error(h(l.INVALID_STATE,["not connecting or connected"]));var _=new d(r.DISCONNECT);this._notify_msg_sent[_]=a(this._disconnected,this),this._schedule_message(_)},R.prototype.getTraceLog=function(){if(this._traceBuffer!==null){this._trace("Client.getTraceLog",new Date),this._trace("Client.getTraceLog in flight messages",this._sentMessages.length);for(var _ in this._sentMessages)this._trace("_sentMessages ",_,this._sentMessages[_]);for(var _ in this._receivedMessages)this._trace("_receivedMessages ",_,this._receivedMessages[_]);return this._traceBuffer}},R.prototype.startTrace=function(){this._traceBuffer===null&&(this._traceBuffer=[]),this._trace("Client.startTrace",new Date,n)},R.prototype.stopTrace=function(){delete this._traceBuffer},R.prototype._doConnect=function(_){if(this.connectOptions.useSSL){var M=_.split(":");M[0]="wss",_=M.join(":")}this._wsuri=_,this.connected=!1,this.connectOptions.mqttVersion<4?this.socket=new WebSocket(_,["mqttv3.1"]):this.socket=new WebSocket(_,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=a(this._on_socket_open,this),this.socket.onmessage=a(this._on_socket_message,this),this.socket.onerror=a(this._on_socket_error,this),this.socket.onclose=a(this._on_socket_close,this),this.sendPinger=new P(this,this.connectOptions.keepAliveInterval),this.receivePinger=new P(this,this.connectOptions.keepAliveInterval),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._connectTimeout=new C(this,this.connectOptions.timeout,this._disconnected,[l.CONNECT_TIMEOUT.code,h(l.CONNECT_TIMEOUT)])},R.prototype._schedule_message=function(_){this._msg_queue.unshift(_),this.connected&&this._process_queue()},R.prototype.store=function(_,M){var I={type:M.type,messageIdentifier:M.messageIdentifier,version:1};switch(M.type){case r.PUBLISH:M.pubRecReceived&&(I.pubRecReceived=!0),I.payloadMessage={};for(var O="",B=M.payloadMessage.payloadBytes,D=0;D<B.length;D++)B[D]<=15?O=O+"0"+B[D].toString(16):O=O+B[D].toString(16);I.payloadMessage.payloadHex=O,I.payloadMessage.qos=M.payloadMessage.qos,I.payloadMessage.destinationName=M.payloadMessage.destinationName,M.payloadMessage.duplicate&&(I.payloadMessage.duplicate=!0),M.payloadMessage.retained&&(I.payloadMessage.retained=!0),_.indexOf("Sent:")===0&&(M.sequence===void 0&&(M.sequence=++this._sequence),I.sequence=M.sequence);break;default:throw Error(h(l.INVALID_STORED_DATA,[_+this._localKey+M.messageIdentifier,I]))}s.setItem(_+this._localKey+M.messageIdentifier,JSON.stringify(I))},R.prototype.restore=function(_){var M=s.getItem(_),I=JSON.parse(M),O=new d(I.type,I);switch(I.type){case r.PUBLISH:for(var B=I.payloadMessage.payloadHex,D=new ArrayBuffer(B.length/2),X=new Uint8Array(D),q=0;B.length>=2;){var Q=parseInt(B.substring(0,2),16);B=B.substring(2,B.length),X[q++]=Q}var ae=new b(X);ae.qos=I.payloadMessage.qos,ae.destinationName=I.payloadMessage.destinationName,I.payloadMessage.duplicate&&(ae.duplicate=!0),I.payloadMessage.retained&&(ae.retained=!0),O.payloadMessage=ae;break;default:throw Error(h(l.INVALID_STORED_DATA,[_,M]))}_.indexOf("Sent:"+this._localKey)===0?(O.payloadMessage.duplicate=!0,this._sentMessages[O.messageIdentifier]=O):_.indexOf("Received:"+this._localKey)===0&&(this._receivedMessages[O.messageIdentifier]=O)},R.prototype._process_queue=function(){for(var _=null;_=this._msg_queue.pop();)this._socket_send(_),this._notify_msg_sent[_]&&(this._notify_msg_sent[_](),delete this._notify_msg_sent[_])},R.prototype._requires_ack=function(_){var M=Object.keys(this._sentMessages).length;if(M>this.maxMessageIdentifier)throw Error("Too many messages:"+M);for(;this._sentMessages[this._message_identifier]!==void 0;)this._message_identifier++;_.messageIdentifier=this._message_identifier,this._sentMessages[_.messageIdentifier]=_,_.type===r.PUBLISH&&this.store("Sent:",_),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},R.prototype._on_socket_open=function(){var _=new d(r.CONNECT,this.connectOptions);_.clientId=this.clientId,this._socket_send(_)},R.prototype._on_socket_message=function(_){this._trace("Client._on_socket_message",_.data);for(var M=this._deframeMessages(_.data),I=0;I<M.length;I+=1)this._handleMessage(M[I])},R.prototype._deframeMessages=function(_){var M=new Uint8Array(_),I=[];if(this.receiveBuffer){var O=new Uint8Array(this.receiveBuffer.length+M.length);O.set(this.receiveBuffer),O.set(M,this.receiveBuffer.length),M=O,delete this.receiveBuffer}try{for(var B=0;B<M.length;){var D=y(M,B),X=D[0];if(B=D[1],X!==null)I.push(X);else break}B<M.length&&(this.receiveBuffer=M.subarray(B))}catch(Q){var q=Q.hasOwnProperty("stack")=="undefined"?Q.stack.toString():"No Error Stack Available";this._disconnected(l.INTERNAL_ERROR.code,h(l.INTERNAL_ERROR,[Q.message,q]));return}return I},R.prototype._handleMessage=function(_){this._trace("Client._handleMessage",_);try{switch(_.type){case r.CONNACK:if(this._connectTimeout.cancel(),this._reconnectTimeout&&this._reconnectTimeout.cancel(),this.connectOptions.cleanSession){for(var M in this._sentMessages){var H=this._sentMessages[M];s.removeItem("Sent:"+this._localKey+H.messageIdentifier)}this._sentMessages={};for(var M in this._receivedMessages){var ae=this._receivedMessages[M];s.removeItem("Received:"+this._localKey+ae.messageIdentifier)}this._receivedMessages={}}if(_.returnCode===0)this.connected=!0,this.connectOptions.uris&&(this.hostIndex=this.connectOptions.uris.length);else{this._disconnected(l.CONNACK_RETURNCODE.code,h(l.CONNACK_RETURNCODE,[_.returnCode,c[_.returnCode]]));break}var B=[];for(var I in this._sentMessages)this._sentMessages.hasOwnProperty(I)&&B.push(this._sentMessages[I]);if(this._buffered_msg_queue.length>0)for(var O=null;O=this._buffered_msg_queue.pop();)B.push(O),this.onMessageDelivered&&(this._notify_msg_sent[O]=this.onMessageDelivered(O.payloadMessage));for(var B=B.sort(function(Y,oe){return Y.sequence-oe.sequence}),D=0,X=B.length;D<X;D++){var H=B[D];if(H.type==r.PUBLISH&&H.pubRecReceived){var q=new d(r.PUBREL,{messageIdentifier:H.messageIdentifier});this._schedule_message(q)}else this._schedule_message(H)}this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext});var Q=!1;this._reconnecting&&(Q=!0,this._reconnectInterval=1,this._reconnecting=!1),this._connected(Q,this._wsuri),this._process_queue();break;case r.PUBLISH:this._receivePublish(_);break;case r.PUBACK:var H=this._sentMessages[_.messageIdentifier];H&&(delete this._sentMessages[_.messageIdentifier],s.removeItem("Sent:"+this._localKey+_.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(H.payloadMessage));break;case r.PUBREC:var H=this._sentMessages[_.messageIdentifier];if(H){H.pubRecReceived=!0;var q=new d(r.PUBREL,{messageIdentifier:_.messageIdentifier});this.store("Sent:",H),this._schedule_message(q)}break;case r.PUBREL:var ae=this._receivedMessages[_.messageIdentifier];s.removeItem("Received:"+this._localKey+_.messageIdentifier),ae&&(this._receiveMessage(ae),delete this._receivedMessages[_.messageIdentifier]);var ee=new d(r.PUBCOMP,{messageIdentifier:_.messageIdentifier});this._schedule_message(ee);break;case r.PUBCOMP:var H=this._sentMessages[_.messageIdentifier];delete this._sentMessages[_.messageIdentifier],s.removeItem("Sent:"+this._localKey+_.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(H.payloadMessage);break;case r.SUBACK:var H=this._sentMessages[_.messageIdentifier];H&&(H.timeOut&&H.timeOut.cancel(),_.returnCode[0]===128?H.onFailure&&H.onFailure(_.returnCode):H.onSuccess&&H.onSuccess(_.returnCode),delete this._sentMessages[_.messageIdentifier]);break;case r.UNSUBACK:var H=this._sentMessages[_.messageIdentifier];H&&(H.timeOut&&H.timeOut.cancel(),H.callback&&H.callback(),delete this._sentMessages[_.messageIdentifier]);break;case r.PINGRESP:this.sendPinger.reset();break;case r.DISCONNECT:this._disconnected(l.INVALID_MQTT_MESSAGE_TYPE.code,h(l.INVALID_MQTT_MESSAGE_TYPE,[_.type]));break;default:this._disconnected(l.INVALID_MQTT_MESSAGE_TYPE.code,h(l.INVALID_MQTT_MESSAGE_TYPE,[_.type]))}}catch(Y){var be=Y.hasOwnProperty("stack")=="undefined"?Y.stack.toString():"No Error Stack Available";this._disconnected(l.INTERNAL_ERROR.code,h(l.INTERNAL_ERROR,[Y.message,be]));return}},R.prototype._on_socket_error=function(_){this._reconnecting||this._disconnected(l.SOCKET_ERROR.code,h(l.SOCKET_ERROR,[_.data]))},R.prototype._on_socket_close=function(){this._reconnecting||this._disconnected(l.SOCKET_CLOSE.code,h(l.SOCKET_CLOSE))},R.prototype._socket_send=function(_){if(_.type==1){var M=this._traceMask(_,"password");this._trace("Client._socket_send",M)}else this._trace("Client._socket_send",_);this.socket.send(_.encode()),this.sendPinger.reset()},R.prototype._receivePublish=function(_){switch(_.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(_);break;case 1:var M=new d(r.PUBACK,{messageIdentifier:_.messageIdentifier});this._schedule_message(M),this._receiveMessage(_);break;case 2:this._receivedMessages[_.messageIdentifier]=_,this.store("Received:",_);var I=new d(r.PUBREC,{messageIdentifier:_.messageIdentifier});this._schedule_message(I);break;default:throw Error("Invaild qos="+_.payloadMessage.qos)}},R.prototype._receiveMessage=function(_){this.onMessageArrived&&this.onMessageArrived(_.payloadMessage)},R.prototype._connected=function(_,M){this.onConnected&&this.onConnected(_,M)},R.prototype._reconnect=function(){this._trace("Client._reconnect"),this.connected||(this._reconnecting=!0,this.sendPinger.cancel(),this.receivePinger.cancel(),this._reconnectInterval<128&&(this._reconnectInterval=this._reconnectInterval*2),this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri))},R.prototype._disconnected=function(_,M){if(this._trace("Client._disconnected",_,M),_!==void 0&&this._reconnecting){this._reconnectTimeout=new C(this,this._reconnectInterval,this._reconnect);return}if(this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._msg_queue=[],this._buffered_msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.readyState===1&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndex<this.connectOptions.uris.length-1)this.hostIndex++,this._doConnect(this.connectOptions.uris[this.hostIndex]);else if(_===void 0&&(_=l.OK.code,M=h(l.OK)),this.connected){if(this.connected=!1,this.onConnectionLost&&this.onConnectionLost({errorCode:_,errorMessage:M,reconnect:this.connectOptions.reconnect,uri:this._wsuri}),_!==l.OK.code&&this.connectOptions.reconnect){this._reconnectInterval=1,this._reconnect();return}}else this.connectOptions.mqttVersion===4&&this.connectOptions.mqttVersionExplicit===!1?(this._trace("Failed to connect V4, dropping back to V3"),this.connectOptions.mqttVersion=3,this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri)):this.connectOptions.onFailure&&this.connectOptions.onFailure({invocationContext:this.connectOptions.invocationContext,errorCode:_,errorMessage:M})},R.prototype._trace=function(){if(this.traceFunction){var _=Array.prototype.slice.call(arguments);for(var M in _)typeof _[M]!="undefined"&&_.splice(M,1,JSON.stringify(_[M]));var I=_.join("");this.traceFunction({severity:"Debug",message:I})}if(this._traceBuffer!==null)for(var M=0,O=arguments.length;M<O;M++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),M===0?this._traceBuffer.push(arguments[M]):typeof arguments[M]=="undefined"?this._traceBuffer.push(arguments[M]):this._traceBuffer.push("  "+JSON.stringify(arguments[M]))},R.prototype._traceMask=function(_,M){var I={};for(var O in _)_.hasOwnProperty(O)&&(O==M?I[O]="******":I[O]=_[O]);return I};var ne=function(_,M,I,O){var B;if(typeof _!="string")throw new Error(h(l.INVALID_TYPE,[typeof _,"host"]));if(arguments.length==2){O=M,B=_;var D=B.match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(D)_=D[4]||D[2],M=parseInt(D[7]),I=D[8];else throw new Error(h(l.INVALID_ARGUMENT,[_,"host"]))}else{if(arguments.length==3&&(O=I,I="/mqtt"),typeof M!="number"||M<0)throw new Error(h(l.INVALID_TYPE,[typeof M,"port"]));if(typeof I!="string")throw new Error(h(l.INVALID_TYPE,[typeof I,"path"]));var X=_.indexOf(":")!==-1&&_.slice(0,1)!=="["&&_.slice(-1)!=="]";B="ws://"+(X?"["+_+"]":_)+":"+M+I}for(var q=0,Q=0;Q<O.length;Q++){var ae=O.charCodeAt(Q);55296<=ae&&ae<=56319&&Q++,q++}if(typeof O!="string"||q>65535)throw new Error(h(l.INVALID_ARGUMENT,[O,"clientId"]));var ee=new R(B,_,M,I,O);Object.defineProperties(this,{host:{get:function(){return _},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},port:{get:function(){return M},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},path:{get:function(){return I},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},uri:{get:function(){return B},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},clientId:{get:function(){return ee.clientId},set:function(){throw new Error(h(l.UNSUPPORTED_OPERATION))}},onConnected:{get:function(){return ee.onConnected},set:function(H){if(typeof H=="function")ee.onConnected=H;else throw new Error(h(l.INVALID_TYPE,[typeof H,"onConnected"]))}},disconnectedPublishing:{get:function(){return ee.disconnectedPublishing},set:function(H){ee.disconnectedPublishing=H}},disconnectedBufferSize:{get:function(){return ee.disconnectedBufferSize},set:function(H){ee.disconnectedBufferSize=H}},onConnectionLost:{get:function(){return ee.onConnectionLost},set:function(H){if(typeof H=="function")ee.onConnectionLost=H;else throw new Error(h(l.INVALID_TYPE,[typeof H,"onConnectionLost"]))}},onMessageDelivered:{get:function(){return ee.onMessageDelivered},set:function(H){if(typeof H=="function")ee.onMessageDelivered=H;else throw new Error(h(l.INVALID_TYPE,[typeof H,"onMessageDelivered"]))}},onMessageArrived:{get:function(){return ee.onMessageArrived},set:function(H){if(typeof H=="function")ee.onMessageArrived=H;else throw new Error(h(l.INVALID_TYPE,[typeof H,"onMessageArrived"]))}},trace:{get:function(){return ee.traceFunction},set:function(H){if(typeof H=="function")ee.traceFunction=H;else throw new Error(h(l.INVALID_TYPE,[typeof H,"onTrace"]))}}}),this.connect=function(H){if(H=H||{},o(H,{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",reconnect:"boolean",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),H.keepAliveInterval===void 0&&(H.keepAliveInterval=60),H.mqttVersion>4||H.mqttVersion<3)throw new Error(h(l.INVALID_ARGUMENT,[H.mqttVersion,"connectOptions.mqttVersion"]));if(H.mqttVersion===void 0?(H.mqttVersionExplicit=!1,H.mqttVersion=4):H.mqttVersionExplicit=!0,H.password!==void 0&&H.userName===void 0)throw new Error(h(l.INVALID_ARGUMENT,[H.password,"connectOptions.password"]));if(H.willMessage){if(!(H.willMessage instanceof b))throw new Error(h(l.INVALID_TYPE,[H.willMessage,"connectOptions.willMessage"]));if(H.willMessage.stringPayload=null,typeof H.willMessage.destinationName=="undefined")throw new Error(h(l.INVALID_TYPE,[typeof H.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if(typeof H.cleanSession=="undefined"&&(H.cleanSession=!0),H.hosts){if(!(H.hosts instanceof Array))throw new Error(h(l.INVALID_ARGUMENT,[H.hosts,"connectOptions.hosts"]));if(H.hosts.length<1)throw new Error(h(l.INVALID_ARGUMENT,[H.hosts,"connectOptions.hosts"]));for(var be=!1,Y=0;Y<H.hosts.length;Y++){if(typeof H.hosts[Y]!="string")throw new Error(h(l.INVALID_TYPE,[typeof H.hosts[Y],"connectOptions.hosts["+Y+"]"]));if(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(H.hosts[Y])){if(Y===0)be=!0;else if(!be)throw new Error(h(l.INVALID_ARGUMENT,[H.hosts[Y],"connectOptions.hosts["+Y+"]"]))}else if(be)throw new Error(h(l.INVALID_ARGUMENT,[H.hosts[Y],"connectOptions.hosts["+Y+"]"]))}if(be)H.uris=H.hosts;else{if(!H.ports)throw new Error(h(l.INVALID_ARGUMENT,[H.ports,"connectOptions.ports"]));if(!(H.ports instanceof Array))throw new Error(h(l.INVALID_ARGUMENT,[H.ports,"connectOptions.ports"]));if(H.hosts.length!==H.ports.length)throw new Error(h(l.INVALID_ARGUMENT,[H.ports,"connectOptions.ports"]));H.uris=[];for(var Y=0;Y<H.hosts.length;Y++){if(typeof H.ports[Y]!="number"||H.ports[Y]<0)throw new Error(h(l.INVALID_TYPE,[typeof H.ports[Y],"connectOptions.ports["+Y+"]"]));var oe=H.hosts[Y],he=H.ports[Y],ge=oe.indexOf(":")!==-1;B="ws://"+(ge?"["+oe+"]":oe)+":"+he+I,H.uris.push(B)}}}ee.connect(H)},this.subscribe=function(H,be){if(typeof H!="string"&&H.constructor!==Array)throw new Error("Invalid argument:"+H);if(be=be||{},o(be,{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),be.timeout&&!be.onFailure)throw new Error("subscribeOptions.timeout specified with no onFailure callback.");if(typeof be.qos!="undefined"&&!(be.qos===0||be.qos===1||be.qos===2))throw new Error(h(l.INVALID_ARGUMENT,[be.qos,"subscribeOptions.qos"]));ee.subscribe(H,be)},this.unsubscribe=function(H,be){if(typeof H!="string"&&H.constructor!==Array)throw new Error("Invalid argument:"+H);if(be=be||{},o(be,{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),be.timeout&&!be.onFailure)throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");ee.unsubscribe(H,be)},this.send=function(H,be,Y,oe){var he;if(arguments.length===0)throw new Error("Invalid argument.length");if(arguments.length==1){if(!(H instanceof b)&&typeof H!="string")throw new Error("Invalid argument:"+typeof H);if(he=H,typeof he.destinationName=="undefined")throw new Error(h(l.INVALID_ARGUMENT,[he.destinationName,"Message.destinationName"]));ee.send(he)}else he=new b(be),he.destinationName=H,arguments.length>=3&&(he.qos=Y),arguments.length>=4&&(he.retained=oe),ee.send(he)},this.publish=function(H,be,Y,oe){var he;if(arguments.length===0)throw new Error("Invalid argument.length");if(arguments.length==1){if(!(H instanceof b)&&typeof H!="string")throw new Error("Invalid argument:"+typeof H);if(he=H,typeof he.destinationName=="undefined")throw new Error(h(l.INVALID_ARGUMENT,[he.destinationName,"Message.destinationName"]));ee.send(he)}else he=new b(be),he.destinationName=H,arguments.length>=3&&(he.qos=Y),arguments.length>=4&&(he.retained=oe),ee.send(he)},this.disconnect=function(){ee.disconnect()},this.getTraceLog=function(){return ee.getTraceLog()},this.startTrace=function(){ee.startTrace()},this.stopTrace=function(){ee.stopTrace()},this.isConnected=function(){return ee.connected}},b=function(_){var M;if(typeof _=="string"||_ instanceof ArrayBuffer||ArrayBuffer.isView(_)&&!(_ instanceof DataView))M=_;else throw h(l.INVALID_ARGUMENT,[_,"newPayload"]);var I,O=0,B=!1,D=!1;Object.defineProperties(this,{payloadString:{enumerable:!0,get:function(){return typeof M=="string"?M:N(M,0,M.length)}},payloadBytes:{enumerable:!0,get:function(){if(typeof M=="string"){var X=new ArrayBuffer(x(M)),q=new Uint8Array(X);return S(M,q,0),q}else return M}},destinationName:{enumerable:!0,get:function(){return I},set:function(X){if(typeof X=="string")I=X;else throw new Error(h(l.INVALID_ARGUMENT,[X,"newDestinationName"]))}},qos:{enumerable:!0,get:function(){return O},set:function(X){if(X===0||X===1||X===2)O=X;else throw new Error("Invalid argument:"+X)}},retained:{enumerable:!0,get:function(){return B},set:function(X){if(typeof X=="boolean")B=X;else throw new Error(h(l.INVALID_ARGUMENT,[X,"newRetained"]))}},topic:{enumerable:!0,get:function(){return I},set:function(X){I=X}},duplicate:{enumerable:!0,get:function(){return D},set:function(X){D=X}}})};return{Client:ne,Message:b}}(typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{});return e})});var F_=On((XO,U_)=>{"use strict";T();U_.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var k_=On((qO,B_)=>{T();B_.exports=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")}});var H_=On((YO,V_)=>{"use strict";T();var YS=k_(),KS=Array.prototype.concat,ZS=Array.prototype.slice,z_=V_.exports=function(e){for(var t=[],n=0,s=e.length;n<s;n++){var r=e[n];YS(r)?t=KS.call(t,ZS.call(r)):t.push(r)}return t};z_.wrap=function(i){return function(){return i(z_(arguments))}}});var q_=On((KO,X_)=>{T();var Ul=F_(),Fl=H_(),G_=Object.hasOwnProperty,W_=Object.create(null);for(Gh in Ul)G_.call(Ul,Gh)&&(W_[Ul[Gh]]=Gh);var Gh,Bn=X_.exports={to:{},get:{}};Bn.get=function(i){var e=i.substring(0,3).toLowerCase(),t,n;switch(e){case"hsl":t=Bn.get.hsl(i),n="hsl";break;case"hwb":t=Bn.get.hwb(i),n="hwb";break;default:t=Bn.get.rgb(i),n="rgb";break}return t?{model:n,value:t}:null};Bn.get.rgb=function(i){if(!i)return null;var e=/^#([a-f0-9]{3,4})$/i,t=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,n=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,s=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,r=/^(\w+)$/,o=[0,0,0,1],a,l,c;if(a=i.match(t)){for(c=a[2],a=a[1],l=0;l<3;l++){var h=l*2;o[l]=parseInt(a.slice(h,h+2),16)}c&&(o[3]=parseInt(c,16)/255)}else if(a=i.match(e)){for(a=a[1],c=a[3],l=0;l<3;l++)o[l]=parseInt(a[l]+a[l],16);c&&(o[3]=parseInt(c+c,16)/255)}else if(a=i.match(n)){for(l=0;l<3;l++)o[l]=parseInt(a[l+1],0);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else if(a=i.match(s)){for(l=0;l<3;l++)o[l]=Math.round(parseFloat(a[l+1])*2.55);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else return(a=i.match(r))?a[1]==="transparent"?[0,0,0,0]:G_.call(Ul,a[1])?(o=Ul[a[1]],o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=zs(o[l],0,255);return o[3]=zs(o[3],0,1),o};Bn.get.hsl=function(i){if(!i)return null;var e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,t=i.match(e);if(t){var n=parseFloat(t[4]),s=(parseFloat(t[1])%360+360)%360,r=zs(parseFloat(t[2]),0,100),o=zs(parseFloat(t[3]),0,100),a=zs(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};Bn.get.hwb=function(i){if(!i)return null;var e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,t=i.match(e);if(t){var n=parseFloat(t[4]),s=(parseFloat(t[1])%360+360)%360,r=zs(parseFloat(t[2]),0,100),o=zs(parseFloat(t[3]),0,100),a=zs(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};Bn.to.hex=function(){var i=Fl(arguments);return"#"+Wh(i[0])+Wh(i[1])+Wh(i[2])+(i[3]<1?Wh(Math.round(i[3]*255)):"")};Bn.to.rgb=function(){var i=Fl(arguments);return i.length<4||i[3]===1?"rgb("+Math.round(i[0])+", "+Math.round(i[1])+", "+Math.round(i[2])+")":"rgba("+Math.round(i[0])+", "+Math.round(i[1])+", "+Math.round(i[2])+", "+i[3]+")"};Bn.to.rgb.percent=function(){var i=Fl(arguments),e=Math.round(i[0]/255*100),t=Math.round(i[1]/255*100),n=Math.round(i[2]/255*100);return i.length<4||i[3]===1?"rgb("+e+"%, "+t+"%, "+n+"%)":"rgba("+e+"%, "+t+"%, "+n+"%, "+i[3]+")"};Bn.to.hsl=function(){var i=Fl(arguments);return i.length<4||i[3]===1?"hsl("+i[0]+", "+i[1]+"%, "+i[2]+"%)":"hsla("+i[0]+", "+i[1]+"%, "+i[2]+"%, "+i[3]+")"};Bn.to.hwb=function(){var i=Fl(arguments),e="";return i.length>=4&&i[3]!==1&&(e=", "+i[3]),"hwb("+i[0]+", "+i[1]+"%, "+i[2]+"%"+e+")"};Bn.to.keyword=function(i){return W_[i.slice(0,3)]};function zs(i,e,t){return Math.min(Math.max(e,i),t)}function Wh(i){var e=Math.round(i).toString(16).toUpperCase();return e.length<2?"0"+e:e}});var K_=On((ZO,Y_)=>{"use strict";T();Y_.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var xp=On(($O,$_)=>{T();var Bl=K_(),Z_={};for(let i of Object.keys(Bl))Z_[Bl[i]]=i;var Ee={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};$_.exports=Ee;for(let i of Object.keys(Ee)){if(!("channels"in Ee[i]))throw new Error("missing channels property: "+i);if(!("labels"in Ee[i]))throw new Error("missing channel labels property: "+i);if(Ee[i].labels.length!==Ee[i].channels)throw new Error("channel and label counts mismatch: "+i);let{channels:e,labels:t}=Ee[i];delete Ee[i].channels,delete Ee[i].labels,Object.defineProperty(Ee[i],"channels",{value:e}),Object.defineProperty(Ee[i],"labels",{value:t})}Ee.rgb.hsl=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=r-s,a,l;r===s?a=0:e===r?a=(t-n)/o:t===r?a=2+(n-e)/o:n===r&&(a=4+(e-t)/o),a=Math.min(a*60,360),a<0&&(a+=360);let c=(s+r)/2;return r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};Ee.rgb.hsv=function(i){let e,t,n,s,r,o=i[0]/255,a=i[1]/255,l=i[2]/255,c=Math.max(o,a,l),h=c-Math.min(o,a,l),u=function(f){return(c-f)/6/h+1/2};return h===0?(s=0,r=0):(r=h/c,e=u(o),t=u(a),n=u(l),o===c?s=n-t:a===c?s=1/3+e-n:l===c&&(s=2/3+t-e),s<0?s+=1:s>1&&(s-=1)),[s*360,r*100,c*100]};Ee.rgb.hwb=function(i){let e=i[0],t=i[1],n=i[2],s=Ee.rgb.hsl(i)[0],r=1/255*Math.min(e,Math.min(t,n));return n=1-1/255*Math.max(e,Math.max(t,n)),[s,r*100,n*100]};Ee.rgb.cmyk=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.min(1-e,1-t,1-n),r=(1-e-s)/(1-s)||0,o=(1-t-s)/(1-s)||0,a=(1-n-s)/(1-s)||0;return[r*100,o*100,a*100,s*100]};function $S(i,e){return(i[0]-e[0])**2+(i[1]-e[1])**2+(i[2]-e[2])**2}Ee.rgb.keyword=function(i){let e=Z_[i];if(e)return e;let t=1/0,n;for(let s of Object.keys(Bl)){let r=Bl[s],o=$S(i,r);o<t&&(t=o,n=s)}return n};Ee.keyword.rgb=function(i){return Bl[i]};Ee.rgb.xyz=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let s=e*.4124+t*.3576+n*.1805,r=e*.2126+t*.7152+n*.0722,o=e*.0193+t*.1192+n*.9505;return[s*100,r*100,o*100]};Ee.rgb.lab=function(i){let e=Ee.rgb.xyz(i),t=e[0],n=e[1],s=e[2];t/=95.047,n/=100,s/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116;let r=116*n-16,o=500*(t-n),a=200*(n-s);return[r,o,a]};Ee.hsl.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100,s,r,o;if(t===0)return o=n*255,[o,o,o];n<.5?s=n*(1+t):s=n+t-n*t;let a=2*n-s,l=[0,0,0];for(let c=0;c<3;c++)r=e+1/3*-(c-1),r<0&&r++,r>1&&r--,6*r<1?o=a+(s-a)*6*r:2*r<1?o=s:3*r<2?o=a+(s-a)*(2/3-r)*6:o=a,l[c]=o*255;return l};Ee.hsl.hsv=function(i){let e=i[0],t=i[1]/100,n=i[2]/100,s=t,r=Math.max(n,.01);n*=2,t*=n<=1?n:2-n,s*=r<=1?r:2-r;let o=(n+t)/2,a=n===0?2*s/(r+s):2*t/(n+t);return[e,a*100,o*100]};Ee.hsv.rgb=function(i){let e=i[0]/60,t=i[1]/100,n=i[2]/100,s=Math.floor(e)%6,r=e-Math.floor(e),o=255*n*(1-t),a=255*n*(1-t*r),l=255*n*(1-t*(1-r));switch(n*=255,s){case 0:return[n,l,o];case 1:return[a,n,o];case 2:return[o,n,l];case 3:return[o,a,n];case 4:return[l,o,n];case 5:return[n,o,a]}};Ee.hsv.hsl=function(i){let e=i[0],t=i[1]/100,n=i[2]/100,s=Math.max(n,.01),r,o;o=(2-t)*n;let a=(2-t)*s;return r=t*s,r/=a<=1?a:2-a,r=r||0,o/=2,[e,r*100,o*100]};Ee.hwb.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100,s=t+n,r;s>1&&(t/=s,n/=s);let o=Math.floor(6*e),a=1-n;r=6*e-o,(o&1)!==0&&(r=1-r);let l=t+r*(a-t),c,h,u;switch(o){default:case 6:case 0:c=a,h=l,u=t;break;case 1:c=l,h=a,u=t;break;case 2:c=t,h=a,u=l;break;case 3:c=t,h=l,u=a;break;case 4:c=l,h=t,u=a;break;case 5:c=a,h=t,u=l;break}return[c*255,h*255,u*255]};Ee.cmyk.rgb=function(i){let e=i[0]/100,t=i[1]/100,n=i[2]/100,s=i[3]/100,r=1-Math.min(1,e*(1-s)+s),o=1-Math.min(1,t*(1-s)+s),a=1-Math.min(1,n*(1-s)+s);return[r*255,o*255,a*255]};Ee.xyz.rgb=function(i){let e=i[0]/100,t=i[1]/100,n=i[2]/100,s,r,o;return s=e*3.2406+t*-1.5372+n*-.4986,r=e*-.9689+t*1.8758+n*.0415,o=e*.0557+t*-.204+n*1.057,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,r=r>.0031308?1.055*r**(1/2.4)-.055:r*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),[s*255,r*255,o*255]};Ee.xyz.lab=function(i){let e=i[0],t=i[1],n=i[2];e/=95.047,t/=100,n/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let s=116*t-16,r=500*(e-t),o=200*(t-n);return[s,r,o]};Ee.lab.xyz=function(i){let e=i[0],t=i[1],n=i[2],s,r,o;r=(e+16)/116,s=t/500+r,o=r-n/200;let a=r**3,l=s**3,c=o**3;return r=a>.008856?a:(r-16/116)/7.787,s=l>.008856?l:(s-16/116)/7.787,o=c>.008856?c:(o-16/116)/7.787,s*=95.047,r*=100,o*=108.883,[s,r,o]};Ee.lab.lch=function(i){let e=i[0],t=i[1],n=i[2],s;s=Math.atan2(n,t)*360/2/Math.PI,s<0&&(s+=360);let o=Math.sqrt(t*t+n*n);return[e,o,s]};Ee.lch.lab=function(i){let e=i[0],t=i[1],s=i[2]/360*2*Math.PI,r=t*Math.cos(s),o=t*Math.sin(s);return[e,r,o]};Ee.rgb.ansi16=function(i,e=null){let[t,n,s]=i,r=e===null?Ee.rgb.hsv(i)[2]:e;if(r=Math.round(r/50),r===0)return 30;let o=30+(Math.round(s/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return r===2&&(o+=60),o};Ee.hsv.ansi16=function(i){return Ee.rgb.ansi16(Ee.hsv.rgb(i),i[2])};Ee.rgb.ansi256=function(i){let e=i[0],t=i[1],n=i[2];return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)};Ee.ansi16.rgb=function(i){let e=i%10;if(e===0||e===7)return i>50&&(e+=3.5),e=e/10.5*255,[e,e,e];let t=(~~(i>50)+1)*.5,n=(e&1)*t*255,s=(e>>1&1)*t*255,r=(e>>2&1)*t*255;return[n,s,r]};Ee.ansi256.rgb=function(i){if(i>=232){let r=(i-232)*10+8;return[r,r,r]}i-=16;let e,t=Math.floor(i/36)/5*255,n=Math.floor((e=i%36)/6)/5*255,s=e%6/5*255;return[t,n,s]};Ee.rgb.hex=function(i){let t=(((Math.round(i[0])&255)<<16)+((Math.round(i[1])&255)<<8)+(Math.round(i[2])&255)).toString(16).toUpperCase();return"000000".substring(t.length)+t};Ee.hex.rgb=function(i){let e=i.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let t=e[0];e[0].length===3&&(t=t.split("").map(a=>a+a).join(""));let n=parseInt(t,16),s=n>>16&255,r=n>>8&255,o=n&255;return[s,r,o]};Ee.rgb.hcg=function(i){let e=i[0]/255,t=i[1]/255,n=i[2]/255,s=Math.max(Math.max(e,t),n),r=Math.min(Math.min(e,t),n),o=s-r,a,l;return o<1?a=r/(1-o):a=0,o<=0?l=0:s===e?l=(t-n)/o%6:s===t?l=2+(n-e)/o:l=4+(e-t)/o,l/=6,l%=1,[l*360,o*100,a*100]};Ee.hsl.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=t<.5?2*e*t:2*e*(1-t),s=0;return n<1&&(s=(t-.5*n)/(1-n)),[i[0],n*100,s*100]};Ee.hsv.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=e*t,s=0;return n<1&&(s=(t-n)/(1-n)),[i[0],n*100,s*100]};Ee.hcg.rgb=function(i){let e=i[0]/360,t=i[1]/100,n=i[2]/100;if(t===0)return[n*255,n*255,n*255];let s=[0,0,0],r=e%1*6,o=r%1,a=1-o,l=0;switch(Math.floor(r)){case 0:s[0]=1,s[1]=o,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=o;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=o,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-t)*n,[(t*s[0]+l)*255,(t*s[1]+l)*255,(t*s[2]+l)*255]};Ee.hcg.hsv=function(i){let e=i[1]/100,t=i[2]/100,n=e+t*(1-e),s=0;return n>0&&(s=e/n),[i[0],s*100,n*100]};Ee.hcg.hsl=function(i){let e=i[1]/100,n=i[2]/100*(1-e)+.5*e,s=0;return n>0&&n<.5?s=e/(2*n):n>=.5&&n<1&&(s=e/(2*(1-n))),[i[0],s*100,n*100]};Ee.hcg.hwb=function(i){let e=i[1]/100,t=i[2]/100,n=e+t*(1-e);return[i[0],(n-e)*100,(1-n)*100]};Ee.hwb.hcg=function(i){let e=i[1]/100,t=i[2]/100,n=1-t,s=n-e,r=0;return s<1&&(r=(n-s)/(1-s)),[i[0],s*100,r*100]};Ee.apple.rgb=function(i){return[i[0]/65535*255,i[1]/65535*255,i[2]/65535*255]};Ee.rgb.apple=function(i){return[i[0]/255*65535,i[1]/255*65535,i[2]/255*65535]};Ee.gray.rgb=function(i){return[i[0]/100*255,i[0]/100*255,i[0]/100*255]};Ee.gray.hsl=function(i){return[0,0,i[0]]};Ee.gray.hsv=Ee.gray.hsl;Ee.gray.hwb=function(i){return[0,100,i[0]]};Ee.gray.cmyk=function(i){return[0,0,0,i[0]]};Ee.gray.lab=function(i){return[i[0],0,0]};Ee.gray.hex=function(i){let e=Math.round(i[0]/100*255)&255,n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n};Ee.rgb.gray=function(i){return[(i[0]+i[1]+i[2])/3/255*100]}});var J_=On((jO,j_)=>{T();var Xh=xp();function jS(){let i={},e=Object.keys(Xh);for(let t=e.length,n=0;n<t;n++)i[e[n]]={distance:-1,parent:null};return i}function JS(i){let e=jS(),t=[i];for(e[i].distance=0;t.length;){let n=t.pop(),s=Object.keys(Xh[n]);for(let r=s.length,o=0;o<r;o++){let a=s[o],l=e[a];l.distance===-1&&(l.distance=e[n].distance+1,l.parent=n,t.unshift(a))}}return e}function QS(i,e){return function(t){return e(i(t))}}function ew(i,e){let t=[e[i].parent,i],n=Xh[e[i].parent][i],s=e[i].parent;for(;e[s].parent;)t.unshift(e[s].parent),n=QS(Xh[e[s].parent][s],n),s=e[s].parent;return n.conversion=t,n}j_.exports=function(i){let e=JS(i),t={},n=Object.keys(e);for(let s=n.length,r=0;r<s;r++){let o=n[r];e[o].parent!==null&&(t[o]=ew(o,e))}return t}});var ev=On((JO,Q_)=>{T();var bp=xp(),tw=J_(),ea={},nw=Object.keys(bp);function iw(i){let e=function(...t){let n=t[0];return n==null?n:(n.length>1&&(t=n),i(t))};return"conversion"in i&&(e.conversion=i.conversion),e}function sw(i){let e=function(...t){let n=t[0];if(n==null)return n;n.length>1&&(t=n);let s=i(t);if(typeof s=="object")for(let r=s.length,o=0;o<r;o++)s[o]=Math.round(s[o]);return s};return"conversion"in i&&(e.conversion=i.conversion),e}nw.forEach(i=>{ea[i]={},Object.defineProperty(ea[i],"channels",{value:bp[i].channels}),Object.defineProperty(ea[i],"labels",{value:bp[i].labels});let e=tw(i);Object.keys(e).forEach(n=>{let s=e[n];ea[i][n]=sw(s),ea[i][n].raw=iw(s)})});Q_.exports=ea});var iv=On((QO,nv)=>{T();var ta=q_(),kn=ev(),tv=["keyword","gray","hex"],Mp={};for(let i of Object.keys(kn))Mp[[...kn[i].labels].sort().join("")]=i;var qh={};function Qt(i,e){if(!(this instanceof Qt))return new Qt(i,e);if(e&&e in tv&&(e=null),e&&!(e in kn))throw new Error("Unknown model: "+e);let t,n;if(i==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(i instanceof Qt)this.model=i.model,this.color=[...i.color],this.valpha=i.valpha;else if(typeof i=="string"){let s=ta.get(i);if(s===null)throw new Error("Unable to parse color from string: "+i);this.model=s.model,n=kn[this.model].channels,this.color=s.value.slice(0,n),this.valpha=typeof s.value[n]=="number"?s.value[n]:1}else if(i.length>0){this.model=e||"rgb",n=kn[this.model].channels;let s=Array.prototype.slice.call(i,0,n);this.color=Sp(s,n),this.valpha=typeof i[n]=="number"?i[n]:1}else if(typeof i=="number")this.model="rgb",this.color=[i>>16&255,i>>8&255,i&255],this.valpha=1;else{this.valpha=1;let s=Object.keys(i);"alpha"in i&&(s.splice(s.indexOf("alpha"),1),this.valpha=typeof i.alpha=="number"?i.alpha:0);let r=s.sort().join("");if(!(r in Mp))throw new Error("Unable to parse color from object: "+JSON.stringify(i));this.model=Mp[r];let{labels:o}=kn[this.model],a=[];for(t=0;t<o.length;t++)a.push(i[o[t]]);this.color=Sp(a)}if(qh[this.model])for(n=kn[this.model].channels,t=0;t<n;t++){let s=qh[this.model][t];s&&(this.color[t]=s(this.color[t]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}Qt.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(i){let e=this.model in ta.to?this:this.rgb();e=e.round(typeof i=="number"?i:1);let t=e.valpha===1?e.color:[...e.color,this.valpha];return ta.to[e.model](t)},percentString(i){let e=this.rgb().round(typeof i=="number"?i:1),t=e.valpha===1?e.color:[...e.color,this.valpha];return ta.to.rgb.percent(t)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let i={},{channels:e}=kn[this.model],{labels:t}=kn[this.model];for(let n=0;n<e;n++)i[t[n]]=this.color[n];return this.valpha!==1&&(i.alpha=this.valpha),i},unitArray(){let i=this.rgb().color;return i[0]/=255,i[1]/=255,i[2]/=255,this.valpha!==1&&i.push(this.valpha),i},unitObject(){let i=this.rgb().object();return i.r/=255,i.g/=255,i.b/=255,this.valpha!==1&&(i.alpha=this.valpha),i},round(i){return i=Math.max(i||0,0),new Qt([...this.color.map(ow(i)),this.valpha],this.model)},alpha(i){return i!==void 0?new Qt([...this.color,Math.max(0,Math.min(1,i))],this.model):this.valpha},red:Rt("rgb",0,Kt(255)),green:Rt("rgb",1,Kt(255)),blue:Rt("rgb",2,Kt(255)),hue:Rt(["hsl","hsv","hsl","hwb","hcg"],0,i=>(i%360+360)%360),saturationl:Rt("hsl",1,Kt(100)),lightness:Rt("hsl",2,Kt(100)),saturationv:Rt("hsv",1,Kt(100)),value:Rt("hsv",2,Kt(100)),chroma:Rt("hcg",1,Kt(100)),gray:Rt("hcg",2,Kt(100)),white:Rt("hwb",1,Kt(100)),wblack:Rt("hwb",2,Kt(100)),cyan:Rt("cmyk",0,Kt(100)),magenta:Rt("cmyk",1,Kt(100)),yellow:Rt("cmyk",2,Kt(100)),black:Rt("cmyk",3,Kt(100)),x:Rt("xyz",0,Kt(95.047)),y:Rt("xyz",1,Kt(100)),z:Rt("xyz",2,Kt(108.833)),l:Rt("lab",0,Kt(100)),a:Rt("lab",1),b:Rt("lab",2),keyword(i){return i!==void 0?new Qt(i):kn[this.model].keyword(this.color)},hex(i){return i!==void 0?new Qt(i):ta.to.hex(this.rgb().round().color)},hexa(i){if(i!==void 0)return new Qt(i);let e=this.rgb().round().color,t=Math.round(this.valpha*255).toString(16).toUpperCase();return t.length===1&&(t="0"+t),ta.to.hex(e)+t},rgbNumber(){let i=this.rgb().color;return(i[0]&255)<<16|(i[1]&255)<<8|i[2]&255},luminosity(){let i=this.rgb().color,e=[];for(let[t,n]of i.entries()){let s=n/255;e[t]=s<=.04045?s/12.92:((s+.055)/1.055)**2.4}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(i){let e=this.luminosity(),t=i.luminosity();return e>t?(e+.05)/(t+.05):(t+.05)/(e+.05)},level(i){let e=this.contrast(i);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){let i=this.rgb().color;return(i[0]*2126+i[1]*7152+i[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let i=this.rgb();for(let e=0;e<3;e++)i.color[e]=255-i.color[e];return i},lighten(i){let e=this.hsl();return e.color[2]+=e.color[2]*i,e},darken(i){let e=this.hsl();return e.color[2]-=e.color[2]*i,e},saturate(i){let e=this.hsl();return e.color[1]+=e.color[1]*i,e},desaturate(i){let e=this.hsl();return e.color[1]-=e.color[1]*i,e},whiten(i){let e=this.hwb();return e.color[1]+=e.color[1]*i,e},blacken(i){let e=this.hwb();return e.color[2]+=e.color[2]*i,e},grayscale(){let i=this.rgb().color,e=i[0]*.3+i[1]*.59+i[2]*.11;return Qt.rgb(e,e,e)},fade(i){return this.alpha(this.valpha-this.valpha*i)},opaquer(i){return this.alpha(this.valpha+this.valpha*i)},rotate(i){let e=this.hsl(),t=e.color[0];return t=(t+i)%360,t=t<0?360+t:t,e.color[0]=t,e},mix(i,e){if(!i||!i.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof i);let t=i.rgb(),n=this.rgb(),s=e===void 0?.5:e,r=2*s-1,o=t.alpha()-n.alpha(),a=((r*o===-1?r:(r+o)/(1+r*o))+1)/2,l=1-a;return Qt.rgb(a*t.red()+l*n.red(),a*t.green()+l*n.green(),a*t.blue()+l*n.blue(),t.alpha()*s+n.alpha()*(1-s))}};for(let i of Object.keys(kn)){if(tv.includes(i))continue;let{channels:e}=kn[i];Qt.prototype[i]=function(...t){return this.model===i?new Qt(this):t.length>0?new Qt(t,i):new Qt([...aw(kn[this.model][i].raw(this.color)),this.valpha],i)},Qt[i]=function(...t){let n=t[0];return typeof n=="number"&&(n=Sp(t,e)),new Qt(n,i)}}function rw(i,e){return Number(i.toFixed(e))}function ow(i){return function(e){return rw(e,i)}}function Rt(i,e,t){i=Array.isArray(i)?i:[i];for(let n of i)(qh[n]||(qh[n]=[]))[e]=t;return i=i[0],function(n){let s;return n!==void 0?(t&&(n=t(n)),s=this[i](),s.color[e]=n,s):(s=this[i]().color[e],t&&(s=t(s)),s)}}function Kt(i){return function(e){return Math.max(0,Math.min(i,e))}}function aw(i){return Array.isArray(i)?i:[i]}function Sp(i,e){for(let t=0;t<e;t++)typeof i[t]!="number"&&(i[t]=0);return i}nv.exports=Qt});var cM=On((HF,lM)=>{"use strict";T();var d2=function(e){return p2(e)&&!m2(e)};function p2(i){return!!i&&typeof i=="object"}function m2(i){var e=Object.prototype.toString.call(i);return e==="[object RegExp]"||e==="[object Date]"||_2(i)}var g2=typeof Symbol=="function"&&Symbol.for,y2=g2?Symbol.for("react.element"):60103;function _2(i){return i.$$typeof===y2}function v2(i){return Array.isArray(i)?[]:{}}function uh(i,e){return e.clone!==!1&&e.isMergeableObject(i)?ml(v2(i),i,e):i}function x2(i,e,t){return i.concat(e).map(function(n){return uh(n,t)})}function b2(i,e){if(!e.customMerge)return ml;var t=e.customMerge(i);return typeof t=="function"?t:ml}function M2(i){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(i).filter(function(e){return Object.propertyIsEnumerable.call(i,e)}):[]}function oM(i){return Object.keys(i).concat(M2(i))}function aM(i,e){try{return e in i}catch{return!1}}function S2(i,e){return aM(i,e)&&!(Object.hasOwnProperty.call(i,e)&&Object.propertyIsEnumerable.call(i,e))}function w2(i,e,t){var n={};return t.isMergeableObject(i)&&oM(i).forEach(function(s){n[s]=uh(i[s],t)}),oM(e).forEach(function(s){S2(i,s)||(aM(i,s)&&t.isMergeableObject(e[s])?n[s]=b2(s,t)(i[s],e[s],t):n[s]=uh(e[s],t))}),n}function ml(i,e,t){t=t||{},t.arrayMerge=t.arrayMerge||x2,t.isMergeableObject=t.isMergeableObject||d2,t.cloneUnlessOtherwiseSpecified=uh;var n=Array.isArray(e),s=Array.isArray(i),r=n===s;return r?n?t.arrayMerge(i,e,t):w2(i,e,t):uh(e,t)}ml.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,s){return ml(n,s,t)},{})};var A2=ml;lM.exports=A2});var L2={};xy(L2,{BadgeRenderer:()=>kt,FloorSelector:()=>xu,LiveDataManager:()=>Yt,LogEvents:()=>bt,Logger:()=>Bt,MapsIndoors:()=>Gi,PositionControl:()=>hd,PositionState:()=>Lt,UserRole:()=>ko,directions:()=>I2,mapView:()=>T2,services:()=>C2});T();T();T();T();var Ad=ln(gd());T();var Py=ln(ii());T();var _d=class{constructor(e,t){this.id=e,this.name=t}},ko=_d;var ji,Sr,zo,vd=class extends Py.EventEmitter{constructor(){super();U(this,ji,void 0);U(this,Sr,void 0);U(this,zo,void 0);let t=document.currentScript||function(){let n=document.getElementsByTagName("script");return n[n.length-1]}();if(t){let n=new URL(t.src).searchParams;W(this,ji,n.get("language")||n.get("lr")||navigator.language||navigator.userLanguage||"en"),W(this,Sr,n.get("apikey")||n.get("apiKey")||void 0)}else W(this,ji,"en");this._userRoles=null,this._venuesToSync=[],this.eventLoggingEnabled=!0}get bookingServiceUrl(){return"https://booking.mapsindoors.com/{{API_KEY}}/api/booking"}get apiUrl(){return $[0]}get apiUrls(){return $}get language(){return g(this,ji)}set language(t){t>""&&t!==g(this,ji)&&(W(this,ji,t),this.emit("language_changed",{lr:g(this,ji)}))}get apiKey(){return g(this,Sr)}set apiKey(t){t!==g(this,Sr)&&(W(this,Sr,t),this.emit("apikey_changed",{apiKey:this.apiKey}))}set authToken(t){this._authToken=t,this.emit("authtoken_changed",{authToken:this.authToken})}get authToken(){return this._authToken}get version(){return"4.38.1"}get userRoles(){return this._userRoles}set userRoles(t=[]){this._userRoles=[].concat(t).filter(n=>n instanceof ko),this.emit("userroles_changed",{userRoles:this.userRoles})}get venuesToSync(){return this._venuesToSync}set venuesToSync(t=[]){this._venuesToSync=[].concat(t),this.emit("venuestosync_changed",{venuesToSync:this.venuesToSync})}get eventLoggingEnabled(){return g(this,zo)===!0}set eventLoggingEnabled(t=!1){W(this,zo,t===!0),g(this,zo)?this.emit("eventlogging_enabled"):this.emit("eventlogging_disabled")}};ji=new WeakMap,Sr=new WeakMap,zo=new WeakMap;var de=new vd;var Sd=(0,Ad.storageFactory)(()=>localStorage),Ny=(0,Ad.storageFactory)(()=>sessionStorage),yl=new Map,Ho,wd=class{constructor(){U(this,Ho,void 0)}getJson(e,t={}){return this.get(e,t).then(Oy)}prepareUrl(e,t,n){if(t.substr(0,2)==="~/")return`${e}/${t.substr(2)}${n!=null?n:""}`;if(/^http(s)?:\/\//i.test(t))return t=t.replace("{{API_KEY}}",de.apiKey),`${t}${n!=null?n:""}`;if(de.apiKey)return`${e}/${de.apiKey}/api/${t}${n!=null?n:""}`;throw Error("Missing api key!")}delete(e,t={}){return this.getApiConfig().then(xd).then(bd).then(({headers:n,apiHost:s})=>{let r=_h(t.search),o=this.prepareUrl(s,e,r);return n=Object.assign({},n,t.headers),fetch(encodeURI(o),{method:"DELETE",headers:n}).then(Md).catch(a=>{if(a instanceof Vo){if(a.status===401)return this.getApiConfig().then(yh).then(()=>this.delete(e,t));throw a}return this.getApiConfig(!1).then(()=>this.delete(e,t))})})}post(e,t={}){return this.getApiConfig().then(xd).then(bd).then(({headers:n,apiHost:s})=>{let r=JSON.stringify(t.body||""),o=_h(t.search);n=Object.assign({},{"Content-Type":"application/json","Content-Length":r.length},n,t.headers);let a=this.prepareUrl(s,e,o);return fetch(encodeURI(a),{method:"POST",headers:n,body:r}).then(Md).catch(c=>{if(c instanceof Vo){if(c.status===401)return this.getApiConfig().then(yh).then(()=>this.post(e,t));throw c}return this.getApiConfig(!1).then(()=>this.post(e,t))})})}get(e,t={}){return this.getApiConfig().then(xd).then(bd).then(({headers:n,apiHost:s})=>{let r=_h(t.search),o=this.prepareUrl(s,e,r);n=Object.assign({},n,t.headers);let a=zM(o,n);if(yl.has(a))return yl.get(a);let l=fetch(encodeURI(o),{headers:n}).then(Md).then(c=>(yl.delete(a),c)).catch(c=>{if(yl.delete(a),c instanceof Vo){if(c.status===401)return this.getApiConfig().then(yh).then(()=>this.get(e,t));throw c}return this.getApiConfig(!1).then(()=>this.get(e,t))});return yl.set(a,l),l})}getApiConfig(e=!0){let t=DM();return e&&g(this,Ho)?g(this,Ho):W(this,Ho,NM(t).then(UM).then(yh).then(FM))}sendLogPackage(e){let t=`~/${e.apiKey}/api/logPackage`;return this.getApiConfig().then(({apiHost:n})=>{let s=this.prepareUrl(n,t),r=new Blob([JSON.stringify(e)],{type:"application/json",length:e.length});return navigator==null?void 0:navigator.sendBeacon(s,r)})}};Ho=new WeakMap;var lt=new wd;function _h(i={}){return i.lr=i.lr||de.language,i=Object.keys(i).reduce((e,t)=>{let n=i[t];return n instanceof Array&&n.length>0?e.push(n.map(s=>`${t}=${s}`).join("&")):(n==null?void 0:n.toString())>""&&!(n instanceof Object)&&e.push(`${t}=${n}`),e},[]),i=i.join("&"),i>""?"?"+i:""}function xd({sessionToken:i,apiHost:e,headers:t={},...n}){return t["mapsindoors-sdk-version"]=`jsapi/${de.version}`,t["mapsindoors-session-token"]=i,{apiHost:e,headers:t,...n}}function bd({apiHost:i,headers:e,...t}){return de.authToken&&(e.Authorization=`Bearer ${de.authToken}`),{apiHost:i,headers:e,...t}}function NM(i){return OM(i.map(e=>BM(`${e}/api`))).then(e=>(e.apiHost=kM(e.apiHost),e))}function OM(i){return new Promise((t,n)=>{Promise.all(i).then(s=>{s.every(r=>e(r))&&n("Unable to reach any of the backend servers! Are you offline?")});for(let s of i)Promise.resolve(s).then(r=>{e(r)||t(r)})});function e(t){return t instanceof Error}}function DM(){let i=Sd.getItem("mi:apiUrls");return i>""?i.split(";"):de.apiUrls}function UM(i){let e=Sd.getItem("mi:apiUrls"),t=i.backendUrls.join(";");return e!==t&&Sd.setItem("mi:apiUrls",t),i}function yh(i){return new Promise(e=>{if(i.authRequired&&i.authRequired===!0){let t=Object.freeze({authIssuer:i.authIssuer,authClients:i.authClients});de.once("authtoken_changed",()=>{e(i)}),mapsindoors.MapsIndoors.onAuthRequired.call(null,t)}else e(i)})}function FM(i){return Ny.getItem("mi:sessionToken")||Ny.setItem("mi:sessionToken",i.sessionToken),i}function BM(i){return fetch(i).then(Oy).then(e=>Object.assign({apiHost:i},e)).catch(e=>e)}function Oy(i){return i.clone().json()}function Md(i){return i.ok?i:i.text().then(e=>{throw new Vo(e||i.statusText||"Unknown error!",i.status)})}function kM(i){return new URL(i).origin}var Vo=class extends Error{constructor(e,t){super(e),this.name="HttpError",this.status=t}};function zM(i,e){return`${i};${Object.entries(e).flatMap(t=>t.join(":")).join(";")}`}function Cs(i,e){let t=_h(e);return btoa(`${i}${t}`)}var Uy=ln(gd()),Dy=(0,Uy.storageFactory)(()=>sessionStorage),Ls=class{static getConfig(){return new Promise(e=>{var t;if(!de.apiKey)de.once("apikey_changed",()=>{Ls.getConfig().then(e)});else{let n=`mi:appConfig:${de.apiKey}:${de.language}`,s=(t=JSON.parse(Dy.getItem(n)))!=null?t:lt.getJson("~/sync/appconfig/",{search:{solutionId:de.apiKey}}).then(r=>(Dy.setItem(n,JSON.stringify(r)),r));e(s)}})}};T();T();T();T();T();var Fy=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function VM(i){return typeof i=="string"&&Fy.test(i)}var By=VM;function HM(i){if(!By(i))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(i.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(i.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(i.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(i.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(i.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var ky=HM;T();var rn=[];for(vh=0;vh<256;++vh)rn.push((vh+256).toString(16).slice(1));var vh;function xh(i,e=0){return(rn[i[e+0]]+rn[i[e+1]]+rn[i[e+2]]+rn[i[e+3]]+"-"+rn[i[e+4]]+rn[i[e+5]]+"-"+rn[i[e+6]]+rn[i[e+7]]+"-"+rn[i[e+8]]+rn[i[e+9]]+"-"+rn[i[e+10]]+rn[i[e+11]]+rn[i[e+12]]+rn[i[e+13]]+rn[i[e+14]]+rn[i[e+15]]).toLowerCase()}T();var bh,GM=new Uint8Array(16);function Ed(){if(!bh&&(bh=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!bh))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return bh(GM)}T();function WM(i){i=unescape(encodeURIComponent(i));for(var e=[],t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var XM="6ba7b810-9dad-11d1-80b4-00c04fd430c8",qM="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Td(i,e,t){function n(s,r,o,a){var l;if(typeof s=="string"&&(s=WM(s)),typeof r=="string"&&(r=ky(r)),((l=r)===null||l===void 0?void 0:l.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var c=new Uint8Array(16+s.length);if(c.set(r),c.set(s,r.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,o){a=a||0;for(var h=0;h<16;++h)o[a+h]=c[h];return o}return xh(c)}try{n.name=i}catch{}return n.DNS=XM,n.URL=qM,n}T();T();var YM=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Id={randomUUID:YM};function KM(i,e,t){if(Id.randomUUID&&!e&&!i)return Id.randomUUID();i=i||{};var n=i.random||(i.rng||Ed)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=n[s];return e}return xh(n)}var _l=KM;T();T();function ZM(i,e,t,n){switch(i){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function Rd(i,e){return i<<e|i>>>32-e}function $M(i){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){var n=unescape(encodeURIComponent(i));i=[];for(var s=0;s<n.length;++s)i.push(n.charCodeAt(s))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);for(var r=i.length/4+2,o=Math.ceil(r/16),a=new Array(o),l=0;l<o;++l){for(var c=new Uint32Array(16),h=0;h<16;++h)c[h]=i[l*64+h*4]<<24|i[l*64+h*4+1]<<16|i[l*64+h*4+2]<<8|i[l*64+h*4+3];a[l]=c}a[o-1][14]=(i.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(i.length-1)*8&4294967295;for(var u=0;u<o;++u){for(var f=new Uint32Array(80),d=0;d<16;++d)f[d]=a[u][d];for(var y=16;y<80;++y)f[y]=Rd(f[y-3]^f[y-8]^f[y-14]^f[y-16],1);for(var v=t[0],p=t[1],m=t[2],A=t[3],x=t[4],S=0;S<80;++S){var N=Math.floor(S/20),P=Rd(v,5)+ZM(N,p,m,A)+x+e[N]+f[S]>>>0;x=A,A=m,m=Rd(p,30)>>>0,p=v,v=P}t[0]=t[0]+v>>>0,t[1]=t[1]+p>>>0,t[2]=t[2]+m>>>0,t[3]=t[3]+A>>>0,t[4]=t[4]+x>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var zy=$M;var jM=Td("v5",80,zy),si=jM;T();T();var Vy=ln(ii());var Cd,ft,Pd=class extends Vy.default{constructor(t){super();U(this,ft,void 0);JM(t)?W(this,ft,t):W(this,ft,new Map)}getItem(t){if(Mh(t))return g(this,ft)instanceof Map?g(this,ft).get(t):g(this,ft).getItem(t)}setItem(t,n){Mh(t)&&Mh(n)&&(g(this,ft)instanceof Map?g(this,ft).set(t,n):g(this,ft).setItem(t,n),this.emit("itemSet"))}removeItem(t){Mh(t)&&(g(this,ft)instanceof Map?g(this,ft).delete(t):g(this,ft).removeItem(t),this.emit("itemRemoved"))}clear(){g(this,ft).clear()}key(t){if(Number.isInteger(t))return g(this,ft)instanceof Map?Array.from(g(this,ft).keys())[t]||null:g(this,ft).key(t)}keys(){return g(this,ft)instanceof Map?g(this,ft).keys():Object.keys(g(this,ft))[Symbol.iterator]()}entries(){return this[Symbol.iterator]()}values(){return g(this,ft)instanceof Map?g(this,ft).values():Object.values(g(this,ft))[Symbol.iterator]()}get length(){return g(this,ft)instanceof Map?g(this,ft).size:g(this,ft).length}[Symbol.iterator](){return g(this,ft)instanceof Map?g(this,ft)[Symbol.iterator]():Object.entries(g(this,ft))[Symbol.iterator]()}static get localStorage(){return Cd||(Cd=new Pd(window.localStorage)),Cd}},Ld=Pd;ft=new WeakMap;function JM(i){try{let e="__some_random_key_you_are_not_going_to_use__";return i.setItem(e,e),i.removeItem(e),!0}catch{return!1}}function Mh(i){return i.constructor===String}var Hy=Ld;var Gy=ln(ii()),Nd=Hy.localStorage,Od=class extends Gy.default{constructor(){super(),window.addEventListener("online",()=>{for(let[e,t]of Nd)if(e.startsWith("MI_LOGPACKAGE:")){let n=JSON.parse(t);n.timestamp=e.replace("MI_LOGPACKAGE:",""),this.dispatch(n)}})}async dispatch(e){navigator.onLine?await lt.sendLogPackage(e)?Nd.removeItem(`MI_LOGPACKAGE:${e.timestamp}`):this.emit("error",{apiKey:e.apiKey}):Nd.setItem(`MI_LOGPACKAGE:${e.timestamp}`,JSON.stringify(e))}},Sh=new Od;T();var Go,vl,xl,bl,Dd=class{constructor(e,t,n){U(this,Go,void 0);U(this,vl,void 0);U(this,xl,void 0);U(this,bl,void 0);W(this,Go,Object.freeze(e)),W(this,vl,Object.freeze(t)),W(this,xl,n),W(this,bl,Date.now())}get apiKey(){return g(this,Go)}get timestamp(){return g(this,bl)}toJSON(){return{apiKey:g(this,Go),entries:g(this,xl),sessionData:g(this,vl)}}};Go=new WeakMap,vl=new WeakMap,xl=new WeakMap,bl=new WeakMap;var Wy=Dd;var wr,Ui,Wo,Ud=class{constructor(e){U(this,wr,void 0);U(this,Ui,void 0);U(this,Wo,void 0);this.apiKey=e,W(this,Ui,[]),W(this,Wo,{component:"MapsIndoors JavaScript SDK",componentVersion:de.version,deviceUserAgent:window.navigator.userAgent,hostApplicationName:location.hostname,sessionId:_l(),sessionStartDate:new Date().toISOString()}),this.interval||(this.interval=setInterval(()=>{this.flush()},3e4))}get apiKey(){return g(this,wr)}set apiKey(e){!g(this,wr)&&e>""&&W(this,wr,e)}log(e){g(this,Ui).push(e),g(this,Ui).length===1e3&&this.flush()}async flush(){if(g(this,Ui).length!==0){let e=new Wy(g(this,wr),g(this,Wo),g(this,Ui));W(this,Ui,[]),await Sh.dispatch(e)}}dismiss(){W(this,Wo,null),W(this,Ui,null)}};wr=new WeakMap,Ui=new WeakMap,Wo=new WeakMap;var Fd=Ud;T();var bt=Object.freeze({appLifeTime:{ENTERED_FOREGROUND:{domain:"app_life_time",event:"entered_foreground"},ENTERED_BACKGROUND:{domain:"app_life_time",event:"entered_background"},MAP_INSTANTIATED:{domain:"app_life_time",event:"map_instantiated"},MAPSINDOORS_INSTANTIATED:{domain:"app_life_time",event:"mapsindoors_instantiated"},SDK_LOADED:{domain:"app_life_time",event:"sdk_loaded"},SDK_UNLOADED:{domain:"app_life_time",event:"sdk_unloaded"}},configuration:{LANGUAGE_CHANGED:{domain:"configuration",event:"language_changed"}},directions:{DIRECTIONS_REQUESTED:{domain:"directions",event:"directions_requested"},DIRECTIONS_RENDERED:{domain:"directions",event:"directions_rendered"}},liveData:{LIVEDATA_ENABLED_FOR_MAP:{domain:"live_data",event:"livedata_enabled_for_map"},SUBSCRIPTION_STARTED:{domain:"live_data",event:"subscription_started"},SUBSCRIPTION_STOPPED:{domain:"live_data",event:"subscription_stopped"}},map:{MAP_CLICKED:{domain:"map",event:"map_clicked"}},search:{SEARCH_PERFORMED:{domain:"search",event:"search_performed"}}});var Fi,ri,Bd=class{constructor(){U(this,Fi,void 0);U(this,ri,void 0);W(this,Fi,!1),de.on("apikey_changed",()=>{this.enable()}),de.on("eventlogging_enabled",()=>{this.enable()}),de.on("eventlogging_disabled",()=>{this.disable()}),de.on("language_changed",()=>{this.log(bt.configuration.LANGUAGE_CHANGED)}),Sh.on("error",({apiKey:e})=>{e===g(this,ri).apiKey&&this.disable()}),window.addEventListener("beforeunload",()=>{this&&g(this,ri)&&(this.log(bt.appLifeTime.SDK_UNLOADED),g(this,ri).flush())}),window.addEventListener("focus",()=>{this.log(bt.appLifeTime.ENTERED_FOREGROUND)}),window.addEventListener("blur",()=>{this.log(bt.appLifeTime.ENTERED_BACKGROUND)}),this.enable().then(()=>{this.log(bt.appLifeTime.SDK_LOADED)})}get enabled(){return g(this,Fi)}async enable(){let e=await Ls.getConfig(),t=e&&e.logConfig&&e.logConfig.eventLoggingEnabled===!0,n=de.eventLoggingEnabled;t===!0&&n===!0?(g(this,Fi)===!1||de.apiKey!==g(this,ri).apiKey)&&(W(this,ri,new Fd(de.apiKey)),W(this,Fi,!0)):this.disable()}disable(){g(this,Fi)===!0&&(W(this,Fi,!1),g(this,ri).dismiss(),W(this,ri,null))}log(e,t){g(this,Fi)&&g(this,ri)instanceof Fd&&g(this,ri).log({logType:"event",domain:e.domain,name:e.event,parameters:t,date:new Date().toISOString()})}};Fi=new WeakMap,ri=new WeakMap;var Bt=new Bd;T();T();var on=Object.freeze({CENTER:"center",ABOVE:"above",RIGHT:"right",BELOW:"below",LEFT:"left"}),xi=Object.freeze({TOP_LEFT:"top_left",TOP_RIGHT:"top_right",BOTTOM_RIGHT:"bottom_right",BOTTOM_LEFT:"bottom_left"});var kt=class{constructor({backgroundColor:e="#1E2025",fontFamily:t='Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',fontSize:n="14px",fontWeight:s="bold",position:r=xi.BOTTOM_LEFT,size:o={width:24,height:24},strokeColor:a="#fafafa",strokeWidth:l=0,text:c="",textColor:h="#FCFCFC"}={}){Object.assign(this,{backgroundColor:e,fontFamily:t,fontSize:n,fontWeight:s,position:r,size:o,strokeColor:a,strokeWidth:l,text:c,textColor:h})}overlay(e,t={}){return new Promise(n=>{let{size:s,strokeColor:r,strokeWidth:o,radius:a,position:l,text:c,backgroundColor:h,textColor:u,scale:f}=Object.assign({radius:8,scale:1},this,t),{width:d,height:y}=e instanceof Image?s:{width:0,height:0},v=QM(l),p=Math.min(d,y)/2,m=a*f,A=o*f,x=0,S=0,N=Math.ceil(p+p*Math.cos(Xo(v))),P=Math.ceil(p+p*Math.sin(Xo(v))),C=Math.max(N+m+A-(p<<1),-(N-(m+A)),0),R=Math.max(P+m+A-(p<<1),-(P-(m+A)),0);x=C,S=R,N<p?N+=C:N-=(p<<1)-d-C,P<p?P+=R:P-=(p<<1)-y-R;let ne=document.createElement("canvas"),b=ne.getContext("2d");b.imageSmoothingQuality="high",b.textAlign="center",b.textBaseline="middle",b.font=`${this.fontWeight} ${this.fontSize}  ${this.fontFamily}`;let _=b.measureText(c);if(ne.width=Math.max(d+Math.ceil(C*2),Math.ceil(_.width+N+A*2)),ne.height=y+Math.ceil(R*2),e instanceof Image&&b.drawImage(e,x,S,d,y),b.textAlign="center",b.textBaseline="middle",b.font=`${this.fontWeight} ${this.fontSize}  ${this.fontFamily}`,b.lineWidth=A,b.strokeStyle=r,_.width>m*1.6){let I=Math.ceil(_.width-m),O=N+I/2;b.beginPath(),b.arc(N,P,m,Xo(90),Xo(270),!1),b.arc(N+I,P,m,Xo(270),Xo(90),!1),b.closePath(),b.fillStyle=h,b.fill(),o>0&&b.stroke(),b.fillStyle=u,b.fillText(c,O,P)}else b.arc(N,P,m,0,Math.PI*2,!0),b.fillStyle=h,o>0&&b.stroke(),b.fill(),b.fillStyle=u,b.fillText(c,N,P);let M=new Image;M.onload=()=>{n(M)},M.src=ne.toDataURL("image/png")})}};function QM(i){var e;switch((e=i==null?void 0:i.toString())==null?void 0:e.toLowerCase()){case"1":case xi.TOP_LEFT:return 225;case"2":case xi.TOP_RIGHT:return 315;case"3":case xi.BOTTOM_RIGHT:return 45;case"4":case xi.BOTTOM_LEFT:default:return 135}}function Xo(i){return i*(Math.PI/180)}kt.UnavailableBadge=new kt({text:"\xD7",backgroundColor:"#DE1B1B"});kt.AvailableBadge=new kt({text:"\u2713",backgroundColor:"#2a844e",fontSize:"12px"});kt.TextBadge=new kt({fontSize:"11px"});kt.BadgePosition=xi;Object.freeze(kt);T();T();T();var Xy=ln(ii());T();function kd(i,e,t){let n=Object(i);Object.prototype.hasOwnProperty.call(n,t)||(n[t]=n[e]),Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}function ct(i){return i==null}function Ps(i){return JSON.parse(JSON.stringify(i))}var Ar,zd=class extends Xy.default{constructor(){super();U(this,Ar,new Map)}set(t,n,s=!1){if(typeof t=="string"){let r=g(this,Ar).get(t);(s||r!==n)&&(g(this,Ar).set(t,n),this.emit(`${t.toLowerCase()}_changed`,{newValue:n,oldValue:r}),this.emit("changed",{key:t,newValue:n,oldValue:r}))}}setValues(t={}){if(typeof t=="object"&&!ct(t))for(let n of Object.keys(t))this.set(n,t[n])}get(t){return g(this,Ar).get(t)}getValues(){return Object.fromEntries(g(this,Ar))}};Ar=new WeakMap;var zt=zd;T();T();function hn(i){return i*Math.PI/180}function Er(i){return i*180/Math.PI}function qy(i){return 1/Math.cos(i)}function Ml(i,e){return Number(Number(i).toFixed(e))}var wh=6378137,eS=12756274,Tr=4007501668557849e-8,Bi=class{constructor(e,t,n){this.lat=e,this.lng=t,this.floor=n}toUrlValue(){return Bi.toUrlValue(this)}toArray(){return Bi.toArray(this)}computeDistanceTo(e){return Bi.computeDistanceBetween(this,e)}computeDestination(e,t){return Bi.computeDestination(this,e,t)}static create(e){let t;return e instanceof Array&&e.length>=2?t=[e[1],e[0],e[2]]:e.coordinates instanceof Array&&e.coordinates.length>=2?t=[e.coordinates[1],e.coordinates[0],e.coordinates[2]]:e.geometry&&e.geometry.coordinates instanceof Array&&e.geometry.coordinates.length>=2?t=[e.geometry.coordinates[1],e.geometry.coordinates[0],e.geometry.coordinates[2]]:e.lat&&e.lng&&(t=[e.lat,e.lng,e.floor]),t?new Bi(...t):null}static toUrlValue(e){return`${e.lat},${e.lng},${e.floor||0}`}static toArray(e){return[e.lng,e.lat]}static computeDistanceBetween(e,t){let n=hn(t.lat-e.lat),s=hn(t.lng-e.lng),r=hn(e.lat),o=hn(t.lat),a=.5-Math.cos(n)/2+Math.cos(r)*Math.cos(o)*(1-Math.cos(s))/2;return eS*Math.asin(Math.sqrt(a))}static computeDestination(e,t,n){let s=hn(e.lng),r=hn(e.lat),o=hn(n),a=Math.asin(Math.sin(r)*Math.cos(t/wh)+Math.cos(r)*Math.sin(t/wh)*Math.cos(o)),l=s+Math.atan2(Math.sin(o)*Math.sin(t/wh)*Math.cos(r),Math.cos(t/wh)-Math.sin(r)*Math.sin(a));return new Bi(Er(a),Er(l))}static getMeterPerPixel(e,t){return Math.cos(hn(e))*Tr/(256*2**t)}static getPixelsPerMeter(e,t){return 256/(Math.cos(hn(e))*Tr/2**t)}},Vt=Bi;var un={color:{comment:"These colors are based upon the work done by CA Technologies with Mineral UI: https://github.com/mineral-ui/mineral-ui",black:{base:{value:"hsl(223, 11%, 13%)",comment:"The a11y rating of white on top of this color: AAA"},black:{value:"hsl(0, 0%, 0%)",comment:"The a11y rating of white on top of this color: AAA"}},white:{base:{value:"hsl(0, 0%, 99%)",comment:"This is the standard background color."},white:{value:"hsl(0, 0%, 100%)"}},transparent:{base:{value:"hsla(0, 0, 0, 0%)",comment:"This is a 100% transparent color."}},hotorchid:{base:{value:"#EF6CCE"}},gray:{base:{value:"{color.gray.60.value}"},"10":{value:"hsl(216, 33%, 97%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(216, 33%, 94%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(218, 31%, 90%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(218, 28%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(217, 22%, 74%)",comment:"The a11y rating of black on top of this color: AAA"},"60":{value:"hsl(217, 15%, 61%)",comment:"The a11y rating of black on top of this color: AA"},"70":{value:"hsl(217, 10%, 49%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA"},"80":{value:"hsl(218, 11%, 39%)",comment:"The a11y rating of white on top of this color: AA"},"90":{value:"hsl(215, 11%, 30%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(217, 11%, 23%)",comment:"The a11y rating of white on top of this color: AAA"}},red:{base:{value:"{color.red.60.value}"},"10":{value:"hsl(0, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(0, 79%, 91%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(0, 87%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(0, 92%, 77%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(0, 89%, 64%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(0, 78%, 49%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(0, 87%, 39%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(0, 82%, 31%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(0, 67%, 24%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(0, 50%, 18%)",comment:"The a11y rating of white on top of this color: AAA"}},green:{base:{value:"{color.green.60.value}"},"10":{value:"hsl(144, 71%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(144, 65%, 80%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(144, 57%, 67%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(144, 47%, 55%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(144, 46%, 43%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(144, 52%, 34%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(144, 53%, 27%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(144, 52%, 21%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(144, 49%, 16%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(143, 43%, 12%)",comment:"The a11y rating of white on top of this color: AAA"}},blue:{base:{value:"{color.blue.60.value}"},"10":{value:"hsl(215, 67%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(217, 88%, 90%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(217, 93%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(217, 92%, 75%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(217, 84%, 64%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(217, 69%, 52%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(217, 74%, 43%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(217, 80%, 33%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(217, 75%, 25%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(218, 48%, 16%)",comment:"The a11y rating of white on top of this color: AAA"}},bronze:{base:{value:"{color.bronze.60.value}"},"10":{value:"hsl(33, 79%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(33, 88%, 83%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(33, 86%, 71%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(33, 79%, 58%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(33, 85%, 44%)",comment:"The a11y rating of black on top of this color: AA"},"60":{value:"hsl(33, 100%, 34%)",comment:"The a11y rating of black on top of this color: AA and AAA denote the minimum contrast ratio: AA Large"},"70":{value:"hsl(33, 96%, 28%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(33, 87%, 22%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(33, 75%, 17%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(32, 62%, 12%)",comment:"The a11y rating of white on top of this color: AAA"}},purple:{base:{value:"{color.purple.60.value}"},"10":{value:"hsl(270, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(271, 77%, 92%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(271, 79%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(270, 77%, 78%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(270, 72%, 68%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(270, 61%, 59%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(270, 52%, 49%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(270, 57%, 39%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(270, 56%, 29%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(270, 49%, 22%)",comment:"The a11y rating of white on top of this color: AAA"}},magenta:{base:{value:"{color.magenta.60.value}"},"10":{value:"hsl(336, 50%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(335, 79%, 91%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(335, 88%, 84%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(335, 87%, 76%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(335, 81%, 63%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(335, 71%, 49%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(335, 81%, 38%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(335, 77%, 31%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(335, 64%, 23%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(336, 52%, 17%)",comment:"The a11y rating of white on top of this color: AAA"}},indigo:{base:{value:"{color.indigo.60.value}"},"10":{value:"hsl(240, 63%, 97%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(240, 84%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(240, 91%, 87%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(240, 89%, 82%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(240, 81%, 74%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(240, 72%, 65%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(240, 59%, 56%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(240, 53%, 46%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(240, 55%, 35%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(240, 46%, 23%)",comment:"The a11y rating of white on top of this color: AAA"}},sky:{base:{value:"{color.sky.60.value}"},"10":{value:"hsl(200, 64%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(200, 86%, 86%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(200, 87%, 76%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(200, 81%, 63%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(200, 73%, 49%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(200, 87%, 37%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(200, 92%, 30%)",comment:"The a11y rating of white on top of this color: AA."},"80":{value:"hsl(200, 90%, 23%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(201, 80%, 18%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(200, 65%, 13%)",comment:"The a11y rating of white on top of this color: AAA"}},teal:{base:{value:"{color.teal.60.value}"},"10":{value:"hsl(177, 54%, 93%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(177, 66%, 79%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(176, 59%, 64%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(176, 49%, 51%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(176, 60%, 39%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(176, 70%, 30%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(176, 72%, 24%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(176, 73%, 19%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(176, 69%, 14%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(176, 65%, 10%)",comment:"The a11y rating of white on top of this color: AAA"}},slate:{base:{value:"{color.slate.60.value}"},"10":{value:"hsl(198, 38%, 95%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(206, 68%, 88%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(206, 63%, 79%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(205, 55%, 69%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(205, 42%, 55%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(205, 37%, 45%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(205, 40%, 36%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(204, 38%, 28%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(204, 33%, 21%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(205, 25%, 15%)",comment:"The a11y rating of white on top of this color: AAA"}},dusk:{base:{value:"{color.dusk.60.value}"},"10":{value:"hsl(264, 24%, 96%)",comment:"The a11y rating of black on top of this color: AAA"},"20":{value:"hsl(256, 63%, 92%)",comment:"The a11y rating of black on top of this color: AAA"},"30":{value:"hsl(256, 61%, 85%)",comment:"The a11y rating of black on top of this color: AAA"},"40":{value:"hsl(255, 52%, 77%)",comment:"The a11y rating of black on top of this color: AAA"},"50":{value:"hsl(255, 43%, 67%)",comment:"The a11y rating of black on top of this color: AA. The a11y rating of white on top of this color: AA Large."},"60":{value:"hsl(254, 33%, 55%)",comment:"The a11y rating of black on top of this color: AA Large. The a11y rating of white on top of this color: AA."},"70":{value:"hsl(255, 29%, 46%)",comment:"The a11y rating of white on top of this color: AA"},"80":{value:"hsl(255, 30%, 36%)",comment:"The a11y rating of white on top of this color: AAA"},"90":{value:"hsl(255, 26%, 26%)",comment:"The a11y rating of white on top of this color: AAA"},"100":{value:"hsl(253, 20%, 18%)",comment:"The a11y rating of white on top of this color: AAA"}}}};T();T();T();T();var bi=Object.freeze({RIGHT:"left",LEFT:"right",TOP:"bottom",BOTTOM:"top"});var ce={visible:!0,iconVisible:!0,zoomFrom:16,zoomTo:999,icon:"https://app.mapsindoors.com/mapsindoors/cms/assets/icons/misc/default-marker.png?71488",iconScale:1,iconSize:{width:20,height:20},iconPlacement:on.CENTER,labelVisible:!0,label:"{{name}}",labelZoomFrom:16,labelType:"FLOATING",labelStyle:{textSize:12,textColor:"#1F2937",textOpacity:1,haloColor:"#ffffff",haloWidth:2,haloBlur:0,bearing:0,graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-lightgray.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]},position:bi.TOP},labelZoomTo:999,polygon:{visible:!1,zoomFrom:18,zoomTo:999,strokeWidth:2,strokeColor:un.color.blue[60].value,strokeOpacity:1,fillColor:un.color.blue[60].value,fillOpacity:.2},model2D:{visible:!0,zoomFrom:16,zoomTo:999,model:null,widthMeters:0,heightMeters:0,bearing:0},walls:{visible:!0,color:un.color.gray[70].value,height:2,zoomFrom:16,zoomTo:999},extrusion:{visible:!0,color:un.color.gray[50].value,height:2.25,zoomFrom:16,zoomTo:999},model3D:{visible:!0,zoomFrom:16,zoomTo:999,model:null,rotationX:0,rotationY:0,rotationZ:0},badge:{visible:!1,zoomFrom:18,zoomTo:22,radius:5,strokeWidth:2,strokeColor:"#3071D9",fillColor:"#3071D9",scale:1,position:xi.TOP_LEFT}},Ah={polygonVisible:!0,polygonStrokeColor:un.color.blue[60].value,polygonStrokeOpacity:1,polygonStrokeWeight:2,polygonFillOpacity:0,polygonZoomFrom:18,polygonZoomTo:999,clickable:!1},Yy={iconScale:1.25,polygon:{lightnessFactor:-.1},labelStyle:{graphic:{stretchX:[[15,385]],stretchY:[[15,385]],content:[24,24,376,376]}},extrusion:{lightnessFactor:-.1},badge:{scale:1.25}},Ir={zoomFrom:15,zoomTo:999,polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},labelStyle:{graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-highlight.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]}},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},badge:{visible:!0,zoomFrom:15,zoomTo:999,radius:6,strokeWidth:4,strokeColor:"#ffffff",fillColor:"#ec4899",scale:1,position:xi.TOP_LEFT}},Rr={zoomFrom:0,zoomTo:999,visible:!0,iconVisible:!0,icon:"https://app.mapsindoors.com/mapsindoors/gfx/select-pin.png",iconScale:1,iconPlacement:on.ABOVE,iconSize:{width:24,height:28},polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1},labelStyle:{graphic:{backgroundImage:"https://app.mapsindoors.com/mapsindoors/cms/assets/graphic-labels/graphic-label-selection.png",stretchX:[[15,64]],stretchY:[[15,16]],content:[10,10,69,22]}},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.1}},Ky={zoomFrom:15,zoomTo:999,iconScale:1.25,polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},badge:{visible:!0,zoomFrom:15,zoomTo:999,radius:6,strokeWidth:4,strokeColor:"#ffffff",fillColor:"#ec4899",scale:1.25,position:xi.TOP_LEFT}},Zy={zoomFrom:0,zoomTo:999,visible:!0,iconVisible:!0,icon:"https://app.mapsindoors.com/mapsindoors/gfx/select-pin.png",iconScale:1.25,iconPlacement:on.ABOVE,iconSize:{width:24,height:28},polygon:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15},extrusion:{zoomFrom:15,zoomTo:999,lightnessFactor:-.15}},nS={iconVisible:!1,labelVisible:!1,zoomFrom:10,zoomTo:15,label:"{{name}}",clickable:!1,polygonVisible:!1},iS={iconVisible:!1,labelVisible:!1,zoomFrom:15,zoomTo:18,label:"{{name}}",clickable:!1,polygonVisible:!1},sS={iconVisible:!1,labelVisible:!1,clickable:!1,polygonVisible:!1},$y={MI_VENUE:nS,MI_FLOOR:sS,MI_BUILDING:iS};T();var Cr,Vd=class{constructor(){U(this,Cr,new Map)}get(e){if(e){let t=g(this,Cr).get(e);return t||(t=fetch(e).then(rS).then(n=>n.blob()).then(n=>URL.createObjectURL(n)).then(n=>jy(n)).catch(()=>jy("data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")),g(this,Cr).set(e,t)),t}return Promise.resolve(null)}clear(){g(this,Cr).forEach(async e=>{let t=await e;URL.revokeObjectURL(t.src)}),g(this,Cr).clear()}};Cr=new WeakMap;function rS(i){if(!i.ok)throw Error(i.statusText);return i}function jy(i){return new Promise(e=>{let t=new Image;t.onload=()=>e(t),t.onerror=()=>e(null),t.src=i})}var oS=new Vd,qo=oS;T();var oi,Hd=class{constructor(){U(this,oi,new Map)}get(e){if(!e)return Promise.resolve(null);if(g(this,oi).has(e))return g(this,oi).get(e);let t=fetch(e).then(aS).then(n=>n.blob()).then(n=>URL.createObjectURL(n)).catch(()=>(g(this,oi).delete(e),null));return g(this,oi).set(e,t),t}has(e){return g(this,oi).has(e)}clear(){for(let e of g(this,oi).keys())g(this,oi).get(e).then(URL.revokeObjectURL),g(this,oi).delete(e);g(this,oi).clear()}};oi=new WeakMap;function aS(i){if(!i.ok)throw Error(i.statusText);return i}var lS=new Hd,Jy=lS;T();var Gd=class{static removeHtmlFrom(e){return new DOMParser().parseFromString(e,"text/html").body.textContent||""}static capitalize(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}},ki=Gd;var cS={clickable:!0},yt=class{constructor(e){Object.assign(this,cS,e)}set imageSize(e){this.iconSize=e}set imageScale(e){this.iconScale=e}set polygonStrokeWidth(e){this.polygonStrokeWeight=e}set polygon(e){if(e)for(let[t,n]of Object.entries(e))this[`polygon${ki.capitalize(t)}`]=n}set labelStyle(e){if(e)for(let[t,n]of Object.entries(e)){let s=t.toLowerCase().startsWith("label")?t.slice(5):t;this[`labelStyle${ki.capitalize(s)}`]=n}}set model2D(e){if(e)for(let[t,n]of Object.entries(e))this[`model2D${ki.capitalize(t)}`]=n}set walls(e){if(e)for(let[t,n]of Object.entries(e))this[`walls${ki.capitalize(t)}`]=n}set extrusion(e){if(e)for(let[t,n]of Object.entries(e))this[`extrusion${ki.capitalize(t)}`]=n}set model3D(e){if(e)for(let[t,n]of Object.entries(e))this[`model3D${ki.capitalize(t)}`]=n}set badge(e){if(e)for(let[t,n]of Object.entries(e))this[`badge${ki.capitalize(t)}`]=n}getIcon(){return this.icon instanceof Image?Promise.resolve(this.icon):this._getIconUrl()>""?qo.get(this._getIconUrl()):Promise.resolve(null)}getIconSize(){let{width:e,height:t}=this.iconSize||{};return e>=0&&t>=0?this.iconSize:{width:0,height:0}}_getIconUrl(){let e=this.icon;if(e){let t=this.getIconSize(),n=Math.max(2,window.devicePixelRatio||1),s=n*t.width,r=n*t.height,o=new URL(e);o.searchParams.append("width",s),o.searchParams.append("height",r),o.searchParams.append("fitMode","cover"),e=o.toString()}return e}get3DModel(){return this.model3DModel?Jy.get(this.model3DModel):Promise.resolve(null)}static merge(e){return e instanceof Array&&e.length>0?e.reduce((t,n={})=>{n=n instanceof yt?n:new yt(n);for(let s of Object.keys(n))(t[s]===void 0||n[s]!==null&&n[s]!==void 0)&&(t[s]=n[s]);return t},new yt):null}static get DEFAULT_RULE(){return Object.freeze(ce)}static get MAX_ZOOM(){return 999}static get IconPlacement(){return on}};T();function Qy(i,e={}){var s;let t=Object.keys((s=e==null?void 0:e.floors)!=null?s:{});if(t.length===0)return;if(!ct(i)&&t.includes(i.toString()))return i;if(Number.isFinite(parseInt(e.defaultFloor)))return parseInt(e.defaultFloor);if(i===void 0)return;let n=Object.keys(e.floors).sort((r,o)=>o-r).reduce((r,o)=>Math.abs(i-o)<=Math.abs(i-r)?o:r);return parseInt(n)}var vp={};xy(vp,{AppConfigService:()=>Ls,BookingService:()=>D_,DirectionsService:()=>Rh,DistanceMatrixService:()=>Yo,GeoCodeService:()=>Ko,LocationsService:()=>Un,ShareService:()=>XS,SolutionsService:()=>Wr,VenuesService:()=>wt});T();T();T();var Xt=class{static fromGeoJSON(e){if(!e)throw new Error("Invalid GeoJSON object!");if(Array.isArray(e.bbox)&&(e.bbox.length===4||e.bbox.length===6))return{south:e.bbox[1],west:e.bbox[0],north:e.bbox[3],east:e.bbox[2]};let t=(e.type||"").toLowerCase(),n={south:90,west:180,north:-90,east:-180};switch(t){case"feature":return this.fromGeoJSON(e==null?void 0:e.geometry);case"point":return{south:e.coordinates[1],west:e.coordinates[0],north:e.coordinates[1],east:e.coordinates[0]};case"linestring":case"multipoint":return s(n,e.coordinates);case"polygon":case"multilinestring":return e.coordinates.reduce(s,n);case"multipolygon":return e.coordinates.reduce((r,o)=>o.reduce(s,r),n);case"geometrycollection":return e.geometries.reduce((r,o)=>this.combine(r,this.fromGeoJSON(o)),n);case"featurecollection":return e.features.reduce((r,o)=>this.combine(r,this.fromGeoJSON(o.geometry)),n);default:throw new Error("Invalid GeoJSON object!")}function s(r,o){let a=o.map(c=>c[0]),l=o.map(c=>c[1]);return r.south=Math.min(r.south,...l),r.west=Math.min(r.west,...a),r.north=Math.max(r.north,...l),r.east=Math.max(r.east,...a),r}}static combine(...e){return e.reduce((t,n)=>t?{south:Math.min(t.south,n.south),west:Math.min(t.west,n.west),north:Math.max(t.north,n.north),east:Math.max(t.east,n.east)}:n)}static equals(e,t){return e.south===t.south&&e.west===t.west&&e.north===t.north&&e.east===t.east}static fromCenterAndRadius(e,t){let n=t*1.414,{lat:s,lng:r}=Vt.computeDestination(e,n,45),{lat:o,lng:a}=Vt.computeDestination(e,n,225);return{south:o,west:a,north:s,east:r}}static getCenter(e){return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}static toUrlValue(e){return Xt.isLatLngBounds(e)?`${e.south},${e.west},${e.north},${e.east}`:""}static isLatLngBounds(e){let{south:t,west:n,north:s,east:r}=e!=null?e:{};return!isNaN(Number.parseFloat(t))&&!isNaN(Number.parseFloat(n))&&!isNaN(Number.parseFloat(s))&&!isNaN(Number.parseFloat(r))}};T();T();T();var je=Object.freeze({RAMP:"ramp",STAIRS:"stairs",STEPS:"steps",LADDER:"ladder",ESCALATOR:"escalator",TRAVELATOR:"travelator",ELEVATOR:"elevator",UNCLASSIFIED:"unclassified",RESIDENTIAL:"residential",FOOTWAY:"footway",WHEELCHAIR_RAMP:"wheelchairramp",WHEELCHAIR_LIFT:"wheelchairlift"});var Yo=class{static getDistanceMatrix(e={}){var a,l,c;if(!e.graphId)throw new Wd("graphId");if(!e.origins)throw new Wd("origins");if(!e.destinations)throw new Wd("destinations");let t=["steps","stairs"].indexOf((a=e.avoid)==null?void 0:a.toLowerCase())>-1?[je.STAIRS,je.STEPS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(","),n="";e.origins=[].concat(e.origins),e.destinations=[].concat(e.destinations),Array.isArray(e==null?void 0:e.excludeHighwayTypes)?(t=(c=(l=e==null?void 0:e.avoidHighwayTypes)==null?void 0:l.join(","))!=null?c:"",n=e.excludeHighwayTypes.join(",")):Array.isArray(e==null?void 0:e.avoidHighwayTypes)&&(t=e.avoidHighwayTypes.join(","));let s=e.origins.map(h=>Object.prototype.hasOwnProperty.call(h,"lat")?Vt.toUrlValue(h):h).join("|"),r=e.destinations.map(h=>Object.prototype.hasOwnProperty.call(h,"lat")?Vt.toUrlValue(h):h).join("|"),o={avoid:t,exclude:n,origins:s,destinations:r,mode:e.travelMode,graphId:e.graphId,appUserRoleIds:[].concat(e.userRoles).join(","),v:7};return lt.getJson(`distancematrix/${e.graphId}`,{search:o}).then(h=>(h.status==="OK"&&(h.origins=e.origins,h.destinations=e.destinations,delete h.origin_addresses,delete h.destination_addresses),h))}};function Wd(i){this.message=`The reqired paramter "${i}" is missing!`}T();var Ko=class{static reverseGeoCode(e){return e=[].concat(e),e=e.map(t=>`${t.lat},${t.lng}`),lt.getJson("geocode",{search:{point:e}})}};var fn=class{static getRoute({origin:e,destination:t,graphId:n,userRoles:s=[],avoidStairs:r,avoidHighwayTypes:o,excludeHighwayTypes:a,stops:l=[],optimize:c=!1}){let h="",u=r?[je.STAIRS,je.STEPS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(",");s&&s.length===0&&(s=(de.userRoles||[]).map(d=>d.id)),Array.isArray(a)?(u=Array.isArray(o)?o.join(","):"",h=a.join(",")):Array.isArray(o)&&(u=o.join(","));let f={origin:typeof e=="string"?e:Vt.toUrlValue(e),destination:typeof t=="string"?t:Vt.toUrlValue(t),appUserRoleIds:[].concat(s).join(","),mode:"WALKING",avoid:u,exclude:h,stops:l.map(d=>Object.prototype.hasOwnProperty.call(d,"lat")?Vt.toUrlValue(d):d).join("|"),optimize:c,v:7};return lt.getJson(`directions/${n}`,{search:f}).then(({routes:d,status:y})=>{if(y!=="OK")return{route:null,status:y};if(d&&d instanceof Array){let v=d[0];return v.stops=[],v.legs=v.legs.reduce((p,m)=>{let A=["route_start","stop_reached","floor_change"].includes(m==null?void 0:m.leg_start_reason),x=p.length===0&&uS(e);if(m.leg_start_reason==="stop_reached"&&v.stops.push(m.start_location),m=dS(m),x&&(m=pS(m,e)),A)p.push(m);else{let S=p.length-1;p[S]=fS(p[S],m)}return p},[]),{route:v,status:y}}return{route:null,status:""}}).then(hS)}static getGraphId(e){return e=[].concat(e).map(t=>typeof t=="string"?t:Vt.toUrlValue(t)),lt.getJson("directions/contains",{search:{point:e,v:7}})}static getDetails(e){return lt.getJson(`directions/details/${e}`,{search:{v:7}})}static getEntryPointsFor(e,t){if(!e>"")return Promise.resolve([]);if(e instanceof Array)return Promise.all(e.map(n=>fn.getEntryPointsFor(n,t)));if(e>""){let n=e;return lt.getJson(`directions/details/${n}`,{search:{v:7}}).then(({entryPoints:s})=>s instanceof Array&&s.length>0?(t>""&&(s=s.filter(r=>(r.travelModes||[]).some(a=>a.toUpperCase()===t.toUpperCase()))),s.map(r=>({lat:r.coordinates[1],lng:r.coordinates[0],floor:r.coordinates[2],label:r.label?r.label[Object.keys(r.label)[0]]:null,travelModes:r.travelModes}))):Promise.resolve([]))}}static getDistanceMatrix(e={}){return Yo.getDistanceMatrix(e)}};async function hS({route:i,status:e}){if(i&&i.legs&&i.legs.length>0){let t=i.legs.reduce((a,l)=>a.concat(l.steps),[]),n=t.reduce((a,l)=>a.concat([l.start_location,l.end_location]),[]),s=await Ko.reverseGeoCode(n),[r,o]=await Promise.all([wt.getVenues(),wt.getBuildings()]);t.forEach(a=>{let l=s.shift(),c=s.shift();a.start_context={venue:l.venue?r.find(h=>h.id===l.venue.id):null,building:l.building?o.find(h=>h.id===l.building.id):null,floor:{name:a.start_location.floor_name,index:a.start_location.zLevel}},a.end_context={venue:c.venue?r.find(h=>h.id===c.venue.id):null,building:c.building?o.find(h=>h.id===c.building.id):null,floor:{name:a.end_location.floor_name,index:a.end_location.zLevel}}})}return{route:i,status:e}}function uS(i){return i.travelModes&&i.travelModes.length===1&&["driving","bicycling"].includes(i.travelModes[0].toLowerCase())}function fS(...i){return i.reduce((e,t)=>e?(e.steps=e.steps.concat(t.steps),e.end_location=t.end_location,e.distance={text:"",value:e.distance.value+t.distance.value},e.duration={text:"",value:e.duration.value+t.duration.value},e.geometry.coordinates=e.geometry.coordinates.concat(t.geometry.coordinates),e.leg_end_reason=t.leg_end_reason,e.stop_index=t.stop_index,e):t)}function dS(i){return i.geometry={type:"LineString",coordinates:[]},i.steps=i.steps.reduce((e,t)=>{let n=e[e.length-1],s=t.geometry.map(r=>[r.lng,r.lat]);if(t.geometry={type:"LineString",coordinates:s},i.geometry.coordinates=i.geometry.coordinates.concat(s),t.route_context=t.abutters==="OutsideOnVenue"?"Outside":t.abutters,t.instructions=t.instructions||t.html_instructions,t.start_context=null,t.end_context=null,delete t.html_instructions,delete t.abutters,!n||n.route_context!==t.route_context||n.travel_mode!==t.travel_mode){let r=Object.assign({},t);r.steps=[t],e.push(r)}else n.geometry.coordinates=[].concat(n.geometry.coordinates,s),n.end_location=t.end_location,n.distance={text:"",value:n.distance.value+t.distance.value},n.duration={text:"",value:n.duration.value+t.duration.value},n.steps.push(t);return e},[]),i}function pS(i,e){return i.steps[0].label=e.label,i.steps[0].parking=!0,i.steps.map(t=>(t.travel_mode="WALKING",t.steps.map(n=>(n.travel_mode="WALKING",n)),t)),i}T();function Sl(i=[],e,t){let n=0,s=i.length;for(t=t instanceof Function?t:(r,o)=>r<o;n<s;){let r=n+s>>>1;t(i[r],e)?n=r+1:s=r}return i.splice(n,0,e),i.length}var An,Rh=class{constructor(e){U(this,An,void 0);W(this,An,e)}setExternalProvider(e){W(this,An,e)}async getRoute({origin:e,destination:t,travelMode:n="WALKING",avoidStairs:s=!1,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a=[],stops:l=[],optimize:c=!1}){let h;a.length>0?a=[].concat(a):de.userRoles&&de.userRoles.length>0&&(a=de.userRoles.map(y=>y.id));let u=g(this,An),f={origin:e,destination:t,travelMode:n,avoidStairs:s,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a,stops:l,optimize:c},d={travel_modes:n,avoid:`${s?"stairs":""}`,avoidHighwayTypes:r,excludeHighwayTypes:o,user_roles:a?a.join(","):""};if(e&&t){let[y,v]=await fn.getGraphId([e,t]);if(y===v&&y>"")return fn.getRoute({...f,graphId:y}).then(p=>p.route).then(p=>(d.provider="mapsindoors",Bt.log(bt.directions.DIRECTIONS_REQUESTED,d),p));if(u){let[p,m]=await fn.getEntryPointsFor([y,v],n);if(!y&&!v)h=g(this,An).getRoute({origin:e,destination:t,travelMode:n}).then(A=>A.route);else if(p.length>0&&!v)h=this._getOutboundRoute({...f,waypoints:p,graphId:y});else if(m.length>0&&!y)h=this._getInboundRoute({...f,waypoints:m,graphId:v});else if(p.length>0&&m.length>0){let A={origin:p,destination:m},x={origin:y,destination:v};h=this._getRouteBetweenVenues({origin:e,destination:t,waypoints:A,graphIds:x,travelMode:n,avoidStairs:s,avoidHighwayTypes:r,excludeHighwayTypes:o,userRoles:a})}return d.provider=g(this,An).ProviderName,Bt.log(bt.directions.DIRECTIONS_REQUESTED,d),h}}}async _getOutboundRoute({origin:e,destination:t,waypoints:n,travelMode:s,graphId:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c,stops:h=[],optimize:u=!1}){let f=yS({travelMode:s,origin:e,destination:t,stops:h}),d=Eh(s,n),y=Th(f,d);y.splice(5);let v={avoid:o?[je.STAIRS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:y,graphId:r,origins:[e],travelMode:s,userRoles:c},p={destinations:[t],origins:y,travelMode:s},m=await Promise.all([fn.getDistanceMatrix(v),g(this,An).getDistanceMatrix(p)]),A=Ih(m);return await Promise.all([fn.getRoute({origin:A.origin,destination:A.waypoints[0],travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r,stops:h,optimize:u}),g(this,An).getRoute({origin:A.waypoints[0],destination:A.destination,travelMode:s})]).then(([S,N])=>Xd(S.route,N.route))}async _getInboundRoute({origin:e,destination:t,waypoints:n,travelMode:s,graphId:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c,stops:h=[],optimize:u=!1}){let f=gS({travelMode:s,origin:e,destination:t,stops:h}),d=Eh(s,n),y=Th(f,d);y.splice(5);let v={destinations:y,origins:[e],travelMode:s},p={avoid:o?[je.STAIRS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:[t],graphId:r,origins:y,travelMode:s,userRoles:c},m=await Promise.all([g(this,An).getDistanceMatrix(v),fn.getDistanceMatrix(p)]),A=Ih(m);return await Promise.all([g(this,An).getRoute({origin:A.origin,destination:A.waypoints[0],travelMode:s}),fn.getRoute({origin:A.waypoints[0],destination:A.destination,travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r,stops:h,optimize:u})]).then(([S,N])=>Xd(S.route,N.route))}async _getRouteBetweenVenues({origin:e,destination:t,waypoints:n,travelMode:s,graphIds:r,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,userRoles:c}){let h=Eh(s,n.origin),u=Eh(s,n.destination),f=Th(s==="WALKING"?t:e,h),d=Th(s==="WALKING"?e:t,u);f.splice(5),d.splice(5);let y={destinations:d,origins:f,travelMode:s},v={avoid:o?[je.STAIRS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:f,graphId:r.origin,origins:[e],travelMode:s,userRoles:c},p={avoid:o?[je.STAIRS,je.LADDER,je.ESCALATOR].join(","):[je.WHEELCHAIR_RAMP,je.WHEELCHAIR_LIFT].join(","),avoidHighwayTypes:a,excludeHighwayTypes:l,destinations:[t],graphId:r.destination,origins:d,travelMode:s,userRoles:c},m=await Promise.all([fn.getDistanceMatrix(v),g(this,An).getDistanceMatrix(y),fn.getDistanceMatrix(p)]),A=Ih(m);return await Promise.all([fn.getRoute({origin:A.origin,destination:A.waypoints[0],travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r.origin}),g(this,An).getRoute({origin:A.waypoints[0],destination:A.waypoints[1],travelMode:s}),fn.getRoute({origin:A.waypoints[1],destination:A.destination,travelMode:s,userRoles:c,avoidStairs:o,avoidHighwayTypes:a,excludeHighwayTypes:l,graphId:r.destination})]).then(S=>Xd(...S.map(N=>N.route)))}};An=new WeakMap;function Ih(i){let e=i.splice(-1,1)[0],t=i.splice(-1,1)[0];function n(r,o){return{text:"",value:r.distance.value+o.distance.value}}function s(r,o){return{text:"",value:r.duration.value+o.duration.value}}for(let[r,o]of t.rows.entries()){let a=[];for(let[l,c]of o.elements.entries())for(let h of e.rows[l].elements)if(h&&c.status==="OK"&&h.status==="OK"){let u={distance:n(c,h),duration:s(c,h),destination:h.destination||e.destinations[0],origin:t.origins[r],status:h.status,waypoints:h.waypoints?[].concat(e.origins[l],h.waypoints):[e.origins[l]]};a.push(u)}else a.push(null);o.elements=a}if(i.length>0)return Ih([].concat(i,t));{let r=[];for(let o of t.rows[0].elements)o&&Sl(r,o,(a,l)=>a.distance.value<l.distance.value);return r[0]}}function Eh(i,e){if(["driving","bicycling"].includes(i.toLowerCase())){let t=e.filter(n=>n.travelModes&&n.travelModes.length===1&&n.travelModes[0].toLowerCase()===i.toLowerCase());return t.length>0?t:e}else return e}function Th(i,e){return e.reduce((t,n)=>{let s=Vt.computeDistanceBetween(n,i);return Sl(t,[s,n],(r,o)=>r[0]<o[0]),t},[]).map(t=>t[1])}function mS(...i){return i.reduce((e,t)=>{if(e.length===0)return e.concat(t);let n=e.splice(-1,1)[0],s=t.splice(0,1)[0],r=n.steps.splice(-1,1)[0],o=s.steps.splice(0,1)[0],a={distance:{text:"",value:n.distance.value+s.distance.value},duration:{text:"",value:n.duration.value+s.duration.value},end_address:s.end_address,end_location:s.end_location,geometry:{type:"LineString",coordinates:n.geometry.coordinates.concat(s.geometry.coordinates)},leg_end_reason:s.leg_end_reason,leg_start_reason:s.leg_start_reason,stop_index:s.stop_index};if(o.parking===!0||o.travel_mode!==r.travel_mode)Object.assign(n,a,{steps:[].concat(n.steps,r,o,s.steps)});else{let l=Object.assign(r,{distance:{text:"",value:r.distance.value+o.distance.value},duration:{text:"",value:r.duration.value+o.duration.value},end_location:o.end_location,geometry:{type:"LineString",coordinates:r.geometry.coordinates.concat(o.geometry.coordinates)},steps:[].concat(r.steps,o.steps)});Object.assign(n,a,{steps:[].concat(n.steps,l,s.steps)})}return e.concat(n,t)},[])}function Xd(...i){return i.reduce((e,t)=>{var r,o,a,l;if(!e)return t;let n=mS(e.legs,t.legs);return{bounds:Xt.combine(...n.map(c=>Xt.fromGeoJSON(c.geometry))),legs:n,copyrights:[e.copyrights,t.copyrights].join(" & "),warnings:[].concat(e.warnings,t.warnings),stops:[].concat((r=e.stops)!=null?r:[],(o=t.stops)!=null?o:[]),ordered_stop_indexes:[].concat((a=e.ordered_stop_indexes)!=null?a:[],(l=t.ordered_stop_indexes)!=null?l:[])}})}function gS({travelMode:i,origin:e,destination:t,stops:n=[]}){return n.length>0?n[0]:i==="WALKING"?e:t}function yS({travelMode:i,origin:e,destination:t,stops:n=[]}){return n.length>0?n[n.length-1]:i==="WALKING"?t:e}T();var L_=ln(ii());T();T();var Ji,qd=class{constructor(){U(this,Ji,new Map)}update(e,t){g(this,Ji).has(e)||g(this,Ji).set(e,new Map);let n=g(this,Ji).get(e),s=n.get(t.domainType);(s==null?void 0:s.timestamp)>t.timestamp||n.set(t.domainType,t)}get(e){var t;return(t=g(this,Ji).get(e))!=null?t:new Map}getByDomain(e,t){var n;return(n=this.get(e))==null?void 0:n.get(t)}remove(e,t){if(!g(this,Ji).has(e))return;g(this,Ji).get(e).delete(t)}};Ji=new WeakMap;var Qi=new qd;var an=class{getFieldForKey(e){let t=this.properties.fields;if(t&&e>""){if(t[e])return t[e];if(t[e.toLowerCase()])return t[e.toLowerCase()];let n=Object.keys(t).reduce((s,r)=>(s[r.toLowerCase()]=r,s),{});return t[n[e.toLowerCase()]]}}get liveUpdates(){return Qi.get(this.id)}getLiveDataForDomain(e){return Qi.getByDomain(this.id,e)}};cn(an,"MIType",Object.freeze({MI_VENUE:"MI_VENUE",MI_BUILDING:"MI_BUILDING",MI_BUILDING_OUTLINE:"MI_BUILDING_OUTLINE",MI_FLOOR:"MI_FLOOR"}));T();T();var Lr,Mi=class{constructor(){U(this,Lr,new Map);this.config=de,this.http=lt}cacheableRequest(e,t={}){t.lr=t.lr||this.config.language;let n=Cs(e,t);if(g(this,Lr).has(n))return g(this,Lr).get(n);{let s=lt.getJson(e,{search:t});return g(this,Lr).set(n,s),s}}resetRequestCache(){g(this,Lr).clear()}};Lr=new WeakMap;T();T();T();var qt=63710088e-1,e_={centimeters:qt*100,centimetres:qt*100,degrees:qt/111325,feet:qt*3.28084,inches:qt*39.37,kilometers:qt/1e3,kilometres:qt/1e3,meters:qt,metres:qt,miles:qt/1609.344,millimeters:qt*1e3,millimetres:qt*1e3,nauticalmiles:qt/1852,radians:1,yards:qt*1.0936},NP={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/qt,yards:1.0936133};function Zo(i,e,t){t===void 0&&(t={});var n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}function Ns(i,e,t){if(t===void 0&&(t={}),!i)throw new Error("coordinates is required");if(!Array.isArray(i))throw new Error("coordinates must be an Array");if(i.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Yd(i[0])||!Yd(i[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:i};return Zo(n,e,t)}function Kd(i,e,t){t===void 0&&(t={});for(var n=0,s=i;n<s.length;n++){var r=s[n];if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var o=0;o<r[r.length-1].length;o++)if(r[r.length-1][o]!==r[0][o])throw new Error("First and last Position are not equivalent.")}var a={type:"Polygon",coordinates:i};return Zo(a,e,t)}function Os(i,e,t){if(t===void 0&&(t={}),i.length<2)throw new Error("coordinates must be an array of two or more positions");var n={type:"LineString",coordinates:i};return Zo(n,e,t)}function Zd(i,e){e===void 0&&(e="kilometers");var t=e_[e];if(!t)throw new Error(e+" units is invalid");return i*t}function $d(i,e){e===void 0&&(e="kilometers");var t=e_[e];if(!t)throw new Error(e+" units is invalid");return i/t}function Pr(i){var e=i%(2*Math.PI);return e*180/Math.PI}function Nt(i){var e=i%360;return e*Math.PI/180}function Ch(i,e,t){if(e===void 0&&(e="kilometers"),t===void 0&&(t="kilometers"),!(i>=0))throw new Error("length must be a positive number");return Zd($d(i,e),t)}function Yd(i){return!isNaN(i)&&i!==null&&!Array.isArray(i)}function Nr(i){return!!i&&i.constructor===Object}function Ds(i,e,t){if(i!==null)for(var n,s,r,o,a,l,c,h=0,u=0,f,d=i.type,y=d==="FeatureCollection",v=d==="Feature",p=y?i.features.length:1,m=0;m<p;m++){c=y?i.features[m].geometry:v?i.geometry:i,f=c?c.type==="GeometryCollection":!1,a=f?c.geometries.length:1;for(var A=0;A<a;A++){var x=0,S=0;if(o=f?c.geometries[A]:c,o!==null){l=o.coordinates;var N=o.type;switch(h=t&&(N==="Polygon"||N==="MultiPolygon")?1:0,N){case null:break;case"Point":if(e(l,u,m,x,S)===!1)return!1;u++,x++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(e(l[n],u,m,x,S)===!1)return!1;u++,N==="MultiPoint"&&x++}N==="LineString"&&x++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(s=0;s<l[n].length-h;s++){if(e(l[n][s],u,m,x,S)===!1)return!1;u++}N==="MultiLineString"&&x++,N==="Polygon"&&S++}N==="Polygon"&&x++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(S=0,s=0;s<l[n].length;s++){for(r=0;r<l[n][s].length-h;r++){if(e(l[n][s][r],u,m,x,S)===!1)return!1;u++}S++}x++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(Ds(o.geometries[n],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function t_(i,e){var t,n,s,r,o,a,l,c,h,u,f=0,d=i.type==="FeatureCollection",y=i.type==="Feature",v=d?i.features.length:1;for(t=0;t<v;t++){for(a=d?i.features[t].geometry:y?i.geometry:i,c=d?i.features[t].properties:y?i.properties:{},h=d?i.features[t].bbox:y?i.bbox:void 0,u=d?i.features[t].id:y?i.id:void 0,l=a?a.type==="GeometryCollection":!1,o=l?a.geometries.length:1,s=0;s<o;s++){if(r=l?a.geometries[s]:a,r===null){if(e(null,f,c,h,u)===!1)return!1;continue}switch(r.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(r,f,c,h,u)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<r.geometries.length;n++)if(e(r.geometries[n],f,c,h,u)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}f++}}function n_(i,e,t){var n=t;return t_(i,function(s,r,o,a,l){r===0&&t===void 0?n=s:n=e(n,s,r,o,a,l)}),n}function _S(i,e){t_(i,function(t,n,s,r,o){var a=t===null?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return e(Zo(t,s,{bbox:r,id:o}),n,0)===!1?!1:void 0}var l;switch(a){case"MultiPoint":l="Point";break;case"MultiLineString":l="LineString";break;case"MultiPolygon":l="Polygon";break}for(var c=0;c<t.coordinates.length;c++){var h=t.coordinates[c],u={type:l,coordinates:h};if(e(Zo(u,s),n,c)===!1)return!1}})}function vS(i,e){_S(i,function(t,n,s){var r=0;if(!!t.geometry){var o=t.geometry.type;if(!(o==="Point"||o==="MultiPoint")){var a,l=0,c=0,h=0;if(Ds(t,function(u,f,d,y,v){if(a===void 0||n>l||y>c||v>h){a=u,l=n,c=y,h=v,r=0;return}var p=Os([a,u],t.properties);if(e(p,n,s,v,r)===!1)return!1;r++,a=u})===!1)return!1}}})}function i_(i,e,t){var n=t,s=!1;return vS(i,function(r,o,a,l,c){s===!1&&t===void 0?n=r:n=e(n,r,o,a,l,c),s=!0}),n}var s_=6378137;function wl(i){return n_(i,function(e,t){return e+xS(t)},0)}function xS(i){var e=0,t;switch(i.type){case"Polygon":return r_(i.coordinates);case"MultiPolygon":for(t=0;t<i.coordinates.length;t++)e+=r_(i.coordinates[t]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function r_(i){var e=0;if(i&&i.length>0){e+=Math.abs(o_(i[0]));for(var t=1;t<i.length;t++)e-=Math.abs(o_(i[t]))}return e}function o_(i){var e,t,n,s,r,o,a,l=0,c=i.length;if(c>2){for(a=0;a<c;a++)a===c-2?(s=c-2,r=c-1,o=0):a===c-1?(s=c-1,r=0,o=1):(s=a,r=a+1,o=a+2),e=i[s],t=i[r],n=i[o],l+=(jd(n[0])-jd(e[0]))*Math.sin(jd(t[1]));l=l*s_*s_/2}return l}function jd(i){return i*Math.PI/180}var a_={anchor:null,createdAt:null,defaultFloor:null,entryPoints:null,floorNames:null,geometry:null,graphId:null,id:null,lastModified:null,name:null,solutionId:null,styles:null,tilesUrl:null,venueInfo:null},l_={administrativeId:null,venueId:null,anchor:null,buildingInfo:null,createdAt:null,floors:null,geometry:null,id:null,lastModified:null},Or,Dr,Jd=class extends Mi{constructor(){super();U(this,Or,new Map);U(this,Dr,new Map);de.on("apikey_changed",()=>{this.resetRequestCache(),this.getVenues()})}async getVenues(){let t=de.venuesToSync,n=[];if((t==null?void 0:t.length)>0){let s=t.map(this.getVenue.bind(this));n=await Promise.all(s).then(r=>r.flat())}else n=await this.cacheableRequest("~/sync/venues",{solutionId:de.apiKey,v:7,includeFloornames:!1});return g(this,Or).clear(),g(this,Dr).clear(),n.map(s=>{var r;return s=Object.assign({},a_,s),g(this,Or).set((r=s.name)==null?void 0:r.toLowerCase(),s),g(this,Dr).set(s.id,s),s})}getVenue(t){return t?g(this,Dr).has(t)?Promise.resolve(g(this,Dr).get(t)):this.cacheableRequest("~/sync/venues",{solutionId:de.apiKey,venueId:t,v:7,includeFloornames:!1}).then(n=>n[0]).then(n=>Object.assign({},a_,n)).catch(()=>null):Promise.resolve(null)}async getVenueByName(t){return g(this,Or).size===0&&await this.getVenues(),g(this,Or).get(t==null?void 0:t.toLowerCase())}getBuildings(t){return new Promise(n=>{this.cacheableRequest("~/sync/buildings",{solutionId:de.apiKey,venueId:t,v:7}).then(s=>Array.isArray(s)?s:[]).then(s=>s.map(r=>Object.assign({},l_,r))).then(s=>n(s))})}getBuilding(t,n){return new Promise((s,r)=>{this.cacheableRequest(`buildings/details/${t}`,{v:7,...n}).then(o=>{o=Object.assign({},l_,o),o.area=bS(o.geometry),s(o)}).catch(()=>r())})}getBuildingInView(t,n){return t?this.cacheableRequest("buildings",Object.assign({},{viewport:Xt.toUrlValue(t),v:7},n)).then(s=>s.id?s:null):Promise.resolve(null)}};Or=new WeakMap,Dr=new WeakMap;function bS(i){return i.type==="Polygon"?wl(i):0}var wt=new Jd;T();var g_=ln(ii());T();function Us(i,e,t,n){var s,r=!1,o=0;function a(){s&&clearTimeout(s)}function l(){a(),r=!0}typeof e!="boolean"&&(n=t,t=e,e=void 0);function c(){for(var h=arguments.length,u=new Array(h),f=0;f<h;f++)u[f]=arguments[f];var d=this,y=Date.now()-o;if(r)return;function v(){o=Date.now(),t.apply(d,u)}function p(){s=void 0}n&&!s&&v(),a(),n===void 0&&y>i?v():e!==!0&&(s=setTimeout(n?p:v,n===void 0?i-y:i))}return c.cancel=l,c}T();var h_=ln(ii()),u_=ln(c_());T();var Dn=Object.freeze({DISCONNECTED:"DISCONNECTED",CONNECTED:"CONNECTED",CONNECTING:"CONNECTING"});var $o,es,El,Lh=class extends h_.default{constructor(){super(...arguments);U(this,$o,new Map);U(this,es,void 0);U(this,El,Dn.DISCONNECTED)}get status(){return g(this,El)}subscribe(t){return new Promise((n,s)=>{this.status!==Dn.CONNECTED&&s("No connection"),g(this,es).subscribe(t,{onSuccess:()=>n(),onFailure:r=>s(r)})})}onMessageArrived(t){let n=JSON.parse(t.payloadString);if(n.topic=n.topic||t.topic,!n.topic)return;let s=g(this,$o).get(n.id);s&&n.timestamp<s||(g(this,$o).set(n.id,n.timestamp),this.emit("update_received",n))}unsubscribe(t){return new Promise((n,s)=>{this.status!==Dn.CONNECTED&&s("No connection"),g(this,es).unsubscribe(t,{onSuccess:()=>n(),onFailure:r=>s(r)})})}connect(){return new Promise((t,n)=>{if(g(this,es))return t();this.setStatus(Dn.CONNECTING);let s=new u_.default.Client("livedata-mq.mapsindoors.com",parseInt(8084),_l());s.onConnectionLost=r=>{this.setStatus(Dn.DISCONNECTED),r.errorCode!==0&&this.emit("error",r)},s.onConnected=r=>{r&&this.emit("reconnected")},s.connect({useSSL:!0,reconnect:!0,onSuccess:()=>{W(this,es,s),g(this,es).onMessageArrived=this.onMessageArrived.bind(this),this.setStatus(Dn.CONNECTED),g(this,$o).clear(),t()},onFailure:r=>{console.warn("Could not connect to live data message queue."),this.setStatus(Dn.DISCONNECTED),n(r)}})})}disconnect(){g(this,es).disconnect(),this.setStatus(Dn.DISCONNECTED)}setStatus(t){W(this,El,t),this.emit("status_changed",t)}};$o=new WeakMap,es=new WeakMap,El=new WeakMap;T();var Ur,ep=class{constructor(){U(this,Ur,void 0)}activeDomainTypes(){return g(this,Ur)!==void 0?Promise.resolve(g(this,Ur)):lt.getJson(`https://liveapi.mapsindoors.com/api/livedata/details/${de.apiKey}`).then(e=>(W(this,Ur,e.domainTypes.map(t=>t.toLowerCase())),g(this,Ur)))}};Ur=new WeakMap;var tp=new ep;T();T();function Si(i,e){return i.reduce((t,n)=>t&&t[n]?t[n]:null,e)}var np=new Map,dn=Object.freeze({UNAVAILABLE:"unavailable",AVAILABLE:"available",BRONZE:"bronze",TEXT:"text"});async function ai(i,e,t,n,s,r){if(!MS(i,s,r,e.src))return null;let o=null;switch(s){case dn.UNAVAILABLE:o=await kt.UnavailableBadge.overlay(e,{size:{width:t,height:n}});break;case dn.AVAILABLE:o=await kt.AvailableBadge.overlay(e,{size:{width:t,height:n}});break;case dn.BRONZE:o=await new kt({text:r,backgroundColor:Si(["color","bronze","60","value"],un)}).overlay(e,{size:{width:t,height:n}});break;case dn.TEXT:o=await kt.TextBadge.overlay(e,{text:r,size:{width:t,height:n}});break}return o&&np.set(i,{badgeType:s,badgeValue:r,iconSrc:e.src}),o}function f_(i){np.delete(i)}async function d_(i,e,t){let n=e.getStatefulDisplayRule(i,!0),s=await n.getIcon();if(!s)return null;let r=i.liveUpdates.get(Yt.LiveDataDomainTypes.AVAILABILITY),o=i.liveUpdates.get(Yt.LiveDataDomainTypes.OCCUPANCY),a=i.liveUpdates.get(Yt.LiveDataDomainTypes.TEMPERATURE),l=i.liveUpdates.get(Yt.LiveDataDomainTypes.CO2),c=i.liveUpdates.get(Yt.LiveDataDomainTypes.HUMIDITY),h=i.liveUpdates.get(Yt.LiveDataDomainTypes.COUNT);if(t.has(Yt.LiveDataDomainTypes.AVAILABILITY)&&t.has(Yt.LiveDataDomainTypes.OCCUPANCY)&&r&&o&&!ct(r.properties.available)&&!ct(o.properties.nrOfPeople))return o.properties.nrOfPeople<0||o.properties.peoplePresence<0?await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.BRONZE,"-"):o.properties.nrOfPeople>0&&r.properties.available===!1?await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.UNAVAILABLE):o.properties.nrOfPeople>0&&r.properties.available===!0?await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.BRONZE,o.properties.nrOfPeople.toString()):o.properties.nrOfPeople===0&&r.properties.available===!1?await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.BRONZE,"-"):o.properties.nrOfPeople===0&&r.properties.available===!0?await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.AVAILABLE):null;if(t.has(Yt.LiveDataDomainTypes.AVAILABILITY)&&r&&!ct(r.properties.available)){if(r.properties.available===!0)return await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.AVAILABLE);if(r.properties.available===!1)return await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.UNAVAILABLE)}if(t.has(Yt.LiveDataDomainTypes.OCCUPANCY)&&o&&!ct(o.properties.nrOfPeople)){let u;return o.properties.nrOfPeople<0||o.properties.peoplePresence<0?u="-":u=o.properties.nrOfPeople.toString(),await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.TEXT,u)}if(t.has(Yt.LiveDataDomainTypes.TEMPERATURE)&&a&&!ct(a.properties.temperature)){let u;return navigator.language==="en-US"?u=Math.round(a.properties.temperature*9/5-459.67):u=Math.round(a.properties.temperature-273.15),await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.TEXT,`${u}\xB0`)}if(t.has(Yt.LiveDataDomainTypes.CO2)&&l&&!ct(l.properties.co2Level))return await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.TEXT,Math.trunc(l.properties.co2Level).toString());if(t.has(Yt.LiveDataDomainTypes.HUMIDITY)&&c&&!ct(c.properties.relativeHumidity))return await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.TEXT,`${Math.trunc(c.properties.relativeHumidity)}%`);if(t.has(Yt.LiveDataDomainTypes.COUNT)&&h&&!ct(h.properties.count))return await ai(i.id,s,n.iconSize.width,n.iconSize.height,dn.TEXT,h.properties.count.toString())}function MS(i,e,t,n){let s=np.get(i);return!(s&&s.badgeType===e&&s.badgeValue===t&&s.iconSrc===n)}var SS=1e3,wS=2e3,sp=Object.freeze({OCCUPANCY:"occupancy",AVAILABILITY:"availability",POSITION:"position",TEMPERATURE:"temperature",CO2:"co2",HUMIDITY:"humidity",COUNT:"count"}),Fr,xn,ts,Br,zi,wi,kr,zr,Fs,Bs,jo,Vr,Hr,Gr,Tl,Il,ip,Yt=class extends g_.default{constructor(t){super();U(this,Gr);U(this,Il);U(this,Fr,void 0);U(this,xn,void 0);U(this,ts,void 0);U(this,Br,void 0);U(this,zi,void 0);U(this,wi,void 0);U(this,kr,void 0);U(this,zr,void 0);U(this,Fs,void 0);U(this,Bs,void 0);U(this,jo,void 0);U(this,Vr,void 0);U(this,Hr,void 0);W(this,Fr,null),W(this,Br,{}),W(this,ts,[]),W(this,zr,new Map),this.mapsindoorsInstanceThrottler=Us(SS,()=>{this.mapsindoorsInstance.emit("data_updated")}),this.mapUpdateThrottler=Us(wS,()=>{this._updateEnabledTopics()}),this.displayRuleOverridesThrottler=Us(2e3,()=>{this.mapsindoorsInstance.revertDisplayRule([...g(this,Hr)]),g(this,Hr).clear(),this.mapsindoorsInstance.overrideDisplayRule(g(this,Vr)),g(this,Vr).clear()}),W(this,xn,new Lh),this.mapsindoorsInstance=t,this._listenForLocationChanges(),g(this,xn).on("update_received",n=>{TS.call(this,n,g(this,Br))}),g(this,xn).on("status_changed",n=>{this.emit("live_data_status_changed",n)}),g(this,xn).on("error",n=>{this.emit("live_data_error",n)}),g(this,xn).on("reconnected",()=>{te(this,Gr,Tl).call(this,this.subscribedTopics)}),de.on("userroles_changed",()=>{this.mapsindoorsInstance.once("locations_changed",()=>AS.call(this))}),this.subscribedTopics=[],W(this,Bs,this._listenForLocationChanges.bind(this)),W(this,jo,this._defaultEnableLiveDataCallback.bind(this)),W(this,Fs,!1),W(this,zi,new Set),W(this,wi,new Map),W(this,kr,new Set),W(this,Vr,new Map),W(this,Hr,new Set)}get status(){return g(this,xn).status}static get LiveDataDomainTypes(){return sp}get LiveDataInfo(){return tp}async subscribe(t){let n=m_(t);await p_(n)!==!1&&(await te(this,Gr,Tl).call(this,[t]),Bt.log(bt.liveData.SUBSCRIPTION_STARTED,{domain_type:n}))}async unsubscribe(t){await te(this,Il,ip).call(this,t);let n=m_(t);Bt.log(bt.liveData.SUBSCRIPTION_STOPPED,{domain_type:n})}async getLiveUpdate(t,n){return await Qi.getByDomain(t,n)}async enableLiveData(t,n){if(t=t.toLowerCase(),await p_(t)!==!1){if(g(this,zi).has(t)){console.warn(`Live Data for ${t} is already enabled`);return}g(this,zr).size===0&&this._listenForLocationChanges(),g(this,zi).add(t),await this._updateEnabledTopics.call(this),Bt.log(bt.liveData.LIVEDATA_ENABLED_FOR_MAP,{domain_type:t}),g(this,Fs)||(this.mapsindoorsInstance.getMapView().addListener("idle",g(this,Bs)),this.mapsindoorsInstance.addListener("floor_changed",g(this,Bs)),W(this,Fs,!0)),n instanceof Function?(g(this,wi).set(t,n),this.mapsindoorsInstance.on("livedata_locations_updated",g(this,wi).get(t))):this.mapsindoorsInstance.on("livedata_locations_updated",g(this,jo))}}async _defaultEnableLiveDataCallback(t){let n=new Set;for(let[s,r]of t.data)if(!g(this,wi).has(s)){for(let o of r)if(!n.has(o)){if(!o.liveUpdates||o.liveUpdates.size===0||o.liveUpdates.size===1&&o.liveUpdates.get("position"))f_(o.id),g(this,Hr).add(o.id);else{let a=await d_(o,this.mapsindoorsInstance,g(this,zi));if(a){let l={iconSize:{width:a.width,height:a.height},icon:a};g(this,Vr).set(o.id,l)}}n.add(o),this.displayRuleOverridesThrottler()}}}_listenForLocationChanges(){this.mapsindoorsInstance.once("locations_changed",t=>{W(this,zr,t),this.mapUpdateThrottler()})}async disableLiveData(t){if(t=t.toLowerCase(),!g(this,zi).has(t))return;let n=new Map;n.set(t,[]);let s=await Un.getLocations();for(let r of s)await IS.call(this,r,t)&&n.get(t).push(r);this.mapsindoorsInstance.emit("livedata_locations_updated",{data:n}),g(this,zi).delete(t),await this._updateEnabledTopics.call(this),g(this,Fs)&&(this.mapsindoorsInstance.getMapView().removeListener("bounds_changed",g(this,Bs)),this.mapsindoorsInstance.removeListener("floor_changed",g(this,Bs)),g(this,wi).has(t)||this.mapsindoorsInstance.removeListener("livedata_locations_updated",g(this,jo)),W(this,Fs,!1)),g(this,wi).has(t)&&(this.mapsindoorsInstance.removeListener("livedata_locations_updated",g(this,wi).get(t)),g(this,wi).delete(t))}async _updateEnabledTopics(){if(g(this,Fr)===null){let s=await mapsindoors.services.SolutionsService.getSolution(de.apiKey);W(this,Fr,s.id)}let t=await ES(g(this,zr),g(this,zi),g(this,Fr)),n=[];for(let s of t)g(this,kr).has(s)||n.push(s);te(this,Gr,Tl).call(this,n);for(let s of g(this,kr))t.has(s)||te(this,Il,ip).call(this,s);W(this,kr,t)}};Fr=new WeakMap,xn=new WeakMap,ts=new WeakMap,Br=new WeakMap,zi=new WeakMap,wi=new WeakMap,kr=new WeakMap,zr=new WeakMap,Fs=new WeakMap,Bs=new WeakMap,jo=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,Gr=new WeakSet,Tl=async function(t){if(t.length===0)return;if(g(this,xn).status!==Dn.CONNECTED){g(this,ts).push(...t),g(this,xn).status!==Dn.CONNECTING&&g(this,xn).connect().then(()=>{let s=g(this,ts);W(this,ts,[]),te(this,Gr,Tl).call(this,s)});return}for(let s of t)g(this,Br)[s]=[],await g(this,xn).subscribe(s);let n=await __(t);await RS.call(this,t,n,g(this,Br)),this.subscribedTopics.push(...t)},Il=new WeakSet,ip=async function(t){if(g(this,xn).status!==Dn.CONNECTED)return g(this,ts).splice(g(this,ts).indexOf(t),1),!1;await g(this,xn).unsubscribe(t),this.subscribedTopics=this.subscribedTopics.filter(n=>n!==t)};async function p_(i){return(await tp.activeDomainTypes()).includes(i)?!0:(console.warn(`Live Data for ${i} is not available`),!1)}async function AS(){(await __(this.subscribedTopics)).forEach(async e=>{await rp.call(this,e.id,e)})}async function ES(i,e,t){var o,a,l;let n=new Set,s=new Set,r=new Set;for(let c of i)((a=(o=c==null?void 0:c.id)==null?void 0:o.substring(0,3))==null?void 0:a.toLowerCase())!=="mi_"&&c&&c.properties&&(ct(c.properties.buildingId)?r.add(c):s.add(c));for(let c of r)for(let h of e)n.add(`${t}/+/+/+/+/${c.id}/${h}`);for(let c of s)for(let h of e)n.add(`${t}/+/+/${(l=c.properties.parentId)!=null?l:"+"}/+/+/${h}`);return n}async function TS(i,e){let t=Object.keys(e).find(n=>y_(i.topic,n));t?e[t].push(i):(await rp.call(this,i.id,i),this.emit("live_update_received",i))}async function rp(i,e){await Qi.update(i,e),this.mapsindoorsInstanceThrottler()}function IS(i,e){return Qi.remove(i.id,e),this.mapsindoorsInstanceThrottler(),!0}function y_(i,e){if(i===e)return!0;let t=i.split("/"),n=e.split("/");if(t.length!==n.length&&e.slice(-1)!=="#")return!1;for(let s=0;s<t.length;s++){let r=t[s],o=n[s];if(o==="#")return!0;if(r!==o&&o!=="+")return!1}return!0}async function RS(i,e,t){for(let n of i){let s=t[n];if(!!s){for(let r of e){if(!y_(r.topic,n))continue;let o=s.filter(c=>c.id===r.id),l=[r].concat(o).reduce((c,h)=>c.timestamp>h.timestamp?c:h);await rp.call(this,l.id,l),this.emit("live_update_received",l)}delete t[n]}}}function __(i){return i.length===0?[]:fetch("https://liveapi.mapsindoors.com/api/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topics:i})}).then(e=>e.ok?e.json():[])}function m_(i){return i.split("/").slice(-1)[0].toLowerCase()}T();var op=5,Rl=Symbol("cache"),ap=class extends Mi{constructor(){super(),this[Rl]=new Map}async getDerivedGeometries(e,t,n,s=["wall","extrusion"]){t=Array.isArray(t)?t:[t].filter(Boolean);let{modules:r}=await Wr.getSolution();if((r==null?void 0:r.includes("3dwalls"))||(r==null?void 0:r.includes("3dextrusions")))if((t==null?void 0:t.length)>0){let o=t.map(a=>this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,venueId:a,v:op,floorIndex:n==null?void 0:n.toString(),geometryTypes:s==null?void 0:s.join(",")}));return Promise.all(o).then(a=>a.flat())}else return this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,v:op,floorIndex:n==null?void 0:n.toString(),geometryTypes:s==null?void 0:s.join(",")});return Promise.resolve([])}async getDerivedGeometriesWithin(e,t,n,s,r=["wall","extrusion"],o=!1){let{modules:a}=await Wr.getSolution();if(!(a!=null&&a.includes("3dwalls"))||!(a!=null&&a.includes("3dextrusions")))return[];let c={solutionId:de.apiKey,venueId:e,floorIndex:t==null?void 0:t.toString(),appUserRoleIds:s,geometryTypes:r==null?void 0:r.join(","),bbox:n,v:7,onlyOutside:o},h=Cs("~/sync/derivedgeometry/bbox",c);return this[Rl].has(h)||this[Rl].set(h,lt.getJson("~/sync/derivedgeometry/bbox",{search:c})),this[Rl].get(h)}async getFloorPlan(e,t,n){return await this.cacheableRequest("~/sync/derivedgeometry",{solutionId:e,venueId:t,v:op,geometryTypes:"floorplan",floorIndex:n}).then(s=>({type:"FeatureCollection",features:[...s.map(r=>({type:"Feature",geometry:r.geometry,properties:{type:r.type}}))]}))}clearCache(){this[Rl].clear()}},Xr=new ap;T();var Jo,qr,Cl,lp,Ll,cp,Ph=class{constructor(e=16){U(this,Cl);U(this,Ll);U(this,Jo,void 0);U(this,qr,7);W(this,Jo,Math.pow(2,e))}getIntersectingCells(e){let{south:t,west:n,north:s,east:r}=e,o=this.getCell({lat:s,lng:n}),a=this.getCell({lat:t,lng:r}),l=[];for(let c=o.x;c<=a.x;c++)for(let h=o.y;h<=a.y;h++){let u=te(this,Cl,lp).call(this,{x:c,y:h});l.push(u)}return l}getCell({lat:e,lng:t}){let n=g(this,Jo),s=Math.floor(n*((t+180)/360)),r=Math.floor(n*(1-Math.log(Math.tan(hn(e))+qy(hn(e)))/Math.PI)/2);return{x:s,y:r}}getCellBounds({lat:e,lng:t}){let{x:n,y:s}=this.getCell({lat:e,lng:t});return te(this,Cl,lp).call(this,{x:n,y:s})}};Jo=new WeakMap,qr=new WeakMap,Cl=new WeakSet,lp=function({x:e,y:t}){let[n,s]=te(this,Ll,cp).call(this,{x:e,y:t}),[r,o]=te(this,Ll,cp).call(this,{x:e+1,y:t+1});return{south:Ml(o,g(this,qr)),west:Ml(n,g(this,qr)),north:Ml(s,g(this,qr)),east:Ml(r,g(this,qr))}},Ll=new WeakSet,cp=function({x:e,y:t}){let n=g(this,Jo),s=Er(Math.atan(Math.sinh(Math.PI*(1-2*t/n))));return[e/n*360-180,s]};T();T();T();function CS(i,e){e===void 0&&(e={});var t=0,n=0,s=0;return Ds(i,function(r){t+=r[0],n+=r[1],s++},!0),Ns([t/s,n/s],e.properties)}var v_=CS;T();T();function Jt(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return i.geometry.coordinates;if(i.type==="Point")return i.coordinates}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return i;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Nh(i){if(Array.isArray(i))return i;if(i.type==="Feature"){if(i.geometry!==null)return i.geometry.coordinates}else if(i.coordinates)return i.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function LS(i,e,t){t===void 0&&(t={});var n;t.final?n=x_(Jt(e),Jt(i)):n=x_(Jt(i),Jt(e));var s=n>180?-(360-n):n;return s}function x_(i,e){var t=Nt(i[1]),n=Nt(e[1]),s=Nt(e[0]-i[0]);s>Math.PI&&(s-=2*Math.PI),s<-Math.PI&&(s+=2*Math.PI);var r=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(t/2+Math.PI/4)),o=Math.atan2(s,r);return(Pr(o)+360)%360}var b_=LS;T();function PS(i,e,t){t===void 0&&(t={});var n=Jt(i),s=Jt(e);s[0]+=s[0]-n[0]>180?-360:n[0]-s[0]>180?360:0;var r=NS(n,s),o=Ch(r,"meters",t.units);return o}function NS(i,e,t){t=t===void 0?qt:Number(t);var n=t,s=i[1]*Math.PI/180,r=e[1]*Math.PI/180,o=r-s,a=Math.abs(e[0]-i[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);var l=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),c=Math.abs(l)>1e-11?o/l:Math.cos(s),h=Math.sqrt(o*o+c*c*a*a),u=h*n;return u}var M_=PS;T();function OS(i,e,t,n){n===void 0&&(n={});var s=e<0,r=Ch(Math.abs(e),n.units,"meters");s&&(r=-Math.abs(r));var o=Jt(i),a=DS(o,r,t);return a[0]+=a[0]-o[0]>180?-360:o[0]-a[0]>180?360:0,Ns(a,n.properties)}function DS(i,e,t,n){n=n===void 0?qt:Number(n);var s=e/n,r=i[0]*Math.PI/180,o=Nt(i[1]),a=Nt(t),l=s*Math.cos(a),c=o+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),u=Math.abs(h)>1e-11?l/h:Math.cos(o),f=s*Math.sin(a)/u,d=r+f;return[(d*180/Math.PI+540)%360-180,c*180/Math.PI]}var Oh=OS;T();function US(i){if(!i)throw new Error("geojson is required");switch(i.type){case"Feature":return S_(i);case"FeatureCollection":return FS(i);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return hp(i);default:throw new Error("unknown GeoJSON type")}}function S_(i){var e={type:"Feature"};return Object.keys(i).forEach(function(t){switch(t){case"type":case"properties":case"geometry":return;default:e[t]=i[t]}}),e.properties=w_(i.properties),e.geometry=hp(i.geometry),e}function w_(i){var e={};return i&&Object.keys(i).forEach(function(t){var n=i[t];typeof n=="object"?n===null?e[t]=null:Array.isArray(n)?e[t]=n.map(function(s){return s}):e[t]=w_(n):e[t]=n}),e}function FS(i){var e={type:"FeatureCollection"};return Object.keys(i).forEach(function(t){switch(t){case"type":case"features":return;default:e[t]=i[t]}}),e.features=i.features.map(function(t){return S_(t)}),e}function hp(i){var e={type:i.type};return i.bbox&&(e.bbox=i.bbox),i.type==="GeometryCollection"?(e.geometries=i.geometries.map(function(t){return hp(t)}),e):(e.coordinates=A_(i.coordinates),e)}function A_(i){var e=i;return typeof e[0]!="object"?e.slice():e.map(function(t){return A_(t)})}var Dh=US;function BS(i,e,t){if(t=t||{},!Nr(t))throw new Error("options is invalid");var n=t.pivot,s=t.mutate;if(!i)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(n||(n=v_(i)),(s===!1||s===void 0)&&(i=Dh(i)),Ds(i,function(r){var o=b_(n,r),a=o+e,l=M_(n,r),c=Nh(Oh(n,l,a));r[0]=c[0],r[1]=c[1]})),i}var up=BS;T();function kS(i,e,t,n){if(n=n||{},!Nr(n))throw new Error("options is invalid");var s=n.units,r=n.zTranslation,o=n.mutate;if(!i)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("distance is required");if(r&&typeof r!="number"&&isNaN(r))throw new Error("zTranslation is not a number");if(r=r!==void 0?r:0,e===0&&r===0)return i;if(t==null||isNaN(t))throw new Error("direction is required");return e<0&&(e=-e,t=t+180),(o===!1||o===void 0)&&(i=Dh(i)),Ds(i,function(a){var l=Nh(Oh(a,e,t,{units:s}));a[0]=l[0],a[1]=l[1],r&&a.length===3&&(a[2]+=r)}),i}var fp=kS;function dp(i,e,t){let n=Math.sqrt(e**2+t**2)/2,s=Er(Math.atan(e/t)),r=fp(i,n,s,{units:"meters"});return[...fp(i,n,s+180,{units:"meters"}).coordinates,...r.coordinates]}function pp(i,e){return Array.isArray(i)||(i=E_(i)),Array.isArray(e)||(e=E_(e)),i[0]<=e[2]&&i[2]>=e[0]&&i[1]<=e[3]&&i[3]>=e[1]}function T_(i){return{north:i[3],east:i[2],south:i[1],west:i[0]}}function E_(i){return[i.west,i.south,i.east,i.north]}function I_([i,e],t,{width:n,height:s}){let o=Math.pow(2,t),a=Tr/(o*256),l=Math.cos(hn(e))*Tr/(o*256),c=n*a,u=s*l/Tr*360,f=c/Tr*360;return{south:e-u/2,west:i-f/2,north:e+u/2,east:i+f/2}}function R_(i,{width:e,height:t}){let s=i.east-i.west,r=i.north-i.south,o=(i.north+i.south)/2,a=Math.log2(360*t/r/256/Math.cos(hn(o))),l=Math.log2(360*e/s/256);return Math.min(a,l)}var Yr=Symbol("applyLiveDataPositionUpdates"),Fn=Symbol("cache"),C_=Symbol("grid"),mp=Symbol("externalIdCache"),Bh,P_,kh,N_,gp=class extends L_.default{constructor(){super();U(this,Bh);U(this,kh);this[mp]=new Map,this[Fn]=new Map,this[C_]=new Ph}[Yr](t){return[].concat(t).map(n=>{let s=Qi.getByDomain(n.id,sp.POSITION);if(s){if(s.properties.coordinates&&typeof s.properties.coordinates.longitude=="number"&&typeof s.properties.coordinates.latitude=="number"){let r=[Number(s.properties.coordinates.longitude),Number(s.properties.coordinates.latitude)];n.geometry.type==="Point"&&(n.geometry.coordinates=r),n.properties.anchor&&n.properties.anchor.coordinates&&(n.properties.anchor.coordinates=r)}typeof s.properties.floor=="number"&&(n.properties.floor=s.properties.floor)}return n})}async getLocation(t){let n={v:7,extendedLocations:!0},s=Cs(`locations/details/${t}`,n);if(this[Fn].has(s)){let o=await this[Fn].get(s);return this[Yr](o).at(0)}let r=Promise.all([wt.getBuildings(),lt.getJson(`locations/details/${t}`,{search:{...n}})]).then(([o,a])=>Xr.getDerivedGeometries(de.apiKey,null,a.properties.floor).then(l=>[o,a,l])).then(Uh).then(o=>o.map(a=>Fh(a))).then(o=>(this[Fn].set(s,o),o)).then(o=>this[Yr](o).at(0));return this[Fn].set(s,r),await r}getLocationsWithin(t,n,s,r=[],o=!1){let l={solutionId:de.apiKey,venueId:t,v:7,appUserRoleIds:r,floorIndex:n==null?void 0:n.toString(),bbox:s,onlyOutside:o},c=Cs("~/sync/locations/bbox",l);return this[Fn].has(c)||this[Fn].set(c,lt.getJson("~/sync/locations/bbox",{search:l})),this[Fn].get(c)}async dataSource(t,n){var y,v;if(ct(n))return[];let s=(de.userRoles||[]).map(p=>p.id).join(","),r=this[C_],o=await wt.getVenues(),a=[],l=[],c=[],h=new Map;for(let p of o){if(!pp(t,(y=p.locationBounds)==null?void 0:y.bbox))continue;h.set(p.id,p),c.push(wt.getBuildings(p.id));let m=r.getIntersectingCells(T_((v=p.locationBounds)==null?void 0:v.bbox));for(let A of m){if(!pp(t,A))continue;let x=Xt.toUrlValue(A),S=this.getLocationsWithin(p.id,n,x,s);l.push(S);let N=te(this,Bh,P_).call(this,p.id,x,s);l.push(N);let P=Xr.getDerivedGeometriesWithin(p.id,n,x,s);a.push(P);let C=te(this,kh,N_).call(this,p.id,x,s);a.push(C)}}let u=await Promise.all(c).then(p=>p.flat()),f=await Promise.all(a).then(p=>p.flat()),d=await Promise.all(l).then(p=>p.flat());return Uh([u,d,f]).then(p=>[...p,...Array.from(h.values()).map(zS),...u.map(m=>{var A;return[VS(m,{venues:h}),HS((A=m.floors)==null?void 0:A[n],{building:m,venues:h,floorIndex:n})]}).flat()].filter(m=>!!m)).then(p=>p.map(m=>Fh(m))).then(p=>this[Yr](p))}async getLocationsByExternalId(t){if(!t)return[];if(t=[].concat(t),t.length<1)return[];let n={v:7},s=[];return t=t.filter(r=>{let o=this[mp].get(r);return o?(s.push(o),!1):!0}),await Promise.all([wt.getBuildings(),lt.post("locations/externalid",{body:t,search:{...n}}).then(r=>r.clone().json())]).then(Uh).then(r=>r.map(o=>(o=Fh(o),this[mp].set(o.properties.externalId,o),o))).then(r=>r.concat(s)).then(r=>this[Yr](r))}async getLocations(t){var c,h,u,f,d,y,v;t=t||{};let n={},s=t.types instanceof Array?t.types.join(","):t.types,r=(d=(u=(c=t.venue)==null?void 0:c.id)!=null?u:(h=await wt.getVenueByName(t.venue))==null?void 0:h.id)!=null?d:(f=await wt.getVenue(t.venue))==null?void 0:f.id,o=(de.userRoles||[]).map(p=>p.id).join(",");n.q=t.q,n.qFields=t.fields||void 0,n.venue=(v=(y=t.venue)==null?void 0:y.name)!=null?v:t.venue,n.building=t.building,n.floor=isNaN(t.floor)?void 0:t.floor.toString(),n.categories=t.categories instanceof Array?t.categories.join(","):t.categories,n.types=s,n.bbox=t.bbox?Xt.toUrlValue(t.bbox):void 0,n.take=t.take,n.skip=t.skip,n.radius=t.radius,n.includeOutsidePOI=t.includeOutsidePOI,n.orderBy=t.orderBy&&t.sortOrder?t.orderBy+" "+t.sortOrder:t.orderBy||void 0,n.extendedLocations=!0,n.appUserRoleIds=o,n.lr=t.lr||void 0,n.v=7,typeof t.near=="string"?n.near=t.near:t.near&&typeof t.near=="object"?n.near=`${t.near.lat}, ${t.near.lng}`:n.near=void 0;let a=Cs("locations",n);if(this[Fn].has(a)){let p=await this[Fn].get(a);return this[Yr](p)}let l=Promise.all([wt.getBuildings(r),lt.getJson("locations",{search:{...n}}),Xr.getDerivedGeometries(de.apiKey,r,t.floor)]).then(Uh).then(p=>p.map(m=>Fh(m))).then(p=>(this[Fn].set(a,p),p)).then(p=>this[Yr](p));return this[Fn].set(a,l),l}clearCache(){return this[Fn].clear()}};Bh=new WeakSet,P_=function(t,n,s=[]){return this.getLocationsWithin(t,void 0,n,s,!0)},kh=new WeakSet,N_=function(t,n,s=[]){return Xr.getDerivedGeometriesWithin(t,void 0,n,s,void 0,!0)};async function Uh([i,e,t=[]]){var o,a,l,c,h,u,f,d,y,v,p,m,A,x,S,N,P,C;e=e instanceof Array?e:[e];let n=new Map(i.map(R=>[R.administrativeId.toLowerCase(),R])),s=new Map(t.filter(R=>R.type.toLowerCase()==="wall").map(R=>[R.geodataId,R])),r=new Map(t.filter(R=>R.type.toLowerCase()==="extrusion").map(R=>[R.geodataId,R]));for(let R of e){let ne=(o=R.properties.venueId)!=null?o:R.properties.venue,b=await wt.getVenueByName(ne==null?void 0:ne.toLowerCase());R.properties.venue=(c=(l=(a=b==null?void 0:b.venueInfo)==null?void 0:a.name)!=null?l:b==null?void 0:b.name)!=null?c:R.properties.venue,(u=(h=R.properties).venueId)!=null||(h.venueId=b==null?void 0:b.name);let _=R.properties.buildingId||R.properties.building,M=n.get(_==null?void 0:_.toLowerCase());R.properties.building=(d=(f=M==null?void 0:M.buildingInfo)==null?void 0:f.name)!=null?d:R.properties.building,(v=(y=R.properties).buildingId)!=null||(y.buildingId=M==null?void 0:M.id),R.properties.extrusionGeometry=(p=r.get(R.id))==null?void 0:p.geometry,R.properties.wallGeometry=(m=s.get(R.id))==null?void 0:m.geometry;let I=(A=M==null?void 0:M.floors)==null?void 0:A[R.properties.floor];(S=(x=R.properties).floorId)!=null||(x.floorId=I==null?void 0:I.id),R.properties.parentId=(C=(P=(N=I==null?void 0:I.id)!=null?N:M==null?void 0:M.id)!=null?P:b==null?void 0:b.id)!=null?C:null,R.properties.displayRule=R.properties.displayRule?new yt(R.properties.displayRule):null}return e}function zS(i){return{id:i.id,type:"Feature",geometry:i.geometry,area:zh(i.geometry),properties:Object.assign({administrativeId:i.name,anchor:i.anchor,floor:"0",locationType:"venue",status:i.status,type:an.MIType.MI_VENUE,venue:i.name},i.venueInfo)}}function VS(i,{venues:e}){var n;let t=e.get(i.venueId);return{id:i.id,type:"Feature",geometry:i.geometry,area:zh(i.geometry),properties:Object.assign({anchor:i.anchor,administrativeId:i.administrativeId,floor:"0",locationType:"building",parentId:i.venueId,status:i.status,type:an.MIType.MI_BUILDING,venue:(n=t==null?void 0:t.name)!=null?n:""},i.buildingInfo)}}function HS(i,{building:e,venues:t,floorIndex:n}){var r,o;let s=t.get(e.venueId);if(!!i)return{id:i.id,type:"Feature",geometry:i.geometry,area:zh(i.geometry),properties:{anchor:e.anchor,building:e.administrativeId,buildingId:e.id,floor:(r=n==null?void 0:n.toString())!=null?r:"",locationType:"floor",floorName:i.name,parentId:e.id,status:i.status,type:an.MIType.MI_FLOOR,venue:(o=s==null?void 0:s.name)!=null?o:""}}}var O_={get(i,e){let t=i[e];return t===i.getLocations?function(){return Bt.log(bt.search.SEARCH_PERFORMED,{parameters_used:Object.keys(arguments[0]).join(", ")}),t.apply(this,arguments)}:t}};function Fh(i){if(!i)return null;let e={id:null,type:null,geometry:null,properties:null},t={aliases:null,anchor:null,building:null,categories:{},displayRule:null,externalId:null,fields:{},floor:null,floorName:null,imageURL:null,locationType:null,mapElement:null,locationSettings:{selectable:null},name:null,roomId:null,type:null,venue:null};return i=Object.assign(new an,e,i),Object.prototype.hasOwnProperty.call(i==null?void 0:i.properties,"imageurl")&&(Object.prototype.hasOwnProperty.call(i==null?void 0:i.properties,"imageURL")||(i.properties.imageURL=i.properties.imageurl),delete i.properties.imageurl),i.properties=Object.assign({},t,i.properties),i.properties.externalId&&(i.properties.roomId=i.properties.externalId),i.properties.displayRule&&(kd(i.properties.displayRule,"imageScale","iconScale"),kd(i.properties.displayRule,"imageSize","iconSize")),i.area=zh(i.geometry),i.properties.displayRule=i.properties.displayRule?new yt(i.properties.displayRule):null,i=GS(i),i.properties.geodesicDistance&&delete i.properties.geodesicDistance,i}function zh(i){return i&&i.type==="Polygon"?wl(i):0}function GS(i){var e,t;switch((t=(e=i.properties)==null?void 0:e.locationType)==null?void 0:t.toLowerCase()){case"venue":return i.type=an.MIType.MI_VENUE,i;case"building":return i.type=an.MIType.MI_BUILDING,i;case"floor":return i.type=an.MIType.MI_FLOOR,i;default:return i}}var Un=new gp;T();var WS={availableLanguages:null,createdAt:null,createdBy:null,customerId:null,defaultLanguage:null,expirationDate:null,id:null,implementationType:null,lastModified:null,lastModifiedBy:null,locationTemplate:null,mapClientUrl:null,minimumVersion:null,modules:null,name:null,types:null,whitelabel:null},Vh=class extends Mi{constructor(){super(),this.config.on("apikey_changed",()=>{this.resetRequestCache(),this.getSolution()})}getSolution(){return this.cacheableRequest("~/sync/solutions",{solutionId:this.config.apiKey,v:7}).then(e=>Object.assign({},WS,e)).then(e=>{for(let t of Object.values(e.types))t.displayRule=new yt(t.displayRule);return e})}getCategories(e={}){return this.cacheableRequest("~/sync/categories",{solutionId:this.config.apiKey,...e})}getUserRoles(e={}){return this.cacheableRequest("~/sync/appuserroles",{solutionId:this.config.apiKey,...e}).then(t=>t.map(({id:n,name:s})=>new ko(n,s)))}};T();var Hh=class extends Mi{directionsToPhone(e,t,n,s,r){return new Promise((o,a)=>{this.http.post("share/route",{body:{CountryCode:s,PhoneNumber:r,Type:"sms",VenueId:e,OriginLocationId:t,DestinationLocationId:n}}).then(()=>o()).catch(l=>{let c=JSON.parse(l.message);a(c.message)})})}};T();T();var Pl,Kr=class{constructor({bookingId:e,locationId:t,startTime:n,endTime:s,participants:r,title:o,description:a,managed:l}){U(this,Pl,void 0);W(this,Pl,e),this.locationId=t,this.startTime=new Date(n),this.endTime=new Date(s),this.participants=r,this.title=o,this.description=a,this.managed=l}get bookingId(){return g(this,Pl)}};Pl=new WeakMap;T();var Nl=class{constructor(e,t){this.providerTenantId=t,this.accessToken=e}};var Ol=de.bookingServiceUrl,Zr,ks,Qo,Dl,_p,yp=class{constructor(){U(this,ks);U(this,Dl);U(this,Zr,void 0)}get MPBooking(){return Kr}get BookingAuthenticationConfig(){return Nl}getBookableLocations({startTime:e,endTime:t,venue:n,building:s,floorIndex:r,category:o,locationType:a}){let l=new Date(e).toISOString(),c=new Date(t).toISOString();return lt.getJson(`${Ol}/available`,{search:{fromUtc:l,toUtc:c,venue:n,building:s,floor:r,category:o,locationType:a},headers:te(this,ks,Qo).call(this)})}getLocationsConfiguredForBooking(){return lt.getJson(`${Ol}/bookable`,{headers:te(this,ks,Qo).call(this)})}getBookingsUsingQuery({location:e,ownerId:t,startTime:n,endTime:s}){let r=e?"locationbookings":t?"userbookings":null,o=e?e.id:null,a=n?new Date(n).toISOString():null,l=s?new Date(s).toISOString():null;return r&&a&&l?lt.getJson(`${Ol}/${r}`,{search:{locationId:o,userId:t,fromUtc:a,toUtc:l},headers:te(this,ks,Qo).call(this)}).then(c=>c.map(h=>te(this,Dl,_p).call(this,h))):Promise.reject()}performBooking(e){return e instanceof Kr?lt.post(`${Ol}`,{body:{locationId:e.locationId,title:e.title,description:e.description,fromUtc:new Date(e.startTime).toISOString(),toUtc:new Date(e.endTime).toISOString(),inviteList:e.participants||[]},headers:te(this,ks,Qo).call(this)}).then(t=>t.json()).then(t=>te(this,Dl,_p).call(this,t)):Promise.reject("Invalid booking!")}cancelBooking(e){return e instanceof Kr?lt.delete(`${Ol}`,{search:{bookingId:e.bookingId,locationId:e.locationId},headers:te(this,ks,Qo).call(this)}):Promise.reject("Invalid booking!")}setAuthenticationConfig(e){(e instanceof Nl||e===null)&&W(this,Zr,e)}};Zr=new WeakMap,ks=new WeakSet,Qo=function(){return g(this,Zr)?{"user-access-token":g(this,Zr).accessToken,"provider-tenantid":g(this,Zr).providerTenantId}:null},Dl=new WeakSet,_p=function(e){return e&&new Kr({bookingId:e.id,startTime:e.fromUtc,endTime:e.toUtc,participants:e.inviteList,...e})};var D_=new yp;var Wr=new Vh,XS=new Hh;T();var lv=ln(ii());T();T();var Ne=Object.freeze({LABEL:"label",LABEL_FLOATING:"label_floating",LABEL_FLAT:"label_flat",LABEL_GRAPHIC:"label_graphic",MODEL2D:"model2d",MODEL3D:"model3d",POINT:"point",POLYGON:"polygon",ROOM_EXTRUSION:"room_extrusion",WALL_EXTRUSION:"wall_extrusion"});T();var qS={align:"center",color:un.color.gray[100].value,fontFamily:"Open Sans, Helvetica, sans-serif",fontSize:"12px",fontWeight:700,strokeStyle:"#444",strokeWeight:0,shadowBlur:0,shadowColor:"#000",maxLength:-1};T();var sv=ln(iv());function Yh(i,e=0){let t;if(e===0)return i;let n=(0,sv.default)(i).hsl(),s=n.l();return e>0?t=s+(100-s)*e:t=s-s*Math.abs(e),n.l(t).hex().toString()}T();var Kh=Object.freeze({FLOATING:"FLOATING",FLAT:"FLAT",GRAPHIC:"GRAPHIC"});var lw=new kt({}),Vi="1af19ac2-91c9-4744-bf0a-37430f8edc9d",cw=1e5,rv=2e5,hw=3e5,uw=4e5,fw=5e5,dw=6e5,pw=7e5,kl=8e5,mw=9e5,Ap=0;async function Ep(i,e,t){var l,c;let n=new Map,s=new Map,r=new Set(t.getHighlight());function o(h){return h&&s.set(h.id,h),h}let a=[];for(let[h,u]of i.entries())if(u){let f=t.getStatefulDisplayRule(u),d=t.getLocationSettings(u);if(u.liveUpdates){let y=e.get(u.id);for(let[v,p]of u.liveUpdates){let m=new Date(p.timestamp),A=y&&y.liveUpdates&&y.liveUpdates.has(v)?new Date(y.liveUpdates.get(v).timestamp):null;m>A&&(n.has(v)?n.get(v).push(u):n.set(v,[u]))}}if(gw(f)){if(wp(u)){let y=((l=t.getSelectedLocation())==null?void 0:l.id)===u.id,v=r.has(u.id),p=rv+h,m=cw+h,A=ww(u,f,m,y,v,d,t).then(o).then(x=>{if(f.labelType===Kh.FLOATING)return Mw(u,f,p,d,t,x)}).then(o);if(a.push(A),f.labelType===Kh.FLAT){let x=Sw(u,f,p,d,t).then(o);a.push(x)}if(f.labelType===Kh.GRAPHIC){let x=((c=t.getHoveredLocation())==null?void 0:c.id)===u.id,S=r.has(u.id),N=rv+h,P=Lw(u,f,N,d,y,x,S,t).then(o);a.push(P)}}if(["Polygon","MultiPolygon"].includes(u.geometry.type)){let y=hw+h,v=Tw(u,f,y,d,t).then(o);a.push(v)}if(f.model2DModel!==null&&wp(u)){let y=uw+h,v=Ew(u,f,y,d,t).then(o);a.push(v)}if(!ct(u.properties.wallGeometry)){let y=fw+h,v=Iw(u,f,y,d,t).then(o);a.push(v)}if(!ct(u.properties.extrusionGeometry)){let y=dw+h,v=Rw(u,f,y,d,t).then(o);a.push(v)}if(!ct(f.model3DModel)&&wp(u)){let y=pw+h,v=Cw(u,f,y,d,t).then(o);a.push(v)}}}return await Promise.all(a),n.size>0&&t.emit("livedata_locations_updated",{data:n}),s}function Vs(i,e,t){return i=i!==null?Number(i):NaN,e=i!==null?Number(e):NaN,!Number.isFinite(i)||!Number.isFinite(e)||i<0||e<0?!1:i<=t&&e>=t}function wp(i){return i.geometry.type==="Point"||i.properties.anchor&&i.properties.anchor.type==="Point"}function gw(i){return i.visible===!0}function Zh(i,e){let t=i.labelZoomFrom||i.zoomFrom,n=i.labelZoomTo||i.zoomTo;return i.labelVisible&&Vs(t,n,e)&&i.label>""}function yw(i,e){let t=i.wallsZoomFrom||i.zoomFrom,n=i.wallsZoomTo||i.zoomTo;return i.wallsVisible===!0&&Vs(t,n,e)}function _w(i,e){let t=i.extrusionZoomFrom||i.zoomFrom,n=i.extrusionZoomTo||i.zoomTo;return i.extrusionVisible===!0&&Vs(t,n,e)}function vw(i,e){let t=i.model3DZoomFrom||i.zoomFrom,n=i.model3DZoomTo||i.zoomTo;return i.model3DVisible===!0&&Vs(t,n,e)}function Tp(i,e){let t=i.zoomFrom||0,n=i.zoomTo||Number.MAX_VALUE;return i.iconVisible===!0&&Vs(t,n,e)}function av(i,e){let t=i.badgeZoomFrom||0,n=i.badgeZoomTo||Number.MAX_VALUE;return i.badgeVisible===!0&&Vs(t,n,e)}function xw(i,e){return i.clickable===!0&&(Tp(i,e)||Zh(i,e))}function ov(i,e){let t=i.polygonZoomFrom||0,n=i.polygonZoomTo||Number.MAX_VALUE;return i.polygonVisible&&Vs(t,n,e)}function bw(i,e){let t=i.model2DZoomFrom||0,n=i.model2DZoomTo||Number.MAX_VALUE;return i.model2DWidthMeters>0&&i.model2DHeightMeters>0&&i.model2DModel&&i.model2DVisible===!0&&Vs(t,n,e)}function ns(i,e){let t=(e==null?void 0:e.selectable)!==!1,n=i.clickable;return(ct(n)||n)&&t}function Mw(i,e,t,n,s,r){let a=s.getMapView().getZoom();if(Zh(e,a)){let l={clickable:ns(e,n),originalId:i.id,featureClass:Ne.LABEL_FLOATING,sortKey:t,labelText:$h(e.label,i),...Pw(s,e,r)},c={type:"Feature",id:si(`TextLabel.${i.id}`,Vi),geometry:Ps(i.properties.anchor||i.geometry),properties:l};return Promise.resolve(c)}else return Promise.resolve(null)}function Sw(i,e,t,n,s){let r=s.getMapView(),o=r.getZoom(),l=(r.getBearing()%360+360)%360,c=ct(e.labelStyleBearing)?ce.labelStyle.bearing:e.labelStyleBearing,h=Math.abs(l-c)<=90||Math.abs(l-c)>=270?c:c+180;if(Zh(e,o)){let u={clickable:ns(e,n),originalId:i.id,featureClass:Ne.LABEL_FLAT,sortKey:t,labelText:$h(e.label,i),labelStyleBearing:h,...Ow(s,e)},f={type:"Feature",id:si(`FlatLabel.${i.id}`,Vi),geometry:Ps(i.properties.anchor||i.geometry),properties:u};return Promise.resolve(f)}else return Promise.resolve(null)}async function ww(i,e,t,n,s,r,o){let l=o.getMapView().getZoom(),c={originalId:i.id,featureClass:Ne.POINT},h,u,f;return Tp(e,l)&&(h=await e.getIcon(),u=Rp(e),f=Fw(e)),av(e,l)&&(h=await Aw(h,e),u={width:h.width,height:h.height},f={x:u.width/2,y:u.height/2}),h?(Object.assign(c,{clickable:ns(e,r),title:$h(e.title,i),iconAnchor:f,icon:h,iconSrc:h.src,iconSize:u,iconScale:u.width/h.naturalWidth,sortKey:n?mw:t,zIndex:i.properties.zIndex,iconAllowOverlap:n||s,iconPlacement:Bw(e)}),{type:"Feature",id:si(`Icon.${i.id}`,Vi),geometry:Ps(i.properties.anchor||i.geometry),liveUpdates:i.liveUpdates?new Map([...i.liveUpdates]):void 0,properties:c}):Promise.resolve(null)}async function Aw(i,e){var n;if(!e.badgeVisible)return i;let t={size:Rp(e),scale:e.badgeScale,radius:e.badgeRadius,backgroundColor:e.badgeFillColor,position:(n=e.badgePosition)!=null?n:kt.BadgePosition.TOP_LEFT,strokeColor:e.badgeStrokeColor,strokeWidth:e.badgeStrokeWidth};return await lw.overlay(i,t)}async function Ew(i,e,t,n,s){var a;let o=s.getMapView().getZoom();if(bw(e,o)){let l=await qo.get(e.model2DModel),c=[e.model2DWidthMeters/l.naturalWidth,1,e.model2DHeightMeters/l.naturalHeight],h={type:"Feature",id:si(`Model2D.${i.id}`,Vi),geometry:(a=i.properties.anchor)!=null?a:i.geometry,properties:{clickable:ns(e,n),originalId:i.id,featureClass:Ne.MODEL2D,sortKey:t,fillOpacity:0,strokeOpacity:0,strokeWidth:0,widthMeters:e.model2DWidthMeters,heightMeters:e.model2DHeightMeters,bearing:e.model2DBearing,rotation:[90,0,(e.model2DBearing%360+360)%360],scale:c,translation:[0,0,.001],imageUrl:l.src}};return Promise.resolve(h)}else return Promise.resolve(null)}function Tw(i,e,t,n,s){var l;let o=s.getMapView().getZoom(),a={type:"Feature",id:si(`Polygon.${i.id}`,Vi),geometry:i.geometry,liveUpdates:i.liveUpdates?new Map([...i.liveUpdates]):void 0,properties:{clickable:ns(e,n),originalId:i.id,featureClass:Ne.POLYGON,sortKey:i.properties.zIndex||t||0,type:i.properties.type}};return ov(e,o)?(Object.assign(a.properties,{fillColor:Yh(e.polygonFillColor,e.polygonLightnessFactor),fillOpacity:e.polygonFillColor>""?e.polygonFillOpacity:0,strokeColor:Yh(e.polygonStrokeColor||e.polygonFillColor||"#000",e.polygonLightnessFactor),strokeOpacity:e.polygonStrokeColor>""?isNaN(e.polygonStrokeOpacity)?1:e.polygonStrokeOpacity:0,strokeWidth:e.polygonStrokeColor>""?parseInt((l=e.polygonStrokeWeight)!=null?l:2):0}),Promise.resolve(a)):ov(e,o)&&xw(e,o)?(Object.assign(a.properties,{fillOpacity:0,strokeOpacity:0}),Promise.resolve(a)):Promise.resolve(null)}function Iw(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<Ap||!yw(e,o))return Promise.resolve(null);{let a={type:"Feature",id:si(`WallExtrusion.${i.id}`,Vi),geometry:i.properties.wallGeometry,properties:{clickable:ns(e,n),featureClass:Ne.WALL_EXTRUSION,originalId:i.id,sortKey:i.properties.zIndex||t||0,type:"MI_EXTRUDED_WALLS",fillColor:e.wallsColor,height:e.wallsHeight}};return Promise.resolve(a)}}function Rw(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<Ap||!_w(e,o))return Promise.resolve(null);{let a={type:"Feature",id:si(`RoomExtrusion.${i.id}`,Vi),geometry:i.properties.extrusionGeometry,properties:{clickable:ns(e,n),featureClass:Ne.ROOM_EXTRUSION,originalId:i.id,sortKey:i.properties.zIndex||t||0,type:"MI_EXTRUDED_ROOM",fillColor:Yh(e.extrusionColor,e.extrusionLightnessFactor),height:e.extrusionHeight}};return Promise.resolve(a)}}async function Cw(i,e,t,n,s){let o=s.getMapView().getZoom();if(o<Ap||!vw(e,o))return Promise.resolve(null);{let a=await e.get3DModel(),l={type:"Feature",id:si(`Model3D.${i.id}`,Vi),geometry:Ps(i.properties.anchor||i.geometry),properties:{clickable:ns(e,n),featureClass:Ne.MODEL3D,sortKey:i.properties.zIndex||t||0,originalId:i.id,type:"MI_MODEL_3D",modelName:si(e.model3DModel,Vi),url:a,rotation:[e.model3DRotationX,e.model3DRotationY,e.model3DRotationZ],scale:[e.model3DScale,e.model3DScale,e.model3DScale]}};return Promise.resolve(l)}}async function Lw(i,e,t,n,s,r,o,a){var h;let c=(await a.getMapView()).getZoom();if(Zh(e,c)){let u={clickable:ns(e,n),originalId:i.id,featureClass:Ne.LABEL_GRAPHIC,sortKey:((h=i==null?void 0:i.properties)==null?void 0:h.zIndex)||t||0,labelText:$h(e.label,i),...Vw(e,s,o),...Nw(a,e,r,s,o)},f={type:"Feature",id:si(`Graphic.${i.id}`,Vi),geometry:Ps(i.properties.anchor||i.geometry),properties:u};return Promise.resolve(f)}else return Promise.resolve(null)}function $h(i,e,t){let n=/{{(.*?)}}/g,s,r=i;for(;(s=n.exec(i))!==null;)r=r.replace(s[0],e.properties[s[1]]||"");return r&&t>0&&r.length>t&&(r=r.slice(0,t).trim()+"\u2026"),r}function Ip(i,e){let t=i.getLabelOptions()||{};return t.style=t.style||{},{labelMaxWidth:e.labelMaxWidth>=0?e.labelMaxWidth:-1,labelStyleHaloColor:t.style.shadowColor||e.labelStyleHaloColor||ce.labelStyle.haloColor,labelStyleOpacity:t.style.textOpacity>=0?t.style.textOpacity:e.labelStyleTextOpacity>=0?e.labelStyleTextOpacity:ce.labelStyle.textOpacity}}function Pw(i,e,t){var a;let n=i.getLabelOptions()||{};n.style=n.style||{};let r=i.getMapView().getZoom(),o=kw(e);return{labelOffset:n.pixelOffset?Uw(e.labelStyleTextSize,e.iconVisible,n.pixelOffset):Dw(e,o,(a=t==null?void 0:t.properties)==null?void 0:a.iconSize),labelStylePosition:Tp(e,r)||av(e,r)?o:ce.labelStyle.position,labelStyleSize:n.style.fontSize?parseInt(n.style.fontSize):parseInt(n.style.fontSize)||e.labelStyleTextSize||ce.labelStyle.textSize,labelStyleColor:n.style.color||e.labelStyleTextColor||ce.labelStyle.textColor,labelStyleHaloBlur:parseInt(n.style.shadowBlur)>=0?n.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:ce.labelStyle.haloBlur,labelStyleHaloWidth:n.style.haloWidth>=0?n.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:ce.labelStyle.haloWidth,...Ip(i,e)}}function Nw(i,e,t,n,s){let r=i.getLabelOptions()||{};r.style=r.style||{};let o=3;return{labelStyleSize:t?r.style.fontSize?parseInt(r.style.fontSize)+o:parseInt(r.style.fontSize)||e.labelStyleTextSize+o:e.labelStyleTextSize||ce.labelStyle.textSize,labelStyleColor:n||s?"#FFFFFF":r.style.color||e.labelStyleTextColor||ce.labelStyle.textColor,labelStyleHaloBlur:n||s?0:parseInt(r.style.shadowBlur)>=0?r.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:ce.labelStyle.haloBlur,labelStyleHaloWidth:n||s?0:r.style.haloWidth>=0?r.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:ce.labelStyle.haloWidth,...Ip(i,e)}}function Ow(i,e){let t=i.getLabelOptions()||{};return t.style=t.style||{},{labelStyleSize:t.style.fontSize?parseInt(t.style.fontSize):parseInt(t.style.fontSize)||e.labelStyleTextSize||ce.labelStyle.textSize,labelStyleColor:t.style.color||e.labelStyleTextColor||ce.labelStyle.textColor,labelStyleHaloBlur:parseInt(t.style.shadowBlur)>=0?t.style.shadowBlur:e.labelStyleHaloBlur>=0?e.labelStyleHaloBlur:ce.labelStyle.haloBlur,labelStyleHaloWidth:t.style.haloWidth>=0?t.style.haloWidth:e.labelStyleHaloWidth>=0?e.labelStyleHaloWidth:ce.labelStyle.haloWidth,...Ip(i,e)}}function Dw(i,e,t){let n=i.labelStyleTextSize>0?i.labelStyleTextSize:12,s=15,r=0,o=0,{widthOffset:a,heightOffset:l}=zw(t,n,s);switch(i.iconPlacement.toLowerCase()){case on.LEFT:r=-a/2;break;case on.RIGHT:r=a/2;break;case on.ABOVE:o=-l/2;break;case on.BELOW:o=l/2;break}switch(e){case bi.RIGHT:return[a+r,o];case bi.LEFT:return[-a+r,o];case bi.TOP:return[r,-l+o];case bi.BOTTOM:return[r,l+o];default:return[0,0]}}function Uw(i,e,t){let n={height:e===!1?0:t?t.height:20,width:t?t.width:0};return[n.width/i,n.height/i]}function Fw(i){let e=Rp(i);return i.anchor||{x:Math.round(e.width/2),y:Math.round(e.height/2)}}function Rp(i){var s,r,o;let e=(r=(s=i.iconScale)!=null?s:i.imageScale)!=null?r:1,{width:t,height:n}=(o=i.iconSize)!=null?o:i.imageSize;return t>0&&n>0?{width:t*e,height:n*e}:{width:24*e,height:24*e}}function Bw(i){var e;switch((e=i==null?void 0:i.iconPlacement)==null?void 0:e.toLowerCase()){case on.ABOVE:return"bottom";case on.RIGHT:return"left";case on.BELOW:return"top";case on.LEFT:return"right";default:return"center"}}function kw(i){var e;switch((e=i==null?void 0:i.labelStylePosition)==null?void 0:e.toLowerCase()){case bi.BOTTOM:return"bottom";case bi.LEFT:return"left";case bi.RIGHT:return"right";case bi.TOP:return"top";default:return"center"}}function zw(i,e,t){let n=i?i.width:0,s=i?i.height:0,o=document.createElement("canvas").getContext("2d");o.font=`${e}px Open Sans Bold`;let a=o.measureText("Mjgp"),l=(n+t)/2/e,c=s/2/(a.fontBoundingBoxAscent-a.fontBoundingBoxDescent);return{widthOffset:l,heightOffset:c}}function Vw(i,e,t){var s,r,o,a,l,c,h,u,f,d,y,v,p,m,A,x,S,N,P,C,R,ne,b,_,M,I,O,B,D,X,q,Q,ae,ee,H,be,Y,oe,he,ge;let n=new Image;return n.crossOrigin="Anonymous",n.width=80,n.height=32,e&&!t?(n.src=(a=(o=(r=(s=Rr)==null?void 0:s.labelStyle)==null?void 0:r.graphic)==null?void 0:o.backgroundImage)!=null?a:ce.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:(u=(h=(c=(l=Rr)==null?void 0:l.labelStyle)==null?void 0:c.graphic)==null?void 0:h.stretchX)!=null?u:ce.labelStyle.graphic.stretchX,stretchY:(v=(y=(d=(f=Rr)==null?void 0:f.labelStyle)==null?void 0:d.graphic)==null?void 0:y.stretchY)!=null?v:ce.labelStyle.graphic.stretchY,content:(x=(A=(m=(p=Rr)==null?void 0:p.labelStyle)==null?void 0:m.graphic)==null?void 0:A.content)!=null?x:ce.labelStyle.graphic.content}}):t?(n.src=(C=(P=(N=(S=Ir)==null?void 0:S.labelStyle)==null?void 0:N.graphic)==null?void 0:P.backgroundImage)!=null?C:ce.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:(_=(b=(ne=(R=Ir)==null?void 0:R.labelStyle)==null?void 0:ne.graphic)==null?void 0:b.stretchX)!=null?_:ce.labelStyle.graphic.stretchX,stretchY:(B=(O=(I=(M=Ir)==null?void 0:M.labelStyle)==null?void 0:I.graphic)==null?void 0:O.stretchY)!=null?B:ce.labelStyle.graphic.stretchY,content:(Q=(q=(X=(D=Ir)==null?void 0:D.labelStyle)==null?void 0:X.graphic)==null?void 0:q.content)!=null?Q:ce.labelStyle.graphic.content}}):(n.src=(ee=(ae=i==null?void 0:i.labelStyleGraphic)==null?void 0:ae.backgroundImage)!=null?ee:ce.labelStyle.graphic.backgroundImage,{backgroundImage:n,iconTextFit:{stretchX:(be=(H=i==null?void 0:i.labelStyleGraphic)==null?void 0:H.stretchX)!=null?be:ce.labelStyle.graphic.stretchX,stretchY:(oe=(Y=i==null?void 0:i.labelStyleGraphic)==null?void 0:Y.stretchY)!=null?oe:ce.labelStyle.graphic.stretchY,content:(ge=(he=i==null?void 0:i.labelStyleGraphic)==null?void 0:he.content)!=null?ge:ce.labelStyle.graphic.content}})}var $r,na,jr,Jh,cv,Qh,hv,jh=class extends lv.EventEmitter{constructor(t){super();U(this,Jh);U(this,Qh);U(this,$r,void 0);U(this,na,void 0);U(this,jr,void 0);cn(this,"update",Gw(t=>{var l;let n=g(this,$r),s=n.getMapView(),r=s==null?void 0:s.getBounds(),o=n==null?void 0:n.getFloor(),a=n==null?void 0:n.getSolutionConfig();return ct(r)||ct(o)||(s==null?void 0:s.getZoom())<((l=a==null?void 0:a.minimumDataLoadZoomLevel)!=null?l:10)?Promise.resolve():Promise.all(Array.from(g(this,na)).map(c=>c.apply(null,[r,o]))).then(c=>c.flat()).then(c=>te(this,Jh,cv).call(this,c)).then(c=>te(this,Qh,hv).call(this,c,t,n)).then(c=>Hw(c)).then(c=>Ep(c,g(this,jr),g(this,$r))).then(c=>W(this,jr,c)).finally(()=>this.emit("update_completed"))}));W(this,$r,t),W(this,na,new Set),W(this,jr,new Map)}addDataSource(t){return typeof t=="function"?(g(this,na).add(t),t):null}getViewData(){return g(this,jr)}};$r=new WeakMap,na=new WeakMap,jr=new WeakMap,Jh=new WeakSet,cv=function(t){let n=g(this,$r).getFilter();return n&&n.length>0?t.filter(s=>s?(s.properties&&typeof s.properties.type=="string"?s.properties.type:"").toLowerCase().startsWith("mi_")||n.includes(s.id):!1):t},Qh=new WeakSet,hv=function(t,n,s){if(n&&t.length>0){let r=[180,90,-180,-90],o=t.reduce((a,l)=>{var h,u,f;if(!l||(f=(u=(h=l==null?void 0:l.properties)==null?void 0:h.type)==null?void 0:u.toLowerCase())!=null&&f.startsWith("mi_"))return a;let c=Xt.fromGeoJSON(l.geometry);return a.bbox=Xt.combine(a.bbox,c),a.features.push(l),a},{type:"FeatureCollection",features:[],bbox:r});Xt.equals(o.bbox,r)||s.goTo(o,{padding:50})}return t};function Hw(i){let e=[];for(let t of i)t&&!isNaN(t.area)&&Sl(e,t,(n,s)=>n.area>s.area);return e}function Gw(i){let e=!1,t=null;function n(...s){if(e){t={args:s};return}e=!0,i.apply(null,s).finally(()=>{if(e=!1,t){let{args:r}=t;t=null,n(...r)}})}return n}T();var ia=class{static merge(e){return e.reduce((t,n={})=>{for(let s of Object.keys(n))(t[s]===void 0||n[s]!==null&&n[s]!==void 0)&&(t[s]=n[s]);return t},new ia)}};T();var uv=ln(ii());var Hs,Jr=class extends uv.EventEmitter{constructor(){super(...arguments);U(this,Hs,new Map)}set(t,n){if(t instanceof Map&&!n)for(let[s,r]of t)g(this,Hs).set(s.toLowerCase(),r);else{let s=t instanceof Array?t:[t];for(let r of s)n?g(this,Hs).set(r.toLowerCase(),n):g(this,Hs).delete(r.toLowerCase())}this.emit("change")}get(t){return g(this,Hs).get(t==null?void 0:t.toLowerCase())}clear(){g(this,Hs).clear()}};Hs=new WeakMap;var Av=ln(ii());T();T();var Hi=class{};cn(Hi,"isString",e=>Object.prototype.toString.call(e)==="[object String]"),cn(Hi,"isNumber",e=>Object.prototype.toString.call(e)==="[object Number]"),cn(Hi,"isBoolean",e=>Object.prototype.toString.call(e)==="[object Boolean]"),cn(Hi,"isUndefined",e=>e===void 0||typeof e=="undefined"),cn(Hi,"isNull",e=>e===null),cn(Hi,"optional",e=>t=>t==null||e(t)),cn(Hi,"isAny",()=>!0);var Ai=Hi;T();var Cp=class{static validateModel(e,t,n){let s={...e};return Reflect.ownKeys(s).reduce((r,o)=>{let a=t[o],l=s[o];!a||a(l)||n&&(s[o]=n[o])},[]),s}static failedValidations(e,t){let n=[];return Reflect.ownKeys(e).reduce((s,r)=>{let o=t[r],a=e[r];!o||o(a)||n.push(r)},[]),n.length>0&&console.error(`Validations failures: ${n.join(", ")}`),n}},eu=Cp;T();var fv=i=>eu.validateModel(i,{extrusionOpacity:Ai.isNumber,wallOpacity:Ai.isNumber},zn.DEFAULTS),zn=class{constructor(e){Object.assign(this,fv(e))}static merge(e,t){return new zn({...e,...fv(t)})}static get DEFAULTS(){return Object.freeze({extrusionOpacity:1,wallOpacity:1})}};var Ww={enableClustering:!0,collisionHandling:0},dv=i=>eu.validateModel(i,{enableClustering:Ai.isBoolean,collisionHandling:Ai.isNumber,automatedZoomLimit:Ai.optional(Ai.isNumber),settings3D:Ai.isAny,mainDisplayRule:Ai.isAny,stateDisplayRules:Ai.isAny},Ww),sa,Qr,ra,zl,tu,pv,nu,mv,iu,gv,su,yv,ru,_v,ou,vv,au,xv,lu,bv,cu=class{constructor(e){U(this,tu);U(this,nu);U(this,iu);U(this,su);U(this,ru);U(this,ou);U(this,au);U(this,lu);U(this,sa,void 0);U(this,Qr,{hover:new yt(Yy),highlight:new yt(Ir),selection:new yt(Rr),hoverHighlight:new yt(Ky),hoverSelection:new yt(Zy)});U(this,ra,void 0);U(this,zl,void 0);Object.defineProperty(this,"mainDisplayRule",{enumerable:!0,get:te(this,tu,pv),set:te(this,nu,mv)}),Object.defineProperty(this,"settings3D",{enumerable:!0,get:te(this,ru,_v),set:te(this,ou,vv)}),Object.defineProperty(this,"buildingHighlightDisplayRule",{enumerable:!0,get:te(this,au,xv),set:te(this,lu,bv)}),Object.defineProperty(this,"stateDisplayRules",{enumerable:!0,get:te(this,iu,gv),set:te(this,su,yv)});let t;e&&(t=Ps(e)),Object.assign(this,dv(t))}static merge(e,t){if(!e&&!t)return new cu;if(!t)return e;let n=dv(t),s={...e,...n};return s.buildingHighlightDisplayRule={...e.buildingHighlightDisplayRule,...n.buildingHighlightDisplayRule},s.settings3D={...e.settings3D,...n.settings3D},s.mainDisplayRule={...e.mainDisplayRule,...n.mainDisplayRule},s.stateDisplayRules={...e.stateDisplayRules,...n.stateDisplayRules},new cu(s)}},oa=cu;sa=new WeakMap,Qr=new WeakMap,ra=new WeakMap,zl=new WeakMap,tu=new WeakSet,pv=function(){return g(this,sa)},nu=new WeakSet,mv=function(e){W(this,sa,yt.merge([yt.DEFAULT_RULE,g(this,sa),e]))},iu=new WeakSet,gv=function(){return g(this,Qr)},su=new WeakSet,yv=function(e){e!=null||(e={});for(let[t,n]of Object.entries(e))t in g(this,Qr)&&(g(this,Qr)[t]=new yt({...g(this,Qr)[t],...n}))},ru=new WeakSet,_v=function(){return g(this,ra)},ou=new WeakSet,vv=function(e){W(this,ra,zn.merge(g(this,ra),e))},au=new WeakSet,xv=function(){return g(this,zl)},lu=new WeakSet,bv=function(e){W(this,zl,yt.merge([Ah,e]))};T();function Mv(i){try{let e=i();return[void 0,e]}catch(e){return[e,void 0]}}function Sv(i){return i().then(e=>[void 0,e]).catch(e=>[e,void 0])}var wv=()=>{},aa,la,is,ss,Vl,eo,Ie,pn,rs,mn,os,as,Hl,Lp,hu,Ev,Gl,Pp,uu,Tv,Gi=class extends Av.default{constructor(t){var o,a;super();U(this,Hl);U(this,hu);U(this,Gl);U(this,uu);U(this,aa,new Jr);U(this,la,void 0);U(this,is,new Jr);U(this,ss,new Jr);U(this,Vl,new Set);U(this,eo,new Set);U(this,Ie,new zt);U(this,pn,void 0);U(this,rs,null);U(this,mn,null);U(this,os,"automatic");U(this,as,"automatic");let n=t||{};this.__VERSION__="4.38.1",W(this,pn,new jh(this)),W(this,as,((o=t==null?void 0:t.buildingSelectionMode)==null?void 0:o.toLowerCase())==="manual"?"manual":"automatic"),W(this,os,((a=t==null?void 0:t.floorSelectionMode)==null?void 0:a.toLowerCase())==="manual"?"manual":"automatic");let s=g(this,pn);s.addDataSource((l,c)=>Un.dataSource(l,c).then(h=>(this.emit("locations_changed",h),h))),s.addDataSource((l,c)=>{var h,u;if(g(this,as)==="manual"){let f=this.getBuilding();return(u=(h=f==null?void 0:f.floors)==null?void 0:h[c])!=null&&u.geometry?Promise.resolve({id:`MI_${f.id}_${c}`,type:"Feature",geometry:f.floors[c].geometry,area:f.area,properties:{type:an.MIType.MI_BUILDING_OUTLINE}}):Promise.resolve(null)}else{let f=this.getMapView();if(f.getPitch()!==0){let y=f.getDiv(),v=y.offsetWidth,p=y.offsetHeight,m=f.getCenter(),A=f.unproject(v>p?{x:v,y:p/2}:{x:v/2,y:p}),x=Vt.computeDistanceBetween(m,A),S=Vt.computeDestination(m,x,225),N=Vt.computeDestination(m,x,45);l={south:S.lat,west:S.lng,north:N.lat,east:N.lng}}return te(this,uu,Tv).call(this,l).then(y=>!y||!(y.floors&&y.floors[c])?null:{id:`MI_${y.id}_${c}`,type:"Feature",geometry:y.floors[c].geometry,area:y.area,properties:{type:an.MIType.MI_BUILDING_OUTLINE}})}});for(let[l,c]of Object.entries($y))g(this,aa).set(l,c);de.on("apikey_changed",()=>{wt.getVenues().then(l=>{var c;l.length&&(((c=de.venuesToSync)==null?void 0:c.length)>0&&(l=l.filter(h=>de.venuesToSync.includes(h.id))),this.setVenue(l[0]))})}),g(this,Ie).addListener("venue_changed",({oldValue:l})=>{var u,f,d,y;let c=this.getVenue(),h=this.getFloor();if(typeof c=="string"&&c>""){wt.getVenue(c).then(v=>this.setVenue(v));return}if(g(this,as)==="automatic"&&g(this,os)==="automatic"){let v=(l==null?void 0:l.id)===(c==null?void 0:c.id)?(u=this.getFloor())!=null?u:c.defaultFloor:(d=(f=c.defaultFloor)!=null?f:h)!=null?d:0;this.setFloor(v)}this.setMapsIndoorsStyle(n.mapStyle||((y=c==null?void 0:c.styles)==null?void 0:y[0])),this.getMapView().setMapsIndoorsTileURL(this.getTileURL()),te(this,Gl,Pp).call(this).then(v=>this.getMapView().setFloorPlan(v)),(l==null?void 0:l.id)!==(c==null?void 0:c.id)&&this.emit("venue_changed",c)}),s.on("update_completed",r(()=>{let l=this.getMapView();if(l&&l.setViewData&&l.isReady){let c=s.getViewData();l.setViewData(c)}},16.66)),g(this,Ie).addListener("building_changed",({oldValue:l})=>{var f;let c=this.getBuilding(),h=this.getFloor(),u=((f=g(this,os))==null?void 0:f.toLowerCase())==="automatic"?Qy(h,c):void 0;!ct(u)&&u!==h?this.setFloor(u):s.update(),(l==null?void 0:l.id)!==(c==null?void 0:c.id)&&this.emit("building_changed",c)}),g(this,Ie).addListener("floor_changed",()=>{let l=this.getMapView();if(l&&l.isReady){s.update();let c=this.getFloor();this.getMapView().setMapsIndoorsTileURL(this.getTileURL()),te(this,Gl,Pp).call(this).then(h=>this.getMapView().setFloorPlan(h)),this.emit("floor_changed",c)}}),this.addListener("data_updated",()=>{g(this,pn).update(),this.emit("redraw")});function r(l,c){let h;return(...u)=>{h||(h=!0,setTimeout(()=>{l.apply(null,u),h=!1},c))}}g(this,is).addListener("change",()=>{s.update(),this.emit("redraw")}),g(this,ss).addListener("change",()=>{s.update(),this.emit("redraw")}),g(this,Ie).addListener("solutionconfig_changed",()=>{var u;let l=g(this,Ie).get("solutionConfig"),c=g(this,Ie).get("buildingOutlineOptions"),h=yt.merge([l==null?void 0:l.buildingHighlightDisplayRule,{polygon:c}]);this.setDisplayRule(an.MIType.MI_BUILDING_OUTLINE,h),(u=this.getMapView())==null||u.setSolutionConfig(l),s.update(),this.emit("redraw")}),g(this,Ie).addListener("mapview_changed",()=>{let l=this.getMapView();l.addListener("bounds_changed",r(()=>{s.update()},500)),l.addListener("click",u=>{Un.getLocation(u).then(f=>{var d;this.emit("click",f),Bt.log(bt.map.MAP_CLICKED,{location_type:(d=f==null?void 0:f.properties)==null?void 0:d.locationType})})}),l.addListener("mouseenter",({id:u})=>{var d;let f=(d=g(this,mn))==null?void 0:d.id;f!==u&&(f&&c.call(this,f),h.call(this,u))});function c(u){var f;W(this,mn,((f=g(this,mn))==null?void 0:f.id)===u?null:g(this,mn)),g(this,pn).update(),Un.getLocation(u).then(d=>{this.emit("mouseleave",d)})}function h(u){!u||Un.getLocation(u).then(f=>{W(this,mn,f),this.emit("mouseenter",f),g(this,pn).update()})}l.addListener("zoom_changed",()=>{this.emit("zoom_changed",this.getZoom())}),Wr.getSolution().then(u=>{let f=new oa(u.solutionConfig),d=u.modules||[];g(this,Ie).set("types",u.types),g(this,Ie).set("solutionConfig",f),g(this,Ie).set("modules",d),d.includes("z22")&&this.getMapView().enableZoom22(),u.whitelabel||l.addLogo();let y=this.getVenue();!y||!y.id?this.once("venue_changed",()=>{this.emit("ready")}):this.emit("ready")})}),g(this,Ie).addListener("mapstyle_changed",()=>{let l=this.getVenue();l&&l.id&&this.getMapView().setMapsIndoorsTileURL(this.getTileURL())}),g(this,Ie).addListener("buildingoutlineoptions_changed",()=>{var f;let l=(f=g(this,Ie).get("solutionConfig"))==null?void 0:f.buildingHighlightDisplayRule,c=g(this,is).get(an.MIType.MI_BUILDING_OUTLINE),h=g(this,Ie).get("buildingOutlineOptions"),u=yt.merge([c,l,{polygon:h}]);this.setDisplayRule(an.MIType.MI_BUILDING_OUTLINE,u)}),g(this,Ie).addListener("labeloptions_changed",()=>{let l=this.getMapView();l&&l.getBounds()&&(s.update(),l.setLabelOptions(g(this,Ie).get("labelOptions")))}),!n.venue&&!this.getVenue()&&wt.getVenues().then(l=>{this.getVenue()||this.setVenue(l[0])}),de.on("language_changed",async()=>{var f,d;let l=(f=this.getVenue())==null?void 0:f.id,c=(d=this.getBuilding())==null?void 0:d.id,[h,u]=await Promise.all([wt.getVenue(l),wt.getBuilding(c)]);g(this,Ie).set("venue",h),g(this,Ie).set("building",u)}),Un.on("update_completed",()=>{s.update()}),Un.on("locations_deleted",()=>{s.update()}),g(this,Ie).setValues(n),g(this,Ie).addListener("floorselectionmode_changed",({newValue:l,oldValue:c})=>{c!==l&&(W(this,os,(l==null?void 0:l.toLowerCase())==="manual"?"manual":"automatic"),g(this,Ie).set("building",this.getBuilding(),!0))}),g(this,Ie).addListener("buildingselectionmode_changed",({newValue:l,oldValue:c})=>{c!==l&&(W(this,as,(l==null?void 0:l.toLowerCase())==="manual"?"manual":"automatic"),g(this,Ie).set("building",this.getBuilding(),!0))}),de.on("userroles_changed",()=>{g(this,pn).update()}),Bt.log(bt.appLifeTime.MAPSINDOORS_INSTANTIATED)}getBuilding(){return g(this,Ie).get("building")}setBuilding(t){var n;if(Object.keys((n=t.floors)!=null?n:{}).length===0){wt.getBuilding(t.id).then(s=>g(this,Ie).set("building",s));return}g(this,Ie).set("building",t)}fitBuilding(t){t=t||this.getBuilding();let n=this.getMapView();return t?new Promise((s,r)=>{(typeof t=="string"?wt.getBuilding(t):Promise.resolve(t)).then(o=>{n&&n.isReady?this.goTo(o).then(s,r):this.once("ready",()=>{this.fitBuilding.call(this,o).then(s,r)})}).catch(r)}):Promise.reject()}goTo(t,{padding:n,maxZoom:s}={padding:0}){var d,y,v;let r=g(this,Ie).get("solutionConfig"),o=this.getMapView(),a=(y=(d=o.getDiv())==null?void 0:d.getBoundingClientRect())!=null?y:{};s=(v=s!=null?s:r==null?void 0:r.automatedZoomLimit)!=null?v:o.getMaxZoom();let[l,c]=Mv(()=>Xt.fromGeoJSON(t));if(l)return Promise.reject(l);let h=R_(c,a,s),u=Vt.toArray(Xt.getCenter(c)),f=h<=s?c:I_(u,s,a);return o.fitBounds(f,n)}filter(t,n){W(this,Vl,new Set(t)),g(this,pn).update(n)}getFilter(){return[...g(this,Vl)]}highlight(t,n){W(this,eo,new Set(t)),g(this,pn).update(n)}getHighlight(){return[...g(this,eo)]}hoverLocation(t){var n;(t==null?void 0:t.id)!==((n=g(this,mn))==null?void 0:n.id)&&(W(this,mn,t),g(this,pn).update())}unhoverLocation(){W(this,mn,null),g(this,pn).update()}getHoveredLocation(){return g(this,mn)}selectLocation(t){var n;(t==null?void 0:t.id)!==((n=g(this,rs))==null?void 0:n.id)&&(W(this,rs,t),g(this,pn).update())}deselectLocation(){W(this,rs,null),g(this,pn).update()}getSelectedLocation(){return g(this,rs)}getLocationSettings(t){var c,h;let n=g(this,Ie).get("solutionConfig"),s=(h=(c=t==null?void 0:t.properties)==null?void 0:c.type)==null?void 0:h.toLowerCase(),o=(g(this,Ie).get("types")||[]).find(u=>{var f;return((f=u==null?void 0:u.name)==null?void 0:f.toLowerCase())===s})||{},a=t.properties.locationSettings,l=[(n==null?void 0:n.locationSettings)||{},o.locationSettings||{},a||{}];return ia.merge(l)}setBuildingOutlineOptions(t){g(this,Ie).set("buildingOutlineOptions",t)}getBuildingOutlineOptions(){let t=g(this,Ie).get("buildingOutlineOptions"),n=Ah;return Object.assign({},{visible:n.visible,strokeColor:n.polygonStrokeColor,strokeOpacity:n.polygonStrokeOpacity,strokeWeight:n.polygonStrokeWeight,zoomFrom:n.zoomFrom,zoomTo:n.zoomTo},t)}_addDataSource(t){g(this,pn).addDataSource(t)}setDisplayRule(t,n){g(this,is).set(t,n)}getDisplayRule(t,n=!1){let s=te(this,Hl,Lp).call(this,t),r=n?{}:g(this,ss).get(t==null?void 0:t.id);return yt.merge([...s,r])}getStatefulDisplayRule(t,n=!1){let s=te(this,Hl,Lp).call(this,t),r=te(this,hu,Ev).call(this,t==null?void 0:t.id),o=n?{}:g(this,ss).get(t==null?void 0:t.id);return yt.merge([...s,r,o])}getDirectionsRenderer(){let t=this.getMapView();if(t)return g(this,la)||W(this,la,new t.DirectionsRenderer(this)),g(this,la)}setFloor(t){let n=this.getMapView(),s=Number(t);if(!isNaN(s)&&s!==this.getFloor()){if(!(n!=null&&n.isReady)){n.once("ready",()=>this.setFloor(t));return}g(this,Ie).set("floor",s)}}getFloor(){return g(this,Ie).get("floor")}getMap(){let t=this.getMapView();return t?t.getMap():null}getZoom(){let t=this.getMapView();return t?t.getZoom():null}setZoom(t){let n=this.getMapView();n&&n.setZoom(t)}getMaxZoom(){let t=this.getMapView();return t?t.getMaxZoom():null}setVenue(t){let n=this.getMapView(),s=this.getVenue();(t&&typeof t=="string"&&!s||t&&typeof t=="object"&&!s||t&&typeof t=="object"&&s&&typeof s=="string"||t&&typeof t=="string"&&s&&typeof s=="object"&&s.id!==t||t&&typeof t=="string"&&s&&typeof s=="string"&&s!==t||t&&typeof t=="object"&&s&&typeof s=="object"&&s.id!==t.id)&&(n?s&&t&&s.solutionId>""&&s.solutionId!==t.solutionId?Wr.getSolution().then(r=>{this.once("venue_changed",()=>{this.emit("ready")}),g(this,Ie).set("types",r.types),g(this,Ie).set("solutionConfig",new oa(r.solutionConfig)),g(this,Ie).set("venue",t)}):g(this,Ie).set("venue",t):this.once("ready",()=>{this.setVenue.call(this,t)}))}getVenue(){return g(this,Ie).get("venue")}fitVenue(t){t=t||this.getVenue();let n=this.getMapView();return t?new Promise((s,r)=>{(typeof t=="string"?wt.getVenue(t):Promise.resolve(t)).then(o=>{n&&n.isReady?this.goTo(o).then(s,r):n.once("ready",()=>{this.fitVenue.call(this,o).then(s,r)})}).catch(r)}):Promise.reject()}setLabelOptions(t){g(this,Ie).set("labelOptions",t)}getLabelOptions(){return g(this,Ie).get("labelOptions")}setMapsIndoorsStyle(t){t&&t.folder>""&&g(this,Ie).set("mapStyle",t)}getMapIndoorsStyle(){return g(this,Ie).get("mapStyle")}getMapIndoorsStyles(){let t=this.getVenue();if(t!=null&&t.styles)return t.styles}overrideDisplayRule(t,n){g(this,ss).set(t,n)}revertDisplayRule(t){g(this,ss).set(t,null)}setMapView(t){g(this,Ie).set("mapView",t)}getMapView(){return g(this,Ie).get("mapView")}getTileURL(){let t=this.getVenue(),n=this.getMapIndoorsStyle(),s=this.getFloor();return!(t!=null&&t.tilesUrl)||!(n!=null&&n.folder)||isNaN(s)||typeof t.tilesUrl!="string"?null:t.tilesUrl.replace("{floor}",s).replace("{style}",n.folder)}deallocate(){qo.clear(),g(this,is).clear(),g(this,aa).clear(),g(this,ss).clear(),g(this,Ie).removeAllListeners(),this.getMapView().deallocate(),de.removeAllListeners(),this.removeAllListeners()}getSolutionConfig(){return de.apiKey?g(this,Ie).get("solutionConfig"):null}setSolutionConfig(t){let n=g(this,Ie).get("solutionConfig");if(n){let s=oa.merge(n,t);g(this,Ie).set("solutionConfig",s)}}setBuildingSelectionMode(t="automatic"){["manual","automatic"].includes(t.toLowerCase())&&t!==g(this,as)&&g(this,Ie).set("buildingSelectionMode",t)}getBuildingSelectionMode(){var t;return((t=g(this,as))==null?void 0:t.toLowerCase())==="automatic"?"automatic":"manual"}setFloorSelectionMode(t="automatic"){["manual","automatic"].includes(t.toLowerCase())&&t!==g(this,os)&&g(this,Ie).set("floorSelectionMode",t)}getFloorSelectionMode(){var t;return((t=g(this,os))==null?void 0:t.toLowerCase())==="automatic"?"automatic":"manual"}static setMapsIndoorsApiKey(t){de.apiKey=t}static getLanguage(){return de.language}static setLanguage(t){t>""&&(de.language=t)}static set onAuthRequired(t){wv=typeof t=="function"?t:()=>{}}static get onAuthRequired(){return wv}static setAuthToken(t){de.authToken=t}static setUserRoles(t){de.userRoles=t}static getUserRoles(){return de.userRoles}static disableEventLogging(t=!0){de.eventLoggingEnabled=t!==!0}static addVenuesToSync(t){de.venuesToSync=[...new Set([].concat(t,de.venuesToSync))]}static removeVenuesToSync(t){t=[].concat(t),de.venuesToSync=de.venuesToSync.filter(n=>!t.includes(n))}static get eventLoggingEnabled(){return de.eventLoggingEnabled}static async synchronizeContent(){}};aa=new WeakMap,la=new WeakMap,is=new WeakMap,ss=new WeakMap,Vl=new WeakMap,eo=new WeakMap,Ie=new WeakMap,pn=new WeakMap,rs=new WeakMap,mn=new WeakMap,os=new WeakMap,as=new WeakMap,Hl=new WeakSet,Lp=function(t){var h,u,f,d,y,v;let n=g(this,Ie).get("solutionConfig"),s=(h=n==null?void 0:n.mainDisplayRule)!=null?h:{},r=(f=(u=t==null?void 0:t.properties)==null?void 0:u.originalId)!=null?f:t==null?void 0:t.id,o=(y=(d=t==null?void 0:t.properties)==null?void 0:d.type)==null?void 0:y.toLowerCase(),a=((v=t==null?void 0:t.properties)==null?void 0:v.displayRule)||{},c=(g(this,Ie).get("types")||[]).find(p=>{var m;return((m=p==null?void 0:p.name)==null?void 0:m.toLowerCase())===o})||{};return[yt.DEFAULT_RULE,s||{},g(this,aa).get(o)||{},c.displayRule||{},g(this,is).get(o)||{},a,g(this,is).get(r)||{}]},hu=new WeakSet,Ev=function(t){var c,h,u,f,d,y;let n=g(this,Ie).get("solutionConfig"),{highlight:s,hover:r,hoverHighlight:o,selection:a,hoverSelection:l}=(c=n==null?void 0:n.stateDisplayRules)!=null?c:{};return t===((h=g(this,mn))==null?void 0:h.id)&&t===((u=g(this,rs))==null?void 0:u.id)?l:t===((f=g(this,rs))==null?void 0:f.id)?a:t===((d=g(this,mn))==null?void 0:d.id)&&g(this,eo).has(t)?o:g(this,eo).has(t)?s:t===((y=g(this,mn))==null?void 0:y.id)&&this.getLocationSettings(g(this,mn)).selectable?r:{}},Gl=new WeakSet,Pp=async function(){let t=this.getVenue(),n=this.getFloor();return t&&!ct(n)?await Xr.getFloorPlan(de.apiKey,t.id,n):{type:"FeatureCollection",features:[]}},uu=new WeakSet,Tv=function(t){return wt.getBuildingInView(t).then(n=>{let s=this.getBuilding();return n?!s||s.id!==n.id?wt.getBuilding(n.id).then(r=>{let o=this.getBuilding();return r&&(!o||o.id!==r.id)?r:o}):s:null}).then(n=>(g(this,Ie).set("building",n),n))};T();T();function Xw(i,e,t){t===void 0&&(t={});var n=Jt(i),s=Jt(e),r=Nt(s[1]-n[1]),o=Nt(s[0]-n[0]),a=Nt(n[1]),l=Nt(s[1]),c=Math.pow(Math.sin(r/2),2)+Math.pow(Math.sin(o/2),2)*Math.cos(a)*Math.cos(l);return Zd(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),t.units)}var fu=Xw;function Np(i,e){return e===void 0&&(e={}),i_(i,function(t,n){var s=n.geometry.coordinates;return t+fu(s[0],s[1],e)},0)}T();T();function Wl(i,e,t){if(t===void 0&&(t={}),t.final===!0)return qw(i,e);var n=Jt(i),s=Jt(e),r=Nt(n[0]),o=Nt(s[0]),a=Nt(n[1]),l=Nt(s[1]),c=Math.sin(o-r)*Math.cos(l),h=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(o-r);return Pr(Math.atan2(c,h))}function qw(i,e){var t=Wl(e,i);return t=(t+180)%360,t}T();function ca(i,e,t,n){n===void 0&&(n={});var s=Jt(i),r=Nt(s[0]),o=Nt(s[1]),a=Nt(t),l=$d(e,n.units),c=Math.asin(Math.sin(o)*Math.cos(l)+Math.cos(o)*Math.sin(l)*Math.cos(a)),h=r+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(o),Math.cos(l)-Math.sin(o)*Math.sin(c)),u=Pr(h),f=Pr(c);return Ns([u,f],n.properties)}function Yw(i,e,t,n){if(n=n||{},!Nr(n))throw new Error("options is invalid");var s,r=[];if(i.type==="Feature")s=i.geometry.coordinates;else if(i.type==="LineString")s=i.coordinates;else throw new Error("input must be a LineString Feature or Geometry");for(var o=s.length,a=0,l,c,h,u=0;u<s.length&&!(e>=a&&u===s.length-1);u++){if(a>e&&r.length===0){if(l=e-a,!l)return r.push(s[u]),Os(r);c=Wl(s[u],s[u-1])-180,h=ca(s[u],l,c,n),r.push(h.geometry.coordinates)}if(a>=t)return l=t-a,l?(c=Wl(s[u],s[u-1])-180,h=ca(s[u],l,c,n),r.push(h.geometry.coordinates),Os(r)):(r.push(s[u]),Os(r));if(a>=e&&r.push(s[u]),u===s.length-1)return Os(r);a+=fu(s[u],s[u+1],n)}if(a<e&&s.length===o)throw new Error("Start position is beyond line");var f=s[s.length-1];return Os([f,f])}var Iv=Yw;var Rv={type:"Feature",geometry:{type:"LineString",coordinates:[]}},Xl,ls,Ei,li,to,Wi,Gs,ha,ql,Op,ua=class extends zt{constructor(t){super();U(this,ql);U(this,Xl,void 0);U(this,ls,void 0);U(this,Ei,void 0);U(this,li,void 0);U(this,to,void 0);U(this,Wi,void 0);U(this,Gs,void 0);U(this,ha,function(){});let n=Object.assign({},{geodesic:!0,minAnimationTime:1.2,speed:300,strokeColor:Si(["color","blue","10","value"],un)||"hsl(215, 67%, 96%)",strokeOpacity:1,strokeWeight:2,zIndex:kl+1},t);this.setValues(n)}setPath(t){t&&t!==g(this,li)&&(W(this,li,t),W(this,Ei,Np(g(this,li),{units:"meters"})),W(this,Xl,g(this,li).coordinates.reduce((n,s)=>n+s[1],0)/g(this,li).coordinates.length),W(this,Wi,0),W(this,Gs,0))}start(){g(this,li)&&(W(this,to,!0),W(this,Wi,performance.now()-g(this,Gs)),W(this,ls,window.requestAnimationFrame(te(this,ql,Op).bind(this))))}stop(){W(this,to,!1),window.cancelAnimationFrame(g(this,ls)),g(this,ha).call(null,Rv),W(this,ls,null),W(this,Gs,0)}pause(){W(this,to,!1),window.cancelAnimationFrame(g(this,ls)),W(this,ls,null)}clear(){this.stop(),W(this,li,null)}set onanimationframe(t){t&&t.constructor&&t.call&&t.apply&&W(this,ha,t)}getOptions(){return this.getValues()}setOptions(t){this.setValues(t)}};Xl=new WeakMap,ls=new WeakMap,Ei=new WeakMap,li=new WeakMap,to=new WeakMap,Wi=new WeakMap,Gs=new WeakMap,ha=new WeakMap,ql=new WeakSet,Op=function(t){let n=this.get("mapsIndoors");if(n instanceof Gi&&g(this,li)&&g(this,to)){let s=Rv,r=n.getZoom(),o=Kw.call(this,r,g(this,Ei),g(this,Xl));W(this,Wi,g(this,Wi)===0?t:g(this,Wi)),W(this,Gs,t-g(this,Wi));let a=o*(g(this,Gs)/1e3),l=a<=g(this,Ei)?0:a-g(this,Ei),c=a<=g(this,Ei)?a:g(this,Ei);a>0&&l<g(this,Ei)&&(s=Iv(g(this,li),l,c,{units:"meters"}),s.properties=this.getOptions()),a>=g(this,Ei)*2&&W(this,Wi,t),g(this,ha).call(null,s),W(this,ls,window.requestAnimationFrame(te(this,ql,Op).bind(this)))}};function Kw(i,e,t){let n=this.get("speed"),s=this.get("minAnimationTime");return n*=Vt.getMeterPerPixel(t,i),e/n<s?e/s:n}T();var Yl,Kl,du,pu,Ws,mu,Zl,gu,yu,_u,fa=class{constructor({fillColor:e="#ef4444",numbered:t=!0}={}){U(this,Yl,!0);U(this,Kl,"#ef4444");U(this,du,"#ffffff");U(this,pu,"#ffffff");U(this,Ws,{width:56,height:66});U(this,mu,g(this,Ws).width/g(this,Ws).height);U(this,Zl,{x:g(this,Ws).width/2,y:17});U(this,gu,28);U(this,yu,new Path2D("M55.77,24.35C54.16,11.74,43.82,1.57,31.16.17c-1.05-.11-2.11-.17-3.16-.17C12.56,0,0,12.56,0,28c0,11.57,7.27,22.09,18.08,26.18.55.21.97.57,1.19,1.03l3.34,6.84c1.01,2.08,3.08,3.37,5.39,3.37s4.38-1.29,5.39-3.37l3.34-6.86c.22-.44.64-.8,1.19-1.01,12.16-4.6,19.5-16.86,17.85-29.83Z"));U(this,_u,new Path2D("M36.5,50.44c-1.46.55-2.68,1.59-3.36,3l-3.34,6.86c-.73,1.5-2.87,1.5-3.6,0l-3.34-6.85c-.68-1.4-1.9-2.45-3.36-3.01-9.06-3.43-15.5-12.18-15.5-22.44C4,13.84,16.26,2.56,30.72,4.15c10.88,1.2,19.7,9.85,21.08,20.71,1.47,11.58-5.33,21.81-15.3,25.58Z"));W(this,Yl,t),W(this,Kl,e)}getImage(e){return new Promise(t=>{let s=56/g(this,mu),r=document.createElement("canvas");r.width=56,r.height=s;let o=r.getContext("2d");o.scale(56/g(this,Ws).width,s/g(this,Ws).height),o.imageSmoothingQuality="high",o.textAlign="center",o.textBaseline="hanging",o.textRendering="optimizeLegibility",o.font=`bold ${g(this,gu)}px sans-serif`,o.clearRect(0,0,r.width,r.height),o.fillStyle=g(this,du),o.fill(g(this,yu)),o.fillStyle=g(this,Kl),o.fill(g(this,_u)),g(this,Yl)&&Number.isInteger(e)&&(o.fillStyle=g(this,pu),o.fillText(e,g(this,Zl).x,g(this,Zl).y,r.width));let a=new Image(r.width,r.height);a.onload=()=>t(a),a.src=r.toDataURL()})}};Yl=new WeakMap,Kl=new WeakMap,du=new WeakMap,pu=new WeakMap,Ws=new WeakMap,mu=new WeakMap,Zl=new WeakMap,gu=new WeakMap,yu=new WeakMap,_u=new WeakMap;var Zw={strokeColor:"#3071D9",strokeOpacity:1,strokeWeight:4,zIndex:kl,fitBounds:!0,visible:!0},Ot,jl,cs,da,no,$l,vu=class{constructor(e){U(this,no);U(this,Ot,void 0);U(this,jl,void 0);U(this,cs,void 0);U(this,da,new fa);if(W(this,cs,e.mapsIndoors),!(g(this,cs)instanceof Gi))throw new Error("mapsIndoors is not an instance of MapsIndoors");let t=e.animation===void 0?new ua({mapsIndoors:g(this,cs)}):e.animation;e.defaultRouteStopIconProvider===null?W(this,da,null):e.defaultRouteStopIconProvider!==void 0&&typeof e.defaultRouteStopIconProvider.getImage=="function"&&W(this,da,e.defaultRouteStopIconProvider);let n=g(this,cs).getMapView();W(this,Ot,new n.DirectionsRenderer(Object.assign({},Zw,e))),g(this,Ot).set("legIndex",0),g(this,Ot).set("stepIndex",-1),this.setAnimation(t),g(this,cs).on("floor_changed",()=>{te(this,no,$l).call(this,this.getStepIndex(),this.getLegIndex())})}setAnimation(e){let t=this.getAnimation();t&&t.clear(),g(this,Ot).set("animation",e)}getAnimation(){return g(this,Ot).get("animation")}async setRoute(e,t=new Map){let n=await $w(e,t,g(this,da));g(this,Ot).set("viewModel",n),W(this,jl,e),this.setStepIndex(-1,0)}getRoute(){return g(this,jl)}setOptions(e){g(this,Ot).setValues(e)}getVisible(){return g(this,Ot).get("visible")}setVisible(e){g(this,Ot).set("visible",e)}setLegIndex(e){let t=this.getRoute();if(t&&t.legs){let n=Qw(e,t.legs);n!==this.getLegIndex()&&this.setStepIndex(-1,n)}}getLegIndex(){return g(this,Ot).get("legIndex")}setStepIndex(e,t){let n=g(this,Ot).get("mapsIndoors"),s=g(this,Ot).get("fitBoundsPadding"),r=this.getRoute();if(t=isNaN(t)||t<0?this.getLegIndex():t,r&&r.legs&&Cv(t,r.legs)){let o=r.legs[t],a=parseInt(n.getFloor()),l=isNaN(o.end_location.zLevel)?0:parseInt(o.end_location.zLevel),c;if(e===-1)g(this,Ot).setStepIndex(e,t),te(this,no,$l).call(this,e,t),c=o.geometry;else if(o&&o.steps&&Cv(e,o.steps))g(this,Ot).setStepIndex(e,t),te(this,no,$l).call(this,e,t),c=o.steps[e].geometry;else return;a!==l&&n.setFloor(l),g(this,Ot).get("fitBounds")===!0&&c&&n.goTo({geometry:c},{padding:s}).then(()=>{a!==l&&n.setFloor(l)})}else r||(g(this,Ot).setStepIndex(e,t),te(this,no,$l).call(this,0,-1))}getStepIndex(){return g(this,Ot).get("stepIndex")}nextLeg(){this.setLegIndex(this.getLegIndex()+1)}previousLeg(){this.setLegIndex(this.getLegIndex()-1)}nextStep(){let e=this.getRoute(),t=this.getLegIndex(),n=this.getStepIndex()+1;if(e&&e.legs){let s=e.legs[t];s&&s.steps&&n<s.steps.length?this.setStepIndex(n,t):this.setStepIndex(0,t+1)}}previousStep(){let e=this.getRoute(),t=this.getLegIndex(),n=this.getStepIndex();if(e&&e.legs){if(n===0&&t===0)return;if(t>0&&n<=0){t-=1;let s=e.legs[t];s&&s.steps&&this.setStepIndex(s.steps.length-1,t)}else this.setStepIndex(n-1,t)}}};Ot=new WeakMap,jl=new WeakMap,cs=new WeakMap,da=new WeakMap,no=new WeakSet,$l=function(e,t){var o,a,l;let n=parseInt(g(this,cs).getFloor()),s=this.getAnimation(),[r]=(o=g(this,Ot).get("viewModel"))!=null?o:[];if(!(!s||!r))if(e>-1&&t>-1){let c=Si([t,e],r);if(c.properties.routeContext!=="Outside"&&((a=c==null?void 0:c.properties)==null?void 0:a.floorIndex)!==n){s.clear();return}s.setPath(c.geometry),s.start()}else if(e===-1&&t>-1){let c=(l=r[t])==null?void 0:l.reduce((h,u)=>u.properties.routeContext!=="Outside"&&parseInt(u.properties.floorIndex)!==n?h:h.concat(u.geometry.coordinates),[]);s.setPath({type:"LineString",coordinates:c}),s.start()}else s.stop()};async function $w(i,e=new Map,t){if(i&&i.legs){let n=jw(e,t),s=await Promise.all(i.stops.map(n));return[i.legs.map(Jw),s]}return[]}function jw(i,e){return async function(n,s){var c,h;let r=i.get(s),o=(c=r==null?void 0:r.iconProvider)!=null?c:e,a=await(o==null?void 0:o.getImage(s+1)),l=a?{width:a.width,height:a.height}:void 0;return{id:s,type:"Feature",geometry:{type:"Point",coordinates:[n.lng,n.lat]},properties:{floorIndex:n.zLevel,stopIndex:s,icon:a,iconSrc:a==null?void 0:a.src,iconScale:.5,iconSize:l,iconPlacement:"bottom",labelFont:'"Open Sans Bold", "Arial Unicode MS Regular", sans-serif',labelFontWeight:"bold",labelText:(h=r==null?void 0:r.label)!=null?h:"",labelSize:16,labelColor:"#1F2937",labelStrokeBlur:0,labelStrokeStyle:"#FFFFFF",labelStrokeWidth:2,labelOffset:[0,.75],labelOpacity:1,sortKey:kl-s,visibility:"visible"}}}}function Jw(i,e){return(i.steps||[]).map((t,n)=>({type:"Feature",geometry:t.geometry,properties:{floorIndex:t.end_location.zLevel,routeContext:t.route_context,legIndex:e,stepIndex:n,visibility:"visible"}}))}function Cv(i,e){return Number.isInteger(i)&&i>-1&&i<e.length}function Qw(i,e){return Math.max(0,Math.min(e.length-1,i))}T();var xu=class{constructor(e,t){e.className="mapsindoors floor-selector",t.addListener("building_changed",s);let n=new MutationObserver(()=>{document.body.contains(e)&&(r(),n.disconnect())});n.observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0}),t.addListener("floor_changed",function(){let a=t.getFloor().toString();Array.from(e.childNodes).forEach(c=>{let h=c.className.split(" ");c.getAttribute("data-floor")===a?h.indexOf("active")<0&&h.push("active"):h.splice(h.indexOf("active"),1),c.className=h.join(" ")})}),t.getBuilding()&&s.call(t);function s(){let a=t.getBuilding();if(e.innerHTML="",a){let l=t.getFloor(),c=!ct(l)&&!isNaN(l)?l.toString():"",h=a.floors;Object.keys(h).sort((u,f)=>f-u).forEach(u=>{let f=document.createElement("a");f.innerHTML=h[u].name,f.setAttribute("data-floor",u),f.onclick=o,f.className=c===u?"active":"",e.appendChild(f)}),r()}}function r(){if(e.scrollHeight>e.clientHeight){let a=e.querySelector(".active");(a&&a.offsetTop+a.clientHeight<e.scrollTop||a.offsetTop>e.scrollTop+e.clientHeight)&&(e.scrollTop=a.offsetTop-e.clientHeight/2-a.clientHeight/2)}}function o(){t.setFloor(this.getAttribute("data-floor"))}}};T();var Ql,ec,Jl=class{constructor(){U(this,Ql,void 0);U(this,ec,void 0);google&&google.maps&&google.maps.DirectionsService&&(W(this,Ql,new google.maps.DirectionsService),W(this,ec,new google.maps.DistanceMatrixService))}get ProviderName(){return"google"}static get availableTravelModes(){return["DRIVING","WALKING","BICYCLING","TRANSIT"]}getRoute(e){return new Promise(t=>{delete e.origin.floor,delete e.destination.floor,e.language=de.language,g(this,Ql).route(e,(n,s)=>{if(s!==google.maps.DirectionsStatus.OK)return t({route:null,status:s});let r=n.routes[0];for(let o of r.legs)if(o.start_location=o.start_location.toJSON(),o.end_location=o.end_location.toJSON(),o.steps=Lv(o.steps,e.travelMode),o.geometry={type:"LineString",coordinates:o.steps.reduce((a,l)=>a.concat(l.geometry.coordinates),[])},!o.arrival_time&&!o.departure_time){let a={distance:o.distance,duration:o.duration,end_context:null,end_location:o.end_location,geometry:o.geometry,highway:null,start_context:null,start_location:o.start_location,steps:o.steps};o.steps=[Object.assign({},o.steps[0],a)]}t({route:r,status:s})})})}getDistanceMatrix(e={origins:[],destinations:[],travelMode:"WALKING"}){let t={origins:e.origins,destinations:e.destinations,travelMode:e.travelMode};return new Promise(s=>{t.travelMode&&t.origins&&t.destinations?g(this,ec).getDistanceMatrix(t,(r,o)=>{s({rows:r.rows,origins:e.origins,destinations:e.destinations,status:o})}):s({rows:[{elements:[{status:"OK",distance:{value:0},duration:{value:0},origin:e.origins[0],destination:e.destinations[0],mode:e.travelMode}]}]})}).then(n);function n(s){return s.rows.forEach((r,o)=>r.elements.forEach((a,l)=>{a.origin=e.origins[o],a.destination=e.destinations[l],a.mode=e.travelMode})),s}}};Ql=new WeakMap,ec=new WeakMap;function Lv(i=[],e){if(!(i.length<0))return i.map(t=>{let n={type:"LineString",coordinates:t.path.map(r=>[r.lng(),r.lat()])},s={distance:t.distance,duration:t.duration,end_context:null,end_location:t.end_location.toJSON(),geometry:n,highway:null,instructions:ki.removeHtmlFrom(t.instructions),maneuver:t.maneuver,route_context:"Outside",start_context:null,start_location:t.start_location.toJSON(),steps:t.steps?Lv(t.steps):[],travel_mode:eA(t.travel_mode)||e};return t.transit&&(s.transit_information=t.transit),s})}function eA(i){return Jl.availableTravelModes.includes(i.toUpperCase())?i.toUpperCase():null}T();T();T();T();var Vn=63710088e-1,H3={centimeters:Vn*100,centimetres:Vn*100,degrees:360/(2*Math.PI),feet:Vn*3.28084,inches:Vn*39.37,kilometers:Vn/1e3,kilometres:Vn/1e3,meters:Vn,metres:Vn,miles:Vn/1609.344,millimeters:Vn*1e3,millimetres:Vn*1e3,nauticalmiles:Vn/1852,radians:1,yards:Vn*1.0936};function tA(i,e,t={}){let n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}function Pv(i,e,t={}){for(let s of i){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<s[s.length-1].length;r++)if(s[s.length-1][r]!==s[0][r])throw new Error("First and last Position are not equivalent.")}return tA({type:"Polygon",coordinates:i},e,t)}function nA(i,e={}){let t=Number(i[0]),n=Number(i[1]),s=Number(i[2]),r=Number(i[3]);if(i.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");let o=[t,n];return Pv([[o,[s,n],[s,r],[t,r],o]],e.properties,{bbox:i,id:e.id})}var Nv=nA;T();T();var iA=Object.defineProperty,pa=(i,e)=>iA(i,"name",{value:e,configurable:!0}),Dv=class{constructor(e){this.direction=!1,this.compareProperties=!0;var t,n,s;this.precision=10**-((t=e==null?void 0:e.precision)!=null?t:17),this.direction=(n=e==null?void 0:e.direction)!=null?n:!1,this.compareProperties=(s=e==null?void 0:e.compareProperties)!=null?s:!0}compare(e,t){if(e.type!==t.type||!tc(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){let n=Dp(e),s=Dp(t);return n.every(r=>s.some(o=>this.compare(r,o)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((n,s)=>Math.abs(n-t[s])<this.precision)}compareLine(e,t,n=0,s=!1){if(!tc(e,t))return!1;let r=e,o=t;if(s&&!this.compareCoord(r[0],o[0])){let l=this.fixStartIndex(o,r);if(l)o=l;else return!1}let a=this.compareCoord(r[n],o[n]);return this.direction||a?this.comparePath(r,o):this.compareCoord(r[n],o[o.length-(1+n)])?this.comparePath(r.slice().reverse(),o):!1}fixStartIndex(e,t){let n,s=-1;for(let r=0;r<e.length;r++)if(this.compareCoord(e[r],t[0])){s=r;break}return s>=0&&(n=[].concat(e.slice(s,e.length),e.slice(1,s+1))),n}comparePath(e,t){return e.every((n,s)=>this.compareCoord(n,t[s]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){let n=e.coordinates.slice(1,e.coordinates.length),s=t.coordinates.slice(1,t.coordinates.length);return n.every(r=>s.some(o=>this.compareLine(r,o,1,!0)))}return!1}compareGeometryCollection(e,t){return tc(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((n,s)=>this.compare(n,t.geometries[s]))}compareFeature(e,t){return e.id===t.id&&(this.compareProperties?Fp(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return tc(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((n,s)=>this.compare(n,t.features[s]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||(e.bbox&&t.bbox?this.compareCoord(e.bbox,t.bbox):!1)}};pa(Dv,"GeojsonEquality");var sA=Dv;function tc(i,e){return i.coordinates?i.coordinates.length===e.coordinates.length:i.length===e.length}pa(tc,"sameLength");function Dp(i){return i.coordinates.map(e=>({type:i.type.replace("Multi",""),coordinates:e}))}pa(Dp,"explode");function Up(i,e,t){return new sA(t).compare(i,e)}pa(Up,"geojsonEquality");function Fp(i,e){if(i===null&&e===null)return!0;if(i===null||e===null)return!1;let t=Object.keys(i),n=Object.keys(e);if(t.length!==n.length)return!1;for(var s of t){let r=i[s],o=e[s],a=Ov(r)&&Ov(o);if(a&&!Fp(r,o)||!a&&r!==o)return!1}return!0}pa(Fp,"equal");var Ov=pa(i=>i!=null&&typeof i=="object","isObject");T();T();var Hn=63710088e-1,K3={centimeters:Hn*100,centimetres:Hn*100,degrees:360/(2*Math.PI),feet:Hn*3.28084,inches:Hn*39.37,kilometers:Hn/1e3,kilometres:Hn/1e3,meters:Hn,metres:Hn,miles:Hn/1609.344,millimeters:Hn*1e3,millimetres:Hn*1e3,nauticalmiles:Hn/1852,radians:1,yards:Hn*1.0936};function Uv(i,e,t={}){let n={type:"Feature"};return(t.id===0||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=e||{},n.geometry=i,n}T();function nc(i){if(Array.isArray(i))return i;if(i.type==="Feature"){if(i.geometry!==null)return i.geometry.coordinates}else if(i.coordinates)return i.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Fv(i,e){return i.type==="FeatureCollection"?"FeatureCollection":i.type==="GeometryCollection"?"GeometryCollection":i.type==="Feature"&&i.geometry!==null?i.geometry.type:i.type}function kp(i,e={}){var t=typeof e=="object"?e.mutate:e;if(!i)throw new Error("geojson is required");var n=Fv(i),s=[];switch(n){case"LineString":s=Bp(i,n);break;case"MultiLineString":case"Polygon":nc(i).forEach(function(o){s.push(Bp(o,n))});break;case"MultiPolygon":nc(i).forEach(function(o){var a=[];o.forEach(function(l){a.push(Bp(l,n))}),s.push(a)});break;case"Point":return i;case"MultiPoint":var r={};nc(i).forEach(function(o){var a=o.join("-");Object.prototype.hasOwnProperty.call(r,a)||(s.push(o),r[a]=!0)});break;default:throw new Error(n+" geometry not supported")}return i.coordinates?t===!0?(i.coordinates=s,i):{type:n,coordinates:s}:t===!0?(i.geometry.coordinates=s,i):Uv({type:n,coordinates:s},i.properties,{bbox:i.bbox,id:i.id})}function Bp(i,e){var t=nc(i);if(t.length===2&&!Bv(t[0],t[1]))return t;var n=[],s=t.length-1,r=n.length;n.push(t[0]);for(var o=1;o<s;o++){var a=n[n.length-1];t[o][0]===a[0]&&t[o][1]===a[1]||(n.push(t[o]),r=n.length,r>2&&kv(n[r-3],n[r-1],n[r-2])&&n.splice(n.length-2,1))}if(n.push(t[t.length-1]),r=n.length,(e==="Polygon"||e==="MultiPolygon")&&Bv(t[0],t[t.length-1])&&r<4)throw new Error("invalid polygon");return e==="LineString"&&r<3||kv(n[r-3],n[r-1],n[r-2])&&n.splice(n.length-2,1),n}function Bv(i,e){return i[0]===e[0]&&i[1]===e[1]}function kv(i,e,t){var n=t[0],s=t[1],r=i[0],o=i[1],a=e[0],l=e[1],c=n-r,h=s-o,u=a-r,f=l-o,d=c*f-h*u;return d!==0?!1:Math.abs(u)>=Math.abs(f)?u>0?r<=n&&n<=a:a<=n&&n<=r:f>0?o<=s&&s<=l:l<=s&&s<=o}T();function zp(i){return i.type==="Feature"?i.geometry:i}function rA(i,e,t={}){let n=t.precision;if(n=n==null||isNaN(n)?6:n,typeof n!="number"||!(n>=0))throw new Error("precision must be a positive number");let s=zp(i).type,r=zp(e).type;return s!==r?!1:Up(kp(i),kp(e),{precision:n})}var zv=rA;var Dt,Gn,Ut,ic,Xs,ma,sc,Vp,bu=class{constructor(e,t){U(this,sc);U(this,Dt,void 0);U(this,Gn,void 0);U(this,Ut,void 0);U(this,ic,window.devicePixelRatio*5);U(this,Xs,void 0);U(this,ma,void 0);W(this,Dt,e),W(this,Gn,new google.maps.OverlayView),g(this,Gn).onAdd=this.onAdd.bind(this),g(this,Gn).draw=this.draw.bind(this),g(this,Gn).onRemove=this.onRemove.bind(this),W(this,Xs,dp(g(this,Dt).geometry,g(this,Dt).properties.widthMeters,g(this,Dt).properties.heightMeters)),W(this,ma,te(this,sc,Vp).call(this,g(this,Xs),g(this,Dt))),g(this,Gn).setMap(t)}update(e){if(oA(g(this,Dt),e,["featureClass","sortKey","type"])){if(g(this,Dt).properties.sortKey!==e.properties.sortKey)return W(this,Dt,e),g(this,Ut).style.zIndex=g(this,Dt).properties.sortKey,!0}else return W(this,Dt,e),W(this,Xs,dp(g(this,Dt).geometry,g(this,Dt).properties.widthMeters,g(this,Dt).properties.heightMeters)),W(this,ma,te(this,sc,Vp).call(this,g(this,Xs),g(this,Dt))),g(this,Ut)instanceof HTMLImageElement&&(g(this,Ut).src=g(this,Dt).properties.imageUrl,this.draw()),!0;return!1}onAdd(){W(this,Ut,document.createElement("img")),g(this,Ut).style.position="absolute",g(this,Ut).src=g(this,Dt).properties.imageUrl,g(this,Gn).getPanes().overlayLayer.appendChild(g(this,Ut))}draw(){let e=g(this,Xs),t=g(this,Gn).getProjection();if(!t)return;let n=t.fromLatLngToDivPixel({lat:e[1],lng:e[0]}),s=t.fromLatLngToDivPixel({lat:e[3],lng:e[2]});if(g(this,Ut)){let r=s.x-n.x,o=n.y-s.y,a=r<=g(this,ic)||o<=g(this,ic)?"none":"block";g(this,Ut).style.display=a,g(this,Ut).style.left=`${Math.round(n.x)}px`,g(this,Ut).style.top=`${Math.round(s.y)}px`,g(this,Ut).style.width=`${Math.round(r)}px`,g(this,Ut).style.height=`${Math.round(o)}px`,g(this,Ut).style.zIndex=g(this,Dt).properties.sortKey,g(this,Ut).style.transform=`rotate(${g(this,Dt).properties.bearing}deg)`}}teardown(){g(this,Gn).setMap(null)}onRemove(){g(this,Ut).parentNode.removeChild(g(this,Ut)),google.maps.event.clearInstanceListeners(this),W(this,Ut,void 0)}setMap(e){e instanceof google.maps.Map&&e!==g(this,Gn).getMap()&&g(this,Gn).setMap(e)}getHitbox(){return g(this,ma)}};Dt=new WeakMap,Gn=new WeakMap,Ut=new WeakMap,ic=new WeakMap,Xs=new WeakMap,ma=new WeakMap,sc=new WeakSet,Vp=function(e,t){let n=Nv(e,{properties:{...t.properties},id:t.id});return up(n,t.properties.bearing)};function oA(i,e,t){if(!zv(i.geometry,e.geometry)||i.id!==e.id||Object.keys(i.properties).length!==Object.keys(e.properties).length)return!1;for(let n of Object.keys(i.properties))if(!t.includes(n)){if(Array.isArray(i.properties[n])&&Array.isArray(e.properties[n])){if(i.properties[n].length!==e.properties[n].length||i.properties[n].some((s,r)=>s!==e.properties[n][r]))return!1}else if(i.properties[n]!==e.properties[n])return!1}return!0}T();var Wn,En,qs,ga,io,rc,Mu=class extends zt{constructor(t,n){super();U(this,qs);U(this,io);U(this,Wn,void 0);U(this,En,void 0);this.on("map_changed",s=>{s.newValue instanceof google.maps.Map&&(g(this,Wn).setMap(s.newValue),g(this,En).setMap(s.newValue))}),this.on("provider_changed",s=>{var o;let r=(o=document.querySelector("mi-my-position"))!=null?o:n;if(s.oldValue)s.oldValue.off?(s.oldValue.off("position_received",te(this,qs,ga).bind(this)),s.oldValue.off("position_error",te(this,io,rc).bind(this))):(r.removeEventListener("position_received",te(this,qs,ga).bind(this)),r.removeEventListener("position_error",te(this,io,rc).bind(this)));else{let a=this.get("map");g(this,Wn).setMap(a),g(this,En).setMap(a)}if(s.newValue){let a=s.newValue;this.set("markerOptions",a.options.positionMarkerStyles),this.set("accuracyOptions",a.options.accuracyCircleStyles),this.set("maxAccuracy",a.options.maxAccuracy),a.on?(a.on("position_received",te(this,qs,ga).bind(this)),a.on("position_error",te(this,io,rc).bind(this))):(r.addEventListener("position_received",te(this,qs,ga).bind(this)),r.addEventListener("position_error",te(this,io,rc).bind(this))),a.hasValidPosition()&&te(this,qs,ga).call(this,{position:a.currentPosition,accurate:a.positionIsAccurate})}else g(this,Wn).setMap(null),g(this,En).setMap(null)}),this.on("markeroptions_changed",s=>{let r=s.newValue,o={path:google.maps.SymbolPath.CIRCLE,fillColor:r.fillColor,fillOpacity:parseFloat(r.fillOpacity),strokeWeight:parseInt(r.strokeWeight),strokeColor:r.strokeColor,scale:parseInt(r.radius)};g(this,Wn).setIcon(o)}),this.on("accuracyoptions_changed",s=>{let r=s.newValue;g(this,En).setOptions({fillColor:r.fillColor,fillOpacity:parseFloat(r.fillOpacity),strokeWeight:0})}),W(this,Wn,new google.maps.Marker({clickable:!1,zIndex:Number.MAX_SAFE_INTEGER})),W(this,En,new google.maps.Circle({clickable:!1,zIndex:Number.MAX_SAFE_INTEGER-1})),this.setValues({map:t,provider:n})}setProvider(t){this.set("provider",t)}deallocate(){this.set("provider",null),this.set("map",null),W(this,Wn,void 0),W(this,En,void 0)}};Wn=new WeakMap,En=new WeakMap,qs=new WeakSet,ga=function(t){let n=t.detail?t.detail.position.coords:t.position.coords,s=this.get("maxAccuracy");n.accuracy<=s?(g(this,Wn).setVisible(!0),g(this,Wn).setPosition({lat:n.latitude,lng:n.longitude}),g(this,En).setVisible(!0),g(this,En).setCenter({lat:n.latitude,lng:n.longitude}),g(this,En).setRadius(n.accuracy)):(g(this,Wn).setVisible(!1),g(this,En).setVisible(!1))},io=new WeakSet,rc=function(){g(this,Wn).setVisible(!1),g(this,En).setVisible(!1)};T();T();var aA={visible:!0},qe,Ti,Ys,ya,_a=class{constructor(e,t){U(this,Ys);U(this,qe,new google.maps.OverlayView);U(this,Ti,void 0);var r,o,a;let n=parseInt(e.properties.labelSize),s={clickable:(r=e==null?void 0:e.properties)==null?void 0:r.clickable,position:new google.maps.LatLng({lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]}),map:t,text:e.properties.labelText,visible:(o=e.properties.labelVisible)!=null?o:aA.visible,style:{fontFamily:e.properties.labelFont,fontSize:`${n}px`,fontWeight:e.properties.labelFontWeight||"normal",color:e.properties.labelColor,strokeStyle:e.properties.labelStrokeStyle,strokeWeight:hA(e),shadowBlur:e.properties.labelShadowBlur||0,shadowColor:e.properties.labelShadowColor,iconPlacement:(a=e.properties.iconPlacement)!=null?a:on.CENTER},pixelOffset:uA(e.properties.labelOffset,n,e.properties.iconPlacement),maxLength:e.properties.labelMaxLength,maxWidth:e.properties.labelMaxWidth,id:e.id};g(this,qe).setOptions(s),g(this,qe).addListener("visible_changed",()=>{let l=g(this,Ti);if(l){let c=this.getVisible();l.style.display=c?"":"none",c&&te(this,Ys,ya).call(this)}}),g(this,qe).addListener("clickable_changed",()=>{let l=g(this,Ti),c=g(this,qe).get("clickable");l&&(l.style.cursor=c===!0?"pointer":"")}),g(this,qe).addListener("style_changed",()=>{te(this,Ys,ya).call(this)}),g(this,qe).addListener("text_changed",()=>{te(this,Ys,ya).call(this)}),g(this,qe).addListener("maxlength_changed",()=>{te(this,Ys,ya).call(this)}),g(this,qe).addListener("pixeloffset_changed",()=>{this.draw()}),g(this,qe).addListener("position_changed",()=>{this.draw()}),g(this,qe).onAdd=this.onAdd.bind(this),g(this,qe).draw=this.draw.bind(this),g(this,qe).onRemove=this.onRemove.bind(this)}teardown(){g(this,qe).setMap(null)}setOptions(e){g(this,qe).setOptions(e)}onAdd(){let e=g(this,qe).get("clickable"),t=W(this,Ti,document.createElement("canvas")),n=this.getVisible();t.style.position="absolute",t.style.display=n?"":"none",t.style.cursor=e===!0?"pointer":"",g(this,qe).getPanes().overlayMouseTarget.appendChild(t),te(this,Ys,ya).call(this),t.addEventListener("click",s=>{g(this,qe).get("clickable")===!0&&(s.cancelBubble=!0,google.maps.event.trigger(this,"click"))}),t.addEventListener("mouseenter",()=>{google.maps.event.trigger(this,"mouseenter")}),t.addEventListener("mouseleave",()=>{google.maps.event.trigger(this,"mouseleave")})}onRemove(){g(this,Ti).parentNode.removeChild(g(this,Ti)),google.maps.event.clearInstanceListeners(this),W(this,Ti,void 0)}draw(){let e=g(this,qe).getProjection(),t=g(this,Ti),n=g(this,qe).get("position"),s=e.fromLatLngToDivPixel(n),r=this.getPixelOffset();t.style.top=`${Math.round(r.height+s.y)}px`,t.style.left=`${Math.round(r.width+s.x)}px`}setStyle(e){g(this,qe).set("style",e)}getStyle(){return g(this,qe).get("style")}setText(e){this.getText()!==e&&g(this,qe).set("text",e||"")}getText(){return g(this,qe).get("text")||""}setVisible(e){g(this,qe).set("visible",e)}getVisible(){return g(this,qe).get("visible")}setPixelOffset(e){g(this,qe).set("pixelOffset",e)}getPixelOffset(){return g(this,qe).get("pixelOffset")||{width:0,height:0}}getMap(){return g(this,qe).getMap()}setMap(e){(e!==g(this,qe).getMap()&&e instanceof google.maps.Map||e===null)&&g(this,qe).setMap(e)}setMaxLength(e){g(this,qe).set("maxLength",e)}getMaxLength(){return g(this,qe).get("maxLength")}setMaxWidth(e){g(this,qe).set("maxWidth",e)}getMaxWidth(){return g(this,qe).get("maxWidth")}setPosition(e){g(this,qe).set("position",e)}getPosition(){return g(this,qe).get("position")}};qe=new WeakMap,Ti=new WeakMap,Ys=new WeakSet,ya=function(){let e=g(this,Ti),t=this.getStyle(),n=e.getContext("2d"),s=parseInt(t.strokeWeight),r=parseInt(t.shadowBlur||0),o=this.getMaxLength()||-1,a=this.getMaxWidth()-(s+r)||-1,l=fA(this.getText(),o),c=l.split(`
`);if(e.style.display!=="none"&&l>""){Hv(e,t),a>0&&Vv(c,n)>a&&(c=dA(c,n,a));let h=cA(s+r,n);e.width=Vv(c,n)+(s+r),e.height=h*c.length,n.clearRect(0,0,e.width,e.height),Hv(e,t);let u=(s+r)/2,f=(s+r)/2;for(let d of c)s&&n.strokeText(d,u,f),n.fillText(d,u,f),f+=h;lA(e,t)}};function lA(i,e){switch((e.align||"center").toLowerCase()){case"left":i.style.marginLeft=`${-parseInt(i.width)}px`;break;case"center":i.style.marginLeft=`${Math.round(-parseInt(i.width)/2)}px`;break;default:i.style.marginLeft="0px";break}}function cA(i,e){let t=e.measureText("Hg");return Math.ceil(t.actualBoundingBoxDescent+t.actualBoundingBoxAscent+i)*1.2}function Vv(i,e){return i.reduce((t,n)=>Math.max(e.measureText(n).width,t),0)}function hA(i){return Number.isNaN(i.properties.labelStrokeWidth)?0:i.properties.labelStrokeWidth*2}function uA(i,e,t="center"){let n=Number.isNaN(i==null?void 0:i[1])?18:e*i[1];t==="bottom"&&(n=n-e/2);let s=Number.isNaN(i==null?void 0:i[0])?0:e*i[0];return{height:n,width:s}}function Hv(i,e){let t=i.getContext("2d");t.textBaseline="top",t.lineJoin="round",t.lineWidth=e.strokeWeight,t.strokeStyle=e.strokeStyle,t.fillStyle=e.color,t.shadowColor=e.shadowColor,t.shadowBlur=parseInt(e.shadowBlur),t.font=`${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}function fA(i,e){return i=i||"",e>0&&i.length+3>e?i.slice(0,e).trim()+"...":i}function dA(i,e,t){let n=[];for(let s of i)if(e.measureText(s).width>t){let o=s.split(" "),a=o.length;for(;o.length>0;){if(e.measureText(o.slice(0,a)).width<t){n=n.concat(o.splice(0,a).join(" ")),a=o.length;continue}else if(a===1){n=n.concat(pA(o.shift(),e,t));let l=n[n.length-1];n.length>1&&e.measureText(`${l} M`).width<t&&l.length>1&&o.unshift(n.pop()),a=o.length;continue}a--}}return n}function pA(i,e,t){let n=[],s=i.split(""),r=i.length;for(;s.length>0;){let o=s.slice(0,r).join("");if(e.measureText(o).width<t||o.length===1){n=n.concat(s.splice(0,r).join("")),r=s.length;continue}r--}return n}var oc,Ks,so,ro,wu,Gv,ac,Hp,Su=class extends zt{constructor(t){super();U(this,wu);U(this,ac);U(this,oc,[]);U(this,Ks,void 0);U(this,so,void 0);U(this,ro,new Map);let n=t.mapsIndoors,s=n.getMapView().getMap();W(this,Ks,new google.maps.Data({map:s,style:mA.bind(this)})),W(this,so,new google.maps.Polyline({map:s})),this.on("changed",({key:r})=>{switch(r){case"viewModel":case"legIndex":te(this,ac,Hp).call(this);break;case"strokeColor":case"strokeWeight":case"strokeOpacity":case"visible":case"zIndex":g(this,Ks).setStyle(g(this,Ks).getStyle());break}}),this.on("visible_changed",({newValue:r})=>{let o=r===!0,a=this.get("animation");g(this,so).setVisible(o),a&&(o===!0?a.start():a.stop())}),this.on("animation_changed",({newValue:r})=>{let o=r;o&&(o.onanimationframe=a=>{if(a){let l=a.geometry.coordinates.map(c=>({lat:c[1],lng:c[0]}));g(this,so).setOptions(a.properties),g(this,so).setPath(l)}})}),this.setValues(t),n.on("floor_changed",te(this,ac,Hp).bind(this))}setStepIndex(t,n){this.set("legIndex",n),this.set("stepIndex",t)}};oc=new WeakMap,Ks=new WeakMap,so=new WeakMap,ro=new WeakMap,wu=new WeakSet,Gv=function(){var o;let[t]=(o=this.get("viewModel"))!=null?o:[],n=this.get("mapsIndoors"),s=parseInt(n.getFloor()),r=this.get("legIndex");if(n&&(t==null?void 0:t[r]))for(let a of t[r]){let l=parseInt(a.properties.floorIndex),c=a.properties.routeContext;a.properties.visibility=c==="Outside"||l===s?"visible":"none"}},ac=new WeakSet,Hp=function(){var h,u;let t=this.get("mapsIndoors"),n=t.getMapView().getMap(),[s,r]=(h=this.get("viewModel"))!=null?h:[],o=this.get("animation"),a=this.get("legIndex"),l=parseInt(t.getFloor());!(s!=null&&s[a])&&o&&o.clear();for(let f of g(this,oc))g(this,Ks).remove(f);let c=new Map((u=r==null?void 0:r.filter(f=>parseInt(f.properties.floorIndex)===l).map(f=>[f.id,f]))!=null?u:[]);for(let[f,d]of g(this,ro))c.has(f)||d.setMap(null);if(s!=null&&s[a]){let f=s[a];te(this,wu,Gv).call(this),W(this,oc,g(this,Ks).addGeoJson({type:"FeatureCollection",features:[...f,...c.values()]}));for(let[d,y]of c){let v=g(this,ro).get(d);if(y.properties.labelText>"")if(v){v.getMap()===null&&v.setMap(n);let p=v.getPosition(),m=new google.maps.LatLng({lat:y.geometry.coordinates[1],lng:y.geometry.coordinates[0]});p.equals(m)||v.setPosition(m),v.getText()!==y.properties.labelText&&v.setText(y.properties.labelText)}else v=new _a(y,n),g(this,ro).set(d,v);else v==null||v.setMap(null),g(this,ro).delete(d)}}};function mA(i){var r;let e=this.get("visible")===!0&&i.getProperty("visibility")==="visible",t=i.getProperty("iconSrc"),n=(r=i.getProperty("iconSize"))!=null?r:{width:0,height:0},s;return t&&(s={url:t,scaledSize:new google.maps.Size(n.width*.5,n.height*.5)}),e?{strokeColor:this.get("strokeColor"),strokeWeight:this.get("strokeWeight"),strokeOpacity:this.get("strokeOpacity"),zIndex:this.get("zIndex"),visible:e,icon:s}:{visible:!1}}T();var ci={INITIALIZING:"INITIALIZING",READY:"READY"};var lc,Xi,Zs,hs,cc,$s,hc,js,uc,Gp,fc,Wp,Au=class extends zt{constructor({element:t,zoom:n=0,...s}){var r;super();U(this,uc);U(this,fc);U(this,lc,ci.INITIALIZING);U(this,Xi,new Map);U(this,Zs,new Map);U(this,hs,void 0);U(this,cc,void 0);U(this,$s,new google.maps.Data);U(this,hc,void 0);U(this,js,[]);if(W(this,hc,!isNaN(s.maxZoom)&&s.maxZoom>=0),g(this,$s).setStyle({fillColor:"#ffffff",fillOpacity:1,strokeColor:"#6B7280",strokeWeight:1.2,zIndex:4e5}),google,(r=google==null?void 0:google.maps)!=null&&r.Map){s.maxZoom=s.maxZoom||21;let o=new google.maps.Map(t,{zoom:n,...s});Bt.log(bt.appLifeTime.MAP_INSTANTIATED),google.maps.event.addListener(o,"idle",()=>{this.emit("idle")}),google.maps.event.addListener(o,"bounds_changed",()=>{this.emit("bounds_changed")}),google.maps.event.addListener(o,"center_changed",()=>{this.emit("center_changed")}),o.data.addListener("click",({feature:a})=>{let l=a.getProperty("originalId");l.startsWith("MI_")||this.emit("click",l)}),o.data.addListener("mouseover",({feature:a})=>{let l=a.getProperty("originalId"),c=a.getId();l.startsWith("MI_")||(g(this,js).push([c,l]),this.emit("mouseenter",{id:l}))}),o.data.addListener("mouseout",({feature:a})=>{var c;let l=g(this,js).findIndex(h=>h[0]===a.getId());g(this,js).splice(l,1),this.emit("mouseenter",{id:(c=g(this,js)[g(this,js).length-1])==null?void 0:c[1]})}),google.maps.event.addListener(o,"maptypeid_changed",()=>{this.emit("maptypeid_changed")}),google.maps.event.addListener(o,"zoom_changed",()=>{this.emit("zoom_changed")}),google.maps.event.addListener(o,"tilesloaded",()=>{this.emit("tiles_loaded")}),google.maps.event.addListener(o,"drag",()=>{this.emit("drag")}),google.maps.event.addListener(o,"dragend",()=>{this.emit("dragend")}),google.maps.event.addListener(o,"dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),google.maps.event.addListener(o,"tilt_changed",()=>{this.emit("user_interaction")}),google.maps.event.addListener(o,"heading_changed",()=>{this.emit("rotateend")}),this.set("map",o),this.set("element",t),o.data.setStyle(te(this,fc,Wp).bind(this)),google.maps.event.addListenerOnce(o,"idle",()=>{this.getMap().getRenderingType()==="VECTOR"?(this.set("rotatable",!0),this.set("tiltable",!0)):(this.set("rotatable",!1),this.set("tiltable",!1))}),g(this,$s).setMap(o),W(this,lc,ci.READY),this.emit("ready")}}get isReady(){return g(this,lc)===ci.READY}getMap(){return this.get("map")}deallocate(){this.getMap().controls.forEach(t=>{t.getArray().forEach(s=>{s.remove()}),t.clear()}),g(this,Xi).forEach(t=>{t.teardown()}),g(this,Xi).clear(),g(this,Zs).forEach(t=>{t.teardown()}),g(this,Zs).clear(),g(this,hs)&&(g(this,hs).deallocate(),W(this,hs,void 0)),this.set("map",null),this.set("element",null)}getBounds(){var n;let t=this.get("map");return(t==null?void 0:t.getBounds)instanceof Function?(n=t.getBounds())==null?void 0:n.toJSON():null}getBearing(){let t=this.get("map");return(t==null?void 0:t.getHeading)instanceof Function?t.getHeading():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setViewData(t){W(this,cc,t);let n=["MI_EXTRUDED_ROOM","MI_EXTRUDED_WALLS","MI_MODEL_3D"];t.forEach((r,o)=>{n.includes(r.properties.type)&&t.delete(o)});let s=this.get("map");s.data.forEach(r=>{let o=r.getId();t.has(o)||s.data.remove(r)});for(let[r,o]of g(this,Xi))t.has(r)||o.setMap(null);for(let[r,o]of g(this,Zs))t.has(r)||o.setMap(null);for(let[r,o]of t){let a=o.properties.featureClass;if(a!==Ne.LABEL_FLOATING)if(a===Ne.LABEL){let l=g(this,Xi).get(o.id);if(l){l.getMap()===null&&(l.setMap(this.getMap()),te(this,uc,Gp).call(this,o,l));let c=l.getPosition(),h=new google.maps.LatLng({lat:o.geometry.coordinates[1],lng:o.geometry.coordinates[0]});c.equals(h)||l.setPosition(h),l.getText()!==o.properties.labelText&&l.setText(o.properties.labelText)}else l=new _a(o,this.getMap()),g(this,Xi).set(o.id,l),te(this,uc,Gp).call(this,o,l)}else if(a===Ne.MODEL2D){let l=g(this,Zs).get(o.id),c=s.data.getFeatureById(r);if(c&&s.data.remove(c),l)l!=null&&l.update(o)&&(l.setMap(this.getMap()),s.data.addGeoJson(l.getHitbox()));else{let h=new bu(o,this.getMap());s.data.addGeoJson(h.getHitbox()),g(this,Zs).set(o.id,h)}}else{let l=s.data.getFeatureById(r);if(!l)s.data.addGeoJson(o);else{let c=l.getGeometry();if(c.getType()==="Point"){let h=c.get(),u=new google.maps.LatLng({lat:o.geometry.coordinates[1],lng:o.geometry.coordinates[0]});h.equals(u)||(s.data.remove(l),s.data.addGeoJson(o))}}}}s.data.setStyle(te(this,fc,Wp).bind(this))}setMapsIndoorsTileURL(t){let n=this.getMap();if(n instanceof google.maps.Map&&t>""){let s=n.overlayMapTypes.getArray().filter(o=>o.name==="MapsIndoorsTiles");s.forEach(o=>{let a=s.findIndex(l=>l.name===o.name);n.overlayMapTypes.removeAt(a)});let r=new Xp(t);n.overlayMapTypes.push(r)}}setLabelOptions(t){this.getMap().data.forEach(s=>{g(this,Xi).has(s.getId())&&g(this,Xi).get(s.getId()).setOptions(t)})}fitBounds(t,n){return new Promise(s=>{let r=this.get("map");(r==null?void 0:r.fitBounds)instanceof Function&&(google.maps.event.addListenerOnce(r,"idle",s),r.fitBounds(t,n))})}getZoom(){let t=this.get("map");return(t==null?void 0:t.getZoom)instanceof Function?t.getZoom():null}getMaxZoom(){let t=this.get("map");if(t)return t.get("maxZoom")}getPitch(){return 0}setZoom(t){let n=this.get("map");(n==null?void 0:n.setZoom)instanceof Function&&n.setZoom(t)}getCenter(){let t=this.get("map");return(t==null?void 0:t.getCenter)instanceof Function?t.getCenter().toJSON():null}setCenter(t){let n=this.get("map");(n==null?void 0:n.setCenter)instanceof Function&&n.setCenter(t)}setSolutionConfig(){}panTo(t){let n=this.get("map");n!=null&&n.panTo&&n.panTo(t)}easeTo({center:t,rotation:n,tilt:s,easing:r}){let o=this.get("map");o&&o.easeTo&&(o.panTo(t),o.setHeading(n),o.setTilt(s))}tilt(t){this.get("map").setTilt(t)}rotate(t){this.get("map").setHeading(t)}panToBounds(t){let n=this.get("map");(n==null?void 0:n.panToBounds)instanceof Function&&n.panToBounds(t)}getDiv(){return this.get("element")}project({lat:t,lng:n}){let s=this.get("map");if((s==null?void 0:s.getProjection)instanceof Function){let r=s.getProjection(),o=new google.maps.LatLng(t,n),a=r.fromLatLngToPoint(o);return{x:a.x,y:a.y}}else return null}unproject({x:t,y:n}){let s=this.get("map");if((s==null?void 0:s.getProjection)instanceof Function){let r=s.getProjection(),o=new google.maps.Point(t,n);return r.fromPointToLatLng(o).toJSON()}else return null}addLogo(){if(this.isReady){if(this.get("map")){let n=this.getDiv();if((n==null?void 0:n.appendChild)instanceof Function){let s=document.createElement("img");s.id="mi_map_logo",s.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",s.style.width="96px",s.style.height="20px",s.style.margin="5px",s.style.position="absolute",s.style.right="54px",s.style.bottom="18px",s.style.zIndex="10000000",n.appendChild(s),new ResizeObserver(()=>{n.clientWidth<359||n.clientHeight<359?s.style.display!=="none"&&(s.style.display="none"):s.style.display==="none"&&(s.style.display="")}).observe(n)}}}else this.once("ready",()=>{this.addLogo()})}get DirectionsRenderer(){return Su}enableZoom22(){let t=this.get("map");if((t==null?void 0:t.set)instanceof Function&&!g(this,hc))return t.set("maxZoom",22)}setPositionProvider(t){let n=this.getMap();g(this,hs)?g(this,hs).setProvider(t):W(this,hs,new Mu(n,t))}setFloorPlan(t){g(this,$s).forEach(n=>g(this,$s).remove(n)),g(this,$s).addGeoJson(t)}hideFeatures(){}setSlot(){}getSlot(){}};lc=new WeakMap,Xi=new WeakMap,Zs=new WeakMap,hs=new WeakMap,cc=new WeakMap,$s=new WeakMap,hc=new WeakMap,js=new WeakMap,uc=new WeakSet,Gp=function(t,n){google.maps.event.addListener(n,"click",()=>{this.emit("click",t.properties.originalId)}),google.maps.event.addListener(n,"mouseenter",()=>{this.emit("mouseenter",{id:t.properties.originalId,featureType:t.geometry.type.toLowerCase()})}),google.maps.event.addListener(n,"mouseleave",()=>{this.emit("mouseleave",t.geometry.type.toLowerCase())})},fc=new WeakSet,Wp=function(t){var s;let n=(s=g(this,cc))==null?void 0:s.get(t.getId());if(n){let r=n.properties.iconSrc,o=gA(n),a=n.properties.iconSize,l=n.properties.fillColor,c=n.properties.fillOpacity,h=n.properties.strokeColor,u=n.properties.strokeOpacity,f=n.properties.strokeWidth,d=n.properties.clickable,y=n.properties.sortKey;return{icon:{url:r,anchor:o,scaledSize:a,labelOrigin:new google.maps.Point(20,50)},fillColor:l,fillOpacity:c,strokeColor:h,strokeOpacity:u,strokeWeight:f,clickable:d,zIndex:y}}return null};function gA(i){let{iconSize:e,iconPlacement:t,featureClass:n}=i.properties;if(n===Ne.POINT&&e){let{width:s,height:r}=e;switch(t){case"bottom_right":return{x:s,y:r};case"bottom":return{x:s/2,y:r};case"bottom_left":return{x:0,y:r};case"left":return{x:0,y:r/2};case"top_left":return{x:0,y:0};case"top":return{x:s/2,y:0};case"top_right":return{x:s,y:0};case"right":return{x:s,y:r/2};default:return{x:s/2,y:r/2}}}return{x:0,y:0}}var Xp=class{constructor(e){return new google.maps.ImageMapType({getTileUrl:function(t,n){return e.replace("{z}",n).replace("{x}",t.x).replace("{y}",t.y)},tileSize:new google.maps.Size(256,256),name:"MapsIndoorsTiles"})}};T();var yA={route:null,status:"ZERO_RESULTS"},Wv={route:null,status:"INVALID_REQUEST"},Xv=new Map([["DRIVING","mapbox/driving"],["WALKING","mapbox/walking"],["BICYCLING","mapbox/cycling"]]),dc=class{constructor(e){this.accessToken=e}get ProviderName(){return"mapbox"}_getMapboxDirectionsProfile(e){let t=Xv,n=(e||"").toUpperCase();return t.has(n)?t.get(n)||"WALKING":(console.error(`TravelMode "${e}" is not supported.`),null)}static get availableTravelModes(){return Array.from(Xv.keys())}getRoute(e){let t=this._getMapboxDirectionsProfile(e.travelMode),n=Eu(e.origin),s=Eu(e.destination);if(!t)return Promise.resolve(Wv);let r=`https://api.mapbox.com/directions/v5/${t}/${n};${s}?geometries=geojson&steps=true&access_token=${this.accessToken}&language=${de.language}`;return fetch(r).then(o=>o.json()).then(o=>{let{routes:a,code:l}=o;if(l!=="Ok")return yA;let c=a[0];for(let h of c.legs){h.geometry={type:"LineString",coordinates:[]},h.distance=Yv(h),h.duration=Kv(h);let u=Object.assign({},h.steps[0]),f=h.steps[h.steps.length-1];qv(f)==="arrive"&&h.steps.pop(),u.steps=h.steps.map(d=>{let y=d.geometry.coordinates,v=y[0],p=y[y.length-1];return h.geometry.coordinates=h.geometry.coordinates.concat(y),{distance:Yv(d),duration:Kv(d),end_location:Zv(p),geometry:d.geometry,highway:null,instructions:d.maneuver.instruction,maneuver:qv(d),route_context:"Outside",start_location:Zv(v),travel_mode:$v(d.mode)||e.travelMode}}),h.start_location=u.steps[0].start_location,h.end_location=u.steps[u.steps.length-1].end_location,u.distance=h.distance,u.duration=h.duration,u.end_context=null,u.end_location=h.end_location,u.geometry=h.geometry,u.highway=null,u.maneuver="",u.route_context="Outside",u.start_context=null,u.start_location=h.start_location,u.travel_mode=$v(u.mode)||e.travelMode,delete u.mode,h.steps=[u]}return{route:c,status:l.toUpperCase()}})}getDistanceMatrix(e={origins:[],destinations:[],travelMode:"WALKING"}){let t=this._getMapboxDirectionsProfile(e.travelMode),n=e.origins.map(Eu),s=e.destinations.map(Eu),r={access_token:this.accessToken,annotations:"duration,distance",sources:n.length>1||s.length>1?[...n.keys()].join(";"):"",destinations:[...s.keys()].map(o=>o+=n.length).join(";")};if(t&&n&&s){let o=`https://api.mapbox.com/directions-matrix/v1/${t}/${n.join(";")};${s.join(";")}?${_A(r)}`;return fetch(o).then(a=>a.json()).then(a=>a.code!=="Ok"?Wv:{rows:a.sources.map((c,h)=>{let u=a.distances[h],f=a.durations[h];return{elements:a.destinations.map((y,v)=>({distance:{value:u[v]||0,text:""},duration:{value:f[v]||0,text:""},mode:e.travelMode,status:u[v]!==null?"OK":"ZERO_RESULTS"}))}}),origins:e.origins,destinations:e.destinations,status:"OK"})}}};function qv(i){let e=i.maneuver.type,t=i.maneuver.modifier;return t=t>""?`-${t.replace(" ","-")}`:"",`${e}${t}`}function Yv(i){return{text:"",value:i.distance}}function Kv(i){return{text:"",value:i.duration}}function Zv(i){return{lat:i[1],lng:i[0]}}function Eu(i){return`${i.lng},${i.lat}`}function _A(i){return Object.entries(i).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&")}function $v(i=""){return dc.availableTravelModes.includes(i.toUpperCase())?i.toUpperCase():null}T();T();T();function vA(i,e,t){t===void 0&&(t={});for(var n=t.steps||64,s=t.properties?t.properties:!Array.isArray(i)&&i.type==="Feature"&&i.properties?i.properties:{},r=[],o=0;o<n;o++)r.push(ca(i,e,o*-360/n,t).geometry.coordinates);return r.push(r[0]),Kd([r],s)}var Tu=vA;var oo="MI_POSITION_SOURCE",qp="MI_CIRCLE_LAYER",Yp="MI_FILL_LAYER",Js,va,ao,pc,Iu=class extends zt{constructor(t,n){super();U(this,Js);U(this,ao);t instanceof mapboxgl.Map&&(t.getSource(oo)||t.addSource(oo,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.getLayer(qp)||t.addLayer({id:qp,filter:["all",["==","$type","Point"]],type:"circle",source:oo,paint:{"circle-color":["get","fillColor"],"circle-radius":["get","radius"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":["get","strokeWeight"],"circle-stroke-color":["get","strokeColor"],"circle-stroke-opacity":["get","fillOpacity"],"circle-pitch-alignment":"map","circle-pitch-scale":"viewport"}}),t.getLayer(Yp)||t.addLayer({id:Yp,filter:["all",["==","$type","Polygon"]],type:"fill",source:oo,paint:{"fill-color":["get","fillColor"],"fill-opacity":["to-number",["get","fillOpacity"]]}})),this.on("provider_changed",s=>{var o;let r=(o=document.querySelector("mi-my-position"))!=null?o:n;if(s.oldValue&&(s.oldValue.off?(s.oldValue.off("position_received",te(this,Js,va).bind(this)),s.oldValue.off("position_error",te(this,ao,pc).bind(this))):(r.removeEventListener("position_received",te(this,Js,va).bind(this)),r.removeEventListener("position_error",te(this,ao,pc).bind(this)))),s.newValue){let a=s.newValue,l=a.options.positionMarkerStyles,c=a.options.accuracyCircleStyles;this.set("markerOptions",{fillColor:l.fillColor,fillOpacity:parseFloat(l.fillOpacity),strokeColor:l.strokeColor,strokeWeight:parseInt(l.strokeWeight),radius:parseInt(l.radius)}),this.set("accuracyOptions",c),this.set("maxAccuracy",a.options.maxAccuracy),a.on?(a.on("position_received",te(this,Js,va).bind(this)),a.on("position_error",te(this,ao,pc).bind(this))):(r.addEventListener("position_received",te(this,Js,va).bind(this)),r.addEventListener("position_error",te(this,ao,pc).bind(this))),a.hasValidPosition()&&te(this,Js,va).call(this,{position:a.currentPosition,accurate:a.positionIsAccurate})}}),this.setValues({map:t,provider:n})}setProvider(t){this.set("provider",t)}deallocate(){let t=this.get("map");t.removeLayer(qp),t.removeLayer(Yp),t.removeSource(oo),this.set("provider",null),this.set("map",null)}};Js=new WeakSet,va=function(t){let s=this.get("map").getSource(oo),r=t.detail?t.detail.position.coords:t.position.coords,o=this.get("maxAccuracy"),a=this.get("markerOptions"),l=this.get("accuracyOptions");if(r.accuracy<=o){let c={type:"Feature",geometry:{type:"Point",coordinates:[r.longitude,r.latitude]},properties:a},h=Tu(c,r.accuracy,{steps:360,units:"meters",properties:l});s.setData({type:"FeatureCollection",features:[c,h]})}else s.setData({type:"FeatureCollection",features:[]})},ao=new WeakSet,pc=function(){let n=this.get("map").getSource(oo);n&&n.setData({type:"FeatureCollection",features:[]})};T();var Kp=Symbol(),Cu=Symbol(),mc=Symbol(),lo=Symbol(),Jv=Symbol(),Ru=Symbol(),co=Symbol(),xa=class extends zt{constructor(e){super(),this[co]=$p(),this[lo]=`${this[co]}_route`,this[Jv]=`${this[co]}_icons`,this[mc]=$p(),this[Kp]=`${this[mc]}_animation`,this.on("mapsindoors_changed",()=>{let t=this.get("mapsIndoors");if(t instanceof Gi){t.on("floor_changed",Zp.bind(this));let n=t.getMap(),s=t.getMapView();this.set("map",n),s.isReady?jv.call(this):n.once("load",()=>{jv.call(this),this.get("viewModel")&&Zp.call(this)})}}),this.on("animation_changed",({newValue:t})=>{let n=t;n&&(n.onanimationframe=s=>{this[Cu]&&this[Cu].setData(s)})}),this.setValues(e)}setStepIndex(e,t){this.set("stepIndex",e),this.set("legIndex",t)}};function jv(){let i=this.get("map");if(i){if(!i.getLayer(this[lo])){i.addSource(this[co],{type:"geojson",data:{type:"FeatureCollection",features:[]}}),i.addSource(this[mc],{type:"geojson",data:{type:"FeatureCollection",features:[]}});let e=null;i.getLayer(Lu)?e=Lu:i.getLayer(ba)&&(e=ba),i.addLayer({id:this[lo],type:"line",slot:"middle",source:this[co],filter:["all",["==","visibility","visible"],["==","$type","LineString"]],layout:{"line-join":"round","line-cap":"round",visibility:"visible"},paint:{"line-color":this.get("strokeColor"),"line-width":this.get("strokeWeight"),"line-opacity":this.get("strokeOpacity")}},e),i.addLayer({id:this[Kp],type:"line",slot:"middle",source:this[mc],layout:{"line-join":"round","line-cap":"round",visibility:"visible","line-sort-key":["get","zIndex"]},paint:{"line-width":["get","strokeWeight"],"line-color":["get","strokeColor"],"line-opacity":["get","strokeOpacity"]}},e),i.addLayer({id:this[Jv],type:"symbol",slot:"middle",source:this[co],filter:["all",["==","visibility","visible"],["==","$type","Point"]],layout:{"icon-allow-overlap":!0,"icon-anchor":"bottom","icon-image":["get","iconSrc"],"icon-optional":!1,"icon-size":["get","iconScale"],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-allow-overlap":!0,"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-padding":0,"text-size":["number",["get","labelSize"],ce.labelStyle.textSize],"text-offset":["get","labelOffset"]},paint:{"text-color":["to-color",["get","labelColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStrokeStyle"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStrokeWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStrokeBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelOpacity"],ce.labelStyle.textOpacity]}})}this[Ru]=i.getSource(this[co]),this[Cu]=i.getSource(this[mc]),this.on("changed",({key:e,newValue:t})=>{switch(e){case"viewModel":case"legIndex":Zp.call(this);break;case"strokeColor":i.setPaintProperty(this[lo],"line-color",t);break;case"strokeWeight":i.setPaintProperty(this[lo],"line-width",t);break;case"strokeOpacity":i.setPaintProperty(this[lo],"line-opacity",t);break}}),this.on("visible_changed",({newValue:e})=>{let t=e===!0,n=this.get("map"),s=this.get("animation");n.setLayoutProperty(this[lo],"visibility",t?"visible":"none"),n.setLayoutProperty(this[Kp],"visibility",t?"visible":"none"),s&&t?s.start():s.stop()})}}function Zp(){var a;let i=this.get("mapsIndoors"),e=this.get("map"),t=parseInt(i.getFloor()),n=this.get("animation"),s=this.get("legIndex"),[r,o]=(a=this.get("viewModel"))!=null?a:[];if(!(r!=null&&r[s])&&n&&n.clear(),this[Ru])if(r!=null&&r[s]){let l=o==null?void 0:o.filter(c=>parseInt(c.properties.floorIndex)===t);for(let c of l)if(c.properties.iconSrc&&!e.hasImage(c.properties.iconSrc)){let h=$p();e.addImage(h,c.properties.icon),c.properties.iconSrc=h}for(let c of r[s]){let h=parseInt(c.properties.floorIndex),u=c.properties.routeContext;c.properties.visibility=u==="Outside"||h===t?"visible":"none"}this[Ru].setData({type:"FeatureCollection",features:[...r[s],...l]})}else this[Ru].setData({type:"FeatureCollection",features:[]}),this[Cu].setData({type:"FeatureCollection",features:[]})}function $p(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}T();T();T();var kc="169";var xA=0,Qv=1,bA=2;var gb=1,MA=2,ys=3,Zi=0,In=1,Yn=2,ar=0,Ba=1,ex=2,tx=3,nx=4,SA=5,_o=100,wA=101,AA=102,EA=103,TA=104,IA=200,RA=201,CA=202,LA=203,Cm=204,Lm=205,PA=206,NA=207,OA=208,DA=209,UA=210,FA=211,BA=212,kA=213,zA=214,Pm=0,Nm=1,Om=2,Ha=3,Dm=4,Um=5,Fm=6,Bm=7,yb=0,VA=1,HA=2,lr=0,GA=1,WA=2,XA=3,qA=4,YA=5,KA=6,ZA=7,ix="attached",$A="detached",_b=300,Ga=301,Wa=302,km=303,zm=304,kf=306,xs=1e3,Pi=1001,bo=1002,tn=1003,zc=1004;var rr=1005;var Wt=1006,xo=1007;var ui=1008;var bs=1009,vb=1010,xb=1011,Rc=1012,Gg=1013,Mo=1014,Ni=1015,Vc=1016,Wg=1017,Xg=1018,Xa=1020,bb=35902,Mb=1021,Sb=1022,Tn=1023,wb=1024,Ab=1025,ka=1026,qa=1027,qg=1028,Yg=1029,Eb=1030,Kg=1031;var Zg=1033,of=33776,af=33777,lf=33778,cf=33779,Vm=35840,Hm=35841,Gm=35842,Wm=35843,Xm=36196,qm=37492,Ym=37496,Km=37808,Zm=37809,$m=37810,jm=37811,Jm=37812,Qm=37813,eg=37814,tg=37815,ng=37816,ig=37817,sg=37818,rg=37819,og=37820,ag=37821,hf=36492,lg=36494,cg=36495,Tb=36283,hg=36284,ug=36285,fg=36286;var cr=2300,hr=2301,jp=2302,sx=2400,rx=2401,ox=2402,jA=2500;var Ib=0,zf=1,Hc=2,JA=3200,QA=3201;var Rb=0,e1=1,Yi="",Gt="srgb",nn="srgb-linear",$g="display-p3",Vf="display-p3-linear",ff="linear",At="srgb",df="rec709",pf="p3";var Ma=7680;var ax=519,t1=512,n1=513,i1=514,Cb=515,s1=516,r1=517,o1=518,a1=519,dg=35044;var lx="300 es",vs=2e3,mf=2001,ur=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let s=this._listeners[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},gn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],cx=1234567,Ec=Math.PI/180,Ya=180/Math.PI;function Oi(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(gn[i&255]+gn[i>>8&255]+gn[i>>16&255]+gn[i>>24&255]+"-"+gn[e&255]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[t&63|128]+gn[t>>8&255]+"-"+gn[t>>16&255]+gn[t>>24&255]+gn[n&255]+gn[n>>8&255]+gn[n>>16&255]+gn[n>>24&255]).toLowerCase()}function _n(i,e,t){return Math.max(e,Math.min(t,i))}function jg(i,e){return(i%e+e)%e}function l1(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function c1(i,e,t){return i!==e?(t-i)/(e-i):0}function Tc(i,e,t){return(1-t)*i+t*e}function h1(i,e,t,n){return Tc(i,e,1-Math.exp(-t*n))}function u1(i,e=1){return e-Math.abs(jg(i,e*2)-e)}function f1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function d1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function p1(i,e){return i+Math.floor(Math.random()*(e-i+1))}function m1(i,e){return i+Math.random()*(e-i)}function g1(i){return i*(.5-Math.random())}function y1(i){i!==void 0&&(cx=i);let e=cx+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function _1(i){return i*Ec}function v1(i){return i*Ya}function x1(i){return(i&i-1)===0&&i!==0}function b1(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function M1(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function S1(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),f=o((e-n)/2),d=r((n-e)/2),y=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*u,l*f,a*c);break;case"YZY":i.set(l*f,a*h,l*u,a*c);break;case"ZXZ":i.set(l*u,l*f,a*h,a*c);break;case"XZX":i.set(a*h,l*y,l*d,a*c);break;case"YXY":i.set(l*d,a*h,l*y,a*c);break;case"ZYZ":i.set(l*y,l*d,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Li(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function pt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var il={DEG2RAD:Ec,RAD2DEG:Ya,generateUUID:Oi,clamp:_n,euclideanModulo:jg,mapLinear:l1,inverseLerp:c1,lerp:Tc,damp:h1,pingpong:u1,smoothstep:f1,smootherstep:d1,randInt:p1,randFloat:m1,randFloatSpread:g1,seededRandom:y1,degToRad:_1,radToDeg:v1,isPowerOfTwo:x1,ceilPowerOfTwo:b1,floorPowerOfTwo:M1,setQuaternionFromProperEuler:S1,normalize:pt,denormalize:Li},Ye=class{constructor(e=0,t=0){Ye.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(_n(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},We=class{constructor(e,t,n,s,r,o,a,l,c){We.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],f=n[2],d=n[5],y=n[8],v=s[0],p=s[3],m=s[6],A=s[1],x=s[4],S=s[7],N=s[2],P=s[5],C=s[8];return r[0]=o*v+a*A+l*N,r[3]=o*p+a*x+l*P,r[6]=o*m+a*S+l*C,r[1]=c*v+h*A+u*N,r[4]=c*p+h*x+u*P,r[7]=c*m+h*S+u*C,r[2]=f*v+d*A+y*N,r[5]=f*p+d*x+y*P,r[8]=f*m+d*S+y*C,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*o-a*c,f=a*l-h*r,d=c*r-o*l,y=t*u+n*f+s*d;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/y;return e[0]=u*v,e[1]=(s*c-h*n)*v,e[2]=(a*n-s*o)*v,e[3]=f*v,e[4]=(h*t-s*l)*v,e[5]=(s*r-a*t)*v,e[6]=d*v,e[7]=(n*l-c*t)*v,e[8]=(o*t-n*r)*v,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return 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],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Jp.makeScale(e,t)),this}rotate(e){return this.premultiply(Jp.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Jp=new We;function Lb(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Cc(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function w1(){let i=Cc("canvas");return i.style.display="block",i}var hx={};function uf(i){i in hx||(hx[i]=!0,console.warn(i))}function A1(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function E1(i){let e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function T1(i){let e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var ux=new We().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),fx=new We().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),gc={[nn]:{transfer:ff,primaries:df,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Gt]:{transfer:At,primaries:df,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Vf]:{transfer:ff,primaries:pf,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(fx),fromReference:i=>i.applyMatrix3(ux)},[$g]:{transfer:At,primaries:pf,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(fx),fromReference:i=>i.applyMatrix3(ux).convertLinearToSRGB()}},I1=new Set([nn,Vf]),it={enabled:!0,_workingColorSpace:nn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!I1.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;let n=gc[e].toReference,s=gc[t].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this._workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this._workingColorSpace)},getPrimaries:function(i){return gc[i].primaries},getTransfer:function(i){return i===Yi?ff:gc[i].transfer},getLuminanceCoefficients:function(i,e=this._workingColorSpace){return i.fromArray(gc[e].luminanceCoefficients)}};function za(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Qp(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Sa,pg=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Sa===void 0&&(Sa=Cc("canvas")),Sa.width=e.width,Sa.height=e.height;let n=Sa.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Sa}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){let t=Cc("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=za(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(za(t[n]/255)*255):t[n]=za(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},R1=0,Ka=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:R1++}),this.uuid=Oi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(em(s[o].image)):r.push(em(s[o]))}else r=em(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function em(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?pg.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var C1=0,Et=class extends ur{constructor(e=Et.DEFAULT_IMAGE,t=Et.DEFAULT_MAPPING,n=Pi,s=Pi,r=Wt,o=ui,a=Tn,l=bs,c=Et.DEFAULT_ANISOTROPY,h=Yi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:C1++}),this.uuid=Oi(),this.name="",this.source=new Ka(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ye(0,0),this.repeat=new Ye(1,1),this.center=new Ye(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==_b)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xs:e.x=e.x-Math.floor(e.x);break;case Pi:e.x=e.x<0?0:1;break;case bo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case xs:e.y=e.y-Math.floor(e.y);break;case Pi:e.y=e.y<0?0:1;break;case bo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Et.DEFAULT_IMAGE=null;Et.DEFAULT_MAPPING=_b;Et.DEFAULT_ANISOTROPY=1;var st=class{constructor(e=0,t=0,n=0,s=1){st.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],u=l[8],f=l[1],d=l[5],y=l[9],v=l[2],p=l[6],m=l[10];if(Math.abs(h-f)<.01&&Math.abs(u-v)<.01&&Math.abs(y-p)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+v)<.1&&Math.abs(y+p)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(c+1)/2,S=(d+1)/2,N=(m+1)/2,P=(h+f)/4,C=(u+v)/4,R=(y+p)/4;return x>S&&x>N?x<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(x),s=P/n,r=C/n):S>N?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=P/s,r=R/s):N<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(N),n=C/r,s=R/r),this.set(n,s,r,t),this}let A=Math.sqrt((p-y)*(p-y)+(u-v)*(u-v)+(f-h)*(f-h));return Math.abs(A)<.001&&(A=1),this.x=(p-y)/A,this.y=(u-v)/A,this.z=(f-h)/A,this.w=Math.acos((c+d+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},mg=class extends ur{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);let s={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let r=new Et(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,s=e.textures.length;n<s;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Ka(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ms=class extends mg{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},gf=class extends Et{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=tn,this.minFilter=tn,this.wrapR=Pi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var gg=class extends Et{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=tn,this.minFilter=tn,this.wrapR=Pi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Zn=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],f=r[o+0],d=r[o+1],y=r[o+2],v=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=y,e[t+3]=v;return}if(u!==v||l!==f||c!==d||h!==y){let p=1-a,m=l*f+c*d+h*y+u*v,A=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){let N=Math.sqrt(x),P=Math.atan2(N,m*A);p=Math.sin(p*P)/N,a=Math.sin(a*P)/N}let S=a*A;if(l=l*p+f*S,c=c*p+d*S,h=h*p+y*S,u=u*p+v*S,p===1-a){let N=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=N,c*=N,h*=N,u*=N}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[o],f=r[o+1],d=r[o+2],y=r[o+3];return e[t]=a*y+h*u+l*d-c*f,e[t+1]=l*y+h*f+c*u-a*d,e[t+2]=c*y+h*d+a*f-l*u,e[t+3]=h*y-a*u-l*f-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),u=a(r/2),f=l(n/2),d=l(s/2),y=l(r/2);switch(o){case"XYZ":this._x=f*h*u+c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u-f*d*y;break;case"YXZ":this._x=f*h*u+c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u+f*d*y;break;case"ZXY":this._x=f*h*u-c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u-f*d*y;break;case"ZYX":this._x=f*h*u-c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u+f*d*y;break;case"YZX":this._x=f*h*u+c*d*y,this._y=c*d*u+f*h*y,this._z=c*h*y-f*d*u,this._w=c*h*u-f*d*y;break;case"XZY":this._x=f*h*u-c*d*y,this._y=c*d*u-f*h*y,this._z=c*h*y+f*d*u,this._w=c*h*u+f*d*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],u=t[10],f=n+a+u;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-l)*d,this._y=(r-c)*d,this._z=(o-s)*d}else if(n>a&&n>u){let d=2*Math.sqrt(1+n-a-u);this._w=(h-l)/d,this._x=.25*d,this._y=(s+o)/d,this._z=(r+c)/d}else if(a>u){let d=2*Math.sqrt(1+a-n-u);this._w=(r-c)/d,this._x=(s+o)/d,this._y=.25*d,this._z=(l+h)/d}else{let d=2*Math.sqrt(1+u-n-a);this._w=(o-s)/d,this._x=(r+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(_n(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,s=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=s,this._z=r,this;let l=1-a*a;if(l<=Number.EPSILON){let d=1-t;return this._w=d*o+t*this._w,this._x=d*n+t*this._x,this._y=d*s+t*this._y,this._z=d*r+t*this._z,this.normalize(),this}let c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=o*u+this._w*f,this._x=n*u+this._x*f,this._y=s*u+this._y*f,this._z=r*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},k=class{constructor(e=0,t=0,n=0){k.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(dx.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(dx.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),u=2*(r*n-o*t);return this.x=t+l*c+o*u-a*h,this.y=n+l*h+a*c-r*u,this.z=s+l*u+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return tm.copy(this).projectOnVector(e),this.sub(tm)}reflect(e){return this.sub(tm.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(_n(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},tm=new k,dx=new Zn,di=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ii.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ii.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Ii.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Ii):Ii.fromBufferAttribute(r,o),Ii.applyMatrix4(e.matrixWorld),this.expandByPoint(Ii);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Pu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Pu.copy(n.boundingBox)),Pu.applyMatrix4(e.matrixWorld),this.union(Pu)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ii),Ii.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yc),Nu.subVectors(this.max,yc),wa.subVectors(e.a,yc),Aa.subVectors(e.b,yc),Ea.subVectors(e.c,yc),Qs.subVectors(Aa,wa),er.subVectors(Ea,Aa),ho.subVectors(wa,Ea);let t=[0,-Qs.z,Qs.y,0,-er.z,er.y,0,-ho.z,ho.y,Qs.z,0,-Qs.x,er.z,0,-er.x,ho.z,0,-ho.x,-Qs.y,Qs.x,0,-er.y,er.x,0,-ho.y,ho.x,0];return!nm(t,wa,Aa,Ea,Nu)||(t=[1,0,0,0,1,0,0,0,1],!nm(t,wa,Aa,Ea,Nu))?!1:(Ou.crossVectors(Qs,er),t=[Ou.x,Ou.y,Ou.z],nm(t,wa,Aa,Ea,Nu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ii).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ii).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(us[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),us[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),us[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),us[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),us[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),us[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),us[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),us[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(us),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},us=[new k,new k,new k,new k,new k,new k,new k,new k],Ii=new k,Pu=new di,wa=new k,Aa=new k,Ea=new k,Qs=new k,er=new k,ho=new k,yc=new k,Nu=new k,Ou=new k,uo=new k;function nm(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){uo.fromArray(i,r);let a=s.x*Math.abs(uo.x)+s.y*Math.abs(uo.y)+s.z*Math.abs(uo.z),l=e.dot(uo),c=t.dot(uo),h=n.dot(uo);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var L1=new di,_c=new k,im=new k,$n=class{constructor(e=new k,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):L1.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_c.subVectors(e,this.center);let t=_c.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(_c,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(im.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_c.copy(e.center).add(im)),this.expandByPoint(_c.copy(e.center).sub(im))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},fs=new k,sm=new k,Du=new k,tr=new k,rm=new k,Uu=new k,om=new k,So=class{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,fs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=fs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(fs.copy(this.origin).addScaledVector(this.direction,t),fs.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){sm.copy(e).add(t).multiplyScalar(.5),Du.copy(t).sub(e).normalize(),tr.copy(this.origin).sub(sm);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Du),a=tr.dot(this.direction),l=-tr.dot(Du),c=tr.lengthSq(),h=Math.abs(1-o*o),u,f,d,y;if(h>0)if(u=o*l-a,f=o*a-l,y=r*h,u>=0)if(f>=-y)if(f<=y){let v=1/h;u*=v,f*=v,d=u*(u+o*f+2*a)+f*(o*u+f+2*l)+c}else f=r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;else f=-r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;else f<=-y?(u=Math.max(0,-(-o*r+a)),f=u>0?-r:Math.min(Math.max(-r,-l),r),d=-u*u+f*(f+2*l)+c):f<=y?(u=0,f=Math.min(Math.max(-r,-l),r),d=f*(f+2*l)+c):(u=Math.max(0,-(o*r+a)),f=u>0?r:Math.min(Math.max(-r,-l),r),d=-u*u+f*(f+2*l)+c);else f=o>0?-r:r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(sm).addScaledVector(Du,f),d}intersectSphere(e,t){fs.subVectors(e.center,this.origin);let n=fs.dot(this.direction),s=fs.dot(fs)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,s=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,s=(e.min.x-f.x)*c),h>=0?(r=(e.min.y-f.y)*h,o=(e.max.y-f.y)*h):(r=(e.max.y-f.y)*h,o=(e.min.y-f.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,fs)!==null}intersectTriangle(e,t,n,s,r){rm.subVectors(t,e),Uu.subVectors(n,e),om.crossVectors(rm,Uu);let o=this.direction.dot(om),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;tr.subVectors(this.origin,e);let l=a*this.direction.dot(Uu.crossVectors(tr,Uu));if(l<0)return null;let c=a*this.direction.dot(rm.cross(tr));if(c<0||l+c>o)return null;let h=-a*tr.dot(om);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Pe=class{constructor(e,t,n,s,r,o,a,l,c,h,u,f,d,y,v,p){Pe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c,h,u,f,d,y,v,p)}set(e,t,n,s,r,o,a,l,c,h,u,f,d,y,v,p){let m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=s,m[1]=r,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=y,m[11]=v,m[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Pe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,s=1/Ta.setFromMatrixColumn(e,0).length(),r=1/Ta.setFromMatrixColumn(e,1).length(),o=1/Ta.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=o*h,d=o*u,y=a*h,v=a*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=d+y*c,t[5]=f-v*c,t[9]=-a*l,t[2]=v-f*c,t[6]=y+d*c,t[10]=o*l}else if(e.order==="YXZ"){let f=l*h,d=l*u,y=c*h,v=c*u;t[0]=f+v*a,t[4]=y*a-d,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=d*a-y,t[6]=v+f*a,t[10]=o*l}else if(e.order==="ZXY"){let f=l*h,d=l*u,y=c*h,v=c*u;t[0]=f-v*a,t[4]=-o*u,t[8]=y+d*a,t[1]=d+y*a,t[5]=o*h,t[9]=v-f*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let f=o*h,d=o*u,y=a*h,v=a*u;t[0]=l*h,t[4]=y*c-d,t[8]=f*c+v,t[1]=l*u,t[5]=v*c+f,t[9]=d*c-y,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let f=o*l,d=o*c,y=a*l,v=a*c;t[0]=l*h,t[4]=v-f*u,t[8]=y*u+d,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=d*u+y,t[10]=f-v*u}else if(e.order==="XZY"){let f=o*l,d=o*c,y=a*l,v=a*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=f*u+v,t[5]=o*h,t[9]=d*u-y,t[2]=y*u-d,t[6]=a*h,t[10]=v*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(P1,e,N1)}lookAt(e,t,n){let s=this.elements;return Xn.subVectors(e,t),Xn.lengthSq()===0&&(Xn.z=1),Xn.normalize(),nr.crossVectors(n,Xn),nr.lengthSq()===0&&(Math.abs(n.z)===1?Xn.x+=1e-4:Xn.z+=1e-4,Xn.normalize(),nr.crossVectors(n,Xn)),nr.normalize(),Fu.crossVectors(Xn,nr),s[0]=nr.x,s[4]=Fu.x,s[8]=Xn.x,s[1]=nr.y,s[5]=Fu.y,s[9]=Xn.y,s[2]=nr.z,s[6]=Fu.z,s[10]=Xn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],f=n[9],d=n[13],y=n[2],v=n[6],p=n[10],m=n[14],A=n[3],x=n[7],S=n[11],N=n[15],P=s[0],C=s[4],R=s[8],ne=s[12],b=s[1],_=s[5],M=s[9],I=s[13],O=s[2],B=s[6],D=s[10],X=s[14],q=s[3],Q=s[7],ae=s[11],ee=s[15];return r[0]=o*P+a*b+l*O+c*q,r[4]=o*C+a*_+l*B+c*Q,r[8]=o*R+a*M+l*D+c*ae,r[12]=o*ne+a*I+l*X+c*ee,r[1]=h*P+u*b+f*O+d*q,r[5]=h*C+u*_+f*B+d*Q,r[9]=h*R+u*M+f*D+d*ae,r[13]=h*ne+u*I+f*X+d*ee,r[2]=y*P+v*b+p*O+m*q,r[6]=y*C+v*_+p*B+m*Q,r[10]=y*R+v*M+p*D+m*ae,r[14]=y*ne+v*I+p*X+m*ee,r[3]=A*P+x*b+S*O+N*q,r[7]=A*C+x*_+S*B+N*Q,r[11]=A*R+x*M+S*D+N*ae,r[15]=A*ne+x*I+S*X+N*ee,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],u=e[6],f=e[10],d=e[14],y=e[3],v=e[7],p=e[11],m=e[15];return y*(+r*l*u-s*c*u-r*a*f+n*c*f+s*a*d-n*l*d)+v*(+t*l*d-t*c*f+r*o*f-s*o*d+s*c*h-r*l*h)+p*(+t*c*u-t*a*d-r*o*u+n*o*d+r*a*h-n*c*h)+m*(-s*a*h-t*l*u+t*a*f+s*o*u-n*o*f+n*l*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],f=e[10],d=e[11],y=e[12],v=e[13],p=e[14],m=e[15],A=u*p*c-v*f*c+v*l*d-a*p*d-u*l*m+a*f*m,x=y*f*c-h*p*c-y*l*d+o*p*d+h*l*m-o*f*m,S=h*v*c-y*u*c+y*a*d-o*v*d-h*a*m+o*u*m,N=y*u*l-h*v*l-y*a*f+o*v*f+h*a*p-o*u*p,P=t*A+n*x+s*S+r*N;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/P;return e[0]=A*C,e[1]=(v*f*r-u*p*r-v*s*d+n*p*d+u*s*m-n*f*m)*C,e[2]=(a*p*r-v*l*r+v*s*c-n*p*c-a*s*m+n*l*m)*C,e[3]=(u*l*r-a*f*r-u*s*c+n*f*c+a*s*d-n*l*d)*C,e[4]=x*C,e[5]=(h*p*r-y*f*r+y*s*d-t*p*d-h*s*m+t*f*m)*C,e[6]=(y*l*r-o*p*r-y*s*c+t*p*c+o*s*m-t*l*m)*C,e[7]=(o*f*r-h*l*r+h*s*c-t*f*c-o*s*d+t*l*d)*C,e[8]=S*C,e[9]=(y*u*r-h*v*r-y*n*d+t*v*d+h*n*m-t*u*m)*C,e[10]=(o*v*r-y*a*r+y*n*c-t*v*c-o*n*m+t*a*m)*C,e[11]=(h*a*r-o*u*r-h*n*c+t*u*c+o*n*d-t*a*d)*C,e[12]=N*C,e[13]=(h*v*s-y*u*s+y*n*f-t*v*f-h*n*p+t*u*p)*C,e[14]=(y*a*s-o*v*s-y*n*l+t*v*l+o*n*p-t*a*p)*C,e[15]=(o*u*s-h*a*s+h*n*l-t*u*l-o*n*f+t*a*f)*C,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+n,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,u=a+a,f=r*c,d=r*h,y=r*u,v=o*h,p=o*u,m=a*u,A=l*c,x=l*h,S=l*u,N=n.x,P=n.y,C=n.z;return s[0]=(1-(v+m))*N,s[1]=(d+S)*N,s[2]=(y-x)*N,s[3]=0,s[4]=(d-S)*P,s[5]=(1-(f+m))*P,s[6]=(p+A)*P,s[7]=0,s[8]=(y+x)*C,s[9]=(p-A)*C,s[10]=(1-(f+v))*C,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements,r=Ta.set(s[0],s[1],s[2]).length(),o=Ta.set(s[4],s[5],s[6]).length(),a=Ta.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],Ri.copy(this);let c=1/r,h=1/o,u=1/a;return Ri.elements[0]*=c,Ri.elements[1]*=c,Ri.elements[2]*=c,Ri.elements[4]*=h,Ri.elements[5]*=h,Ri.elements[6]*=h,Ri.elements[8]*=u,Ri.elements[9]*=u,Ri.elements[10]*=u,t.setFromRotationMatrix(Ri),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,s,r,o,a=vs){let l=this.elements,c=2*r/(t-e),h=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),d,y;if(a===vs)d=-(o+r)/(o-r),y=-2*o*r/(o-r);else if(a===mf)d=-o/(o-r),y=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=d,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=vs){let l=this.elements,c=1/(t-e),h=1/(n-s),u=1/(o-r),f=(t+e)*c,d=(n+s)*h,y,v;if(a===vs)y=(o+r)*u,v=-2*u;else if(a===mf)y=r*u,v=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-d,l[2]=0,l[6]=0,l[10]=v,l[14]=-y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Ta=new k,Ri=new Pe,P1=new k(0,0,0),N1=new k(1,1,1),nr=new k,Fu=new k,Xn=new k,px=new Pe,mx=new Zn,vn=class{constructor(e=0,t=0,n=0,s=vn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],u=s[2],f=s[6],d=s[10];switch(t){case"XYZ":this._y=Math.asin(_n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-_n(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(_n(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-_n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(_n(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-_n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return px.makeRotationFromQuaternion(e),this.setFromRotationMatrix(px,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return mx.setFromEuler(this),this.setFromQuaternion(mx,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};vn.DEFAULT_ORDER="XYZ";var Lc=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},O1=0,gx=new k,Ia=new Zn,ds=new Pe,Bu=new k,vc=new k,D1=new k,U1=new Zn,yx=new k(1,0,0),_x=new k(0,1,0),vx=new k(0,0,1),xx={type:"added"},F1={type:"removed"},Ra={type:"childadded",child:null},am={type:"childremoved",child:null},_t=class extends ur{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:O1++}),this.uuid=Oi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new k,t=new vn,n=new Zn,s=new k(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Pe},normalMatrix:{value:new We}}),this.matrix=new Pe,this.matrixWorld=new Pe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Lc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ia.setFromAxisAngle(e,t),this.quaternion.multiply(Ia),this}rotateOnWorldAxis(e,t){return Ia.setFromAxisAngle(e,t),this.quaternion.premultiply(Ia),this}rotateX(e){return this.rotateOnAxis(yx,e)}rotateY(e){return this.rotateOnAxis(_x,e)}rotateZ(e){return this.rotateOnAxis(vx,e)}translateOnAxis(e,t){return gx.copy(e).applyQuaternion(this.quaternion),this.position.add(gx.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(yx,e)}translateY(e){return this.translateOnAxis(_x,e)}translateZ(e){return this.translateOnAxis(vx,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ds.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Bu.copy(e):Bu.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),vc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ds.lookAt(vc,Bu,this.up):ds.lookAt(Bu,vc,this.up),this.quaternion.setFromRotationMatrix(ds),s&&(ds.extractRotation(s.matrixWorld),Ia.setFromRotationMatrix(ds),this.quaternion.premultiply(Ia.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(xx),Ra.child=e,this.dispatchEvent(Ra),Ra.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(F1),am.child=e,this.dispatchEvent(am),am.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ds.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ds.multiply(e.parent.matrixWorld)),e.applyMatrix4(ds),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(xx),Ra.child=e,this.dispatchEvent(Ra),Ra.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vc,e,D1),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vc,U1,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),u=o(e.shapes),f=o(e.skeletons),d=o(e.animations),y=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),y.length>0&&(n.nodes=y)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};_t.DEFAULT_UP=new k(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ci=new k,ps=new k,lm=new k,ms=new k,Ca=new k,La=new k,bx=new k,cm=new k,hm=new k,um=new k,fm=new st,dm=new st,pm=new st,Kn=class{constructor(e=new k,t=new k,n=new k){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ci.subVectors(e,t),s.cross(Ci);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Ci.subVectors(s,t),ps.subVectors(n,t),lm.subVectors(e,t);let o=Ci.dot(Ci),a=Ci.dot(ps),l=Ci.dot(lm),c=ps.dot(ps),h=ps.dot(lm),u=o*c-a*a;if(u===0)return r.set(0,0,0),null;let f=1/u,d=(c*l-a*h)*f,y=(o*h-a*l)*f;return r.set(1-d-y,y,d)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,ms)===null?!1:ms.x>=0&&ms.y>=0&&ms.x+ms.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,ms)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,ms.x),l.addScaledVector(o,ms.y),l.addScaledVector(a,ms.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return fm.setScalar(0),dm.setScalar(0),pm.setScalar(0),fm.fromBufferAttribute(e,t),dm.fromBufferAttribute(e,n),pm.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(fm,r.x),o.addScaledVector(dm,r.y),o.addScaledVector(pm,r.z),o}static isFrontFacing(e,t,n,s){return Ci.subVectors(n,t),ps.subVectors(e,t),Ci.cross(ps).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ci.subVectors(this.c,this.b),ps.subVectors(this.a,this.b),Ci.cross(ps).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Kn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Kn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;Ca.subVectors(s,n),La.subVectors(r,n),cm.subVectors(e,n);let l=Ca.dot(cm),c=La.dot(cm);if(l<=0&&c<=0)return t.copy(n);hm.subVectors(e,s);let h=Ca.dot(hm),u=La.dot(hm);if(h>=0&&u<=h)return t.copy(s);let f=l*u-h*c;if(f<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(Ca,o);um.subVectors(e,r);let d=Ca.dot(um),y=La.dot(um);if(y>=0&&d<=y)return t.copy(r);let v=d*c-l*y;if(v<=0&&c>=0&&y<=0)return a=c/(c-y),t.copy(n).addScaledVector(La,a);let p=h*y-d*u;if(p<=0&&u-h>=0&&d-y>=0)return bx.subVectors(r,s),a=(u-h)/(u-h+(d-y)),t.copy(s).addScaledVector(bx,a);let m=1/(p+v+f);return o=v*m,a=f*m,t.copy(n).addScaledVector(Ca,o).addScaledVector(La,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Pb={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ir={h:0,s:0,l:0},ku={h:0,s:0,l:0};function mm(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Oe=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Gt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=it.workingColorSpace){if(e=jg(e,1),t=_n(t,0,1),n=_n(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=mm(o,r,e+1/3),this.g=mm(o,r,e),this.b=mm(o,r,e-1/3)}return it.toWorkingColorSpace(this,s),this}setStyle(e,t=Gt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Gt){let n=Pb[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=za(e.r),this.g=za(e.g),this.b=za(e.b),this}copyLinearToSRGB(e){return this.r=Qp(e.r),this.g=Qp(e.g),this.b=Qp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Gt){return it.fromWorkingColorSpace(yn.copy(this),e),Math.round(_n(yn.r*255,0,255))*65536+Math.round(_n(yn.g*255,0,255))*256+Math.round(_n(yn.b*255,0,255))}getHexString(e=Gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.fromWorkingColorSpace(yn.copy(this),t);let n=yn.r,s=yn.g,r=yn.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=it.workingColorSpace){return it.fromWorkingColorSpace(yn.copy(this),t),e.r=yn.r,e.g=yn.g,e.b=yn.b,e}getStyle(e=Gt){it.fromWorkingColorSpace(yn.copy(this),e);let t=yn.r,n=yn.g,s=yn.b;return e!==Gt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(ir),this.setHSL(ir.h+e,ir.s+t,ir.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ir),e.getHSL(ku);let n=Tc(ir.h,ku.h,t),s=Tc(ir.s,ku.s,t),r=Tc(ir.l,ku.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},yn=new Oe;Oe.NAMES=Pb;var B1=0,jn=class extends ur{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:B1++}),this.uuid=Oi(),this.name="",this.type="Material",this.blending=Ba,this.side=Zi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Cm,this.blendDst=Lm,this.blendEquation=_o,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=Ha,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ax,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ma,this.stencilZFail=Ma,this.stencilZPass=Ma,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ba&&(n.blending=this.blending),this.side!==Zi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Cm&&(n.blendSrc=this.blendSrc),this.blendDst!==Lm&&(n.blendDst=this.blendDst),this.blendEquation!==_o&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ha&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ax&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ma&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ma&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ma&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}},Rn=class extends jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.combine=yb,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};var Ht=new k,zu=new Ye,vt=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=dg,this.updateRanges=[],this.gpuType=Ni,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)zu.fromBufferAttribute(this,t),zu.applyMatrix3(e),this.setXY(t,zu.x,zu.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyMatrix3(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyMatrix4(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyNormalMatrix(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.transformDirection(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Li(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=pt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Li(t,this.array)),t}setX(e,t){return this.normalized&&(t=pt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Li(t,this.array)),t}setY(e,t){return this.normalized&&(t=pt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Li(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Li(t,this.array)),t}setW(e,t){return this.normalized&&(t=pt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array),s=pt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array),s=pt(s,this.array),r=pt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==dg&&(e.usage=this.usage),e}};var yf=class extends vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var _f=class extends vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var fi=class extends vt{constructor(e,t,n){super(new Float32Array(e),t,n)}},k1=0,hi=new Pe,gm=new _t,Pa=new k,qn=new di,xc=new di,en=new k,Cn=class extends ur{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:k1++}),this.uuid=Oi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Lb(e)?_f:yf)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new We().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return hi.makeRotationFromQuaternion(e),this.applyMatrix4(hi),this}rotateX(e){return hi.makeRotationX(e),this.applyMatrix4(hi),this}rotateY(e){return hi.makeRotationY(e),this.applyMatrix4(hi),this}rotateZ(e){return hi.makeRotationZ(e),this.applyMatrix4(hi),this}translate(e,t,n){return hi.makeTranslation(e,t,n),this.applyMatrix4(hi),this}scale(e,t,n){return hi.makeScale(e,t,n),this.applyMatrix4(hi),this}lookAt(e){return gm.lookAt(e),gm.updateMatrix(),this.applyMatrix4(gm.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pa).negate(),this.translate(Pa.x,Pa.y,Pa.z),this}setFromPoints(e){let t=[];for(let n=0,s=e.length;n<s;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new fi(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new di);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];qn.setFromBufferAttribute(r),this.morphTargetsRelative?(en.addVectors(this.boundingBox.min,qn.min),this.boundingBox.expandByPoint(en),en.addVectors(this.boundingBox.max,qn.max),this.boundingBox.expandByPoint(en)):(this.boundingBox.expandByPoint(qn.min),this.boundingBox.expandByPoint(qn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new $n);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){let n=this.boundingSphere.center;if(qn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];xc.setFromBufferAttribute(a),this.morphTargetsRelative?(en.addVectors(qn.min,xc.min),qn.expandByPoint(en),en.addVectors(qn.max,xc.max),qn.expandByPoint(en)):(qn.expandByPoint(xc.min),qn.expandByPoint(xc.max))}qn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)en.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(en));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)en.fromBufferAttribute(a,c),l&&(Pa.fromBufferAttribute(e,c),en.add(Pa)),s=Math.max(s,n.distanceToSquared(en))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new vt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let R=0;R<n.count;R++)a[R]=new k,l[R]=new k;let c=new k,h=new k,u=new k,f=new Ye,d=new Ye,y=new Ye,v=new k,p=new k;function m(R,ne,b){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,ne),u.fromBufferAttribute(n,b),f.fromBufferAttribute(r,R),d.fromBufferAttribute(r,ne),y.fromBufferAttribute(r,b),h.sub(c),u.sub(c),d.sub(f),y.sub(f);let _=1/(d.x*y.y-y.x*d.y);!isFinite(_)||(v.copy(h).multiplyScalar(y.y).addScaledVector(u,-d.y).multiplyScalar(_),p.copy(u).multiplyScalar(d.x).addScaledVector(h,-y.x).multiplyScalar(_),a[R].add(v),a[ne].add(v),a[b].add(v),l[R].add(p),l[ne].add(p),l[b].add(p))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let R=0,ne=A.length;R<ne;++R){let b=A[R],_=b.start,M=b.count;for(let I=_,O=_+M;I<O;I+=3)m(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let x=new k,S=new k,N=new k,P=new k;function C(R){N.fromBufferAttribute(s,R),P.copy(N);let ne=a[R];x.copy(ne),x.sub(N.multiplyScalar(N.dot(ne))).normalize(),S.crossVectors(P,ne);let _=S.dot(l[R])<0?-1:1;o.setXYZW(R,x.x,x.y,x.z,_)}for(let R=0,ne=A.length;R<ne;++R){let b=A[R],_=b.start,M=b.count;for(let I=_,O=_+M;I<O;I+=3)C(e.getX(I+0)),C(e.getX(I+1)),C(e.getX(I+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);let s=new k,r=new k,o=new k,a=new k,l=new k,c=new k,h=new k,u=new k;if(e)for(let f=0,d=e.count;f<d;f+=3){let y=e.getX(f+0),v=e.getX(f+1),p=e.getX(f+2);s.fromBufferAttribute(t,y),r.fromBufferAttribute(t,v),o.fromBufferAttribute(t,p),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),a.fromBufferAttribute(n,y),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,p),a.add(h),l.add(h),c.add(h),n.setXYZ(y,a.x,a.y,a.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let f=0,d=t.count;f<d;f+=3)s.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)en.fromBufferAttribute(e,t),en.normalize(),e.setXYZ(t,en.x,en.y,en.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,u=a.normalized,f=new c.constructor(l.length*h),d=0,y=0;for(let v=0,p=l.length;v<p;v++){a.isInterleavedBufferAttribute?d=l[v]*a.data.stride+a.offset:d=l[v]*h;for(let m=0;m<h;m++)f[y++]=c[d++]}return new vt(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Cn,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=e(l,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let h=0,u=c.length;h<u;h++){let f=c[h],d=e(f,n);l.push(d)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,f=c.length;u<f;u++){let d=c[u];h.push(d.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],u=r[c];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Mx=new Pe,fo=new So,Vu=new $n,Sx=new k,Hu=new k,Gu=new k,Wu=new k,ym=new k,Xu=new k,wx=new k,qu=new k,Ct=class extends _t{constructor(e=new Cn,t=new Rn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){Xu.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=a[l],u=r[l];h!==0&&(ym.fromBufferAttribute(u,e),o?Xu.addScaledVector(ym,h):Xu.addScaledVector(ym.sub(t),h))}t.add(Xu)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Vu.copy(n.boundingSphere),Vu.applyMatrix4(r),fo.copy(e.ray).recast(e.near),!(Vu.containsPoint(fo.origin)===!1&&(fo.intersectSphere(Vu,Sx)===null||fo.origin.distanceToSquared(Sx)>(e.far-e.near)**2))&&(Mx.copy(r).invert(),fo.copy(e.ray).applyMatrix4(Mx),!(n.boundingBox!==null&&fo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,fo)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,f=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(o))for(let y=0,v=f.length;y<v;y++){let p=f[y],m=o[p.materialIndex],A=Math.max(p.start,d.start),x=Math.min(a.count,Math.min(p.start+p.count,d.start+d.count));for(let S=A,N=x;S<N;S+=3){let P=a.getX(S),C=a.getX(S+1),R=a.getX(S+2);s=Yu(this,m,e,n,c,h,u,P,C,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let y=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let p=y,m=v;p<m;p+=3){let A=a.getX(p),x=a.getX(p+1),S=a.getX(p+2);s=Yu(this,o,e,n,c,h,u,A,x,S),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let y=0,v=f.length;y<v;y++){let p=f[y],m=o[p.materialIndex],A=Math.max(p.start,d.start),x=Math.min(l.count,Math.min(p.start+p.count,d.start+d.count));for(let S=A,N=x;S<N;S+=3){let P=S,C=S+1,R=S+2;s=Yu(this,m,e,n,c,h,u,P,C,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let y=Math.max(0,d.start),v=Math.min(l.count,d.start+d.count);for(let p=y,m=v;p<m;p+=3){let A=p,x=p+1,S=p+2;s=Yu(this,o,e,n,c,h,u,A,x,S),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}}};function z1(i,e,t,n,s,r,o,a){let l;if(e.side===In?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,e.side===Zi,a),l===null)return null;qu.copy(a),qu.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(qu);return c<t.near||c>t.far?null:{distance:c,point:qu.clone(),object:i}}function Yu(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,Hu),i.getVertexPosition(l,Gu),i.getVertexPosition(c,Wu);let h=z1(i,e,t,n,Hu,Gu,Wu,wx);if(h){let u=new k;Kn.getBarycoord(wx,Hu,Gu,Wu,u),s&&(h.uv=Kn.getInterpolatedAttribute(s,a,l,c,u,new Ye)),r&&(h.uv1=Kn.getInterpolatedAttribute(r,a,l,c,u,new Ye)),o&&(h.normal=Kn.getInterpolatedAttribute(o,a,l,c,u,new k),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new k,materialIndex:0};Kn.getNormal(Hu,Gu,Wu,f.normal),h.face=f,h.barycoord=u}return h}var wo=class extends Cn{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],u=[],f=0,d=0;y("z","y","x",-1,-1,n,t,e,o,r,0),y("z","y","x",1,-1,n,t,-e,o,r,1),y("x","z","y",1,1,e,n,t,s,o,2),y("x","z","y",1,-1,e,n,-t,s,o,3),y("x","y","z",1,-1,e,t,n,s,r,4),y("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new fi(c,3)),this.setAttribute("normal",new fi(h,3)),this.setAttribute("uv",new fi(u,2));function y(v,p,m,A,x,S,N,P,C,R,ne){let b=S/C,_=N/R,M=S/2,I=N/2,O=P/2,B=C+1,D=R+1,X=0,q=0,Q=new k;for(let ae=0;ae<D;ae++){let ee=ae*_-I;for(let H=0;H<B;H++){let be=H*b-M;Q[v]=be*A,Q[p]=ee*x,Q[m]=O,c.push(Q.x,Q.y,Q.z),Q[v]=0,Q[p]=0,Q[m]=P>0?1:-1,h.push(Q.x,Q.y,Q.z),u.push(H/C),u.push(1-ae/R),X+=1}}for(let ae=0;ae<R;ae++)for(let ee=0;ee<C;ee++){let H=f+ee+B*ae,be=f+ee+B*(ae+1),Y=f+(ee+1)+B*(ae+1),oe=f+(ee+1)+B*ae;l.push(H,be,oe),l.push(be,Y,oe),q+=6}a.addGroup(d,q,ne),d+=q,f+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wo(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Za(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function Mn(i){let e={};for(let t=0;t<i.length;t++){let n=Za(i[t]);for(let s in n)e[s]=n[s]}return e}function V1(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Nb(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:it.workingColorSpace}var H1={clone:Za,merge:Mn},G1=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,W1=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,pi=class extends jn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=G1,this.fragmentShader=W1,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Za(e.uniforms),this.uniformsGroups=V1(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},fr=class extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Pe,this.projectionMatrix=new Pe,this.projectionMatrixInverse=new Pe,this.coordinateSystem=vs}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},sr=new k,Ax=new Ye,Ex=new Ye,Zt=class extends fr{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Ya*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ec*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ya*2*Math.atan(Math.tan(Ec*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){sr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,Ax,Ex),t.subVectors(Ex,Ax)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ec*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Na=-90,Oa=1,yg=class extends _t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Zt(Na,Oa,e,t);s.layers=this.layers,this.add(s);let r=new Zt(Na,Oa,e,t);r.layers=this.layers,this.add(r);let o=new Zt(Na,Oa,e,t);o.layers=this.layers,this.add(o);let a=new Zt(Na,Oa,e,t);a.layers=this.layers,this.add(a);let l=new Zt(Na,Oa,e,t);l.layers=this.layers,this.add(l);let c=new Zt(Na,Oa,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===vs)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===mf)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,r),e.setRenderTarget(n,1,s),e.render(t,o),e.setRenderTarget(n,2,s),e.render(t,a),e.setRenderTarget(n,3,s),e.render(t,l),e.setRenderTarget(n,4,s),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,s),e.render(t,h),e.setRenderTarget(u,f,d),e.xr.enabled=y,n.texture.needsPMREMUpdate=!0}},vf=class extends Et{constructor(e,t,n,s,r,o,a,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:Ga,super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},_g=class extends Ms{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new vf(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Wt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},s=new wo(5,5,5),r=new pi({name:"CubemapFromEquirect",uniforms:Za(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:In,blending:ar});r.uniforms.tEquirect.value=t;let o=new Ct(s,r),a=t.minFilter;return t.minFilter===ui&&(t.minFilter=Wt),new yg(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,s){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},_m=new k,X1=new k,q1=new We,_s=class{constructor(e=new k(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=_m.subVectors(n,t).cross(X1.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(_m),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||q1.getNormalMatrix(e),s=this.coplanarPoint(_m).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},po=new $n,Ku=new k,Pc=class{constructor(e=new _s,t=new _s,n=new _s,s=new _s,r=new _s,o=new _s){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=vs){let n=this.planes,s=e.elements,r=s[0],o=s[1],a=s[2],l=s[3],c=s[4],h=s[5],u=s[6],f=s[7],d=s[8],y=s[9],v=s[10],p=s[11],m=s[12],A=s[13],x=s[14],S=s[15];if(n[0].setComponents(l-r,f-c,p-d,S-m).normalize(),n[1].setComponents(l+r,f+c,p+d,S+m).normalize(),n[2].setComponents(l+o,f+h,p+y,S+A).normalize(),n[3].setComponents(l-o,f-h,p-y,S-A).normalize(),n[4].setComponents(l-a,f-u,p-v,S-x).normalize(),t===vs)n[5].setComponents(l+a,f+u,p+v,S+x).normalize();else if(t===mf)n[5].setComponents(a,u,v,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),po.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),po.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(po)}intersectsSprite(e){return po.center.set(0,0,0),po.radius=.7071067811865476,po.applyMatrix4(e.matrixWorld),this.intersectsSphere(po)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(Ku.x=s.normal.x>0?e.max.x:e.min.x,Ku.y=s.normal.y>0?e.max.y:e.min.y,Ku.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ku)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Ob(){let i=null,e=!1,t=null,n=null;function s(r,o){t(r,o),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Y1(i){let e=new WeakMap;function t(a,l){let c=a.array,h=a.usage,u=c.byteLength,f=i.createBuffer();i.bindBuffer(l,f),i.bufferData(l,c,h),a.onUploadCallback();let d;if(c instanceof Float32Array)d=i.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)d=i.SHORT;else if(c instanceof Uint32Array)d=i.UNSIGNED_INT;else if(c instanceof Int32Array)d=i.INT;else if(c instanceof Int8Array)d=i.BYTE;else if(c instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:d,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,l,c){let h=l.array,u=l.updateRanges;if(i.bindBuffer(c,a),u.length===0)i.bufferSubData(c,0,h);else{u.sort((d,y)=>d.start-y.start);let f=0;for(let d=1;d<u.length;d++){let y=u[f],v=u[d];v.start<=y.start+y.count+1?y.count=Math.max(y.count,v.start+v.count-y.start):(++f,u[f]=v)}u.length=f+1;for(let d=0,y=u.length;d<y;d++){let v=u[d];i.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(i.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var mi=class extends Cn{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(s),c=a+1,h=l+1,u=e/a,f=t/l,d=[],y=[],v=[],p=[];for(let m=0;m<h;m++){let A=m*f-o;for(let x=0;x<c;x++){let S=x*u-r;y.push(S,-A,0),v.push(0,0,1),p.push(x/a),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let A=0;A<a;A++){let x=A+c*m,S=A+c*(m+1),N=A+1+c*(m+1),P=A+1+c*m;d.push(x,S,P),d.push(S,N,P)}this.setIndex(d),this.setAttribute("position",new fi(y,3)),this.setAttribute("normal",new fi(v,3)),this.setAttribute("uv",new fi(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mi(e.width,e.height,e.widthSegments,e.heightSegments)}},K1=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,Z1=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,$1=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,j1=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,J1=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,Q1=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,eE=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,tE=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,nE=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,iE=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,sE=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,rE=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,oE=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,aE=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,lE=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,cE=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,hE=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,uE=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,fE=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,dE=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,pE=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,mE=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,gE=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,yE=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,_E=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,vE=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,xE=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,bE=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,ME=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,SE=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,wE="gl_FragColor = linearToOutputTexel( gl_FragColor );",AE=`
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
	vec3( 0.8224621, 0.177538, 0.0 ),
	vec3( 0.0331941, 0.9668058, 0.0 ),
	vec3( 0.0170827, 0.0723974, 0.9105199 )
);
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
	vec3( 1.2249401, - 0.2249404, 0.0 ),
	vec3( - 0.0420569, 1.0420571, 0.0 ),
	vec3( - 0.0196376, - 0.0786361, 1.0982735 )
);
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
	return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
}
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
	return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
}
vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferOETF( in vec4 value ) {
	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.a );
}`,EE=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,TE=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,IE=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,RE=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,CE=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,LE=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,PE=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,NE=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,OE=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,DE=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,UE=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,FE=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,BE=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,kE=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,zE=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,VE=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,HE=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,GE=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,WE=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,XE=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,qE=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,YE=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,KE=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,ZE=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,$E=`#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,jE=`#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,JE=`#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,QE=`#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,eT=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,tT=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,nT=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,iT=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,sT=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,rT=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,oT=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,aT=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,lT=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,cT=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,hT=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,uT=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,fT=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,dT=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,pT=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,mT=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,gT=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,yT=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,_T=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,vT=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,xT=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,bT=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,MT=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,ST=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,wT=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,AT=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,ET=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,TT=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,IT=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,RT=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,CT=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,LT=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,PT=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,NT=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,OT=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,DT=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,UT=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,FT=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,BT=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,kT=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,zT=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,VT=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,HT=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
		
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
		
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		
		#else
		
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,GT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,WT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,XT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,qT=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,YT=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,KT=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,ZT=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,$T=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,jT=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,JT=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,QT=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,eI=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,tI=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,nI=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,iI=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,sI=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,rI=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,oI=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,aI=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,lI=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,cI=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,hI=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,uI=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,fI=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,dI=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,pI=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,mI=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,gI=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,yI=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,_I=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,vI=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,xI=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,bI=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,MI=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,SI=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,wI=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,AI=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,EI=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,Xe={alphahash_fragment:K1,alphahash_pars_fragment:Z1,alphamap_fragment:$1,alphamap_pars_fragment:j1,alphatest_fragment:J1,alphatest_pars_fragment:Q1,aomap_fragment:eE,aomap_pars_fragment:tE,batching_pars_vertex:nE,batching_vertex:iE,begin_vertex:sE,beginnormal_vertex:rE,bsdfs:oE,iridescence_fragment:aE,bumpmap_pars_fragment:lE,clipping_planes_fragment:cE,clipping_planes_pars_fragment:hE,clipping_planes_pars_vertex:uE,clipping_planes_vertex:fE,color_fragment:dE,color_pars_fragment:pE,color_pars_vertex:mE,color_vertex:gE,common:yE,cube_uv_reflection_fragment:_E,defaultnormal_vertex:vE,displacementmap_pars_vertex:xE,displacementmap_vertex:bE,emissivemap_fragment:ME,emissivemap_pars_fragment:SE,colorspace_fragment:wE,colorspace_pars_fragment:AE,envmap_fragment:EE,envmap_common_pars_fragment:TE,envmap_pars_fragment:IE,envmap_pars_vertex:RE,envmap_physical_pars_fragment:zE,envmap_vertex:CE,fog_vertex:LE,fog_pars_vertex:PE,fog_fragment:NE,fog_pars_fragment:OE,gradientmap_pars_fragment:DE,lightmap_pars_fragment:UE,lights_lambert_fragment:FE,lights_lambert_pars_fragment:BE,lights_pars_begin:kE,lights_toon_fragment:VE,lights_toon_pars_fragment:HE,lights_phong_fragment:GE,lights_phong_pars_fragment:WE,lights_physical_fragment:XE,lights_physical_pars_fragment:qE,lights_fragment_begin:YE,lights_fragment_maps:KE,lights_fragment_end:ZE,logdepthbuf_fragment:$E,logdepthbuf_pars_fragment:jE,logdepthbuf_pars_vertex:JE,logdepthbuf_vertex:QE,map_fragment:eT,map_pars_fragment:tT,map_particle_fragment:nT,map_particle_pars_fragment:iT,metalnessmap_fragment:sT,metalnessmap_pars_fragment:rT,morphinstance_vertex:oT,morphcolor_vertex:aT,morphnormal_vertex:lT,morphtarget_pars_vertex:cT,morphtarget_vertex:hT,normal_fragment_begin:uT,normal_fragment_maps:fT,normal_pars_fragment:dT,normal_pars_vertex:pT,normal_vertex:mT,normalmap_pars_fragment:gT,clearcoat_normal_fragment_begin:yT,clearcoat_normal_fragment_maps:_T,clearcoat_pars_fragment:vT,iridescence_pars_fragment:xT,opaque_fragment:bT,packing:MT,premultiplied_alpha_fragment:ST,project_vertex:wT,dithering_fragment:AT,dithering_pars_fragment:ET,roughnessmap_fragment:TT,roughnessmap_pars_fragment:IT,shadowmap_pars_fragment:RT,shadowmap_pars_vertex:CT,shadowmap_vertex:LT,shadowmask_pars_fragment:PT,skinbase_vertex:NT,skinning_pars_vertex:OT,skinning_vertex:DT,skinnormal_vertex:UT,specularmap_fragment:FT,specularmap_pars_fragment:BT,tonemapping_fragment:kT,tonemapping_pars_fragment:zT,transmission_fragment:VT,transmission_pars_fragment:HT,uv_pars_fragment:GT,uv_pars_vertex:WT,uv_vertex:XT,worldpos_vertex:qT,background_vert:YT,background_frag:KT,backgroundCube_vert:ZT,backgroundCube_frag:$T,cube_vert:jT,cube_frag:JT,depth_vert:QT,depth_frag:eI,distanceRGBA_vert:tI,distanceRGBA_frag:nI,equirect_vert:iI,equirect_frag:sI,linedashed_vert:rI,linedashed_frag:oI,meshbasic_vert:aI,meshbasic_frag:lI,meshlambert_vert:cI,meshlambert_frag:hI,meshmatcap_vert:uI,meshmatcap_frag:fI,meshnormal_vert:dI,meshnormal_frag:pI,meshphong_vert:mI,meshphong_frag:gI,meshphysical_vert:yI,meshphysical_frag:_I,meshtoon_vert:vI,meshtoon_frag:xI,points_vert:bI,points_frag:MI,shadow_vert:SI,shadow_frag:wI,sprite_vert:AI,sprite_frag:EI},pe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new Ye(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ye(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},qi={basic:{uniforms:Mn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:Mn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:Mn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:Mn([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:Mn([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:Mn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:Mn([pe.points,pe.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:Mn([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:Mn([pe.common,pe.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:Mn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.meshnormal_vert,fragmentShader:Xe.meshnormal_frag},sprite:{uniforms:Mn([pe.sprite,pe.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Xe.backgroundCube_vert,fragmentShader:Xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distanceRGBA:{uniforms:Mn([pe.common,pe.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xe.distanceRGBA_vert,fragmentShader:Xe.distanceRGBA_frag},shadow:{uniforms:Mn([pe.lights,pe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};qi.physical={uniforms:Mn([qi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new Ye(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new Ye},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new Ye},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};var Zu={r:0,b:0,g:0},mo=new vn,TI=new Pe;function II(i,e,t,n,s,r,o){let a=new Oe(0),l=r===!0?0:1,c,h,u=null,f=0,d=null;function y(A){let x=A.isScene===!0?A.background:null;return x&&x.isTexture&&(x=(A.backgroundBlurriness>0?t:e).get(x)),x}function v(A){let x=!1,S=y(A);S===null?m(a,l):S&&S.isColor&&(m(S,1),x=!0);let N=i.xr.getEnvironmentBlendMode();N==="additive"?n.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(A,x){let S=y(x);S&&(S.isCubeTexture||S.mapping===kf)?(h===void 0&&(h=new Ct(new wo(1,1,1),new pi({name:"BackgroundCubeMaterial",uniforms:Za(qi.backgroundCube.uniforms),vertexShader:qi.backgroundCube.vertexShader,fragmentShader:qi.backgroundCube.fragmentShader,side:In,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(N,P,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),mo.copy(x.backgroundRotation),mo.x*=-1,mo.y*=-1,mo.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(mo.y*=-1,mo.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(TI.makeRotationFromEuler(mo)),h.material.toneMapped=it.getTransfer(S.colorSpace)!==At,(u!==S||f!==S.version||d!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,f=S.version,d=i.toneMapping),h.layers.enableAll(),A.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Ct(new mi(2,2),new pi({name:"BackgroundMaterial",uniforms:Za(qi.background.uniforms),vertexShader:qi.background.vertexShader,fragmentShader:qi.background.fragmentShader,side:Zi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=it.getTransfer(S.colorSpace)!==At,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||f!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,f=S.version,d=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function m(A,x){A.getRGB(Zu,Nb(i)),n.buffers.color.setClear(Zu.r,Zu.g,Zu.b,x,o)}return{getClearColor:function(){return a},setClearColor:function(A,x=1){a.set(A),l=x,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(A){l=A,m(a,l)},render:v,addToRenderList:p}}function RI(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=f(null),r=s,o=!1;function a(b,_,M,I,O){let B=!1,D=u(I,M,_);r!==D&&(r=D,c(r.object)),B=d(b,I,M,O),B&&y(b,I,M,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(B||o)&&(o=!1,S(b,_,M,I),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return i.createVertexArray()}function c(b){return i.bindVertexArray(b)}function h(b){return i.deleteVertexArray(b)}function u(b,_,M){let I=M.wireframe===!0,O=n[b.id];O===void 0&&(O={},n[b.id]=O);let B=O[_.id];B===void 0&&(B={},O[_.id]=B);let D=B[I];return D===void 0&&(D=f(l()),B[I]=D),D}function f(b){let _=[],M=[],I=[];for(let O=0;O<t;O++)_[O]=0,M[O]=0,I[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:_,enabledAttributes:M,attributeDivisors:I,object:b,attributes:{},index:null}}function d(b,_,M,I){let O=r.attributes,B=_.attributes,D=0,X=M.getAttributes();for(let q in X)if(X[q].location>=0){let ae=O[q],ee=B[q];if(ee===void 0&&(q==="instanceMatrix"&&b.instanceMatrix&&(ee=b.instanceMatrix),q==="instanceColor"&&b.instanceColor&&(ee=b.instanceColor)),ae===void 0||ae.attribute!==ee||ee&&ae.data!==ee.data)return!0;D++}return r.attributesNum!==D||r.index!==I}function y(b,_,M,I){let O={},B=_.attributes,D=0,X=M.getAttributes();for(let q in X)if(X[q].location>=0){let ae=B[q];ae===void 0&&(q==="instanceMatrix"&&b.instanceMatrix&&(ae=b.instanceMatrix),q==="instanceColor"&&b.instanceColor&&(ae=b.instanceColor));let ee={};ee.attribute=ae,ae&&ae.data&&(ee.data=ae.data),O[q]=ee,D++}r.attributes=O,r.attributesNum=D,r.index=I}function v(){let b=r.newAttributes;for(let _=0,M=b.length;_<M;_++)b[_]=0}function p(b){m(b,0)}function m(b,_){let M=r.newAttributes,I=r.enabledAttributes,O=r.attributeDivisors;M[b]=1,I[b]===0&&(i.enableVertexAttribArray(b),I[b]=1),O[b]!==_&&(i.vertexAttribDivisor(b,_),O[b]=_)}function A(){let b=r.newAttributes,_=r.enabledAttributes;for(let M=0,I=_.length;M<I;M++)_[M]!==b[M]&&(i.disableVertexAttribArray(M),_[M]=0)}function x(b,_,M,I,O,B,D){D===!0?i.vertexAttribIPointer(b,_,M,O,B):i.vertexAttribPointer(b,_,M,I,O,B)}function S(b,_,M,I){v();let O=I.attributes,B=M.getAttributes(),D=_.defaultAttributeValues;for(let X in B){let q=B[X];if(q.location>=0){let Q=O[X];if(Q===void 0&&(X==="instanceMatrix"&&b.instanceMatrix&&(Q=b.instanceMatrix),X==="instanceColor"&&b.instanceColor&&(Q=b.instanceColor)),Q!==void 0){let ae=Q.normalized,ee=Q.itemSize,H=e.get(Q);if(H===void 0)continue;let be=H.buffer,Y=H.type,oe=H.bytesPerElement,he=Y===i.INT||Y===i.UNSIGNED_INT||Q.gpuType===Gg;if(Q.isInterleavedBufferAttribute){let ge=Q.data,He=ge.stride,Ue=Q.offset;if(ge.isInstancedInterleavedBuffer){for(let et=0;et<q.locationSize;et++)m(q.location+et,ge.meshPerAttribute);b.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let et=0;et<q.locationSize;et++)p(q.location+et);i.bindBuffer(i.ARRAY_BUFFER,be);for(let et=0;et<q.locationSize;et++)x(q.location+et,ee/q.locationSize,Y,ae,He*oe,(Ue+ee/q.locationSize*et)*oe,he)}else{if(Q.isInstancedBufferAttribute){for(let ge=0;ge<q.locationSize;ge++)m(q.location+ge,Q.meshPerAttribute);b.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ge=0;ge<q.locationSize;ge++)p(q.location+ge);i.bindBuffer(i.ARRAY_BUFFER,be);for(let ge=0;ge<q.locationSize;ge++)x(q.location+ge,ee/q.locationSize,Y,ae,ee*oe,ee/q.locationSize*ge*oe,he)}}else if(D!==void 0){let ae=D[X];if(ae!==void 0)switch(ae.length){case 2:i.vertexAttrib2fv(q.location,ae);break;case 3:i.vertexAttrib3fv(q.location,ae);break;case 4:i.vertexAttrib4fv(q.location,ae);break;default:i.vertexAttrib1fv(q.location,ae)}}}}A()}function N(){R();for(let b in n){let _=n[b];for(let M in _){let I=_[M];for(let O in I)h(I[O].object),delete I[O];delete _[M]}delete n[b]}}function P(b){if(n[b.id]===void 0)return;let _=n[b.id];for(let M in _){let I=_[M];for(let O in I)h(I[O].object),delete I[O];delete _[M]}delete n[b.id]}function C(b){for(let _ in n){let M=n[_];if(M[b.id]===void 0)continue;let I=M[b.id];for(let O in I)h(I[O].object),delete I[O];delete M[b.id]}}function R(){ne(),o=!0,r!==s&&(r=s,c(r.object))}function ne(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:R,resetDefaultState:ne,dispose:N,releaseStatesOfGeometry:P,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:p,disableUnusedAttributes:A}}function CI(i,e,t){let n;function s(c){n=c}function r(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function o(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),t.update(h,n,u))}function a(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let d=0;for(let y=0;y<u;y++)d+=h[y];t.update(d,n,1)}function l(c,h,u,f){if(u===0)return;let d=e.get("WEBGL_multi_draw");if(d===null)for(let y=0;y<c.length;y++)o(c[y],h[y],f[y]);else{d.multiDrawArraysInstancedWEBGL(n,c,0,h,0,f,0,u);let y=0;for(let v=0;v<u;v++)y+=h[v];for(let v=0;v<f.length;v++)t.update(y,n,f[v])}}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function LI(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let C=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(C){return!(C!==Tn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let R=C===Vc&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==bs&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Ni&&!R)}function l(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let u=t.logarithmicDepthBuffer===!0,f=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(f===!0){let C=e.get("EXT_clip_control");C.clipControlEXT(C.LOWER_LEFT_EXT,C.ZERO_TO_ONE_EXT)}let d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),x=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),N=y>0,P=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:y,maxTextureSize:v,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:A,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:N,maxSamples:P}}function PI(i){let e=this,t=null,n=0,s=!1,r=!1,o=new _s,a=new We,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){let d=u.length!==0||f||n!==0||s;return s=f,n=u.length,d},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){let y=u.clippingPlanes,v=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||y===null||y.length===0||r&&!p)r?h(null):c();else{let A=r?0:n,x=A*4,S=m.clippingState||null;l.value=S,S=h(y,f,x,d);for(let N=0;N!==x;++N)S[N]=t[N];m.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,y){let v=u!==null?u.length:0,p=null;if(v!==0){if(p=l.value,y!==!0||p===null){let m=d+v*4,A=f.matrixWorldInverse;a.getNormalMatrix(A),(p===null||p.length<m)&&(p=new Float32Array(m));for(let x=0,S=d;x!==v;++x,S+=4)o.copy(u[x]).applyMatrix4(A,a),o.normal.toArray(p,S),p[S+3]=o.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,p}}function NI(i){let e=new WeakMap;function t(o,a){return a===km?o.mapping=Ga:a===zm&&(o.mapping=Wa),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===km||a===zm)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new _g(l.height);return c.fromEquirectangularTexture(i,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){let a=o.target;a.removeEventListener("dispose",s);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}var $a=class extends fr{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Fa=4,Tx=[.125,.215,.35,.446,.526,.582],vo=20,vm=new $a,Ix=new Oe,xm=null,bm=0,Mm=0,Sm=!1,yo=(1+Math.sqrt(5))/2,Da=1/yo,Rx=[new k(-yo,Da,0),new k(yo,Da,0),new k(-Da,0,yo),new k(Da,0,yo),new k(0,yo,-Da),new k(0,yo,Da),new k(-1,1,-1),new k(1,1,-1),new k(-1,1,1),new k(1,1,1)],xf=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,s=100){xm=this._renderer.getRenderTarget(),bm=this._renderer.getActiveCubeFace(),Mm=this._renderer.getActiveMipmapLevel(),Sm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Px(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Lx(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(xm,bm,Mm),this._renderer.xr.enabled=Sm,e.scissorTest=!1,$u(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ga||e.mapping===Wa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xm=this._renderer.getRenderTarget(),bm=this._renderer.getActiveCubeFace(),Mm=this._renderer.getActiveMipmapLevel(),Sm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Wt,minFilter:Wt,generateMipmaps:!1,type:Vc,format:Tn,colorSpace:nn,depthBuffer:!1},s=Cx(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Cx(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=OI(r)),this._blurMaterial=DI(r,e,t)}return s}_compileMaterial(e){let t=new Ct(this._lodPlanes[0],e);this._renderer.compile(t,vm)}_sceneToCubeUV(e,t,n,s){let a=new Zt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Ix),h.toneMapping=lr,h.autoClear=!1;let d=new Rn({name:"PMREM.Background",side:In,depthWrite:!1,depthTest:!1}),y=new Ct(new wo,d),v=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,v=!0):(d.color.copy(Ix),v=!0);for(let m=0;m<6;m++){let A=m%3;A===0?(a.up.set(0,l[m],0),a.lookAt(c[m],0,0)):A===1?(a.up.set(0,0,l[m]),a.lookAt(0,c[m],0)):(a.up.set(0,l[m],0),a.lookAt(0,0,c[m]));let x=this._cubeSize;$u(s,A*x,m>2?x:0,x,x),h.setRenderTarget(s),v&&h.render(y,a),h.render(e,a)}y.geometry.dispose(),y.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===Ga||e.mapping===Wa;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Px()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Lx());let r=s?this._cubemapMaterial:this._equirectMaterial,o=new Ct(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;$u(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,vm)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodPlanes.length;for(let r=1;r<s;r++){let o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Rx[(s-r-1)%Rx.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new Ct(this._lodPlanes[s],c),f=c.uniforms,d=this._sizeLods[n]-1,y=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*vo-1),v=r/y,p=isFinite(r)?1+Math.floor(h*v):vo;p>vo&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${vo}`);let m=[],A=0;for(let C=0;C<vo;++C){let R=C/v,ne=Math.exp(-R*R/2);m.push(ne),C===0?A+=ne:C<p&&(A+=2*ne)}for(let C=0;C<m.length;C++)m[C]=m[C]/A;f.envMap.value=e.texture,f.samples.value=p,f.weights.value=m,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:x}=this;f.dTheta.value=y,f.mipInt.value=x-n;let S=this._sizeLods[s],N=3*S*(s>x-Fa?s-x+Fa:0),P=4*(this._cubeSize-S);$u(t,N,P,3*S,2*S),l.setRenderTarget(t),l.render(u,vm)}};function OI(i){let e=[],t=[],n=[],s=i,r=i-Fa+1+Tx.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);t.push(a);let l=1/a;o>i-Fa?l=Tx[o-i+Fa-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),h=-c,u=1+c,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,y=6,v=3,p=2,m=1,A=new Float32Array(v*y*d),x=new Float32Array(p*y*d),S=new Float32Array(m*y*d);for(let P=0;P<d;P++){let C=P%3*2/3-1,R=P>2?0:-1,ne=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];A.set(ne,v*y*P),x.set(f,p*y*P);let b=[P,P,P,P,P,P];S.set(b,m*y*P)}let N=new Cn;N.setAttribute("position",new vt(A,v)),N.setAttribute("uv",new vt(x,p)),N.setAttribute("faceIndex",new vt(S,m)),e.push(N),s>Fa&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Cx(i,e,t){let n=new Ms(i,e,t);return n.texture.mapping=kf,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function $u(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function DI(i,e,t){let n=new Float32Array(vo),s=new k(0,1,0);return new pi({name:"SphericalGaussianBlur",defines:{n:vo,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Jg(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:ar,depthTest:!1,depthWrite:!1})}function Lx(){return new pi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Jg(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:ar,depthTest:!1,depthWrite:!1})}function Px(){return new pi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Jg(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:ar,depthTest:!1,depthWrite:!1})}function Jg(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function UI(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===km||l===zm,h=l===Ga||l===Wa;if(c||h){let u=e.get(a),f=u!==void 0?u.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return t===null&&(t=new xf(i)),u=c?t.fromEquirectangular(a,u):t.fromCubemap(a,u),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),u.texture;if(u!==void 0)return u.texture;{let d=a.image;return c&&d&&d.height>0||h&&d&&s(d)?(t===null&&(t=new xf(i)),u=c?t.fromEquirectangular(a):t.fromCubemap(a),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),a.addEventListener("dispose",r),u.texture):null}}}return a}function s(a){let l=0,c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function r(a){let l=a.target;l.removeEventListener("dispose",r);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function FI(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&uf("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function BI(i,e,t,n){let s={},r=new WeakMap;function o(u){let f=u.target;f.index!==null&&e.remove(f.index);for(let y in f.attributes)e.remove(f.attributes[y]);for(let y in f.morphAttributes){let v=f.morphAttributes[y];for(let p=0,m=v.length;p<m;p++)e.remove(v[p])}f.removeEventListener("dispose",o),delete s[f.id];let d=r.get(f);d&&(e.remove(d),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(u,f){return s[f.id]===!0||(f.addEventListener("dispose",o),s[f.id]=!0,t.memory.geometries++),f}function l(u){let f=u.attributes;for(let y in f)e.update(f[y],i.ARRAY_BUFFER);let d=u.morphAttributes;for(let y in d){let v=d[y];for(let p=0,m=v.length;p<m;p++)e.update(v[p],i.ARRAY_BUFFER)}}function c(u){let f=[],d=u.index,y=u.attributes.position,v=0;if(d!==null){let A=d.array;v=d.version;for(let x=0,S=A.length;x<S;x+=3){let N=A[x+0],P=A[x+1],C=A[x+2];f.push(N,P,P,C,C,N)}}else if(y!==void 0){let A=y.array;v=y.version;for(let x=0,S=A.length/3-1;x<S;x+=3){let N=x+0,P=x+1,C=x+2;f.push(N,P,P,C,C,N)}}else return;let p=new(Lb(f)?_f:yf)(f,1);p.version=v;let m=r.get(u);m&&e.remove(m),r.set(u,p)}function h(u){let f=r.get(u);if(f){let d=u.index;d!==null&&f.version<d.version&&c(u)}else c(u);return r.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function kI(i,e,t){let n;function s(f){n=f}let r,o;function a(f){r=f.type,o=f.bytesPerElement}function l(f,d){i.drawElements(n,d,r,f*o),t.update(d,n,1)}function c(f,d,y){y!==0&&(i.drawElementsInstanced(n,d,r,f*o,y),t.update(d,n,y))}function h(f,d,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,f,0,y);let p=0;for(let m=0;m<y;m++)p+=d[m];t.update(p,n,1)}function u(f,d,y,v){if(y===0)return;let p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<f.length;m++)c(f[m]/o,d[m],v[m]);else{p.multiDrawElementsInstancedWEBGL(n,d,0,r,f,0,v,0,y);let m=0;for(let A=0;A<y;A++)m+=d[A];for(let A=0;A<v.length;A++)t.update(m,n,v[A])}}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function zI(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function VI(i,e,t){let n=new WeakMap,s=new st;function r(o,a,l){let c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,f=n.get(a);if(f===void 0||f.count!==u){let ne=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",ne)};f!==void 0&&f.texture.dispose();let d=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,v=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],A=a.morphAttributes.color||[],x=0;d===!0&&(x=1),y===!0&&(x=2),v===!0&&(x=3);let S=a.attributes.position.count*x,N=1;S>e.maxTextureSize&&(N=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let P=new Float32Array(S*N*4*u),C=new gf(P,S,N,u);C.type=Ni,C.needsUpdate=!0;let R=x*4;for(let b=0;b<u;b++){let _=p[b],M=m[b],I=A[b],O=S*N*4*b;for(let B=0;B<_.count;B++){let D=B*R;d===!0&&(s.fromBufferAttribute(_,B),P[O+D+0]=s.x,P[O+D+1]=s.y,P[O+D+2]=s.z,P[O+D+3]=0),y===!0&&(s.fromBufferAttribute(M,B),P[O+D+4]=s.x,P[O+D+5]=s.y,P[O+D+6]=s.z,P[O+D+7]=0),v===!0&&(s.fromBufferAttribute(I,B),P[O+D+8]=s.x,P[O+D+9]=s.y,P[O+D+10]=s.z,P[O+D+11]=I.itemSize===4?s.w:1)}}f={count:u,texture:C,size:new Ye(S,N)},n.set(a,f),a.addEventListener("dispose",ne)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let d=0;for(let v=0;v<c.length;v++)d+=c[v];let y=a.morphTargetsRelative?1:1-d;l.getUniforms().setValue(i,"morphTargetBaseInfluence",y),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:r}}function HI(i,e,t,n){let s=new WeakMap;function r(l){let c=n.render.frame,h=l.geometry,u=e.get(l,h);if(s.get(u)!==c&&(e.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),s.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){let f=l.skeleton;s.get(f)!==c&&(f.update(),s.set(f,c))}return u}function o(){s=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}var bf=class extends Et{constructor(e,t,n,s,r,o,a,l,c,h=ka){if(h!==ka&&h!==qa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===ka&&(n=Mo),n===void 0&&h===qa&&(n=Xa),super(null,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:tn,this.minFilter=l!==void 0?l:tn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Db=new Et,Nx=new bf(1,1),Ub=new gf,Fb=new gg,Bb=new vf,Ox=[],Dx=[],Ux=new Float32Array(16),Fx=new Float32Array(9),Bx=new Float32Array(4);function sl(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Ox[s];if(r===void 0&&(r=new Float32Array(s),Ox[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function $t(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function jt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Hf(i,e){let t=Dx[e];t===void 0&&(t=new Int32Array(e),Dx[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function GI(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function WI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;i.uniform2fv(this.addr,e),jt(t,e)}}function XI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if($t(t,e))return;i.uniform3fv(this.addr,e),jt(t,e)}}function qI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;i.uniform4fv(this.addr,e),jt(t,e)}}function YI(i,e){let t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),jt(t,e)}else{if($t(t,n))return;Bx.set(n),i.uniformMatrix2fv(this.addr,!1,Bx),jt(t,n)}}function KI(i,e){let t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),jt(t,e)}else{if($t(t,n))return;Fx.set(n),i.uniformMatrix3fv(this.addr,!1,Fx),jt(t,n)}}function ZI(i,e){let t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),jt(t,e)}else{if($t(t,n))return;Ux.set(n),i.uniformMatrix4fv(this.addr,!1,Ux),jt(t,n)}}function $I(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function jI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;i.uniform2iv(this.addr,e),jt(t,e)}}function JI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if($t(t,e))return;i.uniform3iv(this.addr,e),jt(t,e)}}function QI(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;i.uniform4iv(this.addr,e),jt(t,e)}}function eR(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function tR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;i.uniform2uiv(this.addr,e),jt(t,e)}}function nR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if($t(t,e))return;i.uniform3uiv(this.addr,e),jt(t,e)}}function iR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;i.uniform4uiv(this.addr,e),jt(t,e)}}function sR(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Nx.compareFunction=Cb,r=Nx):r=Db,t.setTexture2D(e||r,s)}function rR(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Fb,s)}function oR(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||Bb,s)}function aR(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||Ub,s)}function lR(i){switch(i){case 5126:return GI;case 35664:return WI;case 35665:return XI;case 35666:return qI;case 35674:return YI;case 35675:return KI;case 35676:return ZI;case 5124:case 35670:return $I;case 35667:case 35671:return jI;case 35668:case 35672:return JI;case 35669:case 35673:return QI;case 5125:return eR;case 36294:return tR;case 36295:return nR;case 36296:return iR;case 35678:case 36198:case 36298:case 36306:case 35682:return sR;case 35679:case 36299:case 36307:return rR;case 35680:case 36300:case 36308:case 36293:return oR;case 36289:case 36303:case 36311:case 36292:return aR}}function cR(i,e){i.uniform1fv(this.addr,e)}function hR(i,e){let t=sl(e,this.size,2);i.uniform2fv(this.addr,t)}function uR(i,e){let t=sl(e,this.size,3);i.uniform3fv(this.addr,t)}function fR(i,e){let t=sl(e,this.size,4);i.uniform4fv(this.addr,t)}function dR(i,e){let t=sl(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function pR(i,e){let t=sl(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function mR(i,e){let t=sl(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function gR(i,e){i.uniform1iv(this.addr,e)}function yR(i,e){i.uniform2iv(this.addr,e)}function _R(i,e){i.uniform3iv(this.addr,e)}function vR(i,e){i.uniform4iv(this.addr,e)}function xR(i,e){i.uniform1uiv(this.addr,e)}function bR(i,e){i.uniform2uiv(this.addr,e)}function MR(i,e){i.uniform3uiv(this.addr,e)}function SR(i,e){i.uniform4uiv(this.addr,e)}function wR(i,e,t){let n=this.cache,s=e.length,r=Hf(t,s);$t(n,r)||(i.uniform1iv(this.addr,r),jt(n,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||Db,r[o])}function AR(i,e,t){let n=this.cache,s=e.length,r=Hf(t,s);$t(n,r)||(i.uniform1iv(this.addr,r),jt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||Fb,r[o])}function ER(i,e,t){let n=this.cache,s=e.length,r=Hf(t,s);$t(n,r)||(i.uniform1iv(this.addr,r),jt(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||Bb,r[o])}function TR(i,e,t){let n=this.cache,s=e.length,r=Hf(t,s);$t(n,r)||(i.uniform1iv(this.addr,r),jt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||Ub,r[o])}function IR(i){switch(i){case 5126:return cR;case 35664:return hR;case 35665:return uR;case 35666:return fR;case 35674:return dR;case 35675:return pR;case 35676:return mR;case 5124:case 35670:return gR;case 35667:case 35671:return yR;case 35668:case 35672:return _R;case 35669:case 35673:return vR;case 5125:return xR;case 36294:return bR;case 36295:return MR;case 36296:return SR;case 35678:case 36198:case 36298:case 36306:case 35682:return wR;case 35679:case 36299:case 36307:return AR;case 35680:case 36300:case 36308:case 36293:return ER;case 36289:case 36303:case 36311:case 36292:return TR}}var vg=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=lR(t.type)}},xg=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=IR(t.type)}},bg=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},wm=/(\w+)(\])?(\[|\.)?/g;function kx(i,e){i.seq.push(e),i.map[e.id]=e}function RR(i,e,t){let n=i.name,s=n.length;for(wm.lastIndex=0;;){let r=wm.exec(n),o=wm.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){kx(t,c===void 0?new vg(a,i,e):new xg(a,i,e));break}else{let u=t.map[a];u===void 0&&(u=new bg(a),kx(t,u)),t=u}}}var Va=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);RR(r,o,this)}}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function zx(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var CR=37297,LR=0;function PR(i,e){let t=i.split(`
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
`)}function NR(i){let e=it.getPrimaries(it.workingColorSpace),t=it.getPrimaries(i),n;switch(e===t?n="":e===pf&&t===df?n="LinearDisplayP3ToLinearSRGB":e===df&&t===pf&&(n="LinearSRGBToLinearDisplayP3"),i){case nn:case Vf:return[n,"LinearTransferOETF"];case Gt:case $g:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function Vx(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=i.getShaderInfoLog(e).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\d+)/.exec(s);if(r){let o=parseInt(r[1]);return t.toUpperCase()+`

`+s+`

`+PR(i.getShaderSource(e),o)}else return s}function OR(i,e){let t=NR(e);return`vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function DR(i,e){let t;switch(e){case GA:t="Linear";break;case WA:t="Reinhard";break;case XA:t="Cineon";break;case qA:t="ACESFilmic";break;case KA:t="AgX";break;case ZA:t="Neutral";break;case YA:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var ju=new k;function UR(){it.getLuminanceCoefficients(ju);let i=ju.x.toFixed(4),e=ju.y.toFixed(4),t=ju.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${i}, ${e}, ${t} );`,"	return dot( weights, rgb );","}"].join(`
`)}function FR(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ac).join(`
`)}function BR(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function kR(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function Ac(i){return i!==""}function Hx(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Gx(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var zR=/^[ \t]*#include +<([\w\d./]+)>/gm;function Mg(i){return i.replace(zR,HR)}var VR=new Map;function HR(i,e){let t=Xe[e];if(t===void 0){let n=VR.get(e);if(n!==void 0)t=Xe[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Mg(t)}var GR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Wx(i){return i.replace(GR,WR)}function WR(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Xx(i){let e=`precision ${i.precision} float;
	precision ${i.precision} int;
	precision ${i.precision} sampler2D;
	precision ${i.precision} samplerCube;
	precision ${i.precision} sampler3D;
	precision ${i.precision} sampler2DArray;
	precision ${i.precision} sampler2DShadow;
	precision ${i.precision} samplerCubeShadow;
	precision ${i.precision} sampler2DArrayShadow;
	precision ${i.precision} isampler2D;
	precision ${i.precision} isampler3D;
	precision ${i.precision} isamplerCube;
	precision ${i.precision} isampler2DArray;
	precision ${i.precision} usampler2D;
	precision ${i.precision} usampler3D;
	precision ${i.precision} usamplerCube;
	precision ${i.precision} usampler2DArray;
	`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function XR(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===gb?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===MA?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===ys&&(e="SHADOWMAP_TYPE_VSM"),e}function qR(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ga:case Wa:e="ENVMAP_TYPE_CUBE";break;case kf:e="ENVMAP_TYPE_CUBE_UV";break}return e}function YR(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Wa:e="ENVMAP_MODE_REFRACTION";break}return e}function KR(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case yb:e="ENVMAP_BLENDING_MULTIPLY";break;case VA:e="ENVMAP_BLENDING_MIX";break;case HA:e="ENVMAP_BLENDING_ADD";break}return e}function ZR(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function $R(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=XR(t),c=qR(t),h=YR(t),u=KR(t),f=ZR(t),d=FR(t),y=BR(r),v=s.createProgram(),p,m,A=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Ac).join(`
`),p.length>0&&(p+=`
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Ac).join(`
`),m.length>0&&(m+=`
`)):(p=[Xx(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","	uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","	attribute vec2 uv1;","#endif","#ifdef USE_UV2","	attribute vec2 uv2;","#endif","#ifdef USE_UV3","	attribute vec2 uv3;","#endif","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(Ac).join(`
`),m=[Xx(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==lr?"#define TONE_MAPPING":"",t.toneMapping!==lr?Xe.tonemapping_pars_fragment:"",t.toneMapping!==lr?DR("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Xe.colorspace_pars_fragment,OR("linearToOutputTexel",t.outputColorSpace),UR(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Ac).join(`
`)),o=Mg(o),o=Hx(o,t),o=Gx(o,t),a=Mg(a),a=Hx(a,t),a=Gx(a,t),o=Wx(o),a=Wx(a),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
`,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+p,m=["#define varying in",t.glslVersion===lx?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===lx?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+m);let x=A+p+o,S=A+m+a,N=zx(s,s.VERTEX_SHADER,x),P=zx(s,s.FRAGMENT_SHADER,S);s.attachShader(v,N),s.attachShader(v,P),t.index0AttributeName!==void 0?s.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v);function C(_){if(i.debug.checkShaderErrors){let M=s.getProgramInfoLog(v).trim(),I=s.getShaderInfoLog(N).trim(),O=s.getShaderInfoLog(P).trim(),B=!0,D=!0;if(s.getProgramParameter(v,s.LINK_STATUS)===!1)if(B=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,v,N,P);else{let X=Vx(s,N,"vertex"),q=Vx(s,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+`

Material Name: `+_.name+`
Material Type: `+_.type+`

Program Info Log: `+M+`
`+X+`
`+q)}else M!==""?console.warn("THREE.WebGLProgram: Program Info Log:",M):(I===""||O==="")&&(D=!1);D&&(_.diagnostics={runnable:B,programLog:M,vertexShader:{log:I,prefix:p},fragmentShader:{log:O,prefix:m}})}s.deleteShader(N),s.deleteShader(P),R=new Va(s,v),ne=kR(s,v)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let ne;this.getAttributes=function(){return ne===void 0&&C(this),ne};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=s.getProgramParameter(v,CR)),b},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=LR++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=N,this.fragmentShader=P,this}var jR=0,Sg=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new wg(e),t.set(e,n)),n}},wg=class{constructor(e){this.id=jR++,this.code=e,this.usedTimes=0}};function JR(i,e,t,n,s,r,o){let a=new Lc,l=new Sg,c=new Set,h=[],u=s.logarithmicDepthBuffer,f=s.reverseDepthBuffer,d=s.vertexTextures,y=s.precision,v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(b){return c.add(b),b===0?"uv":`uv${b}`}function m(b,_,M,I,O){let B=I.fog,D=O.geometry,X=b.isMeshStandardMaterial?I.environment:null,q=(b.isMeshStandardMaterial?t:e).get(b.envMap||X),Q=!!q&&q.mapping===kf?q.image.height:null,ae=v[b.type];b.precision!==null&&(y=s.getMaxPrecision(b.precision),y!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",y,"instead."));let ee=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,H=ee!==void 0?ee.length:0,be=0;D.morphAttributes.position!==void 0&&(be=1),D.morphAttributes.normal!==void 0&&(be=2),D.morphAttributes.color!==void 0&&(be=3);let Y,oe,he,ge;if(ae){let wn=qi[ae];Y=wn.vertexShader,oe=wn.fragmentShader}else Y=b.vertexShader,oe=b.fragmentShader,l.update(b),he=l.getVertexShaderID(b),ge=l.getFragmentShaderID(b);let He=i.getRenderTarget(),Ue=O.isInstancedMesh===!0,et=O.isBatchedMesh===!0,mt=!!b.map,tt=!!b.matcap,F=!!q,Ln=!!b.aoMap,Je=!!b.lightMap,rt=!!b.bumpMap,Be=!!b.normalMap,Mt=!!b.displacementMap,Ve=!!b.emissiveMap,L=!!b.metalnessMap,w=!!b.roughnessMap,K=b.anisotropy>0,se=b.clearcoat>0,le=b.dispersion>0,ie=b.iridescence>0,Re=b.sheen>0,me=b.transmission>0,Me=K&&!!b.anisotropyMap,ot=se&&!!b.clearcoatMap,ue=se&&!!b.clearcoatNormalMap,Se=se&&!!b.clearcoatRoughnessMap,ke=ie&&!!b.iridescenceMap,ze=ie&&!!b.iridescenceThicknessMap,we=Re&&!!b.sheenColorMap,Qe=Re&&!!b.sheenRoughnessMap,Ge=!!b.specularMap,xt=!!b.specularColorMap,z=!!b.specularIntensityMap,ve=me&&!!b.transmissionMap,J=me&&!!b.thicknessMap,re=!!b.gradientMap,ye=!!b.alphaMap,xe=b.alphaTest>0,nt=!!b.alphaHash,Ft=!!b.extensions,Sn=lr;b.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&(Sn=i.toneMapping);let at={shaderID:ae,shaderType:b.type,shaderName:b.name,vertexShader:Y,fragmentShader:oe,defines:b.defines,customVertexShaderID:he,customFragmentShaderID:ge,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:y,batching:et,batchingColor:et&&O._colorsTexture!==null,instancing:Ue,instancingColor:Ue&&O.instanceColor!==null,instancingMorph:Ue&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:He===null?i.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:nn,alphaToCoverage:!!b.alphaToCoverage,map:mt,matcap:tt,envMap:F,envMapMode:F&&q.mapping,envMapCubeUVHeight:Q,aoMap:Ln,lightMap:Je,bumpMap:rt,normalMap:Be,displacementMap:d&&Mt,emissiveMap:Ve,normalMapObjectSpace:Be&&b.normalMapType===e1,normalMapTangentSpace:Be&&b.normalMapType===Rb,metalnessMap:L,roughnessMap:w,anisotropy:K,anisotropyMap:Me,clearcoat:se,clearcoatMap:ot,clearcoatNormalMap:ue,clearcoatRoughnessMap:Se,dispersion:le,iridescence:ie,iridescenceMap:ke,iridescenceThicknessMap:ze,sheen:Re,sheenColorMap:we,sheenRoughnessMap:Qe,specularMap:Ge,specularColorMap:xt,specularIntensityMap:z,transmission:me,transmissionMap:ve,thicknessMap:J,gradientMap:re,opaque:b.transparent===!1&&b.blending===Ba&&b.alphaToCoverage===!1,alphaMap:ye,alphaTest:xe,alphaHash:nt,combine:b.combine,mapUv:mt&&p(b.map.channel),aoMapUv:Ln&&p(b.aoMap.channel),lightMapUv:Je&&p(b.lightMap.channel),bumpMapUv:rt&&p(b.bumpMap.channel),normalMapUv:Be&&p(b.normalMap.channel),displacementMapUv:Mt&&p(b.displacementMap.channel),emissiveMapUv:Ve&&p(b.emissiveMap.channel),metalnessMapUv:L&&p(b.metalnessMap.channel),roughnessMapUv:w&&p(b.roughnessMap.channel),anisotropyMapUv:Me&&p(b.anisotropyMap.channel),clearcoatMapUv:ot&&p(b.clearcoatMap.channel),clearcoatNormalMapUv:ue&&p(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Se&&p(b.clearcoatRoughnessMap.channel),iridescenceMapUv:ke&&p(b.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&p(b.iridescenceThicknessMap.channel),sheenColorMapUv:we&&p(b.sheenColorMap.channel),sheenRoughnessMapUv:Qe&&p(b.sheenRoughnessMap.channel),specularMapUv:Ge&&p(b.specularMap.channel),specularColorMapUv:xt&&p(b.specularColorMap.channel),specularIntensityMapUv:z&&p(b.specularIntensityMap.channel),transmissionMapUv:ve&&p(b.transmissionMap.channel),thicknessMapUv:J&&p(b.thicknessMap.channel),alphaMapUv:ye&&p(b.alphaMap.channel),vertexTangents:!!D.attributes.tangent&&(Be||K),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!D.attributes.uv&&(mt||ye),fog:!!B,useFog:b.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:f,skinning:O.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:be,numDirLights:_.directional.length,numPointLights:_.point.length,numSpotLights:_.spot.length,numSpotLightMaps:_.spotLightMap.length,numRectAreaLights:_.rectArea.length,numHemiLights:_.hemi.length,numDirLightShadows:_.directionalShadowMap.length,numPointLightShadows:_.pointShadowMap.length,numSpotLightShadows:_.spotShadowMap.length,numSpotLightShadowsWithMaps:_.numSpotLightShadowsWithMaps,numLightProbes:_.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:i.shadowMap.enabled&&M.length>0,shadowMapType:i.shadowMap.type,toneMapping:Sn,decodeVideoTexture:mt&&b.map.isVideoTexture===!0&&it.getTransfer(b.map.colorSpace)===At,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Yn,flipSided:b.side===In,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Ft&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ft&&b.extensions.multiDraw===!0||et)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return at.vertexUv1s=c.has(1),at.vertexUv2s=c.has(2),at.vertexUv3s=c.has(3),c.clear(),at}function A(b){let _=[];if(b.shaderID?_.push(b.shaderID):(_.push(b.customVertexShaderID),_.push(b.customFragmentShaderID)),b.defines!==void 0)for(let M in b.defines)_.push(M),_.push(b.defines[M]);return b.isRawShaderMaterial===!1&&(x(_,b),S(_,b),_.push(i.outputColorSpace)),_.push(b.customProgramCacheKey),_.join()}function x(b,_){b.push(_.precision),b.push(_.outputColorSpace),b.push(_.envMapMode),b.push(_.envMapCubeUVHeight),b.push(_.mapUv),b.push(_.alphaMapUv),b.push(_.lightMapUv),b.push(_.aoMapUv),b.push(_.bumpMapUv),b.push(_.normalMapUv),b.push(_.displacementMapUv),b.push(_.emissiveMapUv),b.push(_.metalnessMapUv),b.push(_.roughnessMapUv),b.push(_.anisotropyMapUv),b.push(_.clearcoatMapUv),b.push(_.clearcoatNormalMapUv),b.push(_.clearcoatRoughnessMapUv),b.push(_.iridescenceMapUv),b.push(_.iridescenceThicknessMapUv),b.push(_.sheenColorMapUv),b.push(_.sheenRoughnessMapUv),b.push(_.specularMapUv),b.push(_.specularColorMapUv),b.push(_.specularIntensityMapUv),b.push(_.transmissionMapUv),b.push(_.thicknessMapUv),b.push(_.combine),b.push(_.fogExp2),b.push(_.sizeAttenuation),b.push(_.morphTargetsCount),b.push(_.morphAttributeCount),b.push(_.numDirLights),b.push(_.numPointLights),b.push(_.numSpotLights),b.push(_.numSpotLightMaps),b.push(_.numHemiLights),b.push(_.numRectAreaLights),b.push(_.numDirLightShadows),b.push(_.numPointLightShadows),b.push(_.numSpotLightShadows),b.push(_.numSpotLightShadowsWithMaps),b.push(_.numLightProbes),b.push(_.shadowMapType),b.push(_.toneMapping),b.push(_.numClippingPlanes),b.push(_.numClipIntersection),b.push(_.depthPacking)}function S(b,_){a.disableAll(),_.supportsVertexTextures&&a.enable(0),_.instancing&&a.enable(1),_.instancingColor&&a.enable(2),_.instancingMorph&&a.enable(3),_.matcap&&a.enable(4),_.envMap&&a.enable(5),_.normalMapObjectSpace&&a.enable(6),_.normalMapTangentSpace&&a.enable(7),_.clearcoat&&a.enable(8),_.iridescence&&a.enable(9),_.alphaTest&&a.enable(10),_.vertexColors&&a.enable(11),_.vertexAlphas&&a.enable(12),_.vertexUv1s&&a.enable(13),_.vertexUv2s&&a.enable(14),_.vertexUv3s&&a.enable(15),_.vertexTangents&&a.enable(16),_.anisotropy&&a.enable(17),_.alphaHash&&a.enable(18),_.batching&&a.enable(19),_.dispersion&&a.enable(20),_.batchingColor&&a.enable(21),b.push(a.mask),a.disableAll(),_.fog&&a.enable(0),_.useFog&&a.enable(1),_.flatShading&&a.enable(2),_.logarithmicDepthBuffer&&a.enable(3),_.reverseDepthBuffer&&a.enable(4),_.skinning&&a.enable(5),_.morphTargets&&a.enable(6),_.morphNormals&&a.enable(7),_.morphColors&&a.enable(8),_.premultipliedAlpha&&a.enable(9),_.shadowMapEnabled&&a.enable(10),_.doubleSided&&a.enable(11),_.flipSided&&a.enable(12),_.useDepthPacking&&a.enable(13),_.dithering&&a.enable(14),_.transmission&&a.enable(15),_.sheen&&a.enable(16),_.opaque&&a.enable(17),_.pointsUvs&&a.enable(18),_.decodeVideoTexture&&a.enable(19),_.alphaToCoverage&&a.enable(20),b.push(a.mask)}function N(b){let _=v[b.type],M;if(_){let I=qi[_];M=H1.clone(I.uniforms)}else M=b.uniforms;return M}function P(b,_){let M;for(let I=0,O=h.length;I<O;I++){let B=h[I];if(B.cacheKey===_){M=B,++M.usedTimes;break}}return M===void 0&&(M=new $R(i,_,b,r),h.push(M)),M}function C(b){if(--b.usedTimes===0){let _=h.indexOf(b);h[_]=h[h.length-1],h.pop(),b.destroy()}}function R(b){l.remove(b)}function ne(){l.dispose()}return{getParameters:m,getProgramCacheKey:A,getUniforms:N,acquireProgram:P,releaseProgram:C,releaseShaderCache:R,programs:h,dispose:ne}}function QR(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function eC(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function qx(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Yx(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u,f,d,y,v,p){let m=i[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:y,renderOrder:u.renderOrder,z:v,group:p},i[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=y,m.renderOrder=u.renderOrder,m.z=v,m.group=p),e++,m}function a(u,f,d,y,v,p){let m=o(u,f,d,y,v,p);d.transmission>0?n.push(m):d.transparent===!0?s.push(m):t.push(m)}function l(u,f,d,y,v,p){let m=o(u,f,d,y,v,p);d.transmission>0?n.unshift(m):d.transparent===!0?s.unshift(m):t.unshift(m)}function c(u,f){t.length>1&&t.sort(u||eC),n.length>1&&n.sort(f||qx),s.length>1&&s.sort(f||qx)}function h(){for(let u=e,f=i.length;u<f;u++){let d=i[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:a,unshift:l,finish:h,sort:c}}function tC(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new Yx,i.set(n,[o])):s>=r.length?(o=new Yx,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function nC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new k,color:new Oe};break;case"SpotLight":t={position:new k,direction:new k,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new k,halfWidth:new k,halfHeight:new k};break}return i[e.id]=t,t}}}function iC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var sC=0;function rC(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function oC(i){let e=new nC,t=iC(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new k);let s=new k,r=new Pe,o=new Pe;function a(c){let h=0,u=0,f=0;for(let ne=0;ne<9;ne++)n.probe[ne].set(0,0,0);let d=0,y=0,v=0,p=0,m=0,A=0,x=0,S=0,N=0,P=0,C=0;c.sort(rC);for(let ne=0,b=c.length;ne<b;ne++){let _=c[ne],M=_.color,I=_.intensity,O=_.distance,B=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)h+=M.r*I,u+=M.g*I,f+=M.b*I;else if(_.isLightProbe){for(let D=0;D<9;D++)n.probe[D].addScaledVector(_.sh.coefficients[D],I);C++}else if(_.isDirectionalLight){let D=e.get(_);if(D.color.copy(_.color).multiplyScalar(_.intensity),_.castShadow){let X=_.shadow,q=t.get(_);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,n.directionalShadow[d]=q,n.directionalShadowMap[d]=B,n.directionalShadowMatrix[d]=_.shadow.matrix,A++}n.directional[d]=D,d++}else if(_.isSpotLight){let D=e.get(_);D.position.setFromMatrixPosition(_.matrixWorld),D.color.copy(M).multiplyScalar(I),D.distance=O,D.coneCos=Math.cos(_.angle),D.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),D.decay=_.decay,n.spot[v]=D;let X=_.shadow;if(_.map&&(n.spotLightMap[N]=_.map,N++,X.updateMatrices(_),_.castShadow&&P++),n.spotLightMatrix[v]=X.matrix,_.castShadow){let q=t.get(_);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,n.spotShadow[v]=q,n.spotShadowMap[v]=B,S++}v++}else if(_.isRectAreaLight){let D=e.get(_);D.color.copy(M).multiplyScalar(I),D.halfWidth.set(_.width*.5,0,0),D.halfHeight.set(0,_.height*.5,0),n.rectArea[p]=D,p++}else if(_.isPointLight){let D=e.get(_);if(D.color.copy(_.color).multiplyScalar(_.intensity),D.distance=_.distance,D.decay=_.decay,_.castShadow){let X=_.shadow,q=t.get(_);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,q.shadowCameraNear=X.camera.near,q.shadowCameraFar=X.camera.far,n.pointShadow[y]=q,n.pointShadowMap[y]=B,n.pointShadowMatrix[y]=_.shadow.matrix,x++}n.point[y]=D,y++}else if(_.isHemisphereLight){let D=e.get(_);D.skyColor.copy(_.color).multiplyScalar(I),D.groundColor.copy(_.groundColor).multiplyScalar(I),n.hemi[m]=D,m++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=f;let R=n.hash;(R.directionalLength!==d||R.pointLength!==y||R.spotLength!==v||R.rectAreaLength!==p||R.hemiLength!==m||R.numDirectionalShadows!==A||R.numPointShadows!==x||R.numSpotShadows!==S||R.numSpotMaps!==N||R.numLightProbes!==C)&&(n.directional.length=d,n.spot.length=v,n.rectArea.length=p,n.point.length=y,n.hemi.length=m,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=S+N-P,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=C,R.directionalLength=d,R.pointLength=y,R.spotLength=v,R.rectAreaLength=p,R.hemiLength=m,R.numDirectionalShadows=A,R.numPointShadows=x,R.numSpotShadows=S,R.numSpotMaps=N,R.numLightProbes=C,n.version=sC++)}function l(c,h){let u=0,f=0,d=0,y=0,v=0,p=h.matrixWorldInverse;for(let m=0,A=c.length;m<A;m++){let x=c[m];if(x.isDirectionalLight){let S=n.directional[u];S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),u++}else if(x.isSpotLight){let S=n.spot[d];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),d++}else if(x.isRectAreaLight){let S=n.rectArea[y];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),o.identity(),r.copy(x.matrixWorld),r.premultiply(p),o.extractRotation(r),S.halfWidth.set(x.width*.5,0,0),S.halfHeight.set(0,x.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),y++}else if(x.isPointLight){let S=n.point[f];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),f++}else if(x.isHemisphereLight){let S=n.hemi[v];S.direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(p),v++}}}return{setup:a,setupView:l,state:n}}function Kx(i){let e=new oC(i),t=[],n=[];function s(h){c.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function o(h){n.push(h)}function a(){e.setup(t)}function l(h){e.setupView(t,h)}let c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function aC(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new Kx(i),e.set(s,[a])):r>=o.length?(a=new Kx(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var Ag=class extends jn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=JA,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Eg=class extends jn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},lC=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,cC=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function hC(i,e,t){let n=new Pc,s=new Ye,r=new Ye,o=new st,a=new Ag({depthPacking:QA}),l=new Eg,c={},h=t.maxTextureSize,u={[Zi]:In,[In]:Zi,[Yn]:Yn},f=new pi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ye},radius:{value:4}},vertexShader:lC,fragmentShader:cC}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let y=new Cn;y.setAttribute("position",new vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Ct(y,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gb;let m=this.type;this.render=function(P,C,R){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||P.length===0)return;let ne=i.getRenderTarget(),b=i.getActiveCubeFace(),_=i.getActiveMipmapLevel(),M=i.state;M.setBlending(ar),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);let I=m!==ys&&this.type===ys,O=m===ys&&this.type!==ys;for(let B=0,D=P.length;B<D;B++){let X=P[B],q=X.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",X,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;s.copy(q.mapSize);let Q=q.getFrameExtents();if(s.multiply(Q),r.copy(q.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/Q.x),s.x=r.x*Q.x,q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/Q.y),s.y=r.y*Q.y,q.mapSize.y=r.y)),q.map===null||I===!0||O===!0){let ee=this.type!==ys?{minFilter:tn,magFilter:tn}:{};q.map!==null&&q.map.dispose(),q.map=new Ms(s.x,s.y,ee),q.map.texture.name=X.name+".shadowMap",q.camera.updateProjectionMatrix()}i.setRenderTarget(q.map),i.clear();let ae=q.getViewportCount();for(let ee=0;ee<ae;ee++){let H=q.getViewport(ee);o.set(r.x*H.x,r.y*H.y,r.x*H.z,r.y*H.w),M.viewport(o),q.updateMatrices(X,ee),n=q.getFrustum(),S(C,R,q.camera,X,this.type)}q.isPointLightShadow!==!0&&this.type===ys&&A(q,R),q.needsUpdate=!1}m=this.type,p.needsUpdate=!1,i.setRenderTarget(ne,b,_)};function A(P,C){let R=e.update(v);f.defines.VSM_SAMPLES!==P.blurSamples&&(f.defines.VSM_SAMPLES=P.blurSamples,d.defines.VSM_SAMPLES=P.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Ms(s.x,s.y)),f.uniforms.shadow_pass.value=P.map.texture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,i.setRenderTarget(P.mapPass),i.clear(),i.renderBufferDirect(C,null,R,f,v,null),d.uniforms.shadow_pass.value=P.mapPass.texture,d.uniforms.resolution.value=P.mapSize,d.uniforms.radius.value=P.radius,i.setRenderTarget(P.map),i.clear(),i.renderBufferDirect(C,null,R,d,v,null)}function x(P,C,R,ne){let b=null,_=R.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(_!==void 0)b=_;else if(b=R.isPointLight===!0?l:a,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){let M=b.uuid,I=C.uuid,O=c[M];O===void 0&&(O={},c[M]=O);let B=O[I];B===void 0&&(B=b.clone(),O[I]=B,C.addEventListener("dispose",N)),b=B}if(b.visible=C.visible,b.wireframe=C.wireframe,ne===ys?b.side=C.shadowSide!==null?C.shadowSide:C.side:b.side=C.shadowSide!==null?C.shadowSide:u[C.side],b.alphaMap=C.alphaMap,b.alphaTest=C.alphaTest,b.map=C.map,b.clipShadows=C.clipShadows,b.clippingPlanes=C.clippingPlanes,b.clipIntersection=C.clipIntersection,b.displacementMap=C.displacementMap,b.displacementScale=C.displacementScale,b.displacementBias=C.displacementBias,b.wireframeLinewidth=C.wireframeLinewidth,b.linewidth=C.linewidth,R.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let M=i.properties.get(b);M.light=R}return b}function S(P,C,R,ne,b){if(P.visible===!1)return;if(P.layers.test(C.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&b===ys)&&(!P.frustumCulled||n.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,P.matrixWorld);let I=e.update(P),O=P.material;if(Array.isArray(O)){let B=I.groups;for(let D=0,X=B.length;D<X;D++){let q=B[D],Q=O[q.materialIndex];if(Q&&Q.visible){let ae=x(P,Q,ne,b);P.onBeforeShadow(i,P,C,R,I,ae,q),i.renderBufferDirect(R,null,I,ae,P,q),P.onAfterShadow(i,P,C,R,I,ae,q)}}}else if(O.visible){let B=x(P,O,ne,b);P.onBeforeShadow(i,P,C,R,I,B,null),i.renderBufferDirect(R,null,I,B,P,null),P.onAfterShadow(i,P,C,R,I,B,null)}}let M=P.children;for(let I=0,O=M.length;I<O;I++)S(M[I],C,R,ne,b)}function N(P){P.target.removeEventListener("dispose",N);for(let R in c){let ne=c[R],b=P.target.uuid;b in ne&&(ne[b].dispose(),delete ne[b])}}}var uC={[Pm]:Nm,[Om]:Fm,[Dm]:Bm,[Ha]:Um,[Nm]:Pm,[Fm]:Om,[Bm]:Dm,[Um]:Ha};function fC(i){function e(){let z=!1,ve=new st,J=null,re=new st(0,0,0,0);return{setMask:function(ye){J!==ye&&!z&&(i.colorMask(ye,ye,ye,ye),J=ye)},setLocked:function(ye){z=ye},setClear:function(ye,xe,nt,Ft,Sn){Sn===!0&&(ye*=Ft,xe*=Ft,nt*=Ft),ve.set(ye,xe,nt,Ft),re.equals(ve)===!1&&(i.clearColor(ye,xe,nt,Ft),re.copy(ve))},reset:function(){z=!1,J=null,re.set(-1,0,0,0)}}}function t(){let z=!1,ve=!1,J=null,re=null,ye=null;return{setReversed:function(xe){ve=xe},setTest:function(xe){xe?he(i.DEPTH_TEST):ge(i.DEPTH_TEST)},setMask:function(xe){J!==xe&&!z&&(i.depthMask(xe),J=xe)},setFunc:function(xe){if(ve&&(xe=uC[xe]),re!==xe){switch(xe){case Pm:i.depthFunc(i.NEVER);break;case Nm:i.depthFunc(i.ALWAYS);break;case Om:i.depthFunc(i.LESS);break;case Ha:i.depthFunc(i.LEQUAL);break;case Dm:i.depthFunc(i.EQUAL);break;case Um:i.depthFunc(i.GEQUAL);break;case Fm:i.depthFunc(i.GREATER);break;case Bm:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}re=xe}},setLocked:function(xe){z=xe},setClear:function(xe){ye!==xe&&(i.clearDepth(xe),ye=xe)},reset:function(){z=!1,J=null,re=null,ye=null}}}function n(){let z=!1,ve=null,J=null,re=null,ye=null,xe=null,nt=null,Ft=null,Sn=null;return{setTest:function(at){z||(at?he(i.STENCIL_TEST):ge(i.STENCIL_TEST))},setMask:function(at){ve!==at&&!z&&(i.stencilMask(at),ve=at)},setFunc:function(at,wn,$i){(J!==at||re!==wn||ye!==$i)&&(i.stencilFunc(at,wn,$i),J=at,re=wn,ye=$i)},setOp:function(at,wn,$i){(xe!==at||nt!==wn||Ft!==$i)&&(i.stencilOp(at,wn,$i),xe=at,nt=wn,Ft=$i)},setLocked:function(at){z=at},setClear:function(at){Sn!==at&&(i.clearStencil(at),Sn=at)},reset:function(){z=!1,ve=null,J=null,re=null,ye=null,xe=null,nt=null,Ft=null,Sn=null}}}let s=new e,r=new t,o=new n,a=new WeakMap,l=new WeakMap,c={},h={},u=new WeakMap,f=[],d=null,y=!1,v=null,p=null,m=null,A=null,x=null,S=null,N=null,P=new Oe(0,0,0),C=0,R=!1,ne=null,b=null,_=null,M=null,I=null,O=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),B=!1,D=0,X=i.getParameter(i.VERSION);X.indexOf("WebGL")!==-1?(D=parseFloat(/^WebGL (\d)/.exec(X)[1]),B=D>=1):X.indexOf("OpenGL ES")!==-1&&(D=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),B=D>=2);let q=null,Q={},ae=i.getParameter(i.SCISSOR_BOX),ee=i.getParameter(i.VIEWPORT),H=new st().fromArray(ae),be=new st().fromArray(ee);function Y(z,ve,J,re){let ye=new Uint8Array(4),xe=i.createTexture();i.bindTexture(z,xe),i.texParameteri(z,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(z,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let nt=0;nt<J;nt++)z===i.TEXTURE_3D||z===i.TEXTURE_2D_ARRAY?i.texImage3D(ve,0,i.RGBA,1,1,re,0,i.RGBA,i.UNSIGNED_BYTE,ye):i.texImage2D(ve+nt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ye);return xe}let oe={};oe[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),oe[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),oe[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),oe[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),he(i.DEPTH_TEST),r.setFunc(Ha),Je(!1),rt(Qv),he(i.CULL_FACE),F(ar);function he(z){c[z]!==!0&&(i.enable(z),c[z]=!0)}function ge(z){c[z]!==!1&&(i.disable(z),c[z]=!1)}function He(z,ve){return h[z]!==ve?(i.bindFramebuffer(z,ve),h[z]=ve,z===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ve),z===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ve),!0):!1}function Ue(z,ve){let J=f,re=!1;if(z){J=u.get(ve),J===void 0&&(J=[],u.set(ve,J));let ye=z.textures;if(J.length!==ye.length||J[0]!==i.COLOR_ATTACHMENT0){for(let xe=0,nt=ye.length;xe<nt;xe++)J[xe]=i.COLOR_ATTACHMENT0+xe;J.length=ye.length,re=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,re=!0);re&&i.drawBuffers(J)}function et(z){return d!==z?(i.useProgram(z),d=z,!0):!1}let mt={[_o]:i.FUNC_ADD,[wA]:i.FUNC_SUBTRACT,[AA]:i.FUNC_REVERSE_SUBTRACT};mt[EA]=i.MIN,mt[TA]=i.MAX;let tt={[IA]:i.ZERO,[RA]:i.ONE,[CA]:i.SRC_COLOR,[Cm]:i.SRC_ALPHA,[UA]:i.SRC_ALPHA_SATURATE,[OA]:i.DST_COLOR,[PA]:i.DST_ALPHA,[LA]:i.ONE_MINUS_SRC_COLOR,[Lm]:i.ONE_MINUS_SRC_ALPHA,[DA]:i.ONE_MINUS_DST_COLOR,[NA]:i.ONE_MINUS_DST_ALPHA,[FA]:i.CONSTANT_COLOR,[BA]:i.ONE_MINUS_CONSTANT_COLOR,[kA]:i.CONSTANT_ALPHA,[zA]:i.ONE_MINUS_CONSTANT_ALPHA};function F(z,ve,J,re,ye,xe,nt,Ft,Sn,at){if(z===ar){y===!0&&(ge(i.BLEND),y=!1);return}if(y===!1&&(he(i.BLEND),y=!0),z!==SA){if(z!==v||at!==R){if((p!==_o||x!==_o)&&(i.blendEquation(i.FUNC_ADD),p=_o,x=_o),at)switch(z){case Ba:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ex:i.blendFunc(i.ONE,i.ONE);break;case tx:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case nx:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case Ba:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ex:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case tx:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case nx:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}m=null,A=null,S=null,N=null,P.set(0,0,0),C=0,v=z,R=at}return}ye=ye||ve,xe=xe||J,nt=nt||re,(ve!==p||ye!==x)&&(i.blendEquationSeparate(mt[ve],mt[ye]),p=ve,x=ye),(J!==m||re!==A||xe!==S||nt!==N)&&(i.blendFuncSeparate(tt[J],tt[re],tt[xe],tt[nt]),m=J,A=re,S=xe,N=nt),(Ft.equals(P)===!1||Sn!==C)&&(i.blendColor(Ft.r,Ft.g,Ft.b,Sn),P.copy(Ft),C=Sn),v=z,R=!1}function Ln(z,ve){z.side===Yn?ge(i.CULL_FACE):he(i.CULL_FACE);let J=z.side===In;ve&&(J=!J),Je(J),z.blending===Ba&&z.transparent===!1?F(ar):F(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),r.setFunc(z.depthFunc),r.setTest(z.depthTest),r.setMask(z.depthWrite),s.setMask(z.colorWrite);let re=z.stencilWrite;o.setTest(re),re&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),Mt(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?he(i.SAMPLE_ALPHA_TO_COVERAGE):ge(i.SAMPLE_ALPHA_TO_COVERAGE)}function Je(z){ne!==z&&(z?i.frontFace(i.CW):i.frontFace(i.CCW),ne=z)}function rt(z){z!==xA?(he(i.CULL_FACE),z!==b&&(z===Qv?i.cullFace(i.BACK):z===bA?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ge(i.CULL_FACE),b=z}function Be(z){z!==_&&(B&&i.lineWidth(z),_=z)}function Mt(z,ve,J){z?(he(i.POLYGON_OFFSET_FILL),(M!==ve||I!==J)&&(i.polygonOffset(ve,J),M=ve,I=J)):ge(i.POLYGON_OFFSET_FILL)}function Ve(z){z?he(i.SCISSOR_TEST):ge(i.SCISSOR_TEST)}function L(z){z===void 0&&(z=i.TEXTURE0+O-1),q!==z&&(i.activeTexture(z),q=z)}function w(z,ve,J){J===void 0&&(q===null?J=i.TEXTURE0+O-1:J=q);let re=Q[J];re===void 0&&(re={type:void 0,texture:void 0},Q[J]=re),(re.type!==z||re.texture!==ve)&&(q!==J&&(i.activeTexture(J),q=J),i.bindTexture(z,ve||oe[z]),re.type=z,re.texture=ve)}function K(){let z=Q[q];z!==void 0&&z.type!==void 0&&(i.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function se(){try{i.compressedTexImage2D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function le(){try{i.compressedTexImage3D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ie(){try{i.texSubImage2D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Re(){try{i.texSubImage3D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function me(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Me(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ot(){try{i.texStorage2D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ue(){try{i.texStorage3D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Se(){try{i.texImage2D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ke(){try{i.texImage3D.apply(i,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ze(z){H.equals(z)===!1&&(i.scissor(z.x,z.y,z.z,z.w),H.copy(z))}function we(z){be.equals(z)===!1&&(i.viewport(z.x,z.y,z.z,z.w),be.copy(z))}function Qe(z,ve){let J=l.get(ve);J===void 0&&(J=new WeakMap,l.set(ve,J));let re=J.get(z);re===void 0&&(re=i.getUniformBlockIndex(ve,z.name),J.set(z,re))}function Ge(z,ve){let re=l.get(ve).get(z);a.get(ve)!==re&&(i.uniformBlockBinding(ve,re,z.__bindingPointIndex),a.set(ve,re))}function xt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},q=null,Q={},h={},u=new WeakMap,f=[],d=null,y=!1,v=null,p=null,m=null,A=null,x=null,S=null,N=null,P=new Oe(0,0,0),C=0,R=!1,ne=null,b=null,_=null,M=null,I=null,H.set(0,0,i.canvas.width,i.canvas.height),be.set(0,0,i.canvas.width,i.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:he,disable:ge,bindFramebuffer:He,drawBuffers:Ue,useProgram:et,setBlending:F,setMaterial:Ln,setFlipSided:Je,setCullFace:rt,setLineWidth:Be,setPolygonOffset:Mt,setScissorTest:Ve,activeTexture:L,bindTexture:w,unbindTexture:K,compressedTexImage2D:se,compressedTexImage3D:le,texImage2D:Se,texImage3D:ke,updateUBOMapping:Qe,uniformBlockBinding:Ge,texStorage2D:ot,texStorage3D:ue,texSubImage2D:ie,texSubImage3D:Re,compressedTexSubImage2D:me,compressedTexSubImage3D:Me,scissor:ze,viewport:we,reset:xt}}function Zx(i,e,t,n){let s=dC(n);switch(t){case Mb:return i*e;case wb:return i*e;case Ab:return i*e*2;case qg:return i*e/s.components*s.byteLength;case Yg:return i*e/s.components*s.byteLength;case Eb:return i*e*2/s.components*s.byteLength;case Kg:return i*e*2/s.components*s.byteLength;case Sb:return i*e*3/s.components*s.byteLength;case Tn:return i*e*4/s.components*s.byteLength;case Zg:return i*e*4/s.components*s.byteLength;case of:case af:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case lf:case cf:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Hm:case Wm:return Math.max(i,16)*Math.max(e,8)/4;case Vm:case Gm:return Math.max(i,8)*Math.max(e,8)/2;case Xm:case qm:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ym:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Km:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Zm:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case $m:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case jm:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Jm:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Qm:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case eg:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case tg:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ng:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ig:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case sg:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case rg:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case og:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ag:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case hf:case lg:case cg:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Tb:case hg:return Math.ceil(i/4)*Math.ceil(e/4)*8;case ug:case fg:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function dC(i){switch(i){case bs:case vb:return{byteLength:1,components:1};case Rc:case xb:case Vc:return{byteLength:2,components:1};case Wg:case Xg:return{byteLength:2,components:4};case Mo:case Gg:case Ni:return{byteLength:4,components:1};case bb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function pC(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ye,h=new WeakMap,u,f=new WeakMap,d=!1;try{d=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(L,w){return d?new OffscreenCanvas(L,w):Cc("canvas")}function v(L,w,K){let se=1,le=Ve(L);if((le.width>K||le.height>K)&&(se=K/Math.max(le.width,le.height)),se<1)if(typeof HTMLImageElement!="undefined"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&L instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&L instanceof ImageBitmap||typeof VideoFrame!="undefined"&&L instanceof VideoFrame){let ie=Math.floor(se*le.width),Re=Math.floor(se*le.height);u===void 0&&(u=y(ie,Re));let me=w?y(ie,Re):u;return me.width=ie,me.height=Re,me.getContext("2d").drawImage(L,0,0,ie,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+le.width+"x"+le.height+") to ("+ie+"x"+Re+")."),me}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+le.width+"x"+le.height+")."),L;return L}function p(L){return L.generateMipmaps&&L.minFilter!==tn&&L.minFilter!==Wt}function m(L){i.generateMipmap(L)}function A(L,w,K,se,le=!1){if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let ie=w;if(w===i.RED&&(K===i.FLOAT&&(ie=i.R32F),K===i.HALF_FLOAT&&(ie=i.R16F),K===i.UNSIGNED_BYTE&&(ie=i.R8)),w===i.RED_INTEGER&&(K===i.UNSIGNED_BYTE&&(ie=i.R8UI),K===i.UNSIGNED_SHORT&&(ie=i.R16UI),K===i.UNSIGNED_INT&&(ie=i.R32UI),K===i.BYTE&&(ie=i.R8I),K===i.SHORT&&(ie=i.R16I),K===i.INT&&(ie=i.R32I)),w===i.RG&&(K===i.FLOAT&&(ie=i.RG32F),K===i.HALF_FLOAT&&(ie=i.RG16F),K===i.UNSIGNED_BYTE&&(ie=i.RG8)),w===i.RG_INTEGER&&(K===i.UNSIGNED_BYTE&&(ie=i.RG8UI),K===i.UNSIGNED_SHORT&&(ie=i.RG16UI),K===i.UNSIGNED_INT&&(ie=i.RG32UI),K===i.BYTE&&(ie=i.RG8I),K===i.SHORT&&(ie=i.RG16I),K===i.INT&&(ie=i.RG32I)),w===i.RGB_INTEGER&&(K===i.UNSIGNED_BYTE&&(ie=i.RGB8UI),K===i.UNSIGNED_SHORT&&(ie=i.RGB16UI),K===i.UNSIGNED_INT&&(ie=i.RGB32UI),K===i.BYTE&&(ie=i.RGB8I),K===i.SHORT&&(ie=i.RGB16I),K===i.INT&&(ie=i.RGB32I)),w===i.RGBA_INTEGER&&(K===i.UNSIGNED_BYTE&&(ie=i.RGBA8UI),K===i.UNSIGNED_SHORT&&(ie=i.RGBA16UI),K===i.UNSIGNED_INT&&(ie=i.RGBA32UI),K===i.BYTE&&(ie=i.RGBA8I),K===i.SHORT&&(ie=i.RGBA16I),K===i.INT&&(ie=i.RGBA32I)),w===i.RGB&&K===i.UNSIGNED_INT_5_9_9_9_REV&&(ie=i.RGB9_E5),w===i.RGBA){let Re=le?ff:it.getTransfer(se);K===i.FLOAT&&(ie=i.RGBA32F),K===i.HALF_FLOAT&&(ie=i.RGBA16F),K===i.UNSIGNED_BYTE&&(ie=Re===At?i.SRGB8_ALPHA8:i.RGBA8),K===i.UNSIGNED_SHORT_4_4_4_4&&(ie=i.RGBA4),K===i.UNSIGNED_SHORT_5_5_5_1&&(ie=i.RGB5_A1)}return(ie===i.R16F||ie===i.R32F||ie===i.RG16F||ie===i.RG32F||ie===i.RGBA16F||ie===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function x(L,w){let K;return L?w===null||w===Mo||w===Xa?K=i.DEPTH24_STENCIL8:w===Ni?K=i.DEPTH32F_STENCIL8:w===Rc&&(K=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===Mo||w===Xa?K=i.DEPTH_COMPONENT24:w===Ni?K=i.DEPTH_COMPONENT32F:w===Rc&&(K=i.DEPTH_COMPONENT16),K}function S(L,w){return p(L)===!0||L.isFramebufferTexture&&L.minFilter!==tn&&L.minFilter!==Wt?Math.log2(Math.max(w.width,w.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?w.mipmaps.length:1}function N(L){let w=L.target;w.removeEventListener("dispose",N),C(w),w.isVideoTexture&&h.delete(w)}function P(L){let w=L.target;w.removeEventListener("dispose",P),ne(w)}function C(L){let w=n.get(L);if(w.__webglInit===void 0)return;let K=L.source,se=f.get(K);if(se){let le=se[w.__cacheKey];le.usedTimes--,le.usedTimes===0&&R(L),Object.keys(se).length===0&&f.delete(K)}n.remove(L)}function R(L){let w=n.get(L);i.deleteTexture(w.__webglTexture);let K=L.source,se=f.get(K);delete se[w.__cacheKey],o.memory.textures--}function ne(L){let w=n.get(L);if(L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(w.__webglFramebuffer[se]))for(let le=0;le<w.__webglFramebuffer[se].length;le++)i.deleteFramebuffer(w.__webglFramebuffer[se][le]);else i.deleteFramebuffer(w.__webglFramebuffer[se]);w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer[se])}else{if(Array.isArray(w.__webglFramebuffer))for(let se=0;se<w.__webglFramebuffer.length;se++)i.deleteFramebuffer(w.__webglFramebuffer[se]);else i.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&i.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let se=0;se<w.__webglColorRenderbuffer.length;se++)w.__webglColorRenderbuffer[se]&&i.deleteRenderbuffer(w.__webglColorRenderbuffer[se]);w.__webglDepthRenderbuffer&&i.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let K=L.textures;for(let se=0,le=K.length;se<le;se++){let ie=n.get(K[se]);ie.__webglTexture&&(i.deleteTexture(ie.__webglTexture),o.memory.textures--),n.remove(K[se])}n.remove(L)}let b=0;function _(){b=0}function M(){let L=b;return L>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+s.maxTextures),b+=1,L}function I(L){let w=[];return w.push(L.wrapS),w.push(L.wrapT),w.push(L.wrapR||0),w.push(L.magFilter),w.push(L.minFilter),w.push(L.anisotropy),w.push(L.internalFormat),w.push(L.format),w.push(L.type),w.push(L.generateMipmaps),w.push(L.premultiplyAlpha),w.push(L.flipY),w.push(L.unpackAlignment),w.push(L.colorSpace),w.join()}function O(L,w){let K=n.get(L);if(L.isVideoTexture&&Be(L),L.isRenderTargetTexture===!1&&L.version>0&&K.__version!==L.version){let se=L.image;if(se===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{be(K,L,w);return}}t.bindTexture(i.TEXTURE_2D,K.__webglTexture,i.TEXTURE0+w)}function B(L,w){let K=n.get(L);if(L.version>0&&K.__version!==L.version){be(K,L,w);return}t.bindTexture(i.TEXTURE_2D_ARRAY,K.__webglTexture,i.TEXTURE0+w)}function D(L,w){let K=n.get(L);if(L.version>0&&K.__version!==L.version){be(K,L,w);return}t.bindTexture(i.TEXTURE_3D,K.__webglTexture,i.TEXTURE0+w)}function X(L,w){let K=n.get(L);if(L.version>0&&K.__version!==L.version){Y(K,L,w);return}t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture,i.TEXTURE0+w)}let q={[xs]:i.REPEAT,[Pi]:i.CLAMP_TO_EDGE,[bo]:i.MIRRORED_REPEAT},Q={[tn]:i.NEAREST,[zc]:i.NEAREST_MIPMAP_NEAREST,[rr]:i.NEAREST_MIPMAP_LINEAR,[Wt]:i.LINEAR,[xo]:i.LINEAR_MIPMAP_NEAREST,[ui]:i.LINEAR_MIPMAP_LINEAR},ae={[t1]:i.NEVER,[a1]:i.ALWAYS,[n1]:i.LESS,[Cb]:i.LEQUAL,[i1]:i.EQUAL,[o1]:i.GEQUAL,[s1]:i.GREATER,[r1]:i.NOTEQUAL};function ee(L,w){if(w.type===Ni&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Wt||w.magFilter===xo||w.magFilter===rr||w.magFilter===ui||w.minFilter===Wt||w.minFilter===xo||w.minFilter===rr||w.minFilter===ui)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(L,i.TEXTURE_WRAP_S,q[w.wrapS]),i.texParameteri(L,i.TEXTURE_WRAP_T,q[w.wrapT]),(L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY)&&i.texParameteri(L,i.TEXTURE_WRAP_R,q[w.wrapR]),i.texParameteri(L,i.TEXTURE_MAG_FILTER,Q[w.magFilter]),i.texParameteri(L,i.TEXTURE_MIN_FILTER,Q[w.minFilter]),w.compareFunction&&(i.texParameteri(L,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(L,i.TEXTURE_COMPARE_FUNC,ae[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===tn||w.minFilter!==rr&&w.minFilter!==ui||w.type===Ni&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||n.get(w).__currentAnisotropy){let K=e.get("EXT_texture_filter_anisotropic");i.texParameterf(L,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,s.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy}}}function H(L,w){let K=!1;L.__webglInit===void 0&&(L.__webglInit=!0,w.addEventListener("dispose",N));let se=w.source,le=f.get(se);le===void 0&&(le={},f.set(se,le));let ie=I(w);if(ie!==L.__cacheKey){le[ie]===void 0&&(le[ie]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,K=!0),le[ie].usedTimes++;let Re=le[L.__cacheKey];Re!==void 0&&(le[L.__cacheKey].usedTimes--,Re.usedTimes===0&&R(w)),L.__cacheKey=ie,L.__webglTexture=le[ie].texture}return K}function be(L,w,K){let se=i.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(se=i.TEXTURE_2D_ARRAY),w.isData3DTexture&&(se=i.TEXTURE_3D);let le=H(L,w),ie=w.source;t.bindTexture(se,L.__webglTexture,i.TEXTURE0+K);let Re=n.get(ie);if(ie.version!==Re.__version||le===!0){t.activeTexture(i.TEXTURE0+K);let me=it.getPrimaries(it.workingColorSpace),Me=w.colorSpace===Yi?null:it.getPrimaries(w.colorSpace),ot=w.colorSpace===Yi||me===Me?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ot);let ue=v(w.image,!1,s.maxTextureSize);ue=Mt(w,ue);let Se=r.convert(w.format,w.colorSpace),ke=r.convert(w.type),ze=A(w.internalFormat,Se,ke,w.colorSpace,w.isVideoTexture);ee(se,w);let we,Qe=w.mipmaps,Ge=w.isVideoTexture!==!0,xt=Re.__version===void 0||le===!0,z=ie.dataReady,ve=S(w,ue);if(w.isDepthTexture)ze=x(w.format===qa,w.type),xt&&(Ge?t.texStorage2D(i.TEXTURE_2D,1,ze,ue.width,ue.height):t.texImage2D(i.TEXTURE_2D,0,ze,ue.width,ue.height,0,Se,ke,null));else if(w.isDataTexture)if(Qe.length>0){Ge&&xt&&t.texStorage2D(i.TEXTURE_2D,ve,ze,Qe[0].width,Qe[0].height);for(let J=0,re=Qe.length;J<re;J++)we=Qe[J],Ge?z&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,we.width,we.height,Se,ke,we.data):t.texImage2D(i.TEXTURE_2D,J,ze,we.width,we.height,0,Se,ke,we.data);w.generateMipmaps=!1}else Ge?(xt&&t.texStorage2D(i.TEXTURE_2D,ve,ze,ue.width,ue.height),z&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ue.width,ue.height,Se,ke,ue.data)):t.texImage2D(i.TEXTURE_2D,0,ze,ue.width,ue.height,0,Se,ke,ue.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Ge&&xt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ve,ze,Qe[0].width,Qe[0].height,ue.depth);for(let J=0,re=Qe.length;J<re;J++)if(we=Qe[J],w.format!==Tn)if(Se!==null)if(Ge){if(z)if(w.layerUpdates.size>0){let ye=Zx(we.width,we.height,w.format,w.type);for(let xe of w.layerUpdates){let nt=we.data.subarray(xe*ye/we.data.BYTES_PER_ELEMENT,(xe+1)*ye/we.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,xe,we.width,we.height,1,Se,nt,0,0)}w.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,we.width,we.height,ue.depth,Se,we.data,0,0)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,ze,we.width,we.height,ue.depth,0,we.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ge?z&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,we.width,we.height,ue.depth,Se,ke,we.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,ze,we.width,we.height,ue.depth,0,Se,ke,we.data)}else{Ge&&xt&&t.texStorage2D(i.TEXTURE_2D,ve,ze,Qe[0].width,Qe[0].height);for(let J=0,re=Qe.length;J<re;J++)we=Qe[J],w.format!==Tn?Se!==null?Ge?z&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,we.width,we.height,Se,we.data):t.compressedTexImage2D(i.TEXTURE_2D,J,ze,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ge?z&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,we.width,we.height,Se,ke,we.data):t.texImage2D(i.TEXTURE_2D,J,ze,we.width,we.height,0,Se,ke,we.data)}else if(w.isDataArrayTexture)if(Ge){if(xt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ve,ze,ue.width,ue.height,ue.depth),z)if(w.layerUpdates.size>0){let J=Zx(ue.width,ue.height,w.format,w.type);for(let re of w.layerUpdates){let ye=ue.data.subarray(re*J/ue.data.BYTES_PER_ELEMENT,(re+1)*J/ue.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,re,ue.width,ue.height,1,Se,ke,ye)}w.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ue.width,ue.height,ue.depth,Se,ke,ue.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ze,ue.width,ue.height,ue.depth,0,Se,ke,ue.data);else if(w.isData3DTexture)Ge?(xt&&t.texStorage3D(i.TEXTURE_3D,ve,ze,ue.width,ue.height,ue.depth),z&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ue.width,ue.height,ue.depth,Se,ke,ue.data)):t.texImage3D(i.TEXTURE_3D,0,ze,ue.width,ue.height,ue.depth,0,Se,ke,ue.data);else if(w.isFramebufferTexture){if(xt)if(Ge)t.texStorage2D(i.TEXTURE_2D,ve,ze,ue.width,ue.height);else{let J=ue.width,re=ue.height;for(let ye=0;ye<ve;ye++)t.texImage2D(i.TEXTURE_2D,ye,ze,J,re,0,Se,ke,null),J>>=1,re>>=1}}else if(Qe.length>0){if(Ge&&xt){let J=Ve(Qe[0]);t.texStorage2D(i.TEXTURE_2D,ve,ze,J.width,J.height)}for(let J=0,re=Qe.length;J<re;J++)we=Qe[J],Ge?z&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,Se,ke,we):t.texImage2D(i.TEXTURE_2D,J,ze,Se,ke,we);w.generateMipmaps=!1}else if(Ge){if(xt){let J=Ve(ue);t.texStorage2D(i.TEXTURE_2D,ve,ze,J.width,J.height)}z&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Se,ke,ue)}else t.texImage2D(i.TEXTURE_2D,0,ze,Se,ke,ue);p(w)&&m(se),Re.__version=ie.version,w.onUpdate&&w.onUpdate(w)}L.__version=w.version}function Y(L,w,K){if(w.image.length!==6)return;let se=H(L,w),le=w.source;t.bindTexture(i.TEXTURE_CUBE_MAP,L.__webglTexture,i.TEXTURE0+K);let ie=n.get(le);if(le.version!==ie.__version||se===!0){t.activeTexture(i.TEXTURE0+K);let Re=it.getPrimaries(it.workingColorSpace),me=w.colorSpace===Yi?null:it.getPrimaries(w.colorSpace),Me=w.colorSpace===Yi||Re===me?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Me);let ot=w.isCompressedTexture||w.image[0].isCompressedTexture,ue=w.image[0]&&w.image[0].isDataTexture,Se=[];for(let re=0;re<6;re++)!ot&&!ue?Se[re]=v(w.image[re],!0,s.maxCubemapSize):Se[re]=ue?w.image[re].image:w.image[re],Se[re]=Mt(w,Se[re]);let ke=Se[0],ze=r.convert(w.format,w.colorSpace),we=r.convert(w.type),Qe=A(w.internalFormat,ze,we,w.colorSpace),Ge=w.isVideoTexture!==!0,xt=ie.__version===void 0||se===!0,z=le.dataReady,ve=S(w,ke);ee(i.TEXTURE_CUBE_MAP,w);let J;if(ot){Ge&&xt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,Qe,ke.width,ke.height);for(let re=0;re<6;re++){J=Se[re].mipmaps;for(let ye=0;ye<J.length;ye++){let xe=J[ye];w.format!==Tn?ze!==null?Ge?z&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye,0,0,xe.width,xe.height,ze,xe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye,Qe,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ge?z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye,0,0,xe.width,xe.height,ze,we,xe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye,Qe,xe.width,xe.height,0,ze,we,xe.data)}}}else{if(J=w.mipmaps,Ge&&xt){J.length>0&&ve++;let re=Ve(Se[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,Qe,re.width,re.height)}for(let re=0;re<6;re++)if(ue){Ge?z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,0,0,Se[re].width,Se[re].height,ze,we,Se[re].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,Qe,Se[re].width,Se[re].height,0,ze,we,Se[re].data);for(let ye=0;ye<J.length;ye++){let nt=J[ye].image[re].image;Ge?z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye+1,0,0,nt.width,nt.height,ze,we,nt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye+1,Qe,nt.width,nt.height,0,ze,we,nt.data)}}else{Ge?z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,0,0,ze,we,Se[re]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,0,Qe,ze,we,Se[re]);for(let ye=0;ye<J.length;ye++){let xe=J[ye];Ge?z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye+1,0,0,ze,we,xe.image[re]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+re,ye+1,Qe,ze,we,xe.image[re])}}}p(w)&&m(i.TEXTURE_CUBE_MAP),ie.__version=le.version,w.onUpdate&&w.onUpdate(w)}L.__version=w.version}function oe(L,w,K,se,le,ie){let Re=r.convert(K.format,K.colorSpace),me=r.convert(K.type),Me=A(K.internalFormat,Re,me,K.colorSpace);if(!n.get(w).__hasExternalTextures){let ue=Math.max(1,w.width>>ie),Se=Math.max(1,w.height>>ie);le===i.TEXTURE_3D||le===i.TEXTURE_2D_ARRAY?t.texImage3D(le,ie,Me,ue,Se,w.depth,0,Re,me,null):t.texImage2D(le,ie,Me,ue,Se,0,Re,me,null)}t.bindFramebuffer(i.FRAMEBUFFER,L),rt(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,se,le,n.get(K).__webglTexture,0,Je(w)):(le===i.TEXTURE_2D||le>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&le<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,se,le,n.get(K).__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function he(L,w,K){if(i.bindRenderbuffer(i.RENDERBUFFER,L),w.depthBuffer){let se=w.depthTexture,le=se&&se.isDepthTexture?se.type:null,ie=x(w.stencilBuffer,le),Re=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,me=Je(w);rt(w)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,me,ie,w.width,w.height):K?i.renderbufferStorageMultisample(i.RENDERBUFFER,me,ie,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,ie,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Re,i.RENDERBUFFER,L)}else{let se=w.textures;for(let le=0;le<se.length;le++){let ie=se[le],Re=r.convert(ie.format,ie.colorSpace),me=r.convert(ie.type),Me=A(ie.internalFormat,Re,me,ie.colorSpace),ot=Je(w);K&&rt(w)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,ot,Me,w.width,w.height):rt(w)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ot,Me,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,Me,w.width,w.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ge(L,w){if(w&&w.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,L),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(w.depthTexture).__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),O(w.depthTexture,0);let se=n.get(w.depthTexture).__webglTexture,le=Je(w);if(w.depthTexture.format===ka)rt(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,se,0,le):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,se,0);else if(w.depthTexture.format===qa)rt(w)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,se,0,le):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,se,0);else throw new Error("Unknown depthTexture format")}function He(L){let w=n.get(L),K=L.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==L.depthTexture){let se=L.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),se){let le=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,se.removeEventListener("dispose",le)};se.addEventListener("dispose",le),w.__depthDisposeCallback=le}w.__boundDepthTexture=se}if(L.depthTexture&&!w.__autoAllocateDepthBuffer){if(K)throw new Error("target.depthTexture not supported in Cube render targets");ge(w.__webglFramebuffer,L)}else if(K){w.__webglDepthbuffer=[];for(let se=0;se<6;se++)if(t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer[se]),w.__webglDepthbuffer[se]===void 0)w.__webglDepthbuffer[se]=i.createRenderbuffer(),he(w.__webglDepthbuffer[se],L,!1);else{let le=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=w.__webglDepthbuffer[se];i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,le,i.RENDERBUFFER,ie)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=i.createRenderbuffer(),he(w.__webglDepthbuffer,L,!1);else{let se=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=w.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,le)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ue(L,w,K){let se=n.get(L);w!==void 0&&oe(se.__webglFramebuffer,L,L.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),K!==void 0&&He(L)}function et(L){let w=L.texture,K=n.get(L),se=n.get(w);L.addEventListener("dispose",P);let le=L.textures,ie=L.isWebGLCubeRenderTarget===!0,Re=le.length>1;if(Re||(se.__webglTexture===void 0&&(se.__webglTexture=i.createTexture()),se.__version=w.version,o.memory.textures++),ie){K.__webglFramebuffer=[];for(let me=0;me<6;me++)if(w.mipmaps&&w.mipmaps.length>0){K.__webglFramebuffer[me]=[];for(let Me=0;Me<w.mipmaps.length;Me++)K.__webglFramebuffer[me][Me]=i.createFramebuffer()}else K.__webglFramebuffer[me]=i.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){K.__webglFramebuffer=[];for(let me=0;me<w.mipmaps.length;me++)K.__webglFramebuffer[me]=i.createFramebuffer()}else K.__webglFramebuffer=i.createFramebuffer();if(Re)for(let me=0,Me=le.length;me<Me;me++){let ot=n.get(le[me]);ot.__webglTexture===void 0&&(ot.__webglTexture=i.createTexture(),o.memory.textures++)}if(L.samples>0&&rt(L)===!1){K.__webglMultisampledFramebuffer=i.createFramebuffer(),K.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let me=0;me<le.length;me++){let Me=le[me];K.__webglColorRenderbuffer[me]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,K.__webglColorRenderbuffer[me]);let ot=r.convert(Me.format,Me.colorSpace),ue=r.convert(Me.type),Se=A(Me.internalFormat,ot,ue,Me.colorSpace,L.isXRRenderTarget===!0),ke=Je(L);i.renderbufferStorageMultisample(i.RENDERBUFFER,ke,Se,L.width,L.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+me,i.RENDERBUFFER,K.__webglColorRenderbuffer[me])}i.bindRenderbuffer(i.RENDERBUFFER,null),L.depthBuffer&&(K.__webglDepthRenderbuffer=i.createRenderbuffer(),he(K.__webglDepthRenderbuffer,L,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ie){t.bindTexture(i.TEXTURE_CUBE_MAP,se.__webglTexture),ee(i.TEXTURE_CUBE_MAP,w);for(let me=0;me<6;me++)if(w.mipmaps&&w.mipmaps.length>0)for(let Me=0;Me<w.mipmaps.length;Me++)oe(K.__webglFramebuffer[me][Me],L,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+me,Me);else oe(K.__webglFramebuffer[me],L,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+me,0);p(w)&&m(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Re){for(let me=0,Me=le.length;me<Me;me++){let ot=le[me],ue=n.get(ot);t.bindTexture(i.TEXTURE_2D,ue.__webglTexture),ee(i.TEXTURE_2D,ot),oe(K.__webglFramebuffer,L,ot,i.COLOR_ATTACHMENT0+me,i.TEXTURE_2D,0),p(ot)&&m(i.TEXTURE_2D)}t.unbindTexture()}else{let me=i.TEXTURE_2D;if((L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(me=L.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(me,se.__webglTexture),ee(me,w),w.mipmaps&&w.mipmaps.length>0)for(let Me=0;Me<w.mipmaps.length;Me++)oe(K.__webglFramebuffer[Me],L,w,i.COLOR_ATTACHMENT0,me,Me);else oe(K.__webglFramebuffer,L,w,i.COLOR_ATTACHMENT0,me,0);p(w)&&m(me),t.unbindTexture()}L.depthBuffer&&He(L)}function mt(L){let w=L.textures;for(let K=0,se=w.length;K<se;K++){let le=w[K];if(p(le)){let ie=L.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,Re=n.get(le).__webglTexture;t.bindTexture(ie,Re),m(ie),t.unbindTexture()}}}let tt=[],F=[];function Ln(L){if(L.samples>0){if(rt(L)===!1){let w=L.textures,K=L.width,se=L.height,le=i.COLOR_BUFFER_BIT,ie=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Re=n.get(L),me=w.length>1;if(me)for(let Me=0;Me<w.length;Me++)t.bindFramebuffer(i.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Me,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Re.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Me,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let Me=0;Me<w.length;Me++){if(L.resolveDepthBuffer&&(L.depthBuffer&&(le|=i.DEPTH_BUFFER_BIT),L.stencilBuffer&&L.resolveStencilBuffer&&(le|=i.STENCIL_BUFFER_BIT)),me){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Re.__webglColorRenderbuffer[Me]);let ot=n.get(w[Me]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ot,0)}i.blitFramebuffer(0,0,K,se,0,0,K,se,le,i.NEAREST),l===!0&&(tt.length=0,F.length=0,tt.push(i.COLOR_ATTACHMENT0+Me),L.depthBuffer&&L.resolveDepthBuffer===!1&&(tt.push(ie),F.push(ie),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,F)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,tt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),me)for(let Me=0;Me<w.length;Me++){t.bindFramebuffer(i.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Me,i.RENDERBUFFER,Re.__webglColorRenderbuffer[Me]);let ot=n.get(w[Me]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Re.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Me,i.TEXTURE_2D,ot,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}else if(L.depthBuffer&&L.resolveDepthBuffer===!1&&l){let w=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[w])}}}function Je(L){return Math.min(s.maxSamples,L.samples)}function rt(L){let w=n.get(L);return L.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function Be(L){let w=o.render.frame;h.get(L)!==w&&(h.set(L,w),L.update())}function Mt(L,w){let K=L.colorSpace,se=L.format,le=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||K!==nn&&K!==Yi&&(it.getTransfer(K)===At?(se!==Tn||le!==bs)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",K)),w}function Ve(L){return typeof HTMLImageElement!="undefined"&&L instanceof HTMLImageElement?(c.width=L.naturalWidth||L.width,c.height=L.naturalHeight||L.height):typeof VideoFrame!="undefined"&&L instanceof VideoFrame?(c.width=L.displayWidth,c.height=L.displayHeight):(c.width=L.width,c.height=L.height),c}this.allocateTextureUnit=M,this.resetTextureUnits=_,this.setTexture2D=O,this.setTexture2DArray=B,this.setTexture3D=D,this.setTextureCube=X,this.rebindTextures=Ue,this.setupRenderTarget=et,this.updateRenderTargetMipmap=mt,this.updateMultisampleRenderTarget=Ln,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=oe,this.useMultisampledRTT=rt}function mC(i,e){function t(n,s=Yi){let r,o=it.getTransfer(s);if(n===bs)return i.UNSIGNED_BYTE;if(n===Wg)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Xg)return i.UNSIGNED_SHORT_5_5_5_1;if(n===bb)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===vb)return i.BYTE;if(n===xb)return i.SHORT;if(n===Rc)return i.UNSIGNED_SHORT;if(n===Gg)return i.INT;if(n===Mo)return i.UNSIGNED_INT;if(n===Ni)return i.FLOAT;if(n===Vc)return i.HALF_FLOAT;if(n===Mb)return i.ALPHA;if(n===Sb)return i.RGB;if(n===Tn)return i.RGBA;if(n===wb)return i.LUMINANCE;if(n===Ab)return i.LUMINANCE_ALPHA;if(n===ka)return i.DEPTH_COMPONENT;if(n===qa)return i.DEPTH_STENCIL;if(n===qg)return i.RED;if(n===Yg)return i.RED_INTEGER;if(n===Eb)return i.RG;if(n===Kg)return i.RG_INTEGER;if(n===Zg)return i.RGBA_INTEGER;if(n===of||n===af||n===lf||n===cf)if(o===At)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===of)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===af)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===lf)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===cf)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===of)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===af)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===lf)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===cf)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Vm||n===Hm||n===Gm||n===Wm)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Vm)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Hm)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Gm)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Wm)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Xm||n===qm||n===Ym)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Xm||n===qm)return o===At?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ym)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Km||n===Zm||n===$m||n===jm||n===Jm||n===Qm||n===eg||n===tg||n===ng||n===ig||n===sg||n===rg||n===og||n===ag)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Km)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Zm)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===$m)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===jm)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Jm)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Qm)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===eg)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===tg)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ng)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ig)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===sg)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===rg)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===og)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ag)return o===At?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===hf||n===lg||n===cg)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===hf)return o===At?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===lg)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===cg)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Tb||n===hg||n===ug||n===fg)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===hf)return r.COMPRESSED_RED_RGTC1_EXT;if(n===hg)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ug)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===fg)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Xa?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var Tg=class extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ki=class extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}},gC={type:"move"},Ic=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ki,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ki,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ki,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let v of e.hand.values()){let p=t.getJointPose(v,n),m=this._getHandJoint(c,v);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,y=.005;c.inputState.pinching&&f>d+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gC)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Ki;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},yC=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,_C=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`,Ig=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let s=new Et,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new pi({vertexShader:yC,fragmentShader:_C,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ct(new mi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Rg=class extends ur{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,u=null,f=null,d=null,y=null,v=new Ig,p=t.getContextAttributes(),m=null,A=null,x=[],S=[],N=new Ye,P=null,C=new Zt;C.layers.enable(1),C.viewport=new st;let R=new Zt;R.layers.enable(2),R.viewport=new st;let ne=[C,R],b=new Tg;b.layers.enable(1),b.layers.enable(2);let _=null,M=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let oe=x[Y];return oe===void 0&&(oe=new Ic,x[Y]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(Y){let oe=x[Y];return oe===void 0&&(oe=new Ic,x[Y]=oe),oe.getGripSpace()},this.getHand=function(Y){let oe=x[Y];return oe===void 0&&(oe=new Ic,x[Y]=oe),oe.getHandSpace()};function I(Y){let oe=S.indexOf(Y.inputSource);if(oe===-1)return;let he=x[oe];he!==void 0&&(he.update(Y.inputSource,Y.frame,c||o),he.dispatchEvent({type:Y.type,data:Y.inputSource}))}function O(){s.removeEventListener("select",I),s.removeEventListener("selectstart",I),s.removeEventListener("selectend",I),s.removeEventListener("squeeze",I),s.removeEventListener("squeezestart",I),s.removeEventListener("squeezeend",I),s.removeEventListener("end",O),s.removeEventListener("inputsourceschange",B);for(let Y=0;Y<x.length;Y++){let oe=S[Y];oe!==null&&(S[Y]=null,x[Y].disconnect(oe))}_=null,M=null,v.reset(),e.setRenderTarget(m),d=null,f=null,u=null,s=null,A=null,be.stop(),n.isPresenting=!1,e.setPixelRatio(P),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return y},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(m=e.getRenderTarget(),s.addEventListener("select",I),s.addEventListener("selectstart",I),s.addEventListener("selectend",I),s.addEventListener("squeeze",I),s.addEventListener("squeezestart",I),s.addEventListener("squeezeend",I),s.addEventListener("end",O),s.addEventListener("inputsourceschange",B),p.xrCompatible!==!0&&await t.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(N),s.renderState.layers===void 0){let oe={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(s,t,oe),s.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new Ms(d.framebufferWidth,d.framebufferHeight,{format:Tn,type:bs,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil})}else{let oe=null,he=null,ge=null;p.depth&&(ge=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=p.stencil?qa:ka,he=p.stencil?Xa:Mo);let He={colorFormat:t.RGBA8,depthFormat:ge,scaleFactor:r};u=new XRWebGLBinding(s,t),f=u.createProjectionLayer(He),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),A=new Ms(f.textureWidth,f.textureHeight,{format:Tn,type:bs,depthTexture:new bf(f.textureWidth,f.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,oe),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),be.setContext(s),be.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function B(Y){for(let oe=0;oe<Y.removed.length;oe++){let he=Y.removed[oe],ge=S.indexOf(he);ge>=0&&(S[ge]=null,x[ge].disconnect(he))}for(let oe=0;oe<Y.added.length;oe++){let he=Y.added[oe],ge=S.indexOf(he);if(ge===-1){for(let Ue=0;Ue<x.length;Ue++)if(Ue>=S.length){S.push(he),ge=Ue;break}else if(S[Ue]===null){S[Ue]=he,ge=Ue;break}if(ge===-1)break}let He=x[ge];He&&He.connect(he)}}let D=new k,X=new k;function q(Y,oe,he){D.setFromMatrixPosition(oe.matrixWorld),X.setFromMatrixPosition(he.matrixWorld);let ge=D.distanceTo(X),He=oe.projectionMatrix.elements,Ue=he.projectionMatrix.elements,et=He[14]/(He[10]-1),mt=He[14]/(He[10]+1),tt=(He[9]+1)/He[5],F=(He[9]-1)/He[5],Ln=(He[8]-1)/He[0],Je=(Ue[8]+1)/Ue[0],rt=et*Ln,Be=et*Je,Mt=ge/(-Ln+Je),Ve=Mt*-Ln;if(oe.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ve),Y.translateZ(Mt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),He[10]===-1)Y.projectionMatrix.copy(oe.projectionMatrix),Y.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{let L=et+Mt,w=mt+Mt,K=rt-Ve,se=Be+(ge-Ve),le=tt*mt/w*L,ie=F*mt/w*L;Y.projectionMatrix.makePerspective(K,se,le,ie,L,w),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function Q(Y,oe){oe===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(oe.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let oe=Y.near,he=Y.far;v.texture!==null&&(v.depthNear>0&&(oe=v.depthNear),v.depthFar>0&&(he=v.depthFar)),b.near=R.near=C.near=oe,b.far=R.far=C.far=he,(_!==b.near||M!==b.far)&&(s.updateRenderState({depthNear:b.near,depthFar:b.far}),_=b.near,M=b.far);let ge=Y.parent,He=b.cameras;Q(b,ge);for(let Ue=0;Ue<He.length;Ue++)Q(He[Ue],ge);He.length===2?q(b,C,R):b.projectionMatrix.copy(C.projectionMatrix),ae(Y,b,ge)};function ae(Y,oe,he){he===null?Y.matrix.copy(oe.matrixWorld):(Y.matrix.copy(he.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(oe.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(oe.projectionMatrix),Y.projectionMatrixInverse.copy(oe.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=Ya*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return b},this.getFoveation=function(){if(!(f===null&&d===null))return l},this.setFoveation=function(Y){l=Y,f!==null&&(f.fixedFoveation=Y),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Y)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(b)};let ee=null;function H(Y,oe){if(h=oe.getViewerPose(c||o),y=oe,h!==null){let he=h.views;d!==null&&(e.setRenderTargetFramebuffer(A,d.framebuffer),e.setRenderTarget(A));let ge=!1;he.length!==b.cameras.length&&(b.cameras.length=0,ge=!0);for(let Ue=0;Ue<he.length;Ue++){let et=he[Ue],mt=null;if(d!==null)mt=d.getViewport(et);else{let F=u.getViewSubImage(f,et);mt=F.viewport,Ue===0&&(e.setRenderTargetTextures(A,F.colorTexture,f.ignoreDepthValues?void 0:F.depthStencilTexture),e.setRenderTarget(A))}let tt=ne[Ue];tt===void 0&&(tt=new Zt,tt.layers.enable(Ue),tt.viewport=new st,ne[Ue]=tt),tt.matrix.fromArray(et.transform.matrix),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.projectionMatrix.fromArray(et.projectionMatrix),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert(),tt.viewport.set(mt.x,mt.y,mt.width,mt.height),Ue===0&&(b.matrix.copy(tt.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),ge===!0&&b.cameras.push(tt)}let He=s.enabledFeatures;if(He&&He.includes("depth-sensing")){let Ue=u.getDepthInformation(he[0]);Ue&&Ue.isValid&&Ue.texture&&v.init(e,Ue,s.renderState)}}for(let he=0;he<x.length;he++){let ge=S[he],He=x[he];ge!==null&&He!==void 0&&He.update(ge,oe,c||o)}ee&&ee(Y,oe),oe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:oe}),y=null}let be=new Ob;be.setAnimationLoop(H),this.setAnimationLoop=function(Y){ee=Y},this.dispose=function(){}}},go=new vn,vC=new Pe;function xC(i,e){function t(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Nb(i)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function s(p,m,A,x,S){m.isMeshBasicMaterial||m.isMeshLambertMaterial?r(p,m):m.isMeshToonMaterial?(r(p,m),u(p,m)):m.isMeshPhongMaterial?(r(p,m),h(p,m)):m.isMeshStandardMaterial?(r(p,m),f(p,m),m.isMeshPhysicalMaterial&&d(p,m,S)):m.isMeshMatcapMaterial?(r(p,m),y(p,m)):m.isMeshDepthMaterial?r(p,m):m.isMeshDistanceMaterial?(r(p,m),v(p,m)):m.isMeshNormalMaterial?r(p,m):m.isLineBasicMaterial?(o(p,m),m.isLineDashedMaterial&&a(p,m)):m.isPointsMaterial?l(p,m,A,x):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,t(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===In&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,t(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===In&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,t(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,t(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let A=e.get(m),x=A.envMap,S=A.envMapRotation;x&&(p.envMap.value=x,go.copy(S),go.x*=-1,go.y*=-1,go.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(go.y*=-1,go.z*=-1),p.envMapRotation.value.setFromMatrix4(vC.makeRotationFromEuler(go)),p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,p.aoMapTransform))}function o(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform))}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,A,x){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*A,p.scale.value=x*.5,m.map&&(p.map.value=m.map,t(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function f(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function d(p,m,A){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===In&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,p.specularIntensityMapTransform))}function y(p,m){m.matcap&&(p.matcap.value=m.matcap)}function v(p,m){let A=e.get(m).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function bC(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(A,x){let S=x.program;n.uniformBlockBinding(A,S)}function c(A,x){let S=s[A.id];S===void 0&&(y(A),S=h(A),s[A.id]=S,A.addEventListener("dispose",p));let N=x.program;n.updateUBOMapping(A,N);let P=e.render.frame;r[A.id]!==P&&(f(A),r[A.id]=P)}function h(A){let x=u();A.__bindingPointIndex=x;let S=i.createBuffer(),N=A.__size,P=A.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,N,P),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function u(){for(let A=0;A<a;A++)if(o.indexOf(A)===-1)return o.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(A){let x=s[A.id],S=A.uniforms,N=A.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let P=0,C=S.length;P<C;P++){let R=Array.isArray(S[P])?S[P]:[S[P]];for(let ne=0,b=R.length;ne<b;ne++){let _=R[ne];if(d(_,P,ne,N)===!0){let M=_.__offset,I=Array.isArray(_.value)?_.value:[_.value],O=0;for(let B=0;B<I.length;B++){let D=I[B],X=v(D);typeof D=="number"||typeof D=="boolean"?(_.__data[0]=D,i.bufferSubData(i.UNIFORM_BUFFER,M+O,_.__data)):D.isMatrix3?(_.__data[0]=D.elements[0],_.__data[1]=D.elements[1],_.__data[2]=D.elements[2],_.__data[3]=0,_.__data[4]=D.elements[3],_.__data[5]=D.elements[4],_.__data[6]=D.elements[5],_.__data[7]=0,_.__data[8]=D.elements[6],_.__data[9]=D.elements[7],_.__data[10]=D.elements[8],_.__data[11]=0):(D.toArray(_.__data,O),O+=X.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,M,_.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(A,x,S,N){let P=A.value,C=x+"_"+S;if(N[C]===void 0)return typeof P=="number"||typeof P=="boolean"?N[C]=P:N[C]=P.clone(),!0;{let R=N[C];if(typeof P=="number"||typeof P=="boolean"){if(R!==P)return N[C]=P,!0}else if(R.equals(P)===!1)return R.copy(P),!0}return!1}function y(A){let x=A.uniforms,S=0,N=16;for(let C=0,R=x.length;C<R;C++){let ne=Array.isArray(x[C])?x[C]:[x[C]];for(let b=0,_=ne.length;b<_;b++){let M=ne[b],I=Array.isArray(M.value)?M.value:[M.value];for(let O=0,B=I.length;O<B;O++){let D=I[O],X=v(D),q=S%N,Q=q%X.boundary,ae=q+Q;S+=Q,ae!==0&&N-ae<X.storage&&(S+=N-ae),M.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=S,S+=X.storage}}}let P=S%N;return P>0&&(S+=N-P),A.__size=S,A.__cache={},this}function v(A){let x={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(x.boundary=4,x.storage=4):A.isVector2?(x.boundary=8,x.storage=8):A.isVector3||A.isColor?(x.boundary=16,x.storage=12):A.isVector4?(x.boundary=16,x.storage=16):A.isMatrix3?(x.boundary=48,x.storage=48):A.isMatrix4?(x.boundary=64,x.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),x}function p(A){let x=A.target;x.removeEventListener("dispose",p);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function m(){for(let A in s)i.deleteBuffer(s[A]);o=[],s={},r={}}return{bind:l,update:c,dispose:m}}var dr=class{constructor(e={}){let{canvas:t=w1(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=o;let d=new Uint32Array(4),y=new Int32Array(4),v=null,p=null,m=[],A=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Gt,this.toneMapping=lr,this.toneMappingExposure=1;let x=this,S=!1,N=0,P=0,C=null,R=-1,ne=null,b=new st,_=new st,M=null,I=new Oe(0),O=0,B=t.width,D=t.height,X=1,q=null,Q=null,ae=new st(0,0,B,D),ee=new st(0,0,B,D),H=!1,be=new Pc,Y=!1,oe=!1,he=new Pe,ge=new Pe,He=new k,Ue=new st,et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},mt=!1;function tt(){return C===null?X:1}let F=n;function Ln(E,V){return t.getContext(E,V)}try{let E={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${kc}`),t.addEventListener("webglcontextlost",re,!1),t.addEventListener("webglcontextrestored",ye,!1),t.addEventListener("webglcontextcreationerror",xe,!1),F===null){let V="webgl2";if(F=Ln(V,E),F===null)throw Ln(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Je,rt,Be,Mt,Ve,L,w,K,se,le,ie,Re,me,Me,ot,ue,Se,ke,ze,we,Qe,Ge,xt,z;function ve(){Je=new FI(F),Je.init(),Ge=new mC(F,Je),rt=new LI(F,Je,e,Ge),Be=new fC(F),rt.reverseDepthBuffer&&Be.buffers.depth.setReversed(!0),Mt=new zI(F),Ve=new QR,L=new pC(F,Je,Be,Ve,rt,Ge,Mt),w=new NI(x),K=new UI(x),se=new Y1(F),xt=new RI(F,se),le=new BI(F,se,Mt,xt),ie=new HI(F,le,se,Mt),ze=new VI(F,rt,L),ue=new PI(Ve),Re=new JR(x,w,K,Je,rt,xt,ue),me=new xC(x,Ve),Me=new tC,ot=new aC(Je),ke=new II(x,w,K,Be,ie,f,l),Se=new hC(x,ie,rt),z=new bC(F,Mt,rt,Be),we=new CI(F,Je,Mt),Qe=new kI(F,Je,Mt),Mt.programs=Re.programs,x.capabilities=rt,x.extensions=Je,x.properties=Ve,x.renderLists=Me,x.shadowMap=Se,x.state=Be,x.info=Mt}ve();let J=new Rg(x,F);this.xr=J,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let E=Je.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Je.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(E){E!==void 0&&(X=E,this.setSize(B,D,!1))},this.getSize=function(E){return E.set(B,D)},this.setSize=function(E,V,Z=!0){if(J.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=E,D=V,t.width=Math.floor(E*X),t.height=Math.floor(V*X),Z===!0&&(t.style.width=E+"px",t.style.height=V+"px"),this.setViewport(0,0,E,V)},this.getDrawingBufferSize=function(E){return E.set(B*X,D*X).floor()},this.setDrawingBufferSize=function(E,V,Z){B=E,D=V,X=Z,t.width=Math.floor(E*Z),t.height=Math.floor(V*Z),this.setViewport(0,0,E,V)},this.getCurrentViewport=function(E){return E.copy(b)},this.getViewport=function(E){return E.copy(ae)},this.setViewport=function(E,V,Z,j){E.isVector4?ae.set(E.x,E.y,E.z,E.w):ae.set(E,V,Z,j),Be.viewport(b.copy(ae).multiplyScalar(X).round())},this.getScissor=function(E){return E.copy(ee)},this.setScissor=function(E,V,Z,j){E.isVector4?ee.set(E.x,E.y,E.z,E.w):ee.set(E,V,Z,j),Be.scissor(_.copy(ee).multiplyScalar(X).round())},this.getScissorTest=function(){return H},this.setScissorTest=function(E){Be.setScissorTest(H=E)},this.setOpaqueSort=function(E){q=E},this.setTransparentSort=function(E){Q=E},this.getClearColor=function(E){return E.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor.apply(ke,arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha.apply(ke,arguments)},this.clear=function(E=!0,V=!0,Z=!0){let j=0;if(E){let G=!1;if(C!==null){let fe=C.texture.format;G=fe===Zg||fe===Kg||fe===Yg}if(G){let fe=C.texture.type,_e=fe===bs||fe===Mo||fe===Rc||fe===Xa||fe===Wg||fe===Xg,Ae=ke.getClearColor(),Te=ke.getClearAlpha(),De=Ae.r,Fe=Ae.g,Ce=Ae.b;_e?(d[0]=De,d[1]=Fe,d[2]=Ce,d[3]=Te,F.clearBufferuiv(F.COLOR,0,d)):(y[0]=De,y[1]=Fe,y[2]=Ce,y[3]=Te,F.clearBufferiv(F.COLOR,0,y))}else j|=F.COLOR_BUFFER_BIT}V&&(j|=F.DEPTH_BUFFER_BIT,F.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),Z&&(j|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),F.clear(j)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",re,!1),t.removeEventListener("webglcontextrestored",ye,!1),t.removeEventListener("webglcontextcreationerror",xe,!1),Me.dispose(),ot.dispose(),Ve.dispose(),w.dispose(),K.dispose(),ie.dispose(),xt.dispose(),z.dispose(),Re.dispose(),J.dispose(),J.removeEventListener("sessionstart",fy),J.removeEventListener("sessionend",dy),Mr.stop()};function re(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;let E=Mt.autoReset,V=Se.enabled,Z=Se.autoUpdate,j=Se.needsUpdate,G=Se.type;ve(),Mt.autoReset=E,Se.enabled=V,Se.autoUpdate=Z,Se.needsUpdate=j,Se.type=G}function xe(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function nt(E){let V=E.target;V.removeEventListener("dispose",nt),Ft(V)}function Ft(E){Sn(E),Ve.remove(E)}function Sn(E){let V=Ve.get(E).programs;V!==void 0&&(V.forEach(function(Z){Re.releaseProgram(Z)}),E.isShaderMaterial&&Re.releaseShaderCache(E))}this.renderBufferDirect=function(E,V,Z,j,G,fe){V===null&&(V=et);let _e=G.isMesh&&G.matrixWorld.determinant()<0,Ae=dM(E,V,Z,j,G);Be.setMaterial(j,_e);let Te=Z.index,De=1;if(j.wireframe===!0){if(Te=le.getWireframeAttribute(Z),Te===void 0)return;De=2}let Fe=Z.drawRange,Ce=Z.attributes.position,dt=Fe.start*De,St=(Fe.start+Fe.count)*De;fe!==null&&(dt=Math.max(dt,fe.start*De),St=Math.min(St,(fe.start+fe.count)*De)),Te!==null?(dt=Math.max(dt,0),St=Math.min(St,Te.count)):Ce!=null&&(dt=Math.max(dt,0),St=Math.min(St,Ce.count));let Tt=St-dt;if(Tt<0||Tt===1/0)return;xt.setup(G,j,Ae,Z,Te);let Pn,ht=we;if(Te!==null&&(Pn=se.get(Te),ht=Qe,ht.setIndex(Pn)),G.isMesh)j.wireframe===!0?(Be.setLineWidth(j.wireframeLinewidth*tt()),ht.setMode(F.LINES)):ht.setMode(F.TRIANGLES);else if(G.isLine){let Le=j.linewidth;Le===void 0&&(Le=1),Be.setLineWidth(Le*tt()),G.isLineSegments?ht.setMode(F.LINES):G.isLineLoop?ht.setMode(F.LINE_LOOP):ht.setMode(F.LINE_STRIP)}else G.isPoints?ht.setMode(F.POINTS):G.isSprite&&ht.setMode(F.TRIANGLES);if(G.isBatchedMesh)if(G._multiDrawInstances!==null)ht.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances);else if(Je.get("WEBGL_multi_draw"))ht.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let Le=G._multiDrawStarts,sn=G._multiDrawCounts,ut=G._multiDrawCount,vi=Te?se.get(Te).bytesPerElement:1,Fo=Ve.get(j).currentProgram.getUniforms();for(let Nn=0;Nn<ut;Nn++)Fo.setValue(F,"_gl_DrawID",Nn),ht.render(Le[Nn]/vi,sn[Nn])}else if(G.isInstancedMesh)ht.renderInstances(dt,Tt,G.count);else if(Z.isInstancedBufferGeometry){let Le=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,sn=Math.min(Z.instanceCount,Le);ht.renderInstances(dt,Tt,sn)}else ht.render(dt,Tt)};function at(E,V,Z){E.transparent===!0&&E.side===Yn&&E.forceSinglePass===!1?(E.side=In,E.needsUpdate=!0,dh(E,V,Z),E.side=Zi,E.needsUpdate=!0,dh(E,V,Z),E.side=Yn):dh(E,V,Z)}this.compile=function(E,V,Z=null){Z===null&&(Z=E),p=ot.get(Z),p.init(V),A.push(p),Z.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(p.pushLight(G),G.castShadow&&p.pushShadow(G))}),E!==Z&&E.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(p.pushLight(G),G.castShadow&&p.pushShadow(G))}),p.setupLights();let j=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let fe=G.material;if(fe)if(Array.isArray(fe))for(let _e=0;_e<fe.length;_e++){let Ae=fe[_e];at(Ae,Z,G),j.add(Ae)}else at(fe,Z,G),j.add(fe)}),A.pop(),p=null,j},this.compileAsync=function(E,V,Z=null){let j=this.compile(E,V,Z);return new Promise(G=>{function fe(){if(j.forEach(function(_e){Ve.get(_e).currentProgram.isReady()&&j.delete(_e)}),j.size===0){G(E);return}setTimeout(fe,10)}Je.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let wn=null;function $i(E){wn&&wn(E)}function fy(){Mr.stop()}function dy(){Mr.start()}let Mr=new Ob;Mr.setAnimationLoop($i),typeof self!="undefined"&&Mr.setContext(self),this.setAnimationLoop=function(E){wn=E,J.setAnimationLoop(E),E===null?Mr.stop():Mr.start()},J.addEventListener("sessionstart",fy),J.addEventListener("sessionend",dy),this.render=function(E,V){if(V!==void 0&&V.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),J.enabled===!0&&J.isPresenting===!0&&(J.cameraAutoUpdate===!0&&J.updateCamera(V),V=J.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,V,C),p=ot.get(E,A.length),p.init(V),A.push(p),ge.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),be.setFromProjectionMatrix(ge),oe=this.localClippingEnabled,Y=ue.init(this.clippingPlanes,oe),v=Me.get(E,m.length),v.init(),m.push(v),J.enabled===!0&&J.isPresenting===!0){let fe=x.xr.getDepthSensingMesh();fe!==null&&ud(fe,V,-1/0,x.sortObjects)}ud(E,V,0,x.sortObjects),v.finish(),x.sortObjects===!0&&v.sort(q,Q),mt=J.enabled===!1||J.isPresenting===!1||J.hasDepthSensing()===!1,mt&&ke.addToRenderList(v,E),this.info.render.frame++,Y===!0&&ue.beginShadows();let Z=p.state.shadowsArray;Se.render(Z,E,V),Y===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset();let j=v.opaque,G=v.transmissive;if(p.setupLights(),V.isArrayCamera){let fe=V.cameras;if(G.length>0)for(let _e=0,Ae=fe.length;_e<Ae;_e++){let Te=fe[_e];my(j,G,E,Te)}mt&&ke.render(E);for(let _e=0,Ae=fe.length;_e<Ae;_e++){let Te=fe[_e];py(v,E,Te,Te.viewport)}}else G.length>0&&my(j,G,E,V),mt&&ke.render(E),py(v,E,V);C!==null&&(L.updateMultisampleRenderTarget(C),L.updateRenderTargetMipmap(C)),E.isScene===!0&&E.onAfterRender(x,E,V),xt.resetDefaultState(),R=-1,ne=null,A.pop(),A.length>0?(p=A[A.length-1],Y===!0&&ue.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,m.pop(),m.length>0?v=m[m.length-1]:v=null};function ud(E,V,Z,j){if(E.visible===!1)return;if(E.layers.test(V.layers)){if(E.isGroup)Z=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(V);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||be.intersectsSprite(E)){j&&Ue.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ge);let _e=ie.update(E),Ae=E.material;Ae.visible&&v.push(E,_e,Ae,Z,Ue.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||be.intersectsObject(E))){let _e=ie.update(E),Ae=E.material;if(j&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ue.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Ue.copy(_e.boundingSphere.center)),Ue.applyMatrix4(E.matrixWorld).applyMatrix4(ge)),Array.isArray(Ae)){let Te=_e.groups;for(let De=0,Fe=Te.length;De<Fe;De++){let Ce=Te[De],dt=Ae[Ce.materialIndex];dt&&dt.visible&&v.push(E,_e,dt,Z,Ue.z,Ce)}}else Ae.visible&&v.push(E,_e,Ae,Z,Ue.z,null)}}let fe=E.children;for(let _e=0,Ae=fe.length;_e<Ae;_e++)ud(fe[_e],V,Z,j)}function py(E,V,Z,j){let G=E.opaque,fe=E.transmissive,_e=E.transparent;p.setupLightsView(Z),Y===!0&&ue.setGlobalState(x.clippingPlanes,Z),j&&Be.viewport(b.copy(j)),G.length>0&&fh(G,V,Z),fe.length>0&&fh(fe,V,Z),_e.length>0&&fh(_e,V,Z),Be.buffers.depth.setTest(!0),Be.buffers.depth.setMask(!0),Be.buffers.color.setMask(!0),Be.setPolygonOffset(!1)}function my(E,V,Z,j){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[j.id]===void 0&&(p.state.transmissionRenderTarget[j.id]=new Ms(1,1,{generateMipmaps:!0,type:Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float")?Vc:bs,minFilter:ui,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace}));let fe=p.state.transmissionRenderTarget[j.id],_e=j.viewport||b;fe.setSize(_e.z,_e.w);let Ae=x.getRenderTarget();x.setRenderTarget(fe),x.getClearColor(I),O=x.getClearAlpha(),O<1&&x.setClearColor(16777215,.5),x.clear(),mt&&ke.render(Z);let Te=x.toneMapping;x.toneMapping=lr;let De=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),p.setupLightsView(j),Y===!0&&ue.setGlobalState(x.clippingPlanes,j),fh(E,Z,j),L.updateMultisampleRenderTarget(fe),L.updateRenderTargetMipmap(fe),Je.has("WEBGL_multisampled_render_to_texture")===!1){let Fe=!1;for(let Ce=0,dt=V.length;Ce<dt;Ce++){let St=V[Ce],Tt=St.object,Pn=St.geometry,ht=St.material,Le=St.group;if(ht.side===Yn&&Tt.layers.test(j.layers)){let sn=ht.side;ht.side=In,ht.needsUpdate=!0,gy(Tt,Z,j,Pn,ht,Le),ht.side=sn,ht.needsUpdate=!0,Fe=!0}}Fe===!0&&(L.updateMultisampleRenderTarget(fe),L.updateRenderTargetMipmap(fe))}x.setRenderTarget(Ae),x.setClearColor(I,O),De!==void 0&&(j.viewport=De),x.toneMapping=Te}function fh(E,V,Z){let j=V.isScene===!0?V.overrideMaterial:null;for(let G=0,fe=E.length;G<fe;G++){let _e=E[G],Ae=_e.object,Te=_e.geometry,De=j===null?_e.material:j,Fe=_e.group;Ae.layers.test(Z.layers)&&gy(Ae,V,Z,Te,De,Fe)}}function gy(E,V,Z,j,G,fe){E.onBeforeRender(x,V,Z,j,G,fe),E.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(x,V,Z,j,E,fe),G.transparent===!0&&G.side===Yn&&G.forceSinglePass===!1?(G.side=In,G.needsUpdate=!0,x.renderBufferDirect(Z,V,j,G,E,fe),G.side=Zi,G.needsUpdate=!0,x.renderBufferDirect(Z,V,j,G,E,fe),G.side=Yn):x.renderBufferDirect(Z,V,j,G,E,fe),E.onAfterRender(x,V,Z,j,G,fe)}function dh(E,V,Z){V.isScene!==!0&&(V=et);let j=Ve.get(E),G=p.state.lights,fe=p.state.shadowsArray,_e=G.state.version,Ae=Re.getParameters(E,G.state,fe,V,Z),Te=Re.getProgramCacheKey(Ae),De=j.programs;j.environment=E.isMeshStandardMaterial?V.environment:null,j.fog=V.fog,j.envMap=(E.isMeshStandardMaterial?K:w).get(E.envMap||j.environment),j.envMapRotation=j.environment!==null&&E.envMap===null?V.environmentRotation:E.envMapRotation,De===void 0&&(E.addEventListener("dispose",nt),De=new Map,j.programs=De);let Fe=De.get(Te);if(Fe!==void 0){if(j.currentProgram===Fe&&j.lightsStateVersion===_e)return _y(E,Ae),Fe}else Ae.uniforms=Re.getUniforms(E),E.onBeforeCompile(Ae,x),Fe=Re.acquireProgram(Ae,Te),De.set(Te,Fe),j.uniforms=Ae.uniforms;let Ce=j.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ce.clippingPlanes=ue.uniform),_y(E,Ae),j.needsLights=mM(E),j.lightsStateVersion=_e,j.needsLights&&(Ce.ambientLightColor.value=G.state.ambient,Ce.lightProbe.value=G.state.probe,Ce.directionalLights.value=G.state.directional,Ce.directionalLightShadows.value=G.state.directionalShadow,Ce.spotLights.value=G.state.spot,Ce.spotLightShadows.value=G.state.spotShadow,Ce.rectAreaLights.value=G.state.rectArea,Ce.ltc_1.value=G.state.rectAreaLTC1,Ce.ltc_2.value=G.state.rectAreaLTC2,Ce.pointLights.value=G.state.point,Ce.pointLightShadows.value=G.state.pointShadow,Ce.hemisphereLights.value=G.state.hemi,Ce.directionalShadowMap.value=G.state.directionalShadowMap,Ce.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ce.spotShadowMap.value=G.state.spotShadowMap,Ce.spotLightMatrix.value=G.state.spotLightMatrix,Ce.spotLightMap.value=G.state.spotLightMap,Ce.pointShadowMap.value=G.state.pointShadowMap,Ce.pointShadowMatrix.value=G.state.pointShadowMatrix),j.currentProgram=Fe,j.uniformsList=null,Fe}function yy(E){if(E.uniformsList===null){let V=E.currentProgram.getUniforms();E.uniformsList=Va.seqWithValue(V.seq,E.uniforms)}return E.uniformsList}function _y(E,V){let Z=Ve.get(E);Z.outputColorSpace=V.outputColorSpace,Z.batching=V.batching,Z.batchingColor=V.batchingColor,Z.instancing=V.instancing,Z.instancingColor=V.instancingColor,Z.instancingMorph=V.instancingMorph,Z.skinning=V.skinning,Z.morphTargets=V.morphTargets,Z.morphNormals=V.morphNormals,Z.morphColors=V.morphColors,Z.morphTargetsCount=V.morphTargetsCount,Z.numClippingPlanes=V.numClippingPlanes,Z.numIntersection=V.numClipIntersection,Z.vertexAlphas=V.vertexAlphas,Z.vertexTangents=V.vertexTangents,Z.toneMapping=V.toneMapping}function dM(E,V,Z,j,G){V.isScene!==!0&&(V=et),L.resetTextureUnits();let fe=V.fog,_e=j.isMeshStandardMaterial?V.environment:null,Ae=C===null?x.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:nn,Te=(j.isMeshStandardMaterial?K:w).get(j.envMap||_e),De=j.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,Fe=!!Z.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),Ce=!!Z.morphAttributes.position,dt=!!Z.morphAttributes.normal,St=!!Z.morphAttributes.color,Tt=lr;j.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(Tt=x.toneMapping);let Pn=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ht=Pn!==void 0?Pn.length:0,Le=Ve.get(j),sn=p.state.lights;if(Y===!0&&(oe===!0||E!==ne)){let ni=E===ne&&j.id===R;ue.setState(j,E,ni)}let ut=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==sn.state.version||Le.outputColorSpace!==Ae||G.isBatchedMesh&&Le.batching===!1||!G.isBatchedMesh&&Le.batching===!0||G.isBatchedMesh&&Le.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Le.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Le.instancing===!1||!G.isInstancedMesh&&Le.instancing===!0||G.isSkinnedMesh&&Le.skinning===!1||!G.isSkinnedMesh&&Le.skinning===!0||G.isInstancedMesh&&Le.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Le.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Le.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Le.instancingMorph===!1&&G.morphTexture!==null||Le.envMap!==Te||j.fog===!0&&Le.fog!==fe||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ue.numPlanes||Le.numIntersection!==ue.numIntersection)||Le.vertexAlphas!==De||Le.vertexTangents!==Fe||Le.morphTargets!==Ce||Le.morphNormals!==dt||Le.morphColors!==St||Le.toneMapping!==Tt||Le.morphTargetsCount!==ht)&&(ut=!0):(ut=!0,Le.__version=j.version);let vi=Le.currentProgram;ut===!0&&(vi=dh(j,V,G));let Fo=!1,Nn=!1,fd=!1,Pt=vi.getUniforms(),Rs=Le.uniforms;if(Be.useProgram(vi.program)&&(Fo=!0,Nn=!0,fd=!0),j.id!==R&&(R=j.id,Nn=!0),Fo||ne!==E){rt.reverseDepthBuffer?(he.copy(E.projectionMatrix),E1(he),T1(he),Pt.setValue(F,"projectionMatrix",he)):Pt.setValue(F,"projectionMatrix",E.projectionMatrix),Pt.setValue(F,"viewMatrix",E.matrixWorldInverse);let ni=Pt.map.cameraPosition;ni!==void 0&&ni.setValue(F,He.setFromMatrixPosition(E.matrixWorld)),rt.logarithmicDepthBuffer&&Pt.setValue(F,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&Pt.setValue(F,"isOrthographic",E.isOrthographicCamera===!0),ne!==E&&(ne=E,Nn=!0,fd=!0)}if(G.isSkinnedMesh){Pt.setOptional(F,G,"bindMatrix"),Pt.setOptional(F,G,"bindMatrixInverse");let ni=G.skeleton;ni&&(ni.boneTexture===null&&ni.computeBoneTexture(),Pt.setValue(F,"boneTexture",ni.boneTexture,L))}G.isBatchedMesh&&(Pt.setOptional(F,G,"batchingTexture"),Pt.setValue(F,"batchingTexture",G._matricesTexture,L),Pt.setOptional(F,G,"batchingIdTexture"),Pt.setValue(F,"batchingIdTexture",G._indirectTexture,L),Pt.setOptional(F,G,"batchingColorTexture"),G._colorsTexture!==null&&Pt.setValue(F,"batchingColorTexture",G._colorsTexture,L));let dd=Z.morphAttributes;if((dd.position!==void 0||dd.normal!==void 0||dd.color!==void 0)&&ze.update(G,Z,vi),(Nn||Le.receiveShadow!==G.receiveShadow)&&(Le.receiveShadow=G.receiveShadow,Pt.setValue(F,"receiveShadow",G.receiveShadow)),j.isMeshGouraudMaterial&&j.envMap!==null&&(Rs.envMap.value=Te,Rs.flipEnvMap.value=Te.isCubeTexture&&Te.isRenderTargetTexture===!1?-1:1),j.isMeshStandardMaterial&&j.envMap===null&&V.environment!==null&&(Rs.envMapIntensity.value=V.environmentIntensity),Nn&&(Pt.setValue(F,"toneMappingExposure",x.toneMappingExposure),Le.needsLights&&pM(Rs,fd),fe&&j.fog===!0&&me.refreshFogUniforms(Rs,fe),me.refreshMaterialUniforms(Rs,j,X,D,p.state.transmissionRenderTarget[E.id]),Va.upload(F,yy(Le),Rs,L)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(F,yy(Le),Rs,L),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&Pt.setValue(F,"center",G.center),Pt.setValue(F,"modelViewMatrix",G.modelViewMatrix),Pt.setValue(F,"normalMatrix",G.normalMatrix),Pt.setValue(F,"modelMatrix",G.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){let ni=j.uniformsGroups;for(let pd=0,gM=ni.length;pd<gM;pd++){let vy=ni[pd];z.update(vy,vi),z.bind(vy,vi)}}return vi}function pM(E,V){E.ambientLightColor.needsUpdate=V,E.lightProbe.needsUpdate=V,E.directionalLights.needsUpdate=V,E.directionalLightShadows.needsUpdate=V,E.pointLights.needsUpdate=V,E.pointLightShadows.needsUpdate=V,E.spotLights.needsUpdate=V,E.spotLightShadows.needsUpdate=V,E.rectAreaLights.needsUpdate=V,E.hemisphereLights.needsUpdate=V}function mM(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(E,V,Z){Ve.get(E.texture).__webglTexture=V,Ve.get(E.depthTexture).__webglTexture=Z;let j=Ve.get(E);j.__hasExternalTextures=!0,j.__autoAllocateDepthBuffer=Z===void 0,j.__autoAllocateDepthBuffer||Je.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),j.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(E,V){let Z=Ve.get(E);Z.__webglFramebuffer=V,Z.__useDefaultFramebuffer=V===void 0},this.setRenderTarget=function(E,V=0,Z=0){C=E,N=V,P=Z;let j=!0,G=null,fe=!1,_e=!1;if(E){let Te=Ve.get(E);if(Te.__useDefaultFramebuffer!==void 0)Be.bindFramebuffer(F.FRAMEBUFFER,null),j=!1;else if(Te.__webglFramebuffer===void 0)L.setupRenderTarget(E);else if(Te.__hasExternalTextures)L.rebindTextures(E,Ve.get(E.texture).__webglTexture,Ve.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){let Ce=E.depthTexture;if(Te.__boundDepthTexture!==Ce){if(Ce!==null&&Ve.has(Ce)&&(E.width!==Ce.image.width||E.height!==Ce.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");L.setupDepthRenderbuffer(E)}}let De=E.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(_e=!0);let Fe=Ve.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Fe[V])?G=Fe[V][Z]:G=Fe[V],fe=!0):E.samples>0&&L.useMultisampledRTT(E)===!1?G=Ve.get(E).__webglMultisampledFramebuffer:Array.isArray(Fe)?G=Fe[Z]:G=Fe,b.copy(E.viewport),_.copy(E.scissor),M=E.scissorTest}else b.copy(ae).multiplyScalar(X).floor(),_.copy(ee).multiplyScalar(X).floor(),M=H;if(Be.bindFramebuffer(F.FRAMEBUFFER,G)&&j&&Be.drawBuffers(E,G),Be.viewport(b),Be.scissor(_),Be.setScissorTest(M),fe){let Te=Ve.get(E.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+V,Te.__webglTexture,Z)}else if(_e){let Te=Ve.get(E.texture),De=V||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,Te.__webglTexture,Z||0,De)}R=-1},this.readRenderTargetPixels=function(E,V,Z,j,G,fe,_e){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=Ve.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(Ae=Ae[_e]),Ae){Be.bindFramebuffer(F.FRAMEBUFFER,Ae);try{let Te=E.texture,De=Te.format,Fe=Te.type;if(!rt.textureFormatReadable(De)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!rt.textureTypeReadable(Fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=E.width-j&&Z>=0&&Z<=E.height-G&&F.readPixels(V,Z,j,G,Ge.convert(De),Ge.convert(Fe),fe)}finally{let Te=C!==null?Ve.get(C).__webglFramebuffer:null;Be.bindFramebuffer(F.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(E,V,Z,j,G,fe,_e){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ae=Ve.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(Ae=Ae[_e]),Ae){let Te=E.texture,De=Te.format,Fe=Te.type;if(!rt.textureFormatReadable(De))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!rt.textureTypeReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(V>=0&&V<=E.width-j&&Z>=0&&Z<=E.height-G){Be.bindFramebuffer(F.FRAMEBUFFER,Ae);let Ce=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,Ce),F.bufferData(F.PIXEL_PACK_BUFFER,fe.byteLength,F.STREAM_READ),F.readPixels(V,Z,j,G,Ge.convert(De),Ge.convert(Fe),0);let dt=C!==null?Ve.get(C).__webglFramebuffer:null;Be.bindFramebuffer(F.FRAMEBUFFER,dt);let St=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await A1(F,St,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,Ce),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,fe),F.deleteBuffer(Ce),F.deleteSync(St),fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,V=null,Z=0){E.isTexture!==!0&&(uf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),V=arguments[0]||null,E=arguments[1]);let j=Math.pow(2,-Z),G=Math.floor(E.image.width*j),fe=Math.floor(E.image.height*j),_e=V!==null?V.x:0,Ae=V!==null?V.y:0;L.setTexture2D(E,0),F.copyTexSubImage2D(F.TEXTURE_2D,Z,0,0,_e,Ae,G,fe),Be.unbindTexture()},this.copyTextureToTexture=function(E,V,Z=null,j=null,G=0){E.isTexture!==!0&&(uf("WebGLRenderer: copyTextureToTexture function signature has changed."),j=arguments[0]||null,E=arguments[1],V=arguments[2],G=arguments[3]||0,Z=null);let fe,_e,Ae,Te,De,Fe;Z!==null?(fe=Z.max.x-Z.min.x,_e=Z.max.y-Z.min.y,Ae=Z.min.x,Te=Z.min.y):(fe=E.image.width,_e=E.image.height,Ae=0,Te=0),j!==null?(De=j.x,Fe=j.y):(De=0,Fe=0);let Ce=Ge.convert(V.format),dt=Ge.convert(V.type);L.setTexture2D(V,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,V.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,V.unpackAlignment);let St=F.getParameter(F.UNPACK_ROW_LENGTH),Tt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Pn=F.getParameter(F.UNPACK_SKIP_PIXELS),ht=F.getParameter(F.UNPACK_SKIP_ROWS),Le=F.getParameter(F.UNPACK_SKIP_IMAGES),sn=E.isCompressedTexture?E.mipmaps[G]:E.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,sn.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,sn.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Ae),F.pixelStorei(F.UNPACK_SKIP_ROWS,Te),E.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,G,De,Fe,fe,_e,Ce,dt,sn.data):E.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,G,De,Fe,sn.width,sn.height,Ce,sn.data):F.texSubImage2D(F.TEXTURE_2D,G,De,Fe,fe,_e,Ce,dt,sn),F.pixelStorei(F.UNPACK_ROW_LENGTH,St),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Tt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Pn),F.pixelStorei(F.UNPACK_SKIP_ROWS,ht),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Le),G===0&&V.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),Be.unbindTexture()},this.copyTextureToTexture3D=function(E,V,Z=null,j=null,G=0){E.isTexture!==!0&&(uf("WebGLRenderer: copyTextureToTexture3D function signature has changed."),Z=arguments[0]||null,j=arguments[1]||null,E=arguments[2],V=arguments[3],G=arguments[4]||0);let fe,_e,Ae,Te,De,Fe,Ce,dt,St,Tt=E.isCompressedTexture?E.mipmaps[G]:E.image;Z!==null?(fe=Z.max.x-Z.min.x,_e=Z.max.y-Z.min.y,Ae=Z.max.z-Z.min.z,Te=Z.min.x,De=Z.min.y,Fe=Z.min.z):(fe=Tt.width,_e=Tt.height,Ae=Tt.depth,Te=0,De=0,Fe=0),j!==null?(Ce=j.x,dt=j.y,St=j.z):(Ce=0,dt=0,St=0);let Pn=Ge.convert(V.format),ht=Ge.convert(V.type),Le;if(V.isData3DTexture)L.setTexture3D(V,0),Le=F.TEXTURE_3D;else if(V.isDataArrayTexture||V.isCompressedArrayTexture)L.setTexture2DArray(V,0),Le=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,V.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,V.unpackAlignment);let sn=F.getParameter(F.UNPACK_ROW_LENGTH),ut=F.getParameter(F.UNPACK_IMAGE_HEIGHT),vi=F.getParameter(F.UNPACK_SKIP_PIXELS),Fo=F.getParameter(F.UNPACK_SKIP_ROWS),Nn=F.getParameter(F.UNPACK_SKIP_IMAGES);F.pixelStorei(F.UNPACK_ROW_LENGTH,Tt.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Tt.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Te),F.pixelStorei(F.UNPACK_SKIP_ROWS,De),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Fe),E.isDataTexture||E.isData3DTexture?F.texSubImage3D(Le,G,Ce,dt,St,fe,_e,Ae,Pn,ht,Tt.data):V.isCompressedArrayTexture?F.compressedTexSubImage3D(Le,G,Ce,dt,St,fe,_e,Ae,Pn,Tt.data):F.texSubImage3D(Le,G,Ce,dt,St,fe,_e,Ae,Pn,ht,Tt),F.pixelStorei(F.UNPACK_ROW_LENGTH,sn),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,ut),F.pixelStorei(F.UNPACK_SKIP_PIXELS,vi),F.pixelStorei(F.UNPACK_SKIP_ROWS,Fo),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Nn),G===0&&V.generateMipmaps&&F.generateMipmap(Le),Be.unbindTexture()},this.initRenderTarget=function(E){Ve.get(E).__webglFramebuffer===void 0&&L.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?L.setTextureCube(E,0):E.isData3DTexture?L.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?L.setTexture2DArray(E,0):L.setTexture2D(E,0),Be.unbindTexture()},this.resetState=function(){N=0,P=0,C=null,Be.reset(),xt.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vs}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===$g?"display-p3":"srgb",t.unpackColorSpace=it.workingColorSpace===Vf?"display-p3":"srgb"}};var Jn=class extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new vn,this.environmentIntensity=1,this.environmentRotation=new vn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Nc=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=dg,this.updateRanges=[],this.version=0,this.uuid=Oi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Oi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Oi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},bn=new k,Ao=class{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix4(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyNormalMatrix(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.transformDirection(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Li(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=pt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=pt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=pt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=pt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=pt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Li(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Li(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Li(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Li(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array),s=pt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=pt(t,this.array),n=pt(n,this.array),s=pt(s,this.array),r=pt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new vt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ao(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var $x=new k,jx=new st,Jx=new st,MC=new k,Qx=new Pe,Ju=new k,Am=new $n,eb=new Pe,Em=new So,Mf=class extends Ct{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ix,this.bindMatrix=new Pe,this.bindMatrixInverse=new Pe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new di),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ju),this.boundingBox.expandByPoint(Ju)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new $n),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ju),this.boundingSphere.expandByPoint(Ju)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Am.copy(this.boundingSphere),Am.applyMatrix4(s),e.ray.intersectsSphere(Am)!==!1&&(eb.copy(s).invert(),Em.copy(e.ray).applyMatrix4(eb),!(this.boundingBox!==null&&Em.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Em)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new st,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ix?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$A?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,s=this.geometry;jx.fromBufferAttribute(s.attributes.skinIndex,e),Jx.fromBufferAttribute(s.attributes.skinWeight,e),$x.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let o=Jx.getComponent(r);if(o!==0){let a=jx.getComponent(r);Qx.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(MC.copy($x).applyMatrix4(Qx),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},Oc=class extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}},Sf=class extends Et{constructor(e=null,t=1,n=1,s,r,o,a,l,c=tn,h=tn,u,f){super(null,o,a,l,c,h,s,r,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tb=new Pe,SC=new Pe,ja=class{constructor(e=[],t=[]){this.uuid=Oi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new Pe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Pe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,o=e.length;r<o;r++){let a=e[r]?e[r].matrixWorld:SC;tb.multiplyMatrices(a,t[r]),tb.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new ja(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Sf(t,e,e,Tn,Ni);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){let r=e.bones[n],o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Oc),this.bones.push(o),this.boneInverses.push(new Pe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){let o=t[s];e.bones.push(o.uuid);let a=n[s];e.boneInverses.push(a.toArray())}return e}},Eo=class extends vt{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ua=new Pe,nb=new Pe,Qu=[],ib=new di,wC=new Pe,bc=new Ct,Mc=new $n,wf=class extends Ct{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Eo(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,wC)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new di),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ua),ib.copy(e.boundingBox).applyMatrix4(Ua),this.boundingBox.union(ib)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new $n),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ua),Mc.copy(e.boundingSphere).applyMatrix4(Ua),this.boundingSphere.union(Mc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=s[o+a]}raycast(e,t){let n=this.matrixWorld,s=this.count;if(bc.geometry=this.geometry,bc.material=this.material,bc.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Mc.copy(this.boundingSphere),Mc.applyMatrix4(n),e.ray.intersectsSphere(Mc)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,Ua),nb.multiplyMatrices(n,Ua),bc.matrixWorld=nb,bc.raycast(e,Qu);for(let o=0,a=Qu.length;o<a;o++){let l=Qu[o];l.instanceId=r,l.object=this,t.push(l)}Qu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Eo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new Sf(new Float32Array(s*this.count),s,this.count,qg,Ni));let r=this.morphTexture.source.data.data,o=0;for(let c=0;c<n.length;c++)o+=n[c];let a=this.geometry.morphTargetsRelative?1:1-o,l=s*e;r[l]=a,r.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};var Dc=class extends jn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Af=new k,Ef=new k,sb=new Pe,Sc=new So,ef=new $n,Tm=new k,rb=new k,Ja=class extends _t{constructor(e=new Cn,t=new Dc){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Af.fromBufferAttribute(t,s-1),Ef.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Af.distanceTo(Ef);e.setAttribute("lineDistance",new fi(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ef.copy(n.boundingSphere),ef.applyMatrix4(s),ef.radius+=r,e.ray.intersectsSphere(ef)===!1)return;sb.copy(s).invert(),Sc.copy(e.ray).applyMatrix4(sb);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){let d=Math.max(0,o.start),y=Math.min(h.count,o.start+o.count);for(let v=d,p=y-1;v<p;v+=c){let m=h.getX(v),A=h.getX(v+1),x=tf(this,e,Sc,l,m,A);x&&t.push(x)}if(this.isLineLoop){let v=h.getX(y-1),p=h.getX(d),m=tf(this,e,Sc,l,v,p);m&&t.push(m)}}else{let d=Math.max(0,o.start),y=Math.min(f.count,o.start+o.count);for(let v=d,p=y-1;v<p;v+=c){let m=tf(this,e,Sc,l,v,v+1);m&&t.push(m)}if(this.isLineLoop){let v=tf(this,e,Sc,l,y-1,d);v&&t.push(v)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function tf(i,e,t,n,s,r){let o=i.geometry.attributes.position;if(Af.fromBufferAttribute(o,s),Ef.fromBufferAttribute(o,r),t.distanceSqToSegment(Af,Ef,Tm,rb)>n)return;Tm.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Tm);if(!(l<e.near||l>e.far))return{distance:l,point:rb.clone().applyMatrix4(i.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:i}}var ob=new k,ab=new k,Tf=class extends Ja{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)ob.fromBufferAttribute(t,s),ab.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+ob.distanceTo(ab);e.setAttribute("lineDistance",new fi(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},If=class extends Ja{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Uc=class extends jn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},lb=new Pe,Cg=new So,nf=new $n,sf=new k,Rf=class extends _t{constructor(e=new Cn,t=new Uc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),nf.copy(n.boundingSphere),nf.applyMatrix4(s),nf.radius+=r,e.ray.intersectsSphere(nf)===!1)return;lb.copy(s).invert(),Cg.copy(e.ray).applyMatrix4(lb);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,o.start),d=Math.min(c.count,o.start+o.count);for(let y=f,v=d;y<v;y++){let p=c.getX(y);sf.fromBufferAttribute(u,p),cb(sf,p,l,s,e,t,this)}}else{let f=Math.max(0,o.start),d=Math.min(u.count,o.start+o.count);for(let y=f,v=d;y<v;y++)sf.fromBufferAttribute(u,y),cb(sf,y,l,s,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function cb(i,e,t,n,s,r,o){let a=Cg.distanceSqToPoint(i);if(a<t){let l=new k;Cg.closestPointToPoint(i,l),l.applyMatrix4(n);let c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Qa=class extends Et{constructor(e,t,n,s,r,o,a,l,c,h,u,f){super(null,o,a,l,c,h,s,r,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};var Cf=class extends Et{constructor(e,t,n,s,r,o,a,l,c){super(e,t,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var el=class extends jn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rb,this.normalScale=new Ye(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Qn=class extends el{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ye(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return _n(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};function rf(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function AC(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function EC(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function hb(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let l=0;l!==e;++l)s[o++]=i[a+l]}return s}function kb(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=i[s++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=i[s++];while(r!==void 0)}var pr=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Lg=class extends pr{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:sx,endingEnd:sx}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case rx:r=e,a=2*t-n;break;case ox:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case rx:o=e,l=2*n-t;break;case ox:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,y=(n-t)/(s-t),v=y*y,p=v*y,m=-f*p+2*f*v-f*y,A=(1+f)*p+(-1.5-2*f)*v+(-.5+f)*y+1,x=(-1-d)*p+(1.5+d)*v+.5*y,S=d*p-d*v;for(let N=0;N!==a;++N)r[N]=m*o[h+N]+A*o[c+N]+x*o[l+N]+S*o[u+N];return r}},Pg=class extends pr{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(s-t),u=1-h;for(let f=0;f!==a;++f)r[f]=o[c+f]*u+o[l+f]*h;return r}},Ng=class extends pr{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},gi=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=rf(t,this.TimeBufferType),this.values=rf(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:rf(e.times,Array),values:rf(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ng(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Lg(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case cr:t=this.InterpolantFactoryMethodDiscrete;break;case hr:t=this.InterpolantFactoryMethodLinear;break;case jp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return cr;case this.InterpolantFactoryMethodLinear:return hr;case this.InterpolantFactoryMethodSmooth:return jp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&AC(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===jp,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(s)l=!0;else{let u=a*n,f=u-n,d=u+n;for(let y=0;y!==n;++y){let v=t[u+y];if(v!==t[f+y]||v!==t[d+y]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};gi.prototype.TimeBufferType=Float32Array;gi.prototype.ValueBufferType=Float32Array;gi.prototype.DefaultInterpolation=hr;var mr=class extends gi{constructor(e,t,n){super(e,t,n)}};mr.prototype.ValueTypeName="bool";mr.prototype.ValueBufferType=Array;mr.prototype.DefaultInterpolation=cr;mr.prototype.InterpolantFactoryMethodLinear=void 0;mr.prototype.InterpolantFactoryMethodSmooth=void 0;var Lf=class extends gi{};Lf.prototype.ValueTypeName="color";var Ss=class extends gi{};Ss.prototype.ValueTypeName="number";var Og=class extends pr{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)Zn.slerpFlat(r,0,o,c-a,o,c,l);return r}},ws=class extends gi{InterpolantFactoryMethodLinear(e){return new Og(this.times,this.values,this.getValueSize(),e)}};ws.prototype.ValueTypeName="quaternion";ws.prototype.InterpolantFactoryMethodSmooth=void 0;var gr=class extends gi{constructor(e,t,n){super(e,t,n)}};gr.prototype.ValueTypeName="string";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=cr;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;var As=class extends gi{};As.prototype.ValueTypeName="vector";var Pf=class{constructor(e="",t=-1,n=[],s=jA){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Oi(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(IC(n[o]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(gi.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,o=[];for(let a=0;a<r;a++){let l=[],c=[];l.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let h=EC(l);l=hb(l,1,h),c=hb(c,1,h),!s&&l[0]===0&&(l.push(r),c.push(c[0])),o.push(new Ss(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let s={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){let c=e[a],h=c.name.match(r);if(h&&h.length>1){let u=h[1],f=s[u];f||(s[u]=f=[]),f.push(c)}}let o=[];for(let a in s)o.push(this.CreateFromMorphTargetSequence(a,s[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,f,d,y,v){if(d.length!==0){let p=[],m=[];kb(d,p,m,y),p.length!==0&&v.push(new u(f,p,m))}},s=[],r=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let u=0;u<c.length;u++){let f=c[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let d={},y;for(y=0;y<f.length;y++)if(f[y].morphTargets)for(let v=0;v<f[y].morphTargets.length;v++)d[f[y].morphTargets[v]]=-1;for(let v in d){let p=[],m=[];for(let A=0;A!==f[y].morphTargets.length;++A){let x=f[y];p.push(x.time),m.push(x.morphTarget===v?1:0)}s.push(new Ss(".morphTargetInfluence["+v+"]",p,m))}l=d.length*o}else{let d=".bones["+t[u].name+"]";n(As,d+".position",f,"pos",s),n(ws,d+".quaternion",f,"rot",s),n(As,d+".scale",f,"scl",s)}}return s.length===0?null:new this(r,l,s,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function TC(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ss;case"vector":case"vector2":case"vector3":case"vector4":return As;case"color":return Lf;case"quaternion":return ws;case"bool":case"boolean":return mr;case"string":return gr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function IC(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=TC(i.type);if(i.times===void 0){let t=[],n=[];kb(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}var or={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Dg=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){let d=c[u],y=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return y}return null}}},RC=new Dg,Es=class{constructor(e){this.manager=e!==void 0?e:RC,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Es.DEFAULT_MATERIAL_NAME="__DEFAULT";var gs={},Ug=class extends Error{constructor(e,t){super(e),this.response=t}},Fc=class extends Es{constructor(e){super(e)}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=or.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(gs[e]!==void 0){gs[e].push({onLoad:t,onProgress:n,onError:s});return}gs[e]=[],gs[e].push({onLoad:t,onProgress:n,onError:s});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||c.body===void 0||c.body.getReader===void 0)return c;let h=gs[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=f?parseInt(f):0,y=d!==0,v=0,p=new ReadableStream({start(m){A();function A(){u.read().then(({done:x,value:S})=>{if(x)m.close();else{v+=S.byteLength;let N=new ProgressEvent("progress",{lengthComputable:y,loaded:v,total:d});for(let P=0,C=h.length;P<C;P++){let R=h[P];R.onProgress&&R.onProgress(N)}m.enqueue(S),A()}},x=>{m.error(x)})}}});return new Response(p)}else throw new Ug(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(y=>d.decode(y))}}}).then(c=>{or.add(e,c);let h=gs[e];delete gs[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{let h=gs[e];if(h===void 0)throw this.manager.itemError(e),c;delete gs[e];for(let u=0,f=h.length;u<f;u++){let d=h[u];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var Fg=class extends Es{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=or.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;let a=Cc("img");function l(){h(),or.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(u){h(),s&&s(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}};var yr=class extends Es{constructor(e){super(e)}load(e,t,n,s){let r=new Et,o=new Fg(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}},tl=class extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},Nf=class extends tl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Im=new Pe,ub=new k,fb=new k,Bc=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ye(512,512),this.map=null,this.mapPass=null,this.matrix=new Pe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pc,this._frameExtents=new Ye(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;ub.setFromMatrixPosition(e.matrixWorld),t.position.copy(ub),fb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(fb),t.updateMatrixWorld(),Im.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Im),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Im)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Bg=class extends Bc{constructor(){super(new Zt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=Ya*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Of=class extends tl{constructor(e,t,n=0,s=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=s,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new Bg}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},db=new Pe,wc=new k,Rm=new k,kg=class extends Bc{constructor(){super(new Zt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ye(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new k(1,0,0),new k(-1,0,0),new k(0,0,1),new k(0,0,-1),new k(0,1,0),new k(0,-1,0)],this._cubeUps=[new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,0,1),new k(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,s=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),wc.setFromMatrixPosition(e.matrixWorld),n.position.copy(wc),Rm.copy(n.position),Rm.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Rm),n.updateMatrixWorld(),s.makeTranslation(-wc.x,-wc.y,-wc.z),db.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(db)}},Df=class extends tl{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new kg}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},zg=class extends Bc{constructor(){super(new $a(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Uf=class extends tl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new zg}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var _r=class{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,s=e.length;n<s;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}};var Ff=class extends Es{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=or.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{s&&s(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return or.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),or.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});or.add(e,l),r.manager.itemStart(e)}};var Qg="\\[\\]\\.:\\/",CC=new RegExp("["+Qg+"]","g"),e0="[^"+Qg+"]",LC="[^"+Qg.replace("\\.","")+"]",PC=/((?:WC+[\/:])*)/.source.replace("WC",e0),NC=/(WCOD+)?/.source.replace("WCOD",LC),OC=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e0),DC=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e0),UC=new RegExp("^"+PC+NC+OC+DC+"$"),FC=["material","materials","bones","map"],Vg=class{constructor(e,t,n){let s=n||Ke.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Ke=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Ke.parseTrackName(t),this.node=Ke.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ke.Composite(e,t,n):new Ke(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(CC,"")}static parseTrackName(e){let t=UC.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);FC.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=Ke.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[s];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ke.Composite=Vg;Ke.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ke.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ke.prototype.GetterByBindingType=[Ke.prototype._getValue_direct,Ke.prototype._getValue_array,Ke.prototype._getValue_arrayElement,Ke.prototype._getValue_toArray];Ke.prototype.SetterByBindingTypeAndVersioning=[[Ke.prototype._setValue_direct,Ke.prototype._setValue_direct_setNeedsUpdate,Ke.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ke.prototype._setValue_array,Ke.prototype._setValue_array_setNeedsUpdate,Ke.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ke.prototype._setValue_arrayElement,Ke.prototype._setValue_arrayElement_setNeedsUpdate,Ke.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ke.prototype._setValue_fromArray,Ke.prototype._setValue_fromArray_setNeedsUpdate,Ke.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var zU=new Float32Array(1);var nl=class{constructor(e){this.value=e}clone(){return new nl(this.value.clone===void 0?this.value:this.value.clone())}};var pb=new Pe,Bf=class{constructor(e,t,n=0,s=1/0){this.ray=new So(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Lc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return pb.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(pb),this}intersectObject(e,t=!0,n=[]){return Hg(e,this,n,t),n.sort(mb),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Hg(e[s],this,n,t);return n.sort(mb),n}};function mb(i,e){return i.distance-e.distance}function Hg(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){let r=i.children;for(let o=0,a=r.length;o<a;o++)Hg(r[o],e,t,!0)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:kc}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=kc);T();function t0(i,e){if(e===Ib)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Hc||e===zf){let t=i.getIndex();if(t===null){let o=[],a=i.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,s=[];if(e===Hc)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let r=i.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Gf=class extends Es{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new l0(t)}),this.register(function(t){return new c0(t)}),this.register(function(t){return new _0(t)}),this.register(function(t){return new v0(t)}),this.register(function(t){return new x0(t)}),this.register(function(t){return new u0(t)}),this.register(function(t){return new f0(t)}),this.register(function(t){return new d0(t)}),this.register(function(t){return new p0(t)}),this.register(function(t){return new a0(t)}),this.register(function(t){return new m0(t)}),this.register(function(t){return new h0(t)}),this.register(function(t){return new y0(t)}),this.register(function(t){return new g0(t)}),this.register(function(t){return new r0(t)}),this.register(function(t){return new b0(t)}),this.register(function(t){return new M0(t)})}load(e,t,n,s){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let c=_r.extractUrlBase(e);o=_r.resolveURL(c,this.path)}else o=_r.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new Fc(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r,o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Wb){try{o[Ze.KHR_BINARY_GLTF]=new S0(e)}catch(u){s&&s(u);return}r=JSON.parse(o[Ze.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new C0(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let u=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(u){case Ze.KHR_MATERIALS_UNLIT:o[u]=new o0;break;case Ze.KHR_DRACO_MESH_COMPRESSION:o[u]=new w0(r,this.dracoLoader);break;case Ze.KHR_TEXTURE_TRANSFORM:o[u]=new A0;break;case Ze.KHR_MESH_QUANTIZATION:o[u]=new E0;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};function BC(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}var Ze={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},r0=class{constructor(e){this.parser=e,this.name=Ze.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,s=t.cache.get(n);if(s)return s;let r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,h=new Oe(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],nn);let u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Uf(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Df(h),c.distance=u;break;case"spot":c=new Of(h),c.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,Ts(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}},o0=class{constructor(){this.name=Ze.KHR_MATERIALS_UNLIT}getMaterialType(){return Rn}extendParams(e,t,n){let s=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],nn),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Gt))}return Promise.all(s)}},a0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},l0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ye(a,a)}return Promise.all(r)}},c0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}},h0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},u0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[];t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],nn)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Gt)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},f0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},d0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(a[0],a[1],a[2],nn),Promise.all(r)}},p0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},m0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new Oe().setRGB(a[0],a[1],a[2],nn),o.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,Gt)),Promise.all(r)}},g0=class{constructor(e){this.parser=e,this.name=Ze.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}},y0=class{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Qn}extendMaterialParams(e,t){let n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();let r=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},_0=class{constructor(e){this.parser=e,this.name=Ze.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;let r=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},v0=class{constructor(e){this.parser=e,this.name=Ze.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},x0=class{constructor(e){this.parser=e,this.name=Ze.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},b0=class{constructor(e){this.name=Ze.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let l=s.byteOffset||0,c=s.byteLength||0,h=s.count,u=s.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,s.mode,s.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,s.mode,s.filter),d})})}else return null}},M0=class{constructor(e){this.name=Ze.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let c of s.primitives)if(c.mode!==yi.TRIANGLES&&c.mode!==yi.TRIANGLE_STRIP&&c.mode!==yi.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let h=c.pop(),u=h.isGroup?h.children:[h],f=c[0].count,d=[];for(let y of u){let v=new Pe,p=new k,m=new Zn,A=new k(1,1,1),x=new wf(y.geometry,y.material,f);for(let S=0;S<f;S++)l.TRANSLATION&&p.fromBufferAttribute(l.TRANSLATION,S),l.ROTATION&&m.fromBufferAttribute(l.ROTATION,S),l.SCALE&&A.fromBufferAttribute(l.SCALE,S),x.setMatrixAt(S,v.compose(p,m,A));for(let S in l)if(S==="_COLOR_0"){let N=l[S];x.instanceColor=new Eo(N.array,N.itemSize,N.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&y.geometry.setAttribute(S,l[S]);_t.prototype.copy.call(x,y),this.parser.assignFinalMaterial(x),d.push(x)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}},Wb="glTF",Gc=12,zb={JSON:1313821514,BIN:5130562},S0=class{constructor(e){this.name=Ze.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Gc),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Wb)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let s=this.header.length-Gc,r=new DataView(e,Gc),o=0;for(;o<s;){let a=r.getUint32(o,!0);o+=4;let l=r.getUint32(o,!0);if(o+=4,l===zb.JSON){let c=new Uint8Array(e,Gc+o,a);this.content=n.decode(c)}else if(l===zb.BIN){let c=Gc+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},w0=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ze.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(let h in o){let u=I0[h]||h.toLowerCase();a[u]=o[h]}for(let h in e.attributes){let u=I0[h]||h.toLowerCase();if(o[h]!==void 0){let f=n.accessors[e.attributes[h]],d=rl[f.componentType];c[u]=d.name,l[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){s.decodeDracoFile(h,function(d){for(let y in d.attributes){let v=d.attributes[y],p=l[y];p!==void 0&&(v.normalized=p)}u(d)},a,c,nn,f)})})}},A0=class{constructor(){this.name=Ze.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},E0=class{constructor(){this.name=Ze.KHR_MESH_QUANTIZATION}},Wf=class extends pr{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=s-t,u=(n-t)/h,f=u*u,d=f*u,y=e*c,v=y-c,p=-2*d+3*f,m=d-f,A=1-p,x=m-f+u;for(let S=0;S!==a;S++){let N=o[v+S+a],P=o[v+S+l]*h,C=o[y+S+a],R=o[y+S]*h;r[S]=A*N+x*P+p*C+m*R}return r}},kC=new Zn,T0=class extends Wf{interpolate_(e,t,n,s){let r=super.interpolate_(e,t,n,s);return kC.fromArray(r).normalize().toArray(r),r}},yi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},rl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Vb={9728:tn,9729:Wt,9984:zc,9985:xo,9986:rr,9987:ui},Hb={33071:Pi,33648:bo,10497:xs},n0={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},I0={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},vr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zC={CUBICSPLINE:void 0,LINEAR:hr,STEP:cr},i0={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function VC(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new el({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Zi})),i.DefaultMaterial}function To(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Ts(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function HC(i,e,t){let n=!1,s=!1,r=!1;for(let c=0,h=e.length;c<h;c++){let u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);let o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){let u=e[c];if(n){let f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;o.push(f)}if(s){let f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;a.push(f)}if(r){let f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){let h=c[0],u=c[1],f=c[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=f),i.morphTargetsRelative=!0,i})}function GC(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function WC(i){let e,t=i.extensions&&i.extensions[Ze.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+s0(t.attributes):e=i.indices+":"+s0(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+s0(i.targets[n]);return e}function s0(i){let e="",t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function R0(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function XC(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}var qC=new Pe,C0=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new BC,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator!="undefined"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);s=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap=="undefined"||n&&s<17||r&&o<98?this.textureLoader=new yr(this.options.manager):this.textureLoader=new Ff(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Fc(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return To(r,a,s),Ts(a,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){let o=t[s].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){let o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let s=n.clone(),r=(o,a)=>{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,h]of o.children.entries())r(h,a.children[c])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let s=e(t[n]);if(s)return s}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let s=0;s<t.length;s++){let r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ze.KHR_BINARY_GLTF].body);let s=this.options;return new Promise(function(r,o){n.load(_r.resolveURL(t.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){let t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){let o=n0[s.type],a=rl[s.componentType],l=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new vt(c,o,l))}let r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],l=n0[s.type],c=rl[s.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,f=s.byteOffset||0,d=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0,v,p;if(d&&d!==u){let m=Math.floor(f/d),A="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+m+":"+s.count,x=t.cache.get(A);x||(v=new c(a,m*d,s.count*d/h),x=new Nc(v,d/h),t.cache.add(A,x)),p=new Ao(x,l,f%d/h,y)}else a===null?v=new c(s.count*l):v=new c(a,f,s.count*l),p=new vt(v,l,y);if(s.sparse!==void 0){let m=n0.SCALAR,A=rl[s.sparse.indices.componentType],x=s.sparse.indices.byteOffset||0,S=s.sparse.values.byteOffset||0,N=new A(o[1],x,s.sparse.count*m),P=new c(o[2],S,s.sparse.count*l);a!==null&&(p=new vt(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let C=0,R=N.length;C<R;C++){let ne=N[C];if(p.setX(ne,P[C*l]),l>=2&&p.setY(ne,P[C*l+1]),l>=3&&p.setZ(ne,P[C*l+2]),l>=4&&p.setW(ne,P[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=y}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let f=(r.samplers||{})[o.sampler]||{};return h.magFilter=Vb[f.magFilter]||Wt,h.minFilter=Vb[f.minFilter]||ui,h.wrapS=Hb[f.wrapS]||xs,h.wrapT=Hb[f.wrapT]||xs,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let o=s.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(f),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(l).then(function(u){return new Promise(function(f,d){let y=f;t.isImageBitmapLoader===!0&&(y=function(v){let p=new Et(v);p.needsUpdate=!0,f(p)}),t.load(_r.resolveURL(u,r.path),y,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),Ts(u,o),u.userData.mimeType=o.mimeType||XC(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[Ze.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Ze.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=r.associations.get(o);o=r.extensions[Ze.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Uc,jn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Dc,jn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return el}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],o,a={},l=r.extensions||{},c=[];if(l[Ze.KHR_MATERIALS_UNLIT]){let u=s[Ze.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new Oe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],nn),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,Gt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Yn);let h=r.alphaMode||i0.OPAQUE;if(h===i0.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===i0.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==Rn&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ye(1,1),r.normalTexture.scale!==void 0)){let u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==Rn&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==Rn){let u=r.emissiveFactor;a.emissive=new Oe().setRGB(u[0],u[1],u[2],nn)}return r.emissiveTexture!==void 0&&o!==Rn&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Gt)),Promise.all(c).then(function(){let u=new o(a);return r.name&&(u.name=r.name),Ts(u,r),t.associations.set(u,{materials:e}),r.extensions&&To(s,u,r),u})}createUniqueName(e){let t=Ke.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[Ze.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Gb(l,a,t)})}let o=[];for(let a=0,l=e.length;a<l;a++){let c=e[a],h=WC(c),u=s[h];if(u)o.push(u.promise);else{let f;c.extensions&&c.extensions[Ze.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=Gb(new Cn,c,t),s[h]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){let h=o[l].material===void 0?VC(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){let c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let d=0,y=h.length;d<y;d++){let v=h[d],p=o[d],m,A=c[d];if(p.mode===yi.TRIANGLES||p.mode===yi.TRIANGLE_STRIP||p.mode===yi.TRIANGLE_FAN||p.mode===void 0)m=r.isSkinnedMesh===!0?new Mf(v,A):new Ct(v,A),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),p.mode===yi.TRIANGLE_STRIP?m.geometry=t0(m.geometry,zf):p.mode===yi.TRIANGLE_FAN&&(m.geometry=t0(m.geometry,Hc));else if(p.mode===yi.LINES)m=new Tf(v,A);else if(p.mode===yi.LINE_STRIP)m=new Ja(v,A);else if(p.mode===yi.LINE_LOOP)m=new If(v,A);else if(p.mode===yi.POINTS)m=new Rf(v,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(m.geometry.morphAttributes).length>0&&GC(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),Ts(m,r),p.extensions&&To(s,m,p),t.assignFinalMaterial(m),u.push(m)}for(let d=0,y=u.length;d<y;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&To(s,u[0],r),u[0];let f=new Ki;r.extensions&&To(s,f,r),t.associations.set(f,{meshes:e});for(let d=0,y=u.length;d<y;d++)f.add(u[d]);return f})}loadCamera(e){let t,n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Zt(il.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new $a(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Ts(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){let r=s.pop(),o=s,a=[],l=[];for(let c=0,h=o.length;c<h;c++){let u=o[c];if(u){a.push(u);let f=new Pe;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ja(a,l)})}loadAnimation(e){let t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let u=0,f=s.channels.length;u<f;u++){let d=s.channels[u],y=s.samplers[d.sampler],v=d.target,p=v.node,m=s.parameters!==void 0?s.parameters[y.input]:y.input,A=s.parameters!==void 0?s.parameters[y.output]:y.output;v.node!==void 0&&(o.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",m)),l.push(this.getDependency("accessor",A)),c.push(y),h.push(v))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){let f=u[0],d=u[1],y=u[2],v=u[3],p=u[4],m=[];for(let A=0,x=f.length;A<x;A++){let S=f[A],N=d[A],P=y[A],C=v[A],R=p[A];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();let ne=n._createAnimationTracks(S,N,P,C,R);if(ne)for(let b=0;b<ne.length;b++)m.push(ne[b])}return new Pf(r,void 0,m)})}createNodeMesh(e){let t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(!!a.isMesh)for(let l=0,c=s.weights.length;l<c;l++)a.morphTargetInfluences[l]=s.weights[l]}),o})}loadNode(e){let t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));let l=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){let h=c[0],u=c[1],f=c[2];f!==null&&h.traverse(function(d){!d.isSkinnedMesh||d.bind(f,qC)});for(let d=0,y=u.length;d<y;d++)h.add(u[d]);return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new Oc:c.length>1?h=new Ki:c.length===1?h=c[0]:h=new _t,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),Ts(h,r),r.extensions&&To(n,h,r),r.matrix!==void 0){let u=new Pe;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new Ki;n.name&&(r.name=s.createUniqueName(n.name)),Ts(r,n),n.extensions&&To(t,r,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(s.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,u=l.length;h<u;h++)r.add(l[h]);let c=h=>{let u=new Map;for(let[f,d]of s.associations)(f instanceof jn||f instanceof Et)&&u.set(f,d);return h.traverse(f=>{let d=s.associations.get(f);d!=null&&u.set(f,d)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,n,s,r){let o=[],a=e.name?e.name:e.uuid,l=[];vr[r.path]===vr.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(vr[r.path]){case vr.weights:c=Ss;break;case vr.rotation:c=ws;break;case vr.position:case vr.scale:c=As;break;default:switch(n.itemSize){case 1:c=Ss;break;case 2:case 3:default:c=As;break}break}let h=s.interpolation!==void 0?zC[s.interpolation]:hr,u=this._getArrayFromAccessor(n);for(let f=0,d=l.length;f<d;f++){let y=new c(l[f]+"."+vr[r.path],t.array,u,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=R0(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let s=this instanceof ws?T0:Wf;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function YC(i,e,t){let n=e.attributes,s=new di;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(s.set(new k(l[0],l[1],l[2]),new k(c[0],c[1],c[2])),a.normalized){let h=R0(rl[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=e.targets;if(r!==void 0){let a=new k,l=new k;for(let c=0,h=r.length;c<h;c++){let u=r[c];if(u.POSITION!==void 0){let f=t.json.accessors[u.POSITION],d=f.min,y=f.max;if(d!==void 0&&y!==void 0){if(l.setX(Math.max(Math.abs(d[0]),Math.abs(y[0]))),l.setY(Math.max(Math.abs(d[1]),Math.abs(y[1]))),l.setZ(Math.max(Math.abs(d[2]),Math.abs(y[2]))),f.normalized){let v=R0(rl[f.componentType]);l.multiplyScalar(v)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}i.boundingBox=s;let o=new $n;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=o}function Gb(i,e,t){let n=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){i.setAttribute(a,l)})}for(let o in n){let a=I0[o]||o.toLowerCase();a in i.attributes||s.push(r(n[o],a))}if(e.indices!==void 0&&!i.index){let o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});s.push(o)}return it.workingColorSpace!==nn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${it.workingColorSpace}" not supported.`),Ts(i,e),YC(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?HC(i,e.targets,t):i})}T();var KC=Math.PI/180,YU=180/Math.PI;function xr(i){return i*KC}function Xb(i,e){let t,n=new Bf,s=new Map;function r(h){return h.getSource(i).serialize().data.features.filter(u=>u.properties.featureClass===Ne.MODEL3D)}function o(h){var m,A,x;let u=new fr,f=h.id,d=s.get(f),y=d?d.scene:new Jn,v=new Nf(11646413,9998214,1.1);v.position.set(0,10,0),(!d||d.feature.properties.url!==h.properties.url)&&(y.clear(),s.delete(f),new Gf().load(h.properties.url,function(N){N.scene.rotateX(xr(90)),y.add(N.scene),y.add(v)}.bind(this)));let p=new k((m=h.properties.scale[0])!=null?m:1,(A=h.properties.scale[0])!=null?A:1,(x=h.properties.scale[0])!=null?x:1);y.scale.set(p.x,p.y,p.z),y.setRotationFromEuler(a(h.properties)),s.set(f,{feature:h,scene:y,camera:u})}function a(h){var y,v,p;let u=xr(360-((y=h.rotation[0])!=null?y:0)),f=xr((v=h.rotation[1])!=null?v:0),d=xr(360-((p=h.rotation[2])!=null?p:0));return new vn(u,f,d,"ZXY")}function l(h){let u=h.geometry.coordinates,f=0,d=mapboxgl.MercatorCoordinate.fromLngLat(u,f),y={x:90,y:0,z:0};return{modelTransform:{translateX:d.x,translateY:d.y,translateZ:d.z,rotateX:xr(y.x+h.properties.rotation[0]),rotateY:xr(y.y+h.properties.rotation[1]),rotateZ:xr(y.z+h.properties.rotation[2]),scale:d.meterInMercatorCoordinateUnits()},sceneKey:h.id}}function c(h,u){let f=h.modelTransform,d=new Pe().fromArray(u),y=new Pe().makeTranslation(f.translateX,f.translateY,f.translateZ).scale(new k(f.scale,-f.scale,f.scale)),v=s.get(h.sceneKey).camera;v.projectionMatrix=d.multiply(y),t.resetState(),t.render(s.get(h.sceneKey).scene,v)}return{id:e,type:"custom",renderingMode:"3d",onAdd:(h,u)=>{this.map=h,t=new dr({canvas:h.getCanvas(),context:u,antialias:!0}),t.autoClear=!1},render:(h,u)=>{r(this.map).map(f=>(o(f),f)).map(f=>l(f)).forEach(f=>c(f,u)),this.map.triggerRepaint()},queryRendered3DModels:h=>{let u=r(this.map).filter(d=>d.properties.clickable),f=ZC(h,this.map,s,n,u);return f.length===0?null:f.reduce((d,y)=>{let v=d.intersect?Math.min(...d.intersect.map(m=>m.distance)):Number.MAX_SAFE_INTEGER,p=Math.min(...y.intersect.map(m=>m.distance));return v<p?d:y},{}).feature}}}function ZC(i,e,t,n,s){let r=new Ye;r.x=i.x/e.transform.width*2-1,r.y=1-i.y/e.transform.height*2;let o=[];return t.forEach(a=>{if(!s.some(v=>a.feature.id===v.id))return;let c=a.camera,h=new Pe().copy(c.projectionMatrix).invert(),u=new k().applyMatrix4(h),d=new k(r.x,r.y,1).applyMatrix4(h).clone().sub(u).normalize();n.set(u,d);let y=n.intersectObjects(a.scene.children,!0);y.length>0&&o.push({intersect:y,feature:a.feature})}),o}T();var $C=!!document.createElement("canvas").getContext("webgl2"),Wc,ol,al,Io,qf,Yf,qb,Kf,Yb,Zf,Kb,Xf=class{constructor(e){U(this,Yf);U(this,Kf);U(this,Zf);U(this,Wc,new Map);U(this,ol,new Map);U(this,al,void 0);U(this,Io,void 0);U(this,qf,new yr);cn(this,"id");cn(this,"renderingMode","3d");cn(this,"type","custom");this.id=e}setData(e){W(this,Wc,e.filter(t=>{var n;return((n=t==null?void 0:t.properties)==null?void 0:n.featureClass)===Ne.MODEL2D}).reduce((t,n)=>{var y,v;let s=n==null?void 0:n.id.toString(),r={scene:new Jn,transformation:new Pe},o=mapboxgl.MercatorCoordinate.fromLngLat((v=(y=n.properties)==null?void 0:y.anchor)!=null?v:n.geometry.coordinates,0),a=new mi(n.properties.widthMeters,n.properties.heightMeters),l=te(this,Kf,Yb).call(this,o),c=te(this,Yf,qb).call(this,n.properties),{scene:h,transformation:u}=r,f=new Rn({map:te(this,Zf,Kb).call(this,n.properties.imageUrl),transparent:!0,depthTest:!1}),d=new Ct(a,f);return h.add(d),h.setRotationFromEuler(c),u.makeTranslation(o.x,o.y,o.z),u.scale(l),t.set(s,r)},new Map))}onAdd(e,t){W(this,al,e),W(this,Io,new dr({canvas:g(this,al).getCanvas(),context:t,antialias:!0})),g(this,Io).autoClear=!1}render(e,t){let n=new fr;for(let s of g(this,Wc).values()){let r=s.scene;if(r){let o=s.transformation;n.projectionMatrix=new Pe().fromArray(t).multiply(o),g(this,Io).resetState(),g(this,Io).render(r,n)}}g(this,al).triggerRepaint()}};Wc=new WeakMap,ol=new WeakMap,al=new WeakMap,Io=new WeakMap,qf=new WeakMap,Yf=new WeakSet,qb=function(e){let t=L0(0),n=L0(0),s=L0(-(e.bearing%360+360)%360);return new vn(t,n,s,"XYZ")},Kf=new WeakSet,Yb=function(e){let t=e.meterInMercatorCoordinateUnits();return new k(t,-t,t)},Zf=new WeakSet,Kb=function(e){if(!g(this,ol).has(e)){let t=g(this,qf).load(e);$C&&(t.minFilter=Wt),g(this,ol).set(e,t)}return g(this,ol).get(e).clone()};function L0(i){return i*.01745329251}var Di="MI_GEOJSON_SOURCE",$f="MI_FLOOR_PLAN_SOURCE",jC="MI_FLOOR_PLAN_FILL",JC="MI_FLOOR_PLAN_LINE",Zb="MI_HIGHLIGHT_LAYER",QC="MI_MODEL_2D_LAYER",Lu="MI_MODEL_3D_LAYER",e2="MI_OUTLINE_LAYER",ba="MI_POINT_LAYER",Xc="MI_POLYGON_LAYER",qc="MI_ROOMS_LAYER",Yc="MI_TILES_LAYER",jf="MI_TILES_SOURCE",P0="MI_WALLS_LAYER",t2="MI_FLAT_LABELS_LAYER",N0="MI_GRAPHIC_LABELS_LAYER",$c,ll,jc,Jc,Ro,D0,Qf,$b,Qc,O0,Co,Kc,Jf=class extends zt{constructor({element:t,maxZoom:n,accessToken:s,pitch:r=0,bearing:o=0,...a}){super();U(this,Qf);U(this,Qc);U(this,Co);U(this,$c,ci.INITIALIZING);U(this,ll,void 0);U(this,jc,void 0);U(this,Jc,new Xf(QC));U(this,Ro,null);U(this,D0,void 0);if(W(this,jc,this.isMaxZoomLevelValid(n)),mapboxgl&&mapboxgl.Map){mapboxgl.accessToken=s;let l=new mapboxgl.Map({container:t,style:"mapbox://styles/mapbox/streets-v11",maxZoom:Zc(n),bearing:o,pitch:r,...a});Bt.log(bt.appLifeTime.MAP_INSTANTIATED),l.on("load",()=>{l.addSource($f,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),l.addSource(Di,{type:"geojson",data:{type:"FeatureCollection",features:[]}});let{wallOpacity:c,extrusionOpacity:h}=te(this,Qc,O0).call(this);l.addLayer({filter:["any",["==","featureClass",Ne.POLYGON],["==","featureClass",Ne.MODEL2D]],id:Xc,type:"fill",source:Di,layout:{"fill-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"fill-color":["to-color",["get","fillColor"],ce.polygon.fillColor],"fill-opacity":["number",["get","fillOpacity"],ce.polygon.fillOpacity]}}),l.addLayer({filter:["==","featureClass",Ne.POLYGON],id:e2,type:"line",source:Di,layout:{"line-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"line-width":["number",["get","strokeWidth"],ce.polygon.strokeWidth],"line-color":["to-color",["get","strokeColor"],ce.polygon.strokeColor],"line-opacity":["number",["get","strokeOpacity"],ce.polygon.strokeOpacity]}}),l.addLayer({id:jC,type:"fill",source:$f,paint:{"fill-color":["match",["get","type"],"floorplan","#ffffff","extrusion","#fcfcf2","#ffffff"]}}),l.addLayer({id:JC,type:"line",source:$f,filter:["==",["get","type"],"floorplan"],paint:{"line-width":1.2,"line-color":"#6B7280"}}),l.addLayer(g(this,Jc)),l.addLayer({filter:["any",["==","featureClass",Ne.LABEL_FLAT]],id:t2,source:Di,type:"symbol",layout:{"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-size":["interpolate",["exponential",2],["zoom"],1,["number",["*",["get","labelStyleSize"],2384185791015625e-22],["*",ce.labelStyle.textSize,2384185791015625e-22]],22,["number",["get","labelStyleSize"]],23,["number",["*",["get","labelStyleSize"],2],["*",ce.labelStyle.textSize,2]],24,["number",["*",["get","labelStyleSize"],4],["*",ce.labelStyle.textSize,4]],25,["number",["*",["get","labelStyleSize"],8],["*",ce.labelStyle.textSize,8]]],"text-ignore-placement":!0,"text-allow-overlap":!0,"icon-allow-overlap":!0,"text-rotation-alignment":"map","text-rotate":["number",["get","labelStyleBearing"],ce.labelStyle.bearing]},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),W(this,Ro,Xb(Di,Lu)),l.addLayer(g(this,Ro)),l.addLayer({filter:["any",["==","featureClass",Ne.WALL_EXTRUSION]],id:P0,type:"fill-extrusion",source:Di,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":c,"fill-extrusion-height":["get","height"]}}),l.addLayer({id:qc,filter:["==","featureClass",Ne.ROOM_EXTRUSION],type:"fill-extrusion",source:Di,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":h,"fill-extrusion-height":["get","height"]}}),l.addLayer({filter:["all",["!=","iconAllowOverlap",!0],["any",["==","featureClass",Ne.POINT],["==","featureClass",Ne.LABEL_FLOATING]]],id:ba,type:"symbol",source:Di,layout:{"icon-allow-overlap":!1,"icon-optional":!0,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"text-padding":0,"text-optional":!0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-size":["number",["get","labelStyleSize"],ce.labelStyle.textSize],"text-letter-spacing":-.01,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!1},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),l.addLayer({filter:["all",["==","iconAllowOverlap",!0],["any",["==","featureClass",Ne.POINT],["==","featureClass",Ne.LABEL_FLOATING]]],id:Zb,type:"symbol",source:Di,layout:{"icon-allow-overlap":!0,"icon-optional":!1,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MIN_SAFE_INTEGER],"text-padding":0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Regular","Arial Unicode MS Regular"]],"text-size":["number",["get","labelSize"],12],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!0},paint:{"text-color":["to-color",["get","labelColor"],"hsl(217, 11%, 23%)"],"text-halo-color":["to-color",["get","labelShadowColor"],"#000"],"text-halo-width":["number",["get","labelShadowBlur"],0],"text-halo-blur":["case",[">",["get","labelShadowBlur"],0],1,0]}}),l.addLayer({filter:["any",["==","featureClass",Ne.LABEL_GRAPHIC]],id:N0,source:Di,type:"symbol",layout:{"icon-text-fit":"both","icon-image":["get","imageId"],"icon-allow-overlap":!0,"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"text-size":["number",["get","labelStyleSize"],ce.labelStyle.textSize],"text-allow-overlap":!0,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-padding":0},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),W(this,$c,ci.READY),l.on("mousemove",te(this,Qf,$b).call(this,100)),this.emit("ready")}),l.on("moveend",()=>{this.emit("idle")}),l.on("move",()=>{this.emit("bounds_changed")}),l.on("center_changed",()=>{this.emit("center_changed")}),l.on("click",c=>{var u;let h=((u=g(this,Ro))==null?void 0:u.queryRendered3DModels(c.point))||l.queryRenderedFeatures(c.point,{layers:[Xc,ba,qc,N0]}).find(f=>{var d,y;return!((d=f==null?void 0:f.properties)!=null&&d.originalId.startsWith("MI_"))&&((y=f==null?void 0:f.properties)==null?void 0:y.clickable)===!0});h&&h.properties.clickable!==!1&&this.emit("click",h.properties.originalId)}),l.on("maptypeid_changed",()=>{this.emit("maptypeid_changed")}),l.on("touchstart",()=>{this.emit("user_interaction")}),l.on("zoomend",()=>{this.emit("zoom_changed"),this.emit("user_interaction")}),l.on("tilesloaded",()=>{this.emit("tiles_loaded")}),l.on("dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),l.on("drag",()=>{this.emit("drag")}),l.on("dragend",()=>{this.emit("dragend")}),l.on("rotateend",()=>{this.emit("rotateend")}),l.on("styleimagemissing",c=>{l.loadImage(c.id,(h,u)=>{h||l.hasImage(c.id)||l.addImage(c.id,u)})}),this.addListener("solutionconfig_changed",()=>{let{wallOpacity:c,extrusionOpacity:h}=te(this,Qc,O0).call(this);l.getLayer(P0)&&l.setPaintProperty(P0,"fill-extrusion-opacity",c),l.getLayer(qc)&&l.setPaintProperty(qc,"fill-extrusion-opacity",h)}),this.set("map",l),this.set("element",t),this.set("rotatable",!0),this.set("tiltable",!0)}}isMaxZoomLevelValid(t){return Number.isInteger(+t)&&t>=0}get isReady(){return g(this,$c)===ci.READY}setViewData(t){var r;let n=this.getMap(),s=n==null?void 0:n.getSource(Di);if(s){let o=Array.from(t.values());for(let a of o.filter(l=>l.properties.icon instanceof Image)){let l=a.properties.icon;n.hasImage(l.src)||n.addImage(l.src,l)}for(let a of o.filter(l=>l.properties.featureClass===Ne.LABEL_GRAPHIC)){if(!(((r=a==null?void 0:a.properties)==null?void 0:r.backgroundImage)instanceof Image))continue;let l=a.properties.backgroundImage,c=`${l.src}+${JSON.stringify(a.properties.iconTextFit)}`;n.hasImage(c)||n.addImage(c,l,a.properties.iconTextFit),a.properties.imageId=c}s.setData({type:"FeatureCollection",features:o}),g(this,Jc).setData(o)}}setMapsIndoorsTileURL(t){let n=this.getMap();this.get("tileUrl")!==t&&t>""&&(this.set("tileUrl",t),n.getLayer(Yc)||this.isReady?te(this,Co,Kc).call(this):n.once("load",()=>{te(this,Co,Kc).call(this)}))}get DirectionsRenderer(){return xa}getMap(){return this.get("map")}deallocate(){this.getMap().remove(),this.set("map",null)}getBounds(){let t=this.get("map");if(t&&t.getBounds){let n=t.getBounds();return{west:n.getWest(),south:n.getSouth(),east:n.getEast(),north:n.getNorth()}}return null}getBearing(){let t=this.get("map");return t&&t.getBearing?t.getBearing():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setLabelOptions(){}fitBounds({west:t,south:n,east:s,north:r},o){return new Promise(a=>{let l=this.get("map");if(l&&l.fitBounds){this.once("idle",a);let c={lon:t,lat:n},h={lon:s,lat:r};l.fitBounds([c,h],{padding:o,bearing:l.getBearing(),pitch:l.getPitch(),linear:!0,duration:1e3})}})}getZoom(){let t=this.get("map");return t&&t.getZoom?t.getZoom()+1:null}getMaxZoom(){let t=this.get("map");if(t&&t.getMaxZoom)return t.getMaxZoom()+1}enableZoom22(){let t=this.get("map");t&&t.setMaxZoom&&!g(this,jc)&&(t.setMaxZoom(Zc(25)),t.getLayer(Yc)||this.isReady?te(this,Co,Kc).call(this):t.once("load",()=>{te(this,Co,Kc).call(this)}))}getPitch(){let t=this.get("map");return t&&t.getPitch?t.getPitch():0}setZoom(t){let n=this.get("map");n&&n.setZoom&&n.setZoom(t-1)}getCenter(){let t=this.get("map");return t&&t.getCenter?t.getCenter():null}setCenter({lat:t,lng:n}){let s=this.get("map");s&&s.setCenter&&s.setCenter([n,t])}setSolutionConfig(t){this.set("solutionconfig",t)}panTo({lat:t,lng:n}){let s=this.get("map");s&&s.panTo&&s.panTo([n,t])}easeTo({center:t,rotation:n,tilt:s,easing:r}){let o=this.get("map");o&&o.easeTo&&o.easeTo({center:t,bearing:n,pitch:s,easing:r})}tilt(t,n){let s=this.get("map");n?s.easeTo({pitch:t,duration:n}):s.setPitch(t)}rotate(t){this.get("map").setBearing(t)}panToBounds({west:t,south:n,east:s,north:r}){let o=this.get("map");if(o&&o.panTo&&mapboxgl.LngLatBounds){let l=new mapboxgl.LngLatBounds([t,n,s,r]).getCenter();this.panTo(l)}}getDiv(){return this.get("element")}project({lat:t,lng:n}){let s=this.get("map");return s&&s.project?s.project({lat:t,lng:n}):null}unproject({x:t,y:n}){let s=this.get("map");return s&&s.unproject?s.unproject([t,n]):null}addLogo(){if(this.isReady){if(this.get("map")){let n=this.getDiv();if(n){let s=document.createElement("img");s.id="mi_map_logo",s.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",s.style.width="96px",s.style.height="20px",s.style.margin="5px",s.style.position="absolute",s.style.right="0",s.style.bottom="18px",n.appendChild(s),new ResizeObserver(()=>{n.clientWidth<359||n.clientHeight<359?s.style.display!=="none"&&(s.style.display="none"):s.style.display==="none"&&(s.style.display="")}).observe(n)}}}else this.once("ready",()=>{this.addLogo()})}setPositionProvider(t){let n=this.getMap();g(this,ll)?g(this,ll).setProvider(t):W(this,ll,new Iu(n,t))}setFloorPlan(t){let n=this.get("map");this.isReady?n.getSource($f).setData(t):n.once("load",()=>this.setFloorPlan(t))}hideFeatures(){}setSlot(){}getSlot(){}};$c=new WeakMap,ll=new WeakMap,jc=new WeakMap,Jc=new WeakMap,Ro=new WeakMap,D0=new WeakMap,Qf=new WeakSet,$b=function(t){let n=g(this,Ro),s=this.get("map"),r=null;return Us(t,({point:o})=>{var c,h;if(n){let u=n==null?void 0:n.queryRendered3DModels(o);if(u)return this.emit("mouseenter",{id:(c=u==null?void 0:u.properties)==null?void 0:c.originalId})}let l=s.queryRenderedFeatures(o,{layers:[Xc,qc,ba,Zb,N0]}).find(u=>{var f;return!((f=u==null?void 0:u.properties)!=null&&f.originalId.startsWith("MI_"))});l&&l.properties.originalId!==r?(r=l.properties.originalId,this.emit("mouseenter",{id:(h=l==null?void 0:l.properties)==null?void 0:h.originalId})):!l&&r&&(r=null,this.emit("mouseenter",{id:null}))})},Qc=new WeakSet,O0=function(){var r,o,a,l;let t=this.get("solutionconfig"),n=(o=(r=t==null?void 0:t.settings3D)==null?void 0:r.wallOpacity)!=null?o:zn.DEFAULTS.wallOpacity,s=(l=(a=t==null?void 0:t.settings3D)==null?void 0:a.extrusionOpacity)!=null?l:zn.DEFAULTS.extrusionOpacity;return{wallOpacity:n,extrusionOpacity:s}},Co=new WeakSet,Kc=function(){let t=this.get("tileUrl");if(t>""){let n=this.getMap(),s=n.getLayer(Yc),r=n.getSource(jf),o=n.getLayer(Xc)?Xc:null,a={type:"raster",tiles:[t],tileSize:256};r&&s&&(n.removeLayer(Yc),n.removeSource(jf)),n.addSource(jf,a),n.addLayer({id:Yc,type:"raster",source:jf,minzoom:0},o)}};function Zc(i){return isNaN(i)?20:i-1>0?i-1:20}T();T();var Lo="MI_POSITION_SOURCE",U0="MI_CIRCLE_LAYER",F0="MI_FILL_LAYER",br,cl,Po,eh,ed=class extends zt{constructor(t,n){super();U(this,br);U(this,Po);t instanceof mapboxgl.Map&&(t.getSource(Lo)||t.addSource(Lo,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.getLayer(U0)||t.addLayer({id:U0,filter:["all",["==","$type","Point"]],type:"circle",slot:"top",source:Lo,paint:{"circle-color":["get","fillColor"],"circle-radius":["get","radius"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":["get","strokeWeight"],"circle-stroke-color":["get","strokeColor"],"circle-stroke-opacity":["get","fillOpacity"],"circle-pitch-alignment":"map","circle-pitch-scale":"viewport","circle-emissive-strength":1}}),t.getLayer(F0)||t.addLayer({id:F0,filter:["all",["==","$type","Polygon"]],type:"fill",slot:"top",source:Lo,paint:{"fill-color":["get","fillColor"],"fill-opacity":["to-number",["get","fillOpacity"]]}})),this.on("provider_changed",s=>{var o;let r=(o=document.querySelector("mi-my-position"))!=null?o:n;if(s.oldValue&&(s.oldValue.off?(s.oldValue.off("position_received",te(this,br,cl).bind(this)),s.oldValue.off("position_error",te(this,Po,eh).bind(this))):(r.removeEventListener("position_received",te(this,br,cl).bind(this)),r.removeEventListener("position_error",te(this,Po,eh).bind(this)))),s.newValue){let a=s.newValue,l=a.options.positionMarkerStyles,c=a.options.accuracyCircleStyles;this.set("markerOptions",{fillColor:l.fillColor,fillOpacity:parseFloat(l.fillOpacity),strokeColor:l.strokeColor,strokeWeight:parseInt(l.strokeWeight),radius:parseInt(l.radius)}),this.set("accuracyOptions",c),this.set("maxAccuracy",a.options.maxAccuracy),a.on?(a.on("position_received",te(this,br,cl).bind(this)),a.on("position_error",te(this,Po,eh).bind(this))):(r.addEventListener("position_received",te(this,br,cl).bind(this)),r.addEventListener("position_error",te(this,Po,eh).bind(this))),a.hasValidPosition()&&te(this,br,cl).call(this,{position:a.currentPosition,accurate:a.positionIsAccurate})}}),this.setValues({map:t,provider:n})}setProvider(t){this.set("provider",t)}deallocate(){let t=this.get("map");t.removeLayer(U0),t.removeLayer(F0),t.removeSource(Lo),this.set("provider",null),this.set("map",null)}};br=new WeakSet,cl=function(t){let s=this.get("map").getSource(Lo),r=t.detail?t.detail.position.coords:t.position.coords,o=this.get("maxAccuracy"),a=this.get("markerOptions"),l=this.get("accuracyOptions");if(r.accuracy<=o){let c={type:"Feature",geometry:{type:"Point",coordinates:[r.longitude,r.latitude]},properties:a},h=Tu(c,r.accuracy,{steps:360,units:"meters",properties:l});s.setData({type:"FeatureCollection",features:[c,h]})}else s.setData({type:"FeatureCollection",features:[]})},Po=new WeakSet,eh=function(){let n=this.get("map").getSource(Lo);n&&n.setData({type:"FeatureCollection",features:[]})};T();var Is=Object.freeze({MODEL2D:"MODEL2D",WALLS2D:"WALLS2D",MODEL3D:"MODEL3D",WALLS3D:"WALLS3D",EXTRUSION3D:"EXTRUSION3D",EXTRUDEDBUILDINGS:"EXTRUDEDBUILDINGS"});T();T();T();var th,B0,hl,td;function nd(i,e=1/0,t=null){B0||(B0=new mi(2,2,1,1)),hl||(hl=new pi({uniforms:{blitTexture:new nl(i)},vertexShader:`
			varying vec2 vUv;
			void main(){
				vUv = uv;
				gl_Position = vec4(position.xy * 1.0,0.,.999999);
			}`,fragmentShader:`
			uniform sampler2D blitTexture; 
			varying vec2 vUv;

			void main(){ 
				gl_FragColor = vec4(vUv.xy, 0, 1);
				
				#ifdef IS_SRGB
				gl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );
				#else
				gl_FragColor = texture2D( blitTexture, vUv);
				#endif
			}`})),hl.uniforms.blitTexture.value=i,hl.defines.IS_SRGB=i.colorSpace==Gt,hl.needsUpdate=!0,td||(td=new Ct(B0,hl),td.frustumCulled=!1);let n=new Zt,s=new Jn;s.add(td),t===null&&(t=th=new dr({antialias:!1}));let r=Math.min(i.image.width,e),o=Math.min(i.image.height,e);t.setSize(r,o),t.clear(),t.render(s,n);let a=document.createElement("canvas"),l=a.getContext("2d");a.width=r,a.height=o,l.drawImage(t.domElement,0,0,r,o);let c=new Cf(a);return c.minFilter=i.minFilter,c.magFilter=i.magFilter,c.wrapS=i.wrapS,c.wrapT=i.wrapT,c.colorSpace=i.colorSpace,c.name=i.name,th&&(th.forceContextLoss(),th.dispose(),th=null),c}var jb={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},ul=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new H0(e)}),this.register(function(e){return new G0(e)}),this.register(function(e){return new Y0(e)}),this.register(function(e){return new K0(e)}),this.register(function(e){return new Z0(e)}),this.register(function(e){return new $0(e)}),this.register(function(e){return new W0(e)}),this.register(function(e){return new X0(e)}),this.register(function(e){return new q0(e)}),this.register(function(e){return new j0(e)}),this.register(function(e){return new J0(e)}),this.register(function(e){return new Q0(e)}),this.register(function(e){return new ey(e)}),this.register(function(e){return new ty(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r=new V0,o=[];for(let a=0,l=this.pluginCallbacks.length;a<l;a++)o.push(this.pluginCallbacks[a](r));r.setPlugins(o),r.write(e,t,s).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,s,r,t)})}},$e={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},k0="KHR_mesh_quantization",ei={};ei[tn]=$e.NEAREST;ei[zc]=$e.NEAREST_MIPMAP_NEAREST;ei[rr]=$e.NEAREST_MIPMAP_LINEAR;ei[Wt]=$e.LINEAR;ei[xo]=$e.LINEAR_MIPMAP_NEAREST;ei[ui]=$e.LINEAR_MIPMAP_LINEAR;ei[Pi]=$e.CLAMP_TO_EDGE;ei[xs]=$e.REPEAT;ei[bo]=$e.MIRRORED_REPEAT;var Jb={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},n2=new Oe,Qb=12,i2=1179937895,s2=2,eM=8,r2=1313821514,o2=5130562;function nh(i,e){return i.length===e.length&&i.every(function(t,n){return t===e[n]})}function a2(i){return new TextEncoder().encode(i).buffer}function l2(i){return nh(i.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function c2(i,e,t){let n={min:new Array(i.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(i.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let r=0;r<i.itemSize;r++){let o;i.itemSize>4?o=i.array[s*i.itemSize+r]:(r===0?o=i.getX(s):r===1?o=i.getY(s):r===2?o=i.getZ(s):r===3&&(o=i.getW(s)),i.normalized===!0&&(o=il.normalize(o,i.array))),n.min[r]=Math.min(n.min[r],o),n.max[r]=Math.max(n.max[r],o)}return n}function iM(i){return Math.ceil(i/4)*4}function z0(i,e=0){let t=iM(i.byteLength);if(t!==i.byteLength){let n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let s=i.byteLength;s<t;s++)n[s]=e;return n.buffer}return i}function tM(){return typeof document=="undefined"&&typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(1,1):document.createElement("canvas")}function nM(i,e){if(i.toBlob!==void 0)return new Promise(n=>i.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}var V0=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+kc}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let s=this,r=s.buffers,o=s.json;n=s.options;let a=s.extensionsUsed,l=s.extensionsRequired,c=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(a),u=Object.keys(l);if(h.length>0&&(o.extensionsUsed=h),u.length>0&&(o.extensionsRequired=u),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(c),f.onloadend=function(){let d=z0(f.result),y=new DataView(new ArrayBuffer(eM));y.setUint32(0,d.byteLength,!0),y.setUint32(4,o2,!0);let v=z0(a2(JSON.stringify(o)),32),p=new DataView(new ArrayBuffer(eM));p.setUint32(0,v.byteLength,!0),p.setUint32(4,r2,!0);let m=new ArrayBuffer(Qb),A=new DataView(m);A.setUint32(0,i2,!0),A.setUint32(4,s2,!0);let x=Qb+p.byteLength+v.byteLength+y.byteLength+d.byteLength;A.setUint32(8,x,!0);let S=new Blob([m,p,v,y,d],{type:"application/octet-stream"}),N=new FileReader;N.readAsArrayBuffer(S),N.onloadend=function(){t(N.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(c),f.onloadend=function(){let d=f.result;o.buffers[0].uri=d,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,s=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in r.gltfExtensions)t.extensions[o]=r.gltfExtensions[o],s[o]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new k;for(let s=0,r=e.count;s<r;s++)if(Math.abs(n.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),s=new k;for(let r=0,o=n.count;r<o;r++)s.fromBufferAttribute(n,r),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(r,s.x,s.y,s.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(s.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(s.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(d){return d.colorSpace===Gt?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof Qa&&(e=nd(e)),t instanceof Qa&&(t=nd(t));let s=e?e.image:null,r=t?t.image:null,o=Math.max(s?s.width:0,r?r.width:0),a=Math.max(s?s.height:0,r?r.height:0),l=tM();l.width=o,l.height=a;let c=l.getContext("2d",{willReadFrequently:!0});c.fillStyle="#00ffff",c.fillRect(0,0,o,a);let h=c.getImageData(0,0,o,a);if(s){c.drawImage(s,0,0,o,a);let d=n(e),y=c.getImageData(0,0,o,a).data;for(let v=2;v<y.length;v+=4)h.data[v]=d(y[v]/256)*256}if(r){c.drawImage(r,0,0,o,a);let d=n(t),y=c.getImageData(0,0,o,a).data;for(let v=1;v<y.length;v+=4)h.data[v]=d(y[v]/256)*256}c.putImageData(h,0,0);let f=(e||t).clone();return f.source=new Ka(l),f.colorSpace=Yi,f.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),f}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,s,r){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(t){case $e.BYTE:case $e.UNSIGNED_BYTE:a=1;break;case $e.SHORT:case $e.UNSIGNED_SHORT:a=2;break;default:a=4}let l=e.itemSize*a;r===$e.ARRAY_BUFFER&&(l=Math.ceil(l/4)*4);let c=iM(s*l),h=new DataView(new ArrayBuffer(c)),u=0;for(let y=n;y<n+s;y++){for(let v=0;v<e.itemSize;v++){let p;e.itemSize>4?p=e.array[y*e.itemSize+v]:(v===0?p=e.getX(y):v===1?p=e.getY(y):v===2?p=e.getZ(y):v===3&&(p=e.getW(y)),e.normalized===!0&&(p=il.normalize(p,e.array))),t===$e.FLOAT?h.setFloat32(u,p,!0):t===$e.INT?h.setInt32(u,p,!0):t===$e.UNSIGNED_INT?h.setUint32(u,p,!0):t===$e.SHORT?h.setInt16(u,p,!0):t===$e.UNSIGNED_SHORT?h.setUint16(u,p,!0):t===$e.BYTE?h.setInt8(u,p):t===$e.UNSIGNED_BYTE&&h.setUint8(u,p),u+=a}u%l!==0&&(u+=l-u%l)}let f={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return r!==void 0&&(f.target=r),r===$e.ARRAY_BUFFER&&(f.byteStride=l),this.byteOffset+=c,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let o=z0(r.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,s(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,s){let r=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(e.array.constructor===Float32Array)a=$e.FLOAT;else if(e.array.constructor===Int32Array)a=$e.INT;else if(e.array.constructor===Uint32Array)a=$e.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=$e.SHORT;else if(e.array.constructor===Uint16Array)a=$e.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=$e.BYTE;else if(e.array.constructor===Uint8Array)a=$e.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;let l=c2(e,n,s),c;t!==void 0&&(c=e===t.index?$e.ELEMENT_ARRAY_BUFFER:$e.ARRAY_BUFFER);let h=this.processBufferView(e,a,n,s,c),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:a,count:s,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(u)-1}processImage(e,t,n,s="image/png"){if(e!==null){let r=this,o=r.cache,a=r.json,l=r.options,c=r.pending;o.images.has(e)||o.images.set(e,{});let h=o.images.get(e),u=s+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];a.images||(a.images=[]);let f={mimeType:s},d=tM();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);let y=d.getContext("2d",{willReadFrequently:!0});if(n===!0&&(y.translate(0,d.height),y.scale(1,-1)),e.data!==void 0){t!==Tn&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let p=new Uint8ClampedArray(e.height*e.width*4);for(let m=0;m<p.length;m+=4)p[m+0]=e.data[m+0],p[m+1]=e.data[m+1],p[m+2]=e.data[m+2],p[m+3]=e.data[m+3];y.putImageData(new ImageData(p,e.width,e.height),0,0)}else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas)y.drawImage(e,0,0,d.width,d.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");l.binary===!0?c.push(nM(d,s).then(p=>r.processBufferViewImage(p)).then(p=>{f.bufferView=p})):d.toDataURL!==void 0?f.uri=d.toDataURL(s):c.push(nM(d,s).then(p=>new FileReader().readAsDataURL(p)).then(p=>{f.uri=p}));let v=a.images.push(f)-1;return h[u]=v,v}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:ei[e.magFilter],minFilter:ei[e.minFilter],wrapS:ei[e.wrapS],wrapT:ei[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let n=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof Qa&&(e=nd(e,n.maxTextureSize));let o=e.userData.mimeType;o==="image/webp"&&(o="image/png");let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(a.name=e.name),this._invokeAll(function(c){c.writeTexture&&c.writeTexture(e,a)});let l=r.textures.push(a)-1;return s.textures.set(e,l),l}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=e.color.toArray().concat([e.opacity]);if(nh(r,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(l,a),s.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){let a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),s.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){let a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let c={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(c,e.emissiveMap),s.emissiveTexture=c}}if(e.normalMap){let a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),s.normalTexture=a}if(e.aoMap){let a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),s.occlusionTexture=a}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===Yn&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,s)});let o=n.materials.push(s)-1;return t.materials.set(e,o),o}processMesh(e){let t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let S=0,N=e.material.length;S<N;S++)s.push(e.material[S].uuid);else s.push(e.material.uuid);let r=s.join(":");if(t.meshes.has(r))return t.meshes.get(r);let o=e.geometry,a;e.isLineSegments?a=$e.LINES:e.isLineLoop?a=$e.LINE_LOOP:e.isLine?a=$e.LINE_STRIP:e.isPoints?a=$e.POINTS:a=e.material.wireframe?$e.LINES:$e.TRIANGLES;let l={},c={},h=[],u=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=o.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let y=null;for(let S in o.attributes){if(S.slice(0,5)==="morph")continue;let N=o.attributes[S];if(S=f[S]||S.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(S)||(S="_"+S),t.attributes.has(this.getUID(N))){c[S]=t.attributes.get(this.getUID(N));continue}y=null;let C=N.array;S==="JOINTS_0"&&!(C instanceof Uint16Array)&&!(C instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),y=new vt(new Uint16Array(C),N.itemSize,N.normalized));let R=this.processAccessor(y||N,o);R!==null&&(S.startsWith("_")||this.detectMeshQuantization(S,N),c[S]=R,t.attributes.set(this.getUID(N),R))}if(d!==void 0&&o.setAttribute("normal",d),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let S=[],N=[],P={};if(e.morphTargetDictionary!==void 0)for(let C in e.morphTargetDictionary)P[e.morphTargetDictionary[C]]=C;for(let C=0;C<e.morphTargetInfluences.length;++C){let R={},ne=!1;for(let b in o.morphAttributes){if(b!=="position"&&b!=="normal"){ne||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),ne=!0);continue}let _=o.morphAttributes[b][C],M=b.toUpperCase(),I=o.attributes[b];if(t.attributes.has(this.getUID(_,!0))){R[M]=t.attributes.get(this.getUID(_,!0));continue}let O=_.clone();if(!o.morphTargetsRelative)for(let B=0,D=_.count;B<D;B++)for(let X=0;X<_.itemSize;X++)X===0&&O.setX(B,_.getX(B)-I.getX(B)),X===1&&O.setY(B,_.getY(B)-I.getY(B)),X===2&&O.setZ(B,_.getZ(B)-I.getZ(B)),X===3&&O.setW(B,_.getW(B)-I.getW(B));R[M]=this.processAccessor(O,o),t.attributes.set(this.getUID(I,!0),R[M])}u.push(R),S.push(e.morphTargetInfluences[C]),e.morphTargetDictionary!==void 0&&N.push(P[C])}l.weights=S,N.length>0&&(l.extras={},l.extras.targetNames=N)}let v=Array.isArray(e.material);if(v&&o.groups.length===0)return null;let p=!1;if(v&&o.index===null){let S=[];for(let N=0,P=o.attributes.position.count;N<P;N++)S[N]=N;o.setIndex(S),p=!0}let m=v?e.material:[e.material],A=v?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let S=0,N=A.length;S<N;S++){let P={mode:a,attributes:c};if(this.serializeUserData(o,P),u.length>0&&(P.targets=u),o.index!==null){let R=this.getUID(o.index);(A[S].start!==void 0||A[S].count!==void 0)&&(R+=":"+A[S].start+":"+A[S].count),t.attributes.has(R)?P.indices=t.attributes.get(R):(P.indices=this.processAccessor(o.index,o,A[S].start,A[S].count),t.attributes.set(R,P.indices)),P.indices===null&&delete P.indices}let C=this.processMaterial(m[A[S].materialIndex]);C!==null&&(P.material=C),h.push(P)}p===!0&&o.setIndex(null),l.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(S){S.writeMesh&&S.writeMesh(e,l)});let x=n.meshes.push(l)-1;return t.meshes.set(r,x),x}detectMeshQuantization(e,t){if(this.extensionsUsed[k0])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let s=e.split("_",1)[0];jb[s]&&jb[s].includes(n)&&(this.extensionsUsed[k0]=!0,this.extensionsRequired[k0]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:il.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){let n=this.json,s=this.nodeMap;n.animations||(n.animations=[]),e=ul.Utils.mergeMorphTargetTracks(e.clone(),t);let r=e.tracks,o=[],a=[];for(let l=0;l<r.length;++l){let c=r[l],h=Ke.parseTrackName(c.name),u=Ke.findNode(t,h.nodeName),f=Jb[h.propertyName];if(h.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(h.objectIndex):u=void 0),!u||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name);continue}let d=1,y=c.values.length/c.times.length;f===Jb.morphTargetInfluences&&(y/=u.morphTargetInfluences.length);let v;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(v="CUBICSPLINE",y/=3):c.getInterpolation()===cr?v="STEP":v="LINEAR",a.push({input:this.processAccessor(new vt(c.times,d)),output:this.processAccessor(new vt(c.values,y)),interpolation:v}),o.push({sampler:a.length-1,target:{node:s.get(u),path:f}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:a,channels:o}),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;let o=e.skeleton.bones[0];if(o===void 0)return null;let a=[],l=new Float32Array(r.bones.length*16),c=new Pe;for(let u=0;u<r.bones.length;++u)a.push(n.get(r.bones[u])),c.copy(r.boneInverses[u]),c.multiply(e.bindMatrix).toArray(l,u*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new vt(l,16)),joints:a,skeleton:n.get(o)}),s.skin=t.skins.length-1}processNode(e){let t=this.json,n=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);let r={};if(n.trs){let a=e.quaternion.toArray(),l=e.position.toArray(),c=e.scale.toArray();nh(a,[0,0,0,1])||(r.rotation=a),nh(l,[0,0,0])||(r.translation=l),nh(c,[1,1,1])||(r.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),l2(e.matrix)===!1&&(r.matrix=e.matrix.elements);if(e.name!==""&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){let a=this.processMesh(e);a!==null&&(r.mesh=a)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let a=[];for(let l=0,c=e.children.length;l<c;l++){let h=e.children[l];if(h.visible||n.onlyVisible===!1){let u=this.processNode(h);u!==null&&a.push(u)}}a.length>0&&(r.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,r)});let o=t.nodes.push(r)-1;return s.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);let r=[];for(let o=0,a=e.children.length;o<a;o++){let l=e.children[o];if(l.visible||n.onlyVisible===!1){let c=this.processNode(l);c!==null&&r.push(c)}}r.length>0&&(s.nodes=r),this.serializeUserData(e,s)}processObjects(e){let t=new Jn;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(s){s.beforeParse&&s.beforeParse(e)});let n=[];for(let s=0;s<e.length;s++)e[s]instanceof Jn?this.processScene(e[s]):n.push(e[s]);n.length>0&&this.processObjects(n);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll(function(s){s.afterParse&&s.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},H0=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let n=this.writer,s=n.json,r=n.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},r[this.name]=!0);let a=s.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},G0=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},W0=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let o={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),r.clearcoatTexture=o}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let o={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){let o={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),r.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},X0=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let s=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},q0=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let o={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),r.iridescenceTexture=o}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let o={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Y0=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let o={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),r.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},K0=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,s=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let o={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),r.thicknessTexture=o}e.attenuationDistance!==1/0&&(r.attenuationDistance=e.attenuationDistance),r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Z0=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},$0=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(n2)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.specularIntensityMap){let o={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),r.specularTexture=o}if(e.specularColorMap){let o={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),r.specularColorTexture=o}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},j0=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.sheenRoughnessMap){let o={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),r.sheenRoughnessTexture=o}if(e.sheenColorMap){let o={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),r.sheenColorTexture=o}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},J0=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.anisotropyMap){let o={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),r.anisotropyTexture=o}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Q0=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},ey=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,s=n.extensionsUsed,r={};if(e.bumpMap){let o={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),r.bumpTexture=o}r.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},ty=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,s=e,r=new Float32Array(s.count*3),o=new Float32Array(s.count*4),a=new Float32Array(s.count*3),l=new Pe,c=new k,h=new Zn,u=new k;for(let d=0;d<s.count;d++)s.getMatrixAt(d,l),l.decompose(c,h,u),c.toArray(r,d*3),h.toArray(o,d*4),u.toArray(a,d*3);let f={TRANSLATION:n.processAccessor(new vt(r,3)),ROTATION:n.processAccessor(new vt(o,4)),SCALE:n.processAccessor(new vt(a,3))};s.instanceColor&&(f._COLOR_0=n.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:f},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};ul.Utils={insertKeyframe:function(i,e){let n=i.getValueSize(),s=new i.TimeBufferType(i.times.length+1),r=new i.ValueBufferType(i.values.length+n),o=i.createInterpolant(new i.ValueBufferType(n)),a;if(i.times.length===0){s[0]=e;for(let l=0;l<n;l++)r[l]=0;a=0}else if(e<i.times[0]){if(Math.abs(i.times[0]-e)<.001)return 0;s[0]=e,s.set(i.times,1),r.set(o.evaluate(e),0),r.set(i.values,n),a=0}else if(e>i.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;s[s.length-1]=e,s.set(i.times,0),r.set(i.values,0),r.set(o.evaluate(e),i.values.length),a=s.length-1}else for(let l=0;l<i.times.length;l++){if(Math.abs(i.times[l]-e)<.001)return l;if(i.times[l]<e&&i.times[l+1]>e){s.set(i.times.slice(0,l+1),0),s[l+1]=e,s.set(i.times.slice(l+1),l+2),r.set(i.values.slice(0,(l+1)*n),0),r.set(o.evaluate(e),(l+1)*n),r.set(i.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return i.times=s,i.values=r,a},mergeMorphTargetTracks:function(i,e){let t=[],n={},s=i.tracks;for(let r=0;r<s.length;++r){let o=s[r],a=Ke.parseTrackName(o.name),l=Ke.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(hr)}let c=l.morphTargetInfluences.length,h=l.morphTargetDictionary[a.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let u;if(n[l.uuid]===void 0){u=o.clone();let d=new u.ValueBufferType(c*u.times.length);for(let y=0;y<u.times.length;y++)d[y*c+h]=u.values[y];u.name=(a.nodeName||"")+".morphTargetInfluences",u.values=d,n[l.uuid]=u,t.push(u);continue}let f=o.createInterpolant(new o.ValueBufferType(1));u=n[l.uuid];for(let d=0;d<u.times.length;d++)u.values[d*c+h]=f.evaluate(u.times[d]);for(let d=0;d<o.times.length;d++){let y=this.insertKeyframe(u,o.times[d]);u.values[y*c+h]=o.values[d]}}return i.tracks=t,i}};var h2=!!document.createElement("canvas").getContext("webgl2"),id,sd,fl,No=class{static async createModel(e){var f,d;if(((f=e==null?void 0:e.properties)==null?void 0:f.featureClass)!==Ne.MODEL2D||!((d=e==null?void 0:e.properties)!=null&&d.imageUrl))return;let t=btoa(e.properties.imageUrl.toLowerCase());if(g(this,fl).has(t))return g(this,fl).get(t);let n=new Jn,[s,r]=await Sv(()=>g(this,id).loadAsync(e.properties.imageUrl));if(s)return;h2&&(r.minFilter=Wt);let o=new mi(r.image.naturalWidth,r.image.naturalHeight),a=new Rn({map:r,transparent:!0,depthTest:!1}),l=new Ct(o,a);n.add(l);let c=await g(this,sd).parseAsync(n,{binary:!0}),h=new Blob([c],{type:"application/octet-stream"}),u=URL.createObjectURL(h);return g(this,fl).set(t,u),u}};id=new WeakMap,sd=new WeakMap,fl=new WeakMap,U(No,id,new yr),U(No,sd,new ul),U(No,fl,new Map);var _i="MI_GEOJSON_SOURCE",rd="MI_FLOOR_PLAN_SOURCE",ny="MI_FLOOR_PLAN_FILL",iy="MI_FLOOR_PLAN_LINE",sM="MI_HIGHLIGHT_LAYER",sy="MI_MODEL_3D_LAYER",ry="MI_MODEL_2D_LAYER",u2="MI_OUTLINE_LAYER",oy="MI_POINT_LAYER",ih="MI_POLYGON_LAYER",Oo="MI_ROOMS_LAYER",sh="MI_TILES_LAYER",od="MI_TILES_SOURCE",rh="MI_WALLS_LAYER",f2="MI_FLAT_LABELS_LAYER",ay="MI_GRAPHIC_LABELS_LAYER",ah,dl,lh,cy,ti,ld,ch,pl,Do,cd,rM,hh,ly,Uo,oh,hy,ad=class extends zt{constructor({element:t,maxZoom:n,mapsIndoorsTransitionLevel:s=17,showMapMarkers:r,showRoadNameLabels:o,lightPreset:a="day",accessToken:l,pitch:c=0,bearing:h=0,...u}){super();U(this,cd);U(this,hh);U(this,Uo);U(this,ah,ci.INITIALIZING);U(this,dl,void 0);U(this,lh,void 0);U(this,cy,void 0);U(this,ti,void 0);U(this,ld,null);U(this,ch,[]);U(this,pl,!0);U(this,Do,new Set);U(this,hy,new Map);W(this,lh,this.isMaxZoomLevelValid(n)),W(this,ti,s);let f,d=null,y=!0,v=null;if(mapboxgl&&mapboxgl.Map){mapboxgl.accessToken=l;let x=new mapboxgl.Map({container:t,maxZoom:Zc(n),style:"mapbox://styles/mapspeople/clrakuu6s003j01pf11uz5d45?optimize=true",bearing:h,pitch:c,...u});Bt.log(bt.appLifeTime.MAP_INSTANTIATED),x.on("style.load",()=>{let{wallOpacity:S,extrusionOpacity:N}=te(this,hh,ly).call(this);x.addSource(rd,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),x.addSource(_i,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),x.setConfigProperty("basemap","lightPreset",a),r!==void 0&&(x.setConfigProperty("basemap","showPointOfInterestLabels",r),x.setConfigProperty("basemap","showTransitLabels",r)),o!==void 0&&x.setConfigProperty("basemap","showRoadLabels",o),this.getMapboxZoomLevel(u==null?void 0:u.zoom)>this.getMapboxZoomLevel(g(this,ti))&&(p("off",x),x.setConfigProperty("basemap","showPointOfInterestLabels",!1),x.setConfigProperty("basemap","showTransitLabels",!1)),x.addLayer({filter:["any",["==","featureClass",Ne.POLYGON],["==","featureClass",Ne.MODEL2D]],id:ih,type:"fill",slot:"middle",source:_i,layout:{"fill-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"fill-color":["to-color",["get","fillColor"],ce.polygon.fillColor],"fill-opacity":["number",["get","fillOpacity"],ce.polygon.fillOpacity]}}),x.addLayer({filter:["==","featureClass",Ne.POLYGON],id:u2,type:"line",slot:"middle",source:_i,layout:{"line-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER]},paint:{"line-width":["number",["get","strokeWidth"],ce.polygon.strokeWidth],"line-color":["to-color",["get","strokeColor"],ce.polygon.strokeColor],"line-opacity":["number",["get","strokeOpacity"],ce.polygon.strokeOpacity]}}),x.addLayer({filter:["any",["==","featureClass",Ne.LABEL_FLAT]],id:f2,source:_i,type:"symbol",slot:"middle",layout:{"text-field":["get","labelText"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-size":["interpolate",["exponential",2],["zoom"],1,["number",["*",["get","labelStyleSize"],2384185791015625e-22],["*",ce.labelStyle.textSize,2384185791015625e-22]],22,["number",["get","labelStyleSize"]],23,["number",["*",["get","labelStyleSize"],2],["*",ce.labelStyle.textSize,2]],24,["number",["*",["get","labelStyleSize"],4],["*",ce.labelStyle.textSize,4]],25,["number",["*",["get","labelStyleSize"],8],["*",ce.labelStyle.textSize,8]]],"text-ignore-placement":!0,"text-allow-overlap":!0,"icon-allow-overlap":!0,"text-rotation-alignment":"map","text-rotate":["number",["get","labelStyleBearing"],ce.labelStyle.bearing]},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),x.addLayer({id:ny,type:"fill",slot:"middle",source:rd,paint:{"fill-color":["match",["get","type"],"floorplan","#ffffff","extrusion","#fcfcf2","#ffffff"]}}),x.addLayer({id:iy,type:"line",slot:"middle",source:rd,filter:["==",["get","type"],"floorplan"],paint:{"line-width":1.2,"line-color":"#6B7280"}}),x.addLayer({filter:["==","featureClass",Ne.MODEL3D],id:sy,type:"model",slot:"middle",source:_i,paint:{"model-rotation":["get","rotation"],"model-scale":["get","scale"]},layout:{"model-id":["get","modelName"]}}),x.addLayer({filter:["==","featureClass",Ne.MODEL2D],id:ry,type:"model",slot:"middle",source:_i,paint:{"model-rotation":["get","rotation"],"model-scale":["get","scale"],"model-translation":["get","translation"],"model-cast-shadows":!1},layout:{"model-id":["get","modelId"]}}),x.addLayer({filter:["any",["==","featureClass",Ne.WALL_EXTRUSION]],id:rh,type:"fill-extrusion",slot:"middle",source:_i,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":S,"fill-extrusion-height":["get","height"]}}),x.addLayer({id:Oo,filter:["==","featureClass",Ne.ROOM_EXTRUSION],type:"fill-extrusion",slot:"middle",source:_i,paint:{"fill-extrusion-color":["get","fillColor"],"fill-extrusion-opacity":N,"fill-extrusion-height":["get","height"]}}),x.addLayer({filter:["any",["==","featureClass",Ne.LABEL_GRAPHIC]],id:ay,source:_i,slot:"top",type:"symbol",layout:{"icon-text-fit":"both","icon-image":["get","imageId"],"icon-allow-overlap":!0,"text-field":["get","labelText"],"symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-size":["number",["get","labelStyleSize"],ce.labelStyle.textSize],"text-allow-overlap":!0,"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-letter-spacing":-.01,"text-padding":0},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),x.addLayer({filter:["all",["!=","iconAllowOverlap",!0],["any",["==","featureClass",Ne.POINT],["==","featureClass",Ne.LABEL_FLOATING]]],id:oy,type:"symbol",slot:"middle",source:_i,layout:{"icon-allow-overlap":!1,"icon-optional":!0,"icon-image":["get","iconSrc"],"icon-anchor":["get","iconPlacement"],"icon-size":["number",["get","iconScale"],1],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MAX_SAFE_INTEGER],"symbol-z-elevate":!0,"text-padding":0,"text-optional":!0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Bold","Arial Unicode MS Regular"]],"text-size":["number",["get","labelStyleSize"],ce.labelStyle.textSize],"text-letter-spacing":-.01,"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!1},paint:{"text-color":["to-color",["get","labelStyleColor"],ce.labelStyle.textColor],"text-halo-color":["to-color",["get","labelStyleHaloColor"],ce.labelStyle.haloColor],"text-halo-width":["number",["get","labelStyleHaloWidth"],ce.labelStyle.haloWidth],"text-halo-blur":["number",["get","labelStyleHaloBlur"],ce.labelStyle.haloBlur],"text-opacity":["number",["get","labelStyleOpacity"],ce.labelStyle.textOpacity]}}),x.addLayer({filter:["all",["==","iconAllowOverlap",!0],["any",["==","featureClass",Ne.POINT],["==","featureClass",Ne.LABEL_FLOATING]]],id:sM,type:"symbol",slot:"middle",source:_i,layout:{"icon-allow-overlap":!0,"icon-optional":!1,"icon-image":["get","iconSrc"],"icon-size":["number",["get","iconScale"],1],"icon-anchor":["get","iconPlacement"],"symbol-placement":"point","symbol-sort-key":["number",["get","sortKey"],Number.MIN_SAFE_INTEGER],"symbol-z-elevate":!0,"text-padding":0,"text-field":["get","labelText"],"text-anchor":["get","labelStylePosition"],"text-font":["literal",["Open Sans Regular","Arial Unicode MS Regular"]],"text-size":["number",["get","labelSize"],12],"text-max-width":["case",[">",["number",["get","labelMaxWidth"],0],0],["number",["get","labelMaxWidth"],0],9999999999],"text-offset":["coalesce",["get","labelOffset"],["literal",[0,0]]],"text-allow-overlap":!0},paint:{"text-color":["to-color",["get","labelColor"],"hsl(217, 11%, 23%)"],"text-halo-color":["to-color",["get","labelShadowColor"],"#000"],"text-halo-width":["number",["get","labelShadowBlur"],0],"text-halo-blur":["case",[">",["get","labelShadowBlur"],0],1,0]}}),W(this,ah,ci.READY),x.on("mousemove",te(this,cd,rM).call(this,66)),this.emit("ready")}),x.on("moveend",()=>{this.emit("idle")}),x.on("move",()=>{this.emit("bounds_changed")}),x.on("center_changed",()=>{this.emit("center_changed")}),x.once("style.load",()=>{f=x.getStyle().imports[0].data.name,f==="Mapbox Standard Experimental"&&x.on("zoom",()=>{if(g(this,pl)){let S=x.getZoom(),N=this.getMapboxZoomLevel(s),P=this.getMapboxZoomLevel(s+1),C=o===void 0,R=r===void 0,ne;if(S>N&&S<P){let b=(S-N)/(P-N);ne=1-b,C&&A(!0,x)}else S<P?(ne=1,C&&A(!0,x),R&&m(!0,x)):S>N&&(ne=0,C&&A(!1,x),R&&m(!1,x));p(ne,x)}})}),x.on("click",S=>{let N=x.queryRenderedFeatures(S.point,{layers:[ih,oy,Oo,ay]}).find(P=>{var C,R,ne;return!((R=(C=P==null?void 0:P.properties)==null?void 0:C.originalId)!=null&&R.startsWith("MI_"))&&((ne=P==null?void 0:P.properties)==null?void 0:ne.clickable)===!0});N&&N.properties.clickable!==!1&&this.emit("click",N.properties.originalId)}),x.on("maptypeid_changed",()=>{this.emit("maptypeid_changed")}),x.on("touchstart",()=>{this.emit("user_interaction")}),x.on("zoomend",()=>{this.emit("zoom_changed"),this.emit("user_interaction")}),x.on("tilesloaded",()=>{this.emit("tiles_loaded")}),x.on("dragstart",()=>{this.emit("dragstart"),this.emit("user_interaction")}),x.on("drag",()=>{this.emit("drag")}),x.on("dragend",()=>{this.emit("dragend")}),x.on("rotateend",()=>{this.emit("rotateend")}),x.on("styleimagemissing",S=>{x.loadImage(S.id,(N,P)=>{N||x.hasImage(S.id)||x.addImage(S.id,P)})}),this.addListener("solutionconfig_changed",()=>{let{wallOpacity:S,extrusionOpacity:N}=te(this,hh,ly).call(this);x.getLayer(rh)&&x.setPaintProperty(rh,"fill-extrusion-opacity",S),x.getLayer(Oo)&&x.setPaintProperty(Oo,"fill-extrusion-opacity",N)}),this.set("map",x),this.set("element",t),this.set("rotatable",!0),this.set("tiltable",!0)}function p(x,S){d!==x&&(d=x,S.setConfigProperty("basemap","buildingsOpacity",d))}function m(x,S){y!==x&&(y=x,S.setConfigProperty("basemap","showPointOfInterestLabels",x),S.setConfigProperty("basemap","showPlaceLabels",x),S.setConfigProperty("basemap","showTransitLabels",x))}function A(x,S){v!==x&&(v=x,S.setConfigProperty("basemap","showRoadLabels",x))}}isMaxZoomLevelValid(t){return Number.isInteger(+t)&&t>=0}hideFeatures(t){if(!this.isReady){this.once("ready",()=>{this.hideFeatures(t)});return}let n=this.getMap();W(this,ch,t);let s=this.getZoom();t.includes(Is.WALLS2D)?(n.setLayoutProperty(ny,"visibility","none"),n.setLayoutProperty(iy,"visibility","none")):(n.setLayoutProperty(ny,"visibility","visible"),n.setLayoutProperty(iy,"visibility","visible")),t.includes(Is.WALLS3D)?n.setLayoutProperty(rh,"visibility","none"):n.setLayoutProperty(rh,"visibility","visible"),t.includes(Is.MODEL2D)?n.setLayoutProperty(ry,"visibility","none"):n.setLayoutProperty(ry,"visibility","visible"),t.includes(Is.MODEL3D)?n.setLayoutProperty(sy,"visibility","none"):n.setLayoutProperty(sy,"visibility","visible"),t.includes(Is.EXTRUSION3D)?n.setLayoutProperty(Oo,"visibility","none"):n.setLayoutProperty(Oo,"visibility","visible");let h=t.includes(Is.EXTRUDEDBUILDINGS);if(h)W(this,pl,!1),n.setConfigProperty("basemap","buildingsOpacity",0);else if(s>g(this,ti)+1)n.setConfigProperty("basemap","buildingsOpacity",0);else if(g(this,ti)<s&&s<g(this,ti)+1){let u=(s-g(this,ti))/(g(this,ti)+1-g(this,ti));n.setConfigProperty("basemap","buildingsOpacity",u)}else n.setConfigProperty("basemap","buildingsOpacity",1);h||W(this,pl,!0)}get MapboxFeatures(){return Is}get FeatureType(){return Is}getHiddenFeatures(){return g(this,ch)}get isReady(){return g(this,ah)===ci.READY}async setViewData(t){var r;let n=this.getMap(),s=n==null?void 0:n.getSource(_i);if(s){let o=Array.from(t.values());o.forEach((a,l)=>{a.id=`${l}`});for(let a of o.filter(l=>l.properties.icon instanceof Image)){let l=a.properties.icon;n.hasImage(l.src)||n.addImage(l.src,l)}for(let a of o.filter(l=>l.properties.featureClass===Ne.MODEL2D||l.properties.featureClass===Ne.MODEL3D))if(a.properties.featureClass===Ne.MODEL2D){let l=btoa(a.properties.imageUrl);if(a.properties.modelId=l,!g(this,Do).has(l)){g(this,Do).add(l);let c=await No.createModel(a);if(!c)continue;n.addModel(l,c)}}else if(a.properties.featureClass===Ne.MODEL3D){let l=a.properties.modelName;g(this,Do).has(l)||(g(this,Do).add(l),n.addModel(l,a.properties.url))}for(let a of o.filter(l=>l.properties.featureClass===Ne.LABEL_GRAPHIC)){if(!(((r=a==null?void 0:a.properties)==null?void 0:r.backgroundImage)instanceof Image))continue;let l=a.properties.backgroundImage,c=`${l.src}+${JSON.stringify(a.properties.iconTextFit)}`;n.hasImage(c)||n.addImage(c,l,a.properties.iconTextFit),a.properties.imageId=c}s.setData({type:"FeatureCollection",features:o})}}setMapsIndoorsTileURL(t){let n=this.getMap();this.get("tileUrl")!==t&&t>""&&(this.set("tileUrl",t),n.getLayer(sh)||this.isReady?te(this,Uo,oh).call(this):n.once("load",()=>{te(this,Uo,oh).call(this)}))}get DirectionsRenderer(){return xa}getMapboxZoomLevel(t){return t-1}getMap(){return this.get("map")}deallocate(){this.getMap().remove(),this.set("map",null)}getBounds(){let t=this.get("map");if(t&&t.getBounds){let n=t.getBounds();return{west:n.getWest(),south:n.getSouth(),east:n.getEast(),north:n.getNorth()}}return null}getBearing(){let t=this.get("map");return t&&t.getBearing?t.getBearing():0}get rotatable(){return this.get("rotatable")}get tiltable(){return this.get("tiltable")}setLabelOptions(){}fitBounds({west:t,south:n,east:s,north:r},o){return new Promise(a=>{let l=this.get("map");if(l&&l.fitBounds){this.once("idle",a);let c={lon:t,lat:n},h={lon:s,lat:r};l.fitBounds([c,h],{padding:o,bearing:l.getBearing(),pitch:l.getPitch(),linear:!0,duration:1e3})}})}getZoom(){let t=this.get("map");return t&&t.getZoom?t.getZoom()+1:null}getMaxZoom(){let t=this.get("map");if(t&&t.getMaxZoom)return t.getMaxZoom()+1}enableZoom22(){let t=this.get("map");t&&t.setMaxZoom&&!g(this,lh)&&(t.setMaxZoom(Zc(25)),t.getLayer(sh)||this.isReady?te(this,Uo,oh).call(this):t.once("load",()=>{te(this,Uo,oh).call(this)}))}getPitch(){let t=this.get("map");return t&&t.getPitch?t.getPitch():0}setZoom(t){let n=this.get("map");n&&n.setZoom&&n.setZoom(t-1)}getCenter(){let t=this.get("map");return t&&t.getCenter?t.getCenter():null}setCenter({lat:t,lng:n}){let s=this.get("map");s&&s.setCenter&&s.setCenter([n,t])}setSolutionConfig(t){this.set("solutionconfig",t)}panTo({lat:t,lng:n}){let s=this.get("map");s&&s.panTo&&s.panTo([n,t])}easeTo({center:t,rotation:n,tilt:s,easing:r}){let o=this.get("map");o&&o.easeTo&&o.easeTo({center:t,bearing:n,pitch:s,easing:r})}tilt(t,n){let s=this.get("map");n?s.easeTo({pitch:t,duration:n}):s.setPitch(t)}rotate(t){this.get("map").setBearing(t)}panToBounds({west:t,south:n,east:s,north:r}){let o=this.get("map");if(o&&o.panTo&&mapboxgl.LngLatBounds){let l=new mapboxgl.LngLatBounds([t,n,s,r]).getCenter();this.panTo(l)}}getDiv(){return this.get("element")}project({lat:t,lng:n}){let s=this.get("map");return s&&s.project?s.project({lat:t,lng:n}):null}unproject({x:t,y:n}){let s=this.get("map");return s&&s.unproject?s.unproject([t,n]):null}addLogo(){if(this.isReady){if(this.get("map")){let n=this.getDiv();if(n){let s=document.createElement("img");s.id="mi_map_logo",s.src="https://app.mapsindoors.com/mapsindoors/gfx/mapspeople-on-map-logo%403x.png",s.style.width="96px",s.style.height="20px",s.style.margin="5px",s.style.position="absolute",s.style.right="0",s.style.bottom="18px",n.appendChild(s),new ResizeObserver(()=>{n.clientWidth<359||n.clientHeight<359?s.style.display!=="none"&&(s.style.display="none"):s.style.display==="none"&&(s.style.display="")}).observe(n)}}}else this.once("ready",()=>{this.addLogo()})}setPositionProvider(t){let n=this.getMap();g(this,dl)?g(this,dl).setProvider(t):W(this,dl,new ed(n,t))}setFloorPlan(t){let n=this.get("map");this.isReady?n.getSource(rd).setData(t):n.once("load",()=>this.setFloorPlan(t))}setSlot(t,n){this.get("map").setSlot(t,n)}getSlot(t){return this.get("map").getSlot(t)}};ah=new WeakMap,dl=new WeakMap,lh=new WeakMap,cy=new WeakMap,ti=new WeakMap,ld=new WeakMap,ch=new WeakMap,pl=new WeakMap,Do=new WeakMap,cd=new WeakSet,rM=function(t){let n=g(this,ld),s=this.get("map"),r=null;return Us(t,({point:o,lngLat:a})=>{var h,u;if(n){let f=n==null?void 0:n.queryRendered3DModels(o);if(f)return this.emit("mouseenter",{id:(h=f==null?void 0:f.properties)==null?void 0:h.originalId})}let c=s.queryRenderedFeatures(o,{layers:[ih,Oo,oy,sM,ay]}).find(f=>{var d;return!((d=f==null?void 0:f.properties)!=null&&d.originalId.startsWith("MI_"))});c&&c.geometry.type==="Point"&&(c.geometry={type:"Point",coordinates:a.toArray()}),c&&c.properties.originalId!==r?(r=c.properties.originalId,this.emit("mouseenter",{id:(u=c==null?void 0:c.properties)==null?void 0:u.originalId})):!c&&r&&(r=null,this.emit("mouseenter",{id:null}))})},hh=new WeakSet,ly=function(){var r,o,a,l;let t=this.get("solutionconfig"),n=(o=(r=t==null?void 0:t.settings3D)==null?void 0:r.wallOpacity)!=null?o:zn.DEFAULTS.wallOpacity,s=(l=(a=t==null?void 0:t.settings3D)==null?void 0:a.extrusionOpacity)!=null?l:zn.DEFAULTS.extrusionOpacity;return{wallOpacity:n,extrusionOpacity:s}},Uo=new WeakSet,oh=function(){let t=this.get("tileUrl");if(t>""){let n=this.getMap(),s=n.getLayer(sh),r=n.getSource(od),o=n.getLayer(ih)?ih:null,a={type:"raster",tiles:[t],tileSize:256},l=["interpolate",["linear"],["zoom"],this.getMapboxZoomLevel(g(this,ti)),0,this.getMapboxZoomLevel(g(this,ti)+1),1];r&&s&&(n.removeLayer(sh),n.removeSource(od)),n.addSource(od,a),n.addLayer({id:sh,type:"raster",source:od,slot:"middle",paint:{"raster-opacity":l}},o)}},hy=new WeakMap;T();var uM=ln(ii()),fM=ln(cM());T();var Lt=Object.freeze({POSITION_UNKNOWN:"POSITION_UNKNOWN",POSITION_REQUESTING:"POSITION_REQUESTING",POSITION_INACCURATE:"POSITION_INACCURATE",POSITION_KNOWN:"POSITION_KNOWN",POSITION_CENTERED:"POSITION_CENTERED"});var hM={opacity:{"xx-small":{value:"0"},"x-small":{value:"0.08"},small:{value:"0.16"},medium:{value:"0.24"},large:{value:"0.48"},"x-large":{value:"0.72"},"xx-large":{value:"0.88"},"xxx-large":{value:"1"}}};var hd=class extends uM.default{constructor(e,t){if(super(),!navigator.geolocation){this.emit("position_error",{code:10,message:"Geolocation not available"});return}this.mapsIndoors=t.mapsIndoors,delete t.mapsIndoors,this.positionState,this.currentPosition,this.positionIsAccurate,this.options=(0,fM.default)({maxAccuracy:200,positionOptions:{timeout:3e4,enableHighAccuracy:!0,maximumAge:0},positionMarkerStyles:{radius:"12px",strokeWeight:"2px",strokeColor:Si(["color","white","white","value"],un)||"white",fillColor:Si(["color","blue","60","value"],un)||"#4169E1",fillOpacity:1},accuracyCircleStyles:{fillColor:Si(["color","blue","60","value"],un)||"#4169E1",fillOpacity:Si(["opacity","small","value"],hM)||.16}},t),e.className="mapsindoors position-control",this.positionButton=document.createElement("button"),this.positionButton.addEventListener("click",this.positionButtonClicked.bind(this)),e.appendChild(this.positionButton),!("permissions"in navigator)||!("query"in navigator.permissions)?this.setPositionState(Lt.POSITION_UNKNOWN):navigator.permissions.query({name:"geolocation"}).then(n=>{n.state==="granted"?this.watchPosition():this.setPositionState(Lt.POSITION_UNKNOWN)})}positionButtonClicked(e){switch(e.stopPropagation(),this.positionState){case Lt.POSITION_UNKNOWN:this.watchPosition(!0);break;case Lt.POSITION_KNOWN:case Lt.POSITION_CENTERED:this.panToCurrentPosition();break}}setPositionProviderOnMapView(){let e=this.mapsIndoors.getMapView();e.isReady?e.setPositionProvider(this):e.once("ready",()=>{e.setPositionProvider(this)})}setPositionState(e){this.positionState=e;let t="mapsindoors position-control__button position-control__button--",n="";switch(this.positionState){case Lt.POSITION_UNKNOWN:case Lt.POSITION_INACCURATE:t+="unknown",n="Show position on map";break;case Lt.POSITION_REQUESTING:t+="requesting",n="Requesting position...";break;case Lt.POSITION_KNOWN:t+="known",n="Center position on map";break;case Lt.POSITION_CENTERED:t+="centered",n="Center position on map";break}this.positionButton.className=t,this.positionButton.setAttribute("aria-label",n)}watchPosition(e=!1){if(!navigator.geolocation)return;this.setPositionState(Lt.POSITION_REQUESTING),this.setPositionProviderOnMapView();let t=Date.now();navigator.geolocation.watchPosition(n=>{this.currentPosition&&n.coords.accuracy===this.currentPosition.coords.accuracy&&n.coords.latitude===this.currentPosition.coords.latitude&&n.coords.longitude===this.currentPosition.coords.longitude||(this.currentPosition=n,this.positionIsAccurate=this.currentPosition.coords.accuracy<=this.options.maxAccuracy,this.positionIsAccurate?this.setPositionState(Lt.POSITION_KNOWN):(this.setPositionState(Lt.POSITION_INACCURATE),this.emit("position_error",{code:11,message:"Inaccurate position: "+n.coords.accuracy})),this.emit("position_received",{position:this.currentPosition,selfInvoked:e,accurate:this.positionIsAccurate}))},n=>{(n.code!==3||!this.currentPosition||this.currentPosition.timestamp<=t)&&this.setPositionUnknown(n)},this.options.positionOptions)}setPositionUnknown(e){this.setPositionState(Lt.POSITION_UNKNOWN),this.emit("position_error",e)}hasValidPosition(){return[Lt.POSITION_KNOWN,Lt.POSITION_CENTERED,Lt.POSITION_INACCURATE].includes(this.positionState)}panToCurrentPosition(){!this.hasValidPosition()||(this.mapsIndoors.getMapView().panTo({lat:this.currentPosition.coords.latitude,lng:this.currentPosition.coords.longitude}),this.setPositionState(Lt.POSITION_CENTERED),this.mapsIndoors.getMapView().once("idle",()=>{this.mapsIndoors.getMapView().once("idle",()=>{this.setPositionState(Lt.POSITION_KNOWN)})}))}};var T2={GoogleMapsView:Au,MapboxView:Jf,MapboxV3View:ad},I2={GoogleMapsProvider:Jl,MapboxProvider:dc,DirectionsRenderer:vu,DefaultRouteAnimation:ua,DefaultRouteStopIconProvider:fa},R2=new Proxy(Un,O_),C2=Object.assign({},vp,{LocationsService:R2}),uy=document.createElement("link");uy.rel="stylesheet";uy.href=document.currentScript.src.replace(/\.js(\.gz)?([?#]?(.*?))$/,".css$1");document.head.appendChild(uy);return wM(L2);})();
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
