From 414e654544457ca93d7faad3a7e5cd6685a6e6d6 Mon Sep 17 00:00:00 2001 From: wataru Date: Fri, 2 Sep 2022 11:41:24 +0900 Subject: [PATCH] update --- docs/assets/setting.json | 3 ++- docs/index.js | 2 +- package.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/assets/setting.json b/docs/assets/setting.json index fa47f822b..2237e8732 100755 --- a/docs/assets/setting.json +++ b/docs/assets/setting.json @@ -31,6 +31,7 @@ "screen_draw_skip_rate": 3, "visualizer_draw_skip_rate": 3, "cross_fade_lower_value": 0.1, - "cross_fade_overlap_rate": 0.03 + "cross_fade_offset_rate": 0.3, + "cross_fade_end_rate": 0.6 } } diff --git a/docs/index.js b/docs/index.js index 68dde4176..3060813e8 100755 --- a/docs/index.js +++ b/docs/index.js @@ -1,2 +1,2 @@ /*! For license information please see index.js.LICENSE.txt */ -(()=>{var __webpack_modules__={914:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RawSha256=void 0;var i=n(6532),r=function(){function e(){this.state=Int32Array.from(i.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return e.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=0,n=e.byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>i.MAX_HASHABLE_LENGTH)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,this.bufferLength===i.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var e=8*this.bytesHashed,t=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),n=this.bufferLength;if(t.setUint8(this.bufferLength++,128),n%i.BLOCK_SIZE>=i.BLOCK_SIZE-8){for(var r=this.bufferLength;r>>24&255,a[4*r+1]=this.state[r]>>>16&255,a[4*r+2]=this.state[r]>>>8&255,a[4*r+3]=this.state[r]>>>0&255;return a},e.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],r=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=0;d>>17|h<<15)^(h>>>19|h<<13)^h>>>10,p=((h=this.temp[d-15])>>>7|h<<25)^(h>>>18|h<<14)^h>>>3;this.temp[d]=(f+this.temp[d-7]|0)+(p+this.temp[d-16]|0)}var m=(((s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+(s&c^~s&l)|0)+(u+(i.KEY[d]+this.temp[d]|0)|0)|0,g=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&r^n&a^r&a)|0;u=l,l=c,c=s,s=o+m|0,o=a,a=r,r=n,n=m+g|0}t[0]+=n,t[1]+=r,t[2]+=a,t[3]+=o,t[4]+=s,t[5]+=c,t[6]+=l,t[7]+=u},e}();t.RawSha256=r},6532:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_HASHABLE_LENGTH=t.INIT=t.KEY=t.DIGEST_LENGTH=t.BLOCK_SIZE=void 0,t.BLOCK_SIZE=64,t.DIGEST_LENGTH=32,t.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.MAX_HASHABLE_LENGTH=Math.pow(2,53)-1},1938:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),(0,n(655).__exportStar)(n(5430),t)},5430:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Sha256=void 0;var i=n(655),r=n(6532),a=n(914),o=n(7658),s=function(){function e(e){if(this.hash=new a.RawSha256,e){this.outer=new a.RawSha256;var t=function(e){var t=(0,o.convertToBuffer)(e);if(t.byteLength>r.BLOCK_SIZE){var n=new a.RawSha256;n.update(t),t=n.digest()}var i=new Uint8Array(r.BLOCK_SIZE);return i.set(t),i}(e),n=new Uint8Array(r.BLOCK_SIZE);n.set(t);for(var i=0;i{"use strict";var i=n(8764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.convertToBuffer=void 0;var r=n(470),a=void 0!==i&&i.from?function(e){return i.from(e,"utf8")}:r.fromUtf8;t.convertToBuffer=function(e){return e instanceof Uint8Array?e:"string"==typeof e?a(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}},7658:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=t.numToUint8=t.isEmptyData=t.convertToBuffer=void 0;var i=n(1106);Object.defineProperty(t,"convertToBuffer",{enumerable:!0,get:function(){return i.convertToBuffer}});var r=n(4304);Object.defineProperty(t,"isEmptyData",{enumerable:!0,get:function(){return r.isEmptyData}});var a=n(2174);Object.defineProperty(t,"numToUint8",{enumerable:!0,get:function(){return a.numToUint8}});var o=n(1558);Object.defineProperty(t,"uint32ArrayFrom",{enumerable:!0,get:function(){return o.uint32ArrayFrom}})},4304:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEmptyData=void 0,t.isEmptyData=function(e){return"string"==typeof e?0===e.length:0===e.byteLength}},2174:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.numToUint8=void 0,t.numToUint8=function(e){return new Uint8Array([(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])}},1558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=void 0,t.uint32ArrayFrom=function(e){if(!Uint32Array.from){for(var t=new Uint32Array(e.length),n=0;n{"use strict";n.r(t),n.d(t,{fromHex:()=>s,toHex:()=>c});for(var i={},r={},a=0;a<256;a++){var o=a.toString(16).toLowerCase();1===o.length&&(o="0".concat(o)),i[a]=o,r[o]=a}function s(e){if(e.length%2!=0)throw new Error("Hex encoded strings must have an even number length");for(var t=new Uint8Array(e.length/2),n=0;n{"use strict";n.r(t),n.d(t,{fromUtf8:()=>i,toUtf8:()=>r});var i=function(e){return"function"==typeof TextEncoder?function(e){return(new TextEncoder).encode(e)}(e):function(e){for(var t=[],n=0,i=e.length;n>6|192,63&r|128);else if(n+1>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}else t.push(r>>12|224,r>>6&63|128,63&r|128)}return Uint8Array.from(t)}(e)},r=function(e){return"function"==typeof TextDecoder?function(e){return new TextDecoder("utf-8").decode(e)}(e):function(e){for(var t="",n=0,i=e.length;n(()=>{var e={373:function(e,t,n){var i;"undefined"!=typeof self&&self,i=()=>(()=>{var e={252:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlockingQueue=void 0;var n=function(){function e(){this._resolvers=[],this._promises=[]}return e.prototype._add=function(){var e=this;this._promises.push(new Promise((function(t){e._resolvers.push(t)})))},e.prototype.enqueue=function(e){this._resolvers.length||this._add(),this._resolvers.shift()(e)},e.prototype.dequeue=function(){return this._promises.length||this._add(),this._promises.shift()},e.prototype.isEmpty=function(){return!this._promises.length},e.prototype.isBlocked=function(){return!!this._resolvers.length},Object.defineProperty(e.prototype,"length",{get:function(){return this._promises.length-this._resolvers.length},enumerable:!1,configurable:!0}),e}();t.BlockingQueue=n},289:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBrowserType=t.BrowserTypes=void 0,t.BrowserTypes={MSIE:"MSIE",EDGE:"EDGE",CHROME:"CHROME",SAFARI:"SAFARI",FIREFOX:"FIREFOX",OPERA:"OPERA",OTHER:"OTHER"},t.getBrowserType=function(){var e=window.navigator.userAgent.toLowerCase();return-1!==e.indexOf("msie")||-1!==e.indexOf("trident")?t.BrowserTypes.MSIE:-1!==e.indexOf("edge")?t.BrowserTypes.EDGE:-1!==e.indexOf("chrome")?t.BrowserTypes.CHROME:-1!==e.indexOf("safari")?t.BrowserTypes.SAFARI:-1!==e.indexOf("firefox")?t.BrowserTypes.FIREFOX:-1!==e.indexOf("opera")?t.BrowserTypes.OPERA:t.BrowserTypes.OTHER}},187:function(e,t,n){"use strict";var i=n(764).lW,r=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,i,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]100)throw new Error("queue is fulled: ".concat(this.sem.length));return[4,this.lock()];case 1:e=a.sent(),r=new Promise((function(e,r){if(!l.worker)throw new Error("worker is not activated.");l.worker.onmessage=function(t){t.data.message===c.WorkerResponse.PREDICTED?e(t.data.prediction):(console.log("Prediction something wrong..",t.data.message),r(t))},i?n instanceof Uint8ClampedArray?l.worker.postMessage({message:c.WorkerCommand.PREDICT,params:t,data:n},[n.buffer]):l.worker.postMessage({message:c.WorkerCommand.PREDICT,params:t,data:n},[n]):l.worker.postMessage({message:c.WorkerCommand.PREDICT,params:t,data:n})})),a.label=2;case 2:return a.trys.push([2,4,5,6]),[4,r];case 3:return o=a.sent(),[3,6];case 4:return s=a.sent(),console.log("worker prediction error. :",s),[3,6];case 5:return this.unlock(e),[7];case 6:return[2,o]}}))}))},this.useWorker=function(e){return!e.processOnLocal&&(!1!==e.useWorkerForSafari||(0,s.getBrowserType)()!==s.BrowserTypes.SAFARI)},this.fetchData=function(t){return r(e,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return t.startsWith("data:")?(e=t.split(",")[1],[2,i.from(e,"base64")]):[4,fetch(t,{method:"GET"})];case 1:return[4,n.sent().arrayBuffer()];case 2:return[2,n.sent()]}}))}))},this.sem.enqueue(0)},t.WorkerDispatcher=function(e){var t=this;this.imageProcessor=null,this.config=null,this.callbacks=null,this.setCallback=function(e){t.callbacks=e},this.dispach=function(e){return r(t,void 0,void 0,(function(){var t,n,i,r;return a(this,(function(a){switch(a.label){case 0:return this.callbacks?e.data.message!==c.WorkerCommand.INITIALIZE?[3,2]:(this.config=e.data.config,t=this,[4,this.callbacks.init(this.config)]):(console.warn("[worker] Dispatcher callbacks is not initialized"),[2]);case 1:return t.imageProcessor=a.sent(),this.context.postMessage({message:c.WorkerResponse.INITIALIZED}),console.log("[worker] Initialized"),[3,4];case 2:return e.data.message!==c.WorkerCommand.PREDICT?[3,4]:this.imageProcessor?this.config?(n=e.data.params,i=e.data.data,[4,this.imageProcessor.predict(this.config,n,i)]):(console.warn("[worker] Dispatcher config is not initialized"),[2]):(console.warn("[worker] ImageProcessor is not initialized"),[2]);case 3:r=a.sent(),this.context.postMessage({message:c.WorkerResponse.PREDICTED,prediction:r}),a.label=4;case 4:return[2]}}))}))},this.context=e}},301:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WorkerResponse=t.WorkerCommand=void 0,t.WorkerCommand={INITIALIZE:"initialize",PREDICT:"predict"},t.WorkerResponse={INITIALIZED:"initialized",PREDICTED:"predicted"}},55:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(187),t),r(n(289),t)},742:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),n=t[0],i=t[1];return 3*(n+i)/4-i},t.toByteArray=function(e){var t,n,a=c(e),o=a[0],s=a[1],l=new r(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),u=0,d=s>0?o-4:o;for(n=0;n>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===s&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,l[u++]=255&t),1===s&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l},t.fromByteArray=function(e){for(var t,i=e.length,r=i%3,a=[],o=16383,s=0,c=i-r;sc?c:s+o));return 1===r?(t=e[i-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===r&&(t=(e[i-2]<<8)+e[i-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),a.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,s=a.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,i){for(var r,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},764:(e,t,n)=>{"use strict";const i=n(742),r=n(645),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.lW=c,t.h2=50;const o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,n)}function l(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|m(e,t);let i=s(n);const r=i.write(e,t);return r!==n&&(i=i.slice(0,r)),i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(J(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(J(e,ArrayBuffer)||e&&J(e.buffer,ArrayBuffer))return f(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(J(e,SharedArrayBuffer)||e&&J(e.buffer,SharedArrayBuffer)))return f(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,n);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||$(e.length)?s(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return u(e),s(e<0?0:0|p(e))}function h(e){const t=e.length<0?0:0|p(e.length),n=s(t);for(let i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||J(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(e).length;default:if(r)return i?-1:q(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){let i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,n);case"utf8":case"utf-8":return L(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return z(this,t,n);case"base64":return w(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function C(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function v(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,i,r);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,i,r){let a,o=1,s=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,s/=2,c/=2,n/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let i=-1;for(a=n;as&&(n=s-c),a=n;a>=0;a--){let n=!0;for(let i=0;ir&&(i=r):i=r;const a=t.length;let o;for(i>a/2&&(i=a/2),o=0;o>8,r=n%256,a.push(r),a.push(i);return a}(t,e.length-n),e,n,i)}function w(e,t,n){return 0===t&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function L(e,t,n){n=Math.min(e.length,n);const i=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=n){let n,i,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[r+1],128==(192&n)&&(c=(31&t)<<6|63&n,c>127&&(a=c));break;case 3:n=e[r+1],i=e[r+2],128==(192&n)&&128==(192&i)&&(c=(15&t)<<12|(63&n)<<6|63&i,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[r+1],i=e[r+2],s=e[r+3],128==(192&n)&&128==(192&i)&&128==(192&s)&&(c=(15&t)<<18|(63&n)<<12|(63&i)<<6|63&s,c>65535&&c<1114112&&(a=c))}}null===a?(a=65533,o=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|1023&a),i.push(a),r+=o}return function(e){const t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);let n="",i=0;for(;ii.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(i,r)):Uint8Array.prototype.set.call(i,t,r);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(i,r)}r+=t.length}return i},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tn&&(e+=" ... "),""},a&&(c.prototype[a]=c.prototype.inspect),c.prototype.compare=function(e,t,n,i,r){if(J(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;let a=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(t>>>=0);const s=Math.min(a,o),l=this.slice(i,r),u=e.slice(t,n);for(let e=0;e>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return M(this,e,t,n);case"ascii":case"latin1":case"binary":return x(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function T(e,t,n){let i="";n=Math.min(e.length,n);for(let r=t;ri)&&(n=i);let r="";for(let i=t;in)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,n,i,r,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function P(e,t,n,i,r){U(t,i,r,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function I(e,t,n,i,r){U(t,i,r,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}function k(e,t,n,i,r,a){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function N(e,t,n,i,a){return t=+t,n>>>=0,a||k(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function D(e,t,n,i,a){return t=+t,n>>>=0,a||k(e,0,n,8),r.write(e,t,n,i,52,8),n+8}c.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e],r=1,a=0;for(;++a>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e+--t],r=1;for(;t>0&&(r*=256);)i+=this[e+--t]*r;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(i)+(BigInt(r)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(i)<>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e],r=1,a=0;for(;++a=r&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let i=t,r=1,a=this[e+--i];for(;i>0&&(r*=256);)a+=this[e+--i]*r;return r*=128,a>=r&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||H(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){e>>>=0,t||H(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(i)<>>=0,t||H(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||H(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||H(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||H(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,n,i){e=+e,t>>>=0,n>>>=0,i||R(this,e,t,n,Math.pow(2,8*n)-1,0);let r=1,a=0;for(this[t]=255&e;++a>>=0,n>>>=0,i||R(this,e,t,n,Math.pow(2,8*n)-1,0);let r=n-1,a=1;for(this[t+r]=255&e;--r>=0&&(a*=256);)this[t+r]=e/a&255;return t+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return P(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return I(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}let r=0,a=1,o=0;for(this[t]=255&e;++r>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}let r=n-1,a=1,o=0;for(this[t+r]=255&e;--r>=0&&(a*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/a>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return P(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return I(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,n){return N(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return N(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(r=t;r=i+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function U(e,t,n,i,r,a){if(e>n||e3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(a+1)}${i}`:`>= -(2${i} ** ${8*(a+1)-1}${i}) and < 2 ** ${8*(a+1)-1}${i}`:`>= ${t}${i} and <= ${n}${i}`,new O.ERR_OUT_OF_RANGE("value",r,e)}!function(e,t,n){W(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||G(t,e.length-(n+1))}(i,r,a)}function W(e,t){if("number"!=typeof e)throw new O.ERR_INVALID_ARG_TYPE(t,"number",e)}function G(e,t,n){if(Math.floor(e)!==e)throw W(e,n),new O.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new O.ERR_BUFFER_OUT_OF_BOUNDS;throw new O.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}B("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),B("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),B("ERR_OUT_OF_RANGE",(function(e,t,n){let i=`The value of "${e}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=F(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=F(r)),r+="n"),i+=` It must be ${t}. Received ${r}`,i}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function q(e,t){let n;t=t||1/0;const i=e.length;let r=null;const a=[];for(let o=0;o55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&a.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function X(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,n,i){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function J(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function $(e){return e!=e}const K=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)t[i+r]=e[n]+e[r]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},645:(e,t)=>{t.read=function(e,t,n,i,r){var a,o,s=8*r-i-1,c=(1<>1,u=-7,d=n?r-1:0,h=n?-1:1,f=e[t+d];for(d+=h,a=f&(1<<-u)-1,f>>=-u,u+=s;u>0;a=256*a+e[t+d],d+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=i;u>0;o=256*o+e[t+d],d+=h,u-=8);if(0===a)a=1-l;else{if(a===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,i),a-=l}return(f?-1:1)*o*Math.pow(2,a-i)},t.write=function(e,t,n,i,r,a){var o,s,c,l=8*a-r-1,u=(1<>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:a-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*Math.pow(2,r),o+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[n+f]=255&s,f+=p,s/=256,r-=8);for(o=o<0;e[n+f]=255&o,f+=p,o/=256,l-=8);e[n+f-p]|=128*m}},477:e=>{"use strict";e.exports=function(e,t,n,i){var r=self||window;try{try{var a;try{a=new r.Blob([e])}catch(t){(a=new(r.BlobBuilder||r.WebKitBlobBuilder||r.MozBlobBuilder||r.MSBlobBuilder)).append(e),a=a.getBlob()}var o=r.URL||r.webkitURL,s=o.createObjectURL(a),c=new r[t](s,n);return o.revokeObjectURL(s),c}catch(i){return new r[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!i)throw Error("Inline worker is not supported");return new r[t](i,n)}}},503:(e,t,n)=>{var i,a=n(764).lW,o=(i=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,o,s=void 0!==(e=e||{})?e:{},c=Object.assign;s.ready=new Promise((function(e,n){t=e,o=n}));var l,u,d,h,f,p,m=c({},s),g=[],C="./this.program",v=(e,t)=>{throw t},y="object"==typeof window,b="function"==typeof importScripts,M="object"==typeof r&&"object"==typeof r.versions&&"string"==typeof r.versions.node,x="";M?(x=b?n(375).dirname(x)+"/":"//",p=()=>{f||(h=n(384),f=n(375))},l=function(e,t){return p(),e=f.normalize(e),h.readFileSync(e,t?null:"utf8")},d=e=>{var t=l(e,!0);return t.buffer||(t=new Uint8Array(t)),t},u=(e,t,n)=>{p(),e=f.normalize(e),h.readFile(e,(function(e,i){e?n(e):t(i.buffer)}))},r.argv.length>1&&(C=r.argv[1].replace(/\\/g,"/")),g=r.argv.slice(2),r.on("uncaughtException",(function(e){if(!(e instanceof Ae))throw e})),r.on("unhandledRejection",(function(e){throw e})),v=(e,t)=>{if(W())throw r.exitCode=e,t;var n;(n=t)instanceof Ae||w("exiting due to exception: "+n),r.exit(e)},s.inspect=function(){return"[Emscripten Module object]"}):(y||b)&&(b?x=self.location.href:"undefined"!=typeof document&&document.currentScript&&(x=document.currentScript.src),i&&(x=i),x=0!==x.indexOf("blob:")?x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},b&&(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),u=(e,t,n)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):n()},i.onerror=n,i.send(null)});var _,S=s.print||console.log.bind(console),w=s.printErr||console.warn.bind(console);c(s,m),m=null,s.arguments&&(g=s.arguments),s.thisProgram&&(C=s.thisProgram),s.quit&&(v=s.quit),s.wasmBinary&&(_=s.wasmBinary);var L,E=s.noExitRuntime||!0;"object"!=typeof WebAssembly&&Q("no native wasm support detected");var T,z,A,V,H=!1,R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function P(e,t,n){for(var i=t+n,r=t;e[r]&&!(r>=i);)++r;if(r-t>16&&e.subarray&&R)return R.decode(e.subarray(t,r));for(var a="";t>10,56320|1023&l)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a}function I(e,t){return e?P(A,e,t):""}function k(e,t,n,i){if(!(i>0))return 0;for(var r=n,a=n+i-1,o=0;o=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}return t[n]=0,n-r}function N(e){for(var t=0,n=0;n=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++n)),i<=127?++t:t+=i<=2047?2:i<=65535?3:4}return t}function D(e){T=e,s.HEAP8=z=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAP32=V=new Int32Array(e),s.HEAPU8=A=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAPU32=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=new Float64Array(e)}s.INITIAL_MEMORY;var O,B=[],F=[],U=[];function W(){return E||!1}var G,j,q,X,Y=0,J=null,$=null;function K(e){Y++,s.monitorRunDependencies&&s.monitorRunDependencies(Y)}function Z(e){if(Y--,s.monitorRunDependencies&&s.monitorRunDependencies(Y),0==Y&&(null!==J&&(clearInterval(J),J=null),$)){var t=$;$=null,t()}}function Q(e){s.onAbort&&s.onAbort(e),w(e="Aborted("+e+")"),H=!0,e+=". Build with -s ASSERTIONS=1 for more info.";var t=new WebAssembly.RuntimeError(e);throw o(t),t}function ee(e){return e.startsWith("data:application/octet-stream;base64,")}function te(e){return e.startsWith("file://")}function ne(e){try{if(e==G&&_)return new Uint8Array(_);if(d)return d(e);throw"both async and sync fetching of the wasm failed"}catch(e){Q(e)}}function ie(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var n=t.func;"number"==typeof n?void 0===t.arg?oe(n)():oe(n)(t.arg):n(void 0===t.arg?null:t.arg)}else t(s)}}s.preloadedImages={},s.preloadedAudios={},ee(G="tflite-simd.wasm")||(j=G,G=s.locateFile?s.locateFile(j,x):x+j);var re,ae=[];function oe(e){var t=ae[e];return t||(e>=ae.length&&(ae.length=e+1),ae[e]=t=O.get(e)),t}function se(e){this.excPtr=e,this.ptr=e-16,this.set_type=function(e){V[this.ptr+4>>2]=e},this.get_type=function(){return V[this.ptr+4>>2]},this.set_destructor=function(e){V[this.ptr+8>>2]=e},this.get_destructor=function(){return V[this.ptr+8>>2]},this.set_refcount=function(e){V[this.ptr>>2]=e},this.set_caught=function(e){e=e?1:0,z[this.ptr+12>>0]=e},this.get_caught=function(){return 0!=z[this.ptr+12>>0]},this.set_rethrown=function(e){e=e?1:0,z[this.ptr+13>>0]=e},this.get_rethrown=function(){return 0!=z[this.ptr+13>>0]},this.init=function(e,t){this.set_type(e),this.set_destructor(t),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=V[this.ptr>>2];V[this.ptr>>2]=e+1},this.release_ref=function(){var e=V[this.ptr>>2];return V[this.ptr>>2]=e-1,1===e}}function ce(e){try{return L.grow(e-T.byteLength+65535>>>16),D(L.buffer),1}catch(e){}}re=M?()=>{var e=r.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now();var le={};function ue(){if(!ue.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:C||"./this.program"};for(var t in le)void 0===le[t]?delete e[t]:e[t]=le[t];var n=[];for(var t in e)n.push(t+"="+e[t]);ue.strings=n}return ue.strings}var de={splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,t){for(var n=0,i=e.length-1;i>=0;i--){var r=e[i];"."===r?e.splice(i,1):".."===r?(e.splice(i,1),n++):n&&(e.splice(i,1),n--)}if(t)for(;n;n--)e.unshift("..");return e},normalize:function(e){var t="/"===e.charAt(0),n="/"===e.substr(-1);return(e=de.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},dirname:function(e){var t=de.splitPath(e),n=t[0],i=t[1];return n||i?(i&&(i=i.substr(0,i.length-1)),n+i):"."},basename:function(e){if("/"===e)return"/";var t=(e=(e=de.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},extname:function(e){return de.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return de.normalize(e.join("/"))},join2:function(e,t){return de.normalize(e+"/"+t)}};function he(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(M)try{var t=n(782);return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){Q("randomDevice")}}var fe={resolve:function(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var i=n>=0?arguments[n]:ge.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t="/"===i.charAt(0)}return(t?"/":"")+(e=de.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."},relative:function(e,t){function n(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=fe.resolve(e).substr(1),t=fe.resolve(t).substr(1);for(var i=n(e.split("/")),r=n(t.split("/")),a=Math.min(i.length,r.length),o=a,s=0;s0?n.slice(0,i).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n");if(!t)return null;e.input=Se(t,!0)}return e.input.shift()},put_char:function(e,t){null===t||10===t?(S(P(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&e.output.length>0&&(S(P(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(w(P(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&e.output.length>0&&(w(P(e.output,0)),e.output=[])}}},me={ops_table:null,mount:function(e){return me.createNode(null,"/",16895,0)},createNode:function(e,t,n,i){if(ge.isBlkdev(n)||ge.isFIFO(n))throw new ge.ErrnoError(63);me.ops_table||(me.ops_table={dir:{node:{getattr:me.node_ops.getattr,setattr:me.node_ops.setattr,lookup:me.node_ops.lookup,mknod:me.node_ops.mknod,rename:me.node_ops.rename,unlink:me.node_ops.unlink,rmdir:me.node_ops.rmdir,readdir:me.node_ops.readdir,symlink:me.node_ops.symlink},stream:{llseek:me.stream_ops.llseek}},file:{node:{getattr:me.node_ops.getattr,setattr:me.node_ops.setattr},stream:{llseek:me.stream_ops.llseek,read:me.stream_ops.read,write:me.stream_ops.write,allocate:me.stream_ops.allocate,mmap:me.stream_ops.mmap,msync:me.stream_ops.msync}},link:{node:{getattr:me.node_ops.getattr,setattr:me.node_ops.setattr,readlink:me.node_ops.readlink},stream:{}},chrdev:{node:{getattr:me.node_ops.getattr,setattr:me.node_ops.setattr},stream:ge.chrdev_stream_ops}});var r=ge.createNode(e,t,n,i);return ge.isDir(r.mode)?(r.node_ops=me.ops_table.dir.node,r.stream_ops=me.ops_table.dir.stream,r.contents={}):ge.isFile(r.mode)?(r.node_ops=me.ops_table.file.node,r.stream_ops=me.ops_table.file.stream,r.usedBytes=0,r.contents=null):ge.isLink(r.mode)?(r.node_ops=me.ops_table.link.node,r.stream_ops=me.ops_table.link.stream):ge.isChrdev(r.mode)&&(r.node_ops=me.ops_table.chrdev.node,r.stream_ops=me.ops_table.chrdev.stream),r.timestamp=Date.now(),e&&(e.contents[t]=r,e.timestamp=r.timestamp),r},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,t){var n=e.contents?e.contents.length:0;if(!(n>=t)){t=Math.max(t,n*(n<1048576?2:1.125)>>>0),0!=n&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var n=e.contents;e.contents=new Uint8Array(t),n&&e.contents.set(n.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr:function(e){var t={};return t.dev=ge.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ge.isDir(e.mode)?t.size=4096:ge.isFile(e.mode)?t.size=e.usedBytes:ge.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&me.resizeFileStorage(e,t.size)},lookup:function(e,t){throw ge.genericErrors[44]},mknod:function(e,t,n,i){return me.createNode(e,t,n,i)},rename:function(e,t,n){if(ge.isDir(e.mode)){var i;try{i=ge.lookupNode(t,n)}catch(e){}if(i)for(var r in i.contents)throw new ge.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=n,t.contents[n]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var n=ge.lookupNode(e,t);for(var i in n.contents)throw new ge.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var n in e.contents)e.contents.hasOwnProperty(n)&&t.push(n);return t},symlink:function(e,t,n){var i=me.createNode(e,t,41471,0);return i.link=n,i},readlink:function(e){if(!ge.isLink(e.mode))throw new ge.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,n,i,r){var a=e.node.contents;if(r>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-r,i);if(o>8&&a.subarray)t.set(a.subarray(r,r+o),n);else for(var s=0;s0||i+n{if(!(e=fe.resolve(ge.cwd(),e)))return{path:"",node:null};var n={follow_mount:!0,recurse_count:0};for(var i in n)void 0===t[i]&&(t[i]=n[i]);if(t.recurse_count>8)throw new ge.ErrnoError(32);for(var r=de.normalizeArray(e.split("/").filter((e=>!!e)),!1),a=ge.root,o="/",s=0;s40)throw new ge.ErrnoError(32)}}return{path:o,node:a}},getPath:e=>{for(var t;;){if(ge.isRoot(e)){var n=e.mount.mountpoint;return t?"/"!==n[n.length-1]?n+"/"+t:n+t:n}t=t?e.name+"/"+t:e.name,e=e.parent}},hashName:(e,t)=>{for(var n=0,i=0;i>>0)%ge.nameTable.length},hashAddNode:e=>{var t=ge.hashName(e.parent.id,e.name);e.name_next=ge.nameTable[t],ge.nameTable[t]=e},hashRemoveNode:e=>{var t=ge.hashName(e.parent.id,e.name);if(ge.nameTable[t]===e)ge.nameTable[t]=e.name_next;else for(var n=ge.nameTable[t];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode:(e,t)=>{var n=ge.mayLookup(e);if(n)throw new ge.ErrnoError(n,e);for(var i=ge.hashName(e.id,t),r=ge.nameTable[i];r;r=r.name_next){var a=r.name;if(r.parent.id===e.id&&a===t)return r}return ge.lookup(e,t)},createNode:(e,t,n,i)=>{var r=new ge.FSNode(e,t,n,i);return ge.hashAddNode(r),r},destroyNode:e=>{ge.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var t=ge.flagModes[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t},flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ge.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>ge.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,t)=>{try{return ge.lookupNode(e,t),20}catch(e){}return ge.nodePermissions(e,"wx")},mayDelete:(e,t,n)=>{var i;try{i=ge.lookupNode(e,t)}catch(e){return e.errno}var r=ge.nodePermissions(e,"wx");if(r)return r;if(n){if(!ge.isDir(i.mode))return 54;if(ge.isRoot(i)||ge.getPath(i)===ge.cwd())return 10}else if(ge.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?ge.isLink(e.mode)?32:ge.isDir(e.mode)&&("r"!==ge.flagsToPermissionString(t)||512&t)?31:ge.nodePermissions(e,ge.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:(e=0,t=ge.MAX_OPEN_FDS)=>{for(var n=e;n<=t;n++)if(!ge.streams[n])return n;throw new ge.ErrnoError(33)},getStream:e=>ge.streams[e],createStream:(e,t,n)=>{ge.FSStream||(ge.FSStream=function(){},ge.FSStream.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var i=new ge.FSStream;for(var r in e)i[r]=e[r];e=i;var a=ge.nextfd(t,n);return e.fd=a,ge.streams[a]=e,e},closeStream:e=>{ge.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ge.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ge.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ge.devices[e]={stream_ops:t}},getDevice:e=>ge.devices[e],getMounts:e=>{for(var t=[],n=[e];n.length;){var i=n.pop();t.push(i),n.push.apply(n,i.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ge.syncFSRequests++,ge.syncFSRequests>1&&w("warning: "+ge.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var n=ge.getMounts(ge.root.mount),i=0;function r(e){return ge.syncFSRequests--,t(e)}function a(e){if(e)return a.errored?void 0:(a.errored=!0,r(e));++i>=n.length&&r(null)}n.forEach((t=>{if(!t.type.syncfs)return a(null);t.type.syncfs(t,e,a)}))},mount:(e,t,n)=>{var i,r="/"===n,a=!n;if(r&&ge.root)throw new ge.ErrnoError(10);if(!r&&!a){var o=ge.lookupPath(n,{follow_mount:!1});if(n=o.path,i=o.node,ge.isMountpoint(i))throw new ge.ErrnoError(10);if(!ge.isDir(i.mode))throw new ge.ErrnoError(54)}var s={type:e,opts:t,mountpoint:n,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,r?ge.root=c:i&&(i.mounted=s,i.mount&&i.mount.mounts.push(s)),c},unmount:e=>{var t=ge.lookupPath(e,{follow_mount:!1});if(!ge.isMountpoint(t.node))throw new ge.ErrnoError(28);var n=t.node,i=n.mounted,r=ge.getMounts(i);Object.keys(ge.nameTable).forEach((e=>{for(var t=ge.nameTable[e];t;){var n=t.name_next;r.includes(t.mount)&&ge.destroyNode(t),t=n}})),n.mounted=null;var a=n.mount.mounts.indexOf(i);n.mount.mounts.splice(a,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,n)=>{var i=ge.lookupPath(e,{parent:!0}).node,r=de.basename(e);if(!r||"."===r||".."===r)throw new ge.ErrnoError(28);var a=ge.mayCreate(i,r);if(a)throw new ge.ErrnoError(a);if(!i.node_ops.mknod)throw new ge.ErrnoError(63);return i.node_ops.mknod(i,r,t,n)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ge.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ge.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var n=e.split("/"),i="",r=0;r(void 0===n&&(n=t,t=438),t|=8192,ge.mknod(e,t,n)),symlink:(e,t)=>{if(!fe.resolve(e))throw new ge.ErrnoError(44);var n=ge.lookupPath(t,{parent:!0}).node;if(!n)throw new ge.ErrnoError(44);var i=de.basename(t),r=ge.mayCreate(n,i);if(r)throw new ge.ErrnoError(r);if(!n.node_ops.symlink)throw new ge.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename:(e,t)=>{var n,i,r=de.dirname(e),a=de.dirname(t),o=de.basename(e),s=de.basename(t);if(n=ge.lookupPath(e,{parent:!0}).node,i=ge.lookupPath(t,{parent:!0}).node,!n||!i)throw new ge.ErrnoError(44);if(n.mount!==i.mount)throw new ge.ErrnoError(75);var c,l=ge.lookupNode(n,o),u=fe.relative(e,a);if("."!==u.charAt(0))throw new ge.ErrnoError(28);if("."!==(u=fe.relative(t,r)).charAt(0))throw new ge.ErrnoError(55);try{c=ge.lookupNode(i,s)}catch(e){}if(l!==c){var d=ge.isDir(l.mode),h=ge.mayDelete(n,o,d);if(h)throw new ge.ErrnoError(h);if(h=c?ge.mayDelete(i,s,d):ge.mayCreate(i,s))throw new ge.ErrnoError(h);if(!n.node_ops.rename)throw new ge.ErrnoError(63);if(ge.isMountpoint(l)||c&&ge.isMountpoint(c))throw new ge.ErrnoError(10);if(i!==n&&(h=ge.nodePermissions(n,"w")))throw new ge.ErrnoError(h);ge.hashRemoveNode(l);try{n.node_ops.rename(l,i,s)}catch(e){throw e}finally{ge.hashAddNode(l)}}},rmdir:e=>{var t=ge.lookupPath(e,{parent:!0}).node,n=de.basename(e),i=ge.lookupNode(t,n),r=ge.mayDelete(t,n,!0);if(r)throw new ge.ErrnoError(r);if(!t.node_ops.rmdir)throw new ge.ErrnoError(63);if(ge.isMountpoint(i))throw new ge.ErrnoError(10);t.node_ops.rmdir(t,n),ge.destroyNode(i)},readdir:e=>{var t=ge.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ge.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ge.lookupPath(e,{parent:!0}).node;if(!t)throw new ge.ErrnoError(44);var n=de.basename(e),i=ge.lookupNode(t,n),r=ge.mayDelete(t,n,!1);if(r)throw new ge.ErrnoError(r);if(!t.node_ops.unlink)throw new ge.ErrnoError(63);if(ge.isMountpoint(i))throw new ge.ErrnoError(10);t.node_ops.unlink(t,n),ge.destroyNode(i)},readlink:e=>{var t=ge.lookupPath(e).node;if(!t)throw new ge.ErrnoError(44);if(!t.node_ops.readlink)throw new ge.ErrnoError(28);return fe.resolve(ge.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var n=ge.lookupPath(e,{follow:!t}).node;if(!n)throw new ge.ErrnoError(44);if(!n.node_ops.getattr)throw new ge.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>ge.stat(e,!0),chmod:(e,t,n)=>{var i;if(!(i="string"==typeof e?ge.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new ge.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ge.chmod(e,t,!0)},fchmod:(e,t)=>{var n=ge.getStream(e);if(!n)throw new ge.ErrnoError(8);ge.chmod(n.node,t)},chown:(e,t,n,i)=>{var r;if(!(r="string"==typeof e?ge.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new ge.ErrnoError(63);r.node_ops.setattr(r,{timestamp:Date.now()})},lchown:(e,t,n)=>{ge.chown(e,t,n,!0)},fchown:(e,t,n)=>{var i=ge.getStream(e);if(!i)throw new ge.ErrnoError(8);ge.chown(i.node,t,n)},truncate:(e,t)=>{if(t<0)throw new ge.ErrnoError(28);var n;if(!(n="string"==typeof e?ge.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ge.ErrnoError(63);if(ge.isDir(n.mode))throw new ge.ErrnoError(31);if(!ge.isFile(n.mode))throw new ge.ErrnoError(28);var i=ge.nodePermissions(n,"w");if(i)throw new ge.ErrnoError(i);n.node_ops.setattr(n,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var n=ge.getStream(e);if(!n)throw new ge.ErrnoError(8);if(0==(2097155&n.flags))throw new ge.ErrnoError(28);ge.truncate(n.node,t)},utime:(e,t,n)=>{var i=ge.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,n)})},open:(e,t,n,i,r)=>{if(""===e)throw new ge.ErrnoError(44);var a;if(n=void 0===n?438:n,n=64&(t="string"==typeof t?ge.modeStringToFlags(t):t)?4095&n|32768:0,"object"==typeof e)a=e;else{e=de.normalize(e);try{a=ge.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(a){if(128&t)throw new ge.ErrnoError(20)}else a=ge.mknod(e,n,0),o=!0;if(!a)throw new ge.ErrnoError(44);if(ge.isChrdev(a.mode)&&(t&=-513),65536&t&&!ge.isDir(a.mode))throw new ge.ErrnoError(54);if(!o){var c=ge.mayOpen(a,t);if(c)throw new ge.ErrnoError(c)}512&t&&ge.truncate(a,0),t&=-131713;var l=ge.createStream({node:a,path:ge.getPath(a),flags:t,seekable:!0,position:0,stream_ops:a.stream_ops,ungotten:[],error:!1},i,r);return l.stream_ops.open&&l.stream_ops.open(l),!s.logReadFiles||1&t||(ge.readFiles||(ge.readFiles={}),e in ge.readFiles||(ge.readFiles[e]=1)),l},close:e=>{if(ge.isClosed(e))throw new ge.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ge.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,n)=>{if(ge.isClosed(e))throw new ge.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ge.ErrnoError(70);if(0!=n&&1!=n&&2!=n)throw new ge.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,n),e.ungotten=[],e.position},read:(e,t,n,i,r)=>{if(i<0||r<0)throw new ge.ErrnoError(28);if(ge.isClosed(e))throw new ge.ErrnoError(8);if(1==(2097155&e.flags))throw new ge.ErrnoError(8);if(ge.isDir(e.node.mode))throw new ge.ErrnoError(31);if(!e.stream_ops.read)throw new ge.ErrnoError(28);var a=void 0!==r;if(a){if(!e.seekable)throw new ge.ErrnoError(70)}else r=e.position;var o=e.stream_ops.read(e,t,n,i,r);return a||(e.position+=o),o},write:(e,t,n,i,r,a)=>{if(i<0||r<0)throw new ge.ErrnoError(28);if(ge.isClosed(e))throw new ge.ErrnoError(8);if(0==(2097155&e.flags))throw new ge.ErrnoError(8);if(ge.isDir(e.node.mode))throw new ge.ErrnoError(31);if(!e.stream_ops.write)throw new ge.ErrnoError(28);e.seekable&&1024&e.flags&&ge.llseek(e,0,2);var o=void 0!==r;if(o){if(!e.seekable)throw new ge.ErrnoError(70)}else r=e.position;var s=e.stream_ops.write(e,t,n,i,r,a);return o||(e.position+=s),s},allocate:(e,t,n)=>{if(ge.isClosed(e))throw new ge.ErrnoError(8);if(t<0||n<=0)throw new ge.ErrnoError(28);if(0==(2097155&e.flags))throw new ge.ErrnoError(8);if(!ge.isFile(e.node.mode)&&!ge.isDir(e.node.mode))throw new ge.ErrnoError(43);if(!e.stream_ops.allocate)throw new ge.ErrnoError(138);e.stream_ops.allocate(e,t,n)},mmap:(e,t,n,i,r,a)=>{if(0!=(2&r)&&0==(2&a)&&2!=(2097155&e.flags))throw new ge.ErrnoError(2);if(1==(2097155&e.flags))throw new ge.ErrnoError(2);if(!e.stream_ops.mmap)throw new ge.ErrnoError(43);return e.stream_ops.mmap(e,t,n,i,r,a)},msync:(e,t,n,i,r)=>e&&e.stream_ops.msync?e.stream_ops.msync(e,t,n,i,r):0,munmap:e=>0,ioctl:(e,t,n)=>{if(!e.stream_ops.ioctl)throw new ge.ErrnoError(59);return e.stream_ops.ioctl(e,t,n)},readFile:(e,t={})=>{if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'+t.encoding+'"');var n,i=ge.open(e,t.flags),r=ge.stat(e).size,a=new Uint8Array(r);return ge.read(i,a,0,r,0),"utf8"===t.encoding?n=P(a,0):"binary"===t.encoding&&(n=a),ge.close(i),n},writeFile:(e,t,n={})=>{n.flags=n.flags||577;var i=ge.open(e,n.flags,n.mode);if("string"==typeof t){var r=new Uint8Array(N(t)+1),a=k(t,r,0,r.length);ge.write(i,r,0,a,void 0,n.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ge.write(i,t,0,t.byteLength,void 0,n.canOwn)}ge.close(i)},cwd:()=>ge.currentPath,chdir:e=>{var t=ge.lookupPath(e,{follow:!0});if(null===t.node)throw new ge.ErrnoError(44);if(!ge.isDir(t.node.mode))throw new ge.ErrnoError(54);var n=ge.nodePermissions(t.node,"x");if(n)throw new ge.ErrnoError(n);ge.currentPath=t.path},createDefaultDirectories:()=>{ge.mkdir("/tmp"),ge.mkdir("/home"),ge.mkdir("/home/web_user")},createDefaultDevices:()=>{ge.mkdir("/dev"),ge.registerDevice(ge.makedev(1,3),{read:()=>0,write:(e,t,n,i,r)=>i}),ge.mkdev("/dev/null",ge.makedev(1,3)),pe.register(ge.makedev(5,0),pe.default_tty_ops),pe.register(ge.makedev(6,0),pe.default_tty1_ops),ge.mkdev("/dev/tty",ge.makedev(5,0)),ge.mkdev("/dev/tty1",ge.makedev(6,0));var e=he();ge.createDevice("/dev","random",e),ge.createDevice("/dev","urandom",e),ge.mkdir("/dev/shm"),ge.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ge.mkdir("/proc");var e=ge.mkdir("/proc/self");ge.mkdir("/proc/self/fd"),ge.mount({mount:()=>{var t=ge.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var n=+t,i=ge.getStream(n);if(!i)throw new ge.ErrnoError(8);var r={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return r.parent=r,r}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{s.stdin?ge.createDevice("/dev","stdin",s.stdin):ge.symlink("/dev/tty","/dev/stdin"),s.stdout?ge.createDevice("/dev","stdout",null,s.stdout):ge.symlink("/dev/tty","/dev/stdout"),s.stderr?ge.createDevice("/dev","stderr",null,s.stderr):ge.symlink("/dev/tty1","/dev/stderr"),ge.open("/dev/stdin",0),ge.open("/dev/stdout",1),ge.open("/dev/stderr",1)},ensureErrnoError:()=>{ge.ErrnoError||(ge.ErrnoError=function(e,t){this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ge.ErrnoError.prototype=new Error,ge.ErrnoError.prototype.constructor=ge.ErrnoError,[44].forEach((e=>{ge.genericErrors[e]=new ge.ErrnoError(e),ge.genericErrors[e].stack=""})))},staticInit:()=>{ge.ensureErrnoError(),ge.nameTable=new Array(4096),ge.mount(me,{},"/"),ge.createDefaultDirectories(),ge.createDefaultDevices(),ge.createSpecialDirectories(),ge.filesystems={MEMFS:me}},init:(e,t,n)=>{ge.init.initialized=!0,ge.ensureErrnoError(),s.stdin=e||s.stdin,s.stdout=t||s.stdout,s.stderr=n||s.stderr,ge.createStandardStreams()},quit:()=>{ge.init.initialized=!1;for(var e=0;e{var n=0;return e&&(n|=365),t&&(n|=146),n},findObject:(e,t)=>{var n=ge.analyzePath(e,t);return n.exists?n.object:null},analyzePath:(e,t)=>{try{e=(i=ge.lookupPath(e,{follow:!t})).path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=ge.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=i.path,n.parentObject=i.node,n.name=de.basename(e),i=ge.lookupPath(e,{follow:!t}),n.exists=!0,n.path=i.path,n.object=i.node,n.name=i.node.name,n.isRoot="/"===i.path}catch(e){n.error=e.errno}return n},createPath:(e,t,n,i)=>{e="string"==typeof e?e:ge.getPath(e);for(var r=t.split("/").reverse();r.length;){var a=r.pop();if(a){var o=de.join2(e,a);try{ge.mkdir(o)}catch(e){}e=o}}return o},createFile:(e,t,n,i,r)=>{var a=de.join2("string"==typeof e?e:ge.getPath(e),t),o=ge.getMode(i,r);return ge.create(a,o)},createDataFile:(e,t,n,i,r,a)=>{var o=t;e&&(e="string"==typeof e?e:ge.getPath(e),o=t?de.join2(e,t):e);var s=ge.getMode(i,r),c=ge.create(o,s);if(n){if("string"==typeof n){for(var l=new Array(n.length),u=0,d=n.length;u{var r=de.join2("string"==typeof e?e:ge.getPath(e),t),a=ge.getMode(!!n,!!i);ge.createDevice.major||(ge.createDevice.major=64);var o=ge.makedev(ge.createDevice.major++,0);return ge.registerDevice(o,{open:e=>{e.seekable=!1},close:e=>{i&&i.buffer&&i.buffer.length&&i(10)},read:(e,t,i,r,a)=>{for(var o=0,s=0;s{for(var o=0;o{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!l)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Se(l(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new ge.ErrnoError(29)}},createLazyFile:(e,t,n,i,r)=>{function a(){this.lengthKnown=!1,this.chunks=[]}if(a.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,n=e/this.chunkSize|0;return this.getter(n)[t]}},a.prototype.setDataGetter=function(e){this.getter=e},a.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",n,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+n+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),r=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,a=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;r||(o=i);var s=this;s.setDataGetter((e=>{var t=e*o,r=(e+1)*o-1;if(r=Math.min(r,i-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var r=new XMLHttpRequest;if(r.open("GET",n,!1),i!==o&&r.setRequestHeader("Range","bytes="+e+"-"+t),"undefined"!=typeof Uint8Array&&(r.responseType="arraybuffer"),r.overrideMimeType&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.send(null),!(r.status>=200&&r.status<300||304===r.status))throw new Error("Couldn't load "+n+". Status: "+r.status);return void 0!==r.response?new Uint8Array(r.response||[]):Se(r.responseText||"",!0)})(t,r)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!a&&i||(o=i=1,i=this.getter(0).length,o=i,S("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!b)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var o=new a;Object.defineProperties(o,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:o}}else s={isDevice:!1,url:n};var c=ge.createFile(e,t,s,i,r);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};return Object.keys(c.stream_ops).forEach((e=>{var t=c.stream_ops[e];l[e]=function(){return ge.forceLoadFile(c),t.apply(null,arguments)}})),l.read=(e,t,n,i,r)=>{ge.forceLoadFile(c);var a=e.node.contents;if(r>=a.length)return 0;var o=Math.min(a.length-r,i);if(a.slice)for(var s=0;s{var d=t?fe.resolve(de.join2(e,t)):e;function h(n){function u(n){l&&l(),s||ge.createDataFile(e,t,n,i,r,c),a&&a(),Z()}Browser.handledByPreloadPlugin(n,d,u,(()=>{o&&o(),Z()}))||u(n)}K(),"string"==typeof n?function(e,t,n,i){var r="al "+e;u(e,(function(t){t||Q('Loading data file "'+e+'" failed (no arrayBuffer).'),(e=>{h(e)})(new Uint8Array(t)),r&&Z()}),(function(t){if(!n)throw'Loading data file "'+e+'" failed.';n()})),r&&K()}(n,0,o):h(n)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var i=ge.indexedDB();try{var r=i.open(ge.DB_NAME(),ge.DB_VERSION)}catch(e){return n(e)}r.onupgradeneeded=()=>{S("creating db"),r.result.createObjectStore(ge.DB_STORE_NAME)},r.onsuccess=()=>{var i=r.result.transaction([ge.DB_STORE_NAME],"readwrite"),a=i.objectStore(ge.DB_STORE_NAME),o=0,s=0,c=e.length;function l(){0==s?t():n()}e.forEach((e=>{var t=a.put(ge.analyzePath(e).object.contents,e);t.onsuccess=()=>{++o+s==c&&l()},t.onerror=()=>{s++,o+s==c&&l()}})),i.onerror=n},r.onerror=n},loadFilesFromDB:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var i=ge.indexedDB();try{var r=i.open(ge.DB_NAME(),ge.DB_VERSION)}catch(e){return n(e)}r.onupgradeneeded=n,r.onsuccess=()=>{var i=r.result;try{var a=i.transaction([ge.DB_STORE_NAME],"readonly")}catch(e){return void n(e)}var o=a.objectStore(ge.DB_STORE_NAME),s=0,c=0,l=e.length;function u(){0==c?t():n()}e.forEach((e=>{var t=o.get(e);t.onsuccess=()=>{ge.analyzePath(e).exists&&ge.unlink(e),ge.createDataFile(de.dirname(e),de.basename(e),t.result,!0,!0,!0),++s+c==l&&u()},t.onerror=()=>{c++,s+c==l&&u()}})),a.onerror=n},r.onerror=n}},Ce={mappings:{},DEFAULT_POLLMASK:5,calculateAt:function(e,t,n){if("/"===t[0])return t;var i;if(-100===e)i=ge.cwd();else{var r=ge.getStream(e);if(!r)throw new ge.ErrnoError(8);i=r.path}if(0==t.length){if(!n)throw new ge.ErrnoError(44);return i}return de.join2(i,t)},doStat:function(e,t,n){try{var i=e(t)}catch(e){if(e&&e.node&&de.normalize(t)!==de.normalize(ge.getPath(e.node)))return-54;throw e}return V[n>>2]=i.dev,V[n+4>>2]=0,V[n+8>>2]=i.ino,V[n+12>>2]=i.mode,V[n+16>>2]=i.nlink,V[n+20>>2]=i.uid,V[n+24>>2]=i.gid,V[n+28>>2]=i.rdev,V[n+32>>2]=0,X=[i.size>>>0,(q=i.size,+Math.abs(q)>=1?q>0?(0|Math.min(+Math.floor(q/4294967296),4294967295))>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],V[n+40>>2]=X[0],V[n+44>>2]=X[1],V[n+48>>2]=4096,V[n+52>>2]=i.blocks,V[n+56>>2]=i.atime.getTime()/1e3|0,V[n+60>>2]=0,V[n+64>>2]=i.mtime.getTime()/1e3|0,V[n+68>>2]=0,V[n+72>>2]=i.ctime.getTime()/1e3|0,V[n+76>>2]=0,X=[i.ino>>>0,(q=i.ino,+Math.abs(q)>=1?q>0?(0|Math.min(+Math.floor(q/4294967296),4294967295))>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],V[n+80>>2]=X[0],V[n+84>>2]=X[1],0},doMsync:function(e,t,n,i,r){var a=A.slice(e,e+n);ge.msync(t,a,r,n,i)},doMkdir:function(e,t){return"/"===(e=de.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),ge.mkdir(e,t,0),0},doMknod:function(e,t,n){switch(61440&t){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return ge.mknod(e,t,n),0},doReadlink:function(e,t,n){if(n<=0)return-28;var i=ge.readlink(e),r=Math.min(n,N(i)),a=z[t+r];return k(i,A,t,n+1),z[t+r]=a,r},doAccess:function(e,t){if(-8&t)return-28;var n=ge.lookupPath(e,{follow:!0}).node;if(!n)return-44;var i="";return 4&t&&(i+="r"),2&t&&(i+="w"),1&t&&(i+="x"),i&&ge.nodePermissions(n,i)?-2:0},doDup:function(e,t,n){var i=ge.getStream(n);return i&&ge.close(i),ge.open(e,t,0,n,n).fd},doReadv:function(e,t,n,i){for(var r=0,a=0;a>2],s=V[t+(8*a+4)>>2],c=ge.read(e,z,o,s,i);if(c<0)return-1;if(r+=c,c>2],s=V[t+(8*a+4)>>2],c=ge.write(e,z,o,s,i);if(c<0)return-1;r+=c}return r},varargs:void 0,get:function(){return Ce.varargs+=4,V[Ce.varargs-4>>2]},getStr:function(e){return I(e)},getStreamFromFD:function(e){var t=ge.getStream(e);if(!t)throw new ge.ErrnoError(8);return t},get64:function(e,t){return e}};function ve(e){return e%4==0&&(e%100!=0||e%400==0)}function ye(e,t){for(var n=0,i=0;i<=t;n+=e[i++]);return n}var be=[31,29,31,30,31,30,31,31,30,31,30,31],Me=[31,28,31,30,31,30,31,31,30,31,30,31];function xe(e,t){for(var n=new Date(e.getTime());t>0;){var i=ve(n.getFullYear()),r=n.getMonth(),a=(i?be:Me)[r];if(!(t>a-n.getDate()))return n.setDate(n.getDate()+t),n;t-=a-n.getDate()+1,n.setDate(1),r<11?n.setMonth(r+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1))}return n}var _e=function(e,t,n,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ge.nextInode++,this.name=t,this.mode=n,this.node_ops={},this.stream_ops={},this.rdev=i};function Se(e,t,n){var i=n>0?n:N(e)+1,r=new Array(i),a=k(e,r,0,r.length);return t&&(r.length=a),r}Object.defineProperties(_e.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ge.isDir(this.mode)}},isDevice:{get:function(){return ge.isChrdev(this.mode)}}}),ge.FSNode=_e,ge.staticInit();var we,Le={d:function(e){return Ee(e+16)+16},c:function(e,t,n){throw new se(e).init(t,n),e},f:function(e,t){Q("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},i:function(e,t){Q("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},a:function(){Q("")},b:function(e,t){var n;if(0===e)n=Date.now();else{if(1!==e&&4!==e)return V[Te()>>2]=28,-1;n=re()}return V[t>>2]=n/1e3|0,V[t+4>>2]=n%1e3*1e3*1e3|0,0},o:function(){return 2147483648},g:re,h:function(e,t,n){A.copyWithin(e,t,t+n)},n:function(e){var t,n=A.length,i=2147483648;if((e>>>=0)>i)return!1;for(var r=1;r<=4;r*=2){var a=n*(1+.2/r);if(a=Math.min(a,e+100663296),ce(Math.min(i,((t=Math.max(e,a))%65536>0&&(t+=65536-t%65536),t))))return!0}return!1},p:function(e,t){var n=0;return ue().forEach((function(i,r){var a=t+n;V[e+4*r>>2]=a,function(e,t,n){for(var i=0;i>0]=e.charCodeAt(i);z[t>>0]=0}(i,a),n+=i.length+1})),0},q:function(e,t){var n=ue();V[e>>2]=n.length;var i=0;return n.forEach((function(e){i+=e.length+1})),V[t>>2]=i,0},s:function(e){!function(e,t){var n;W(),n=e,W()||(s.onExit&&s.onExit(n),H=!0),v(n,new Ae(n))}(e)},j:function(e){try{var t=Ce.getStreamFromFD(e);return ge.close(t),0}catch(e){if(void 0===ge||!(e instanceof ge.ErrnoError))throw e;return e.errno}},r:function(e,t,n,i){try{var r=Ce.getStreamFromFD(e),a=Ce.doReadv(r,t,n);return V[i>>2]=a,0}catch(e){if(void 0===ge||!(e instanceof ge.ErrnoError))throw e;return e.errno}},k:function(e,t,n,i,r){try{var a=Ce.getStreamFromFD(e),o=4294967296*n+(t>>>0),s=9007199254740992;return o<=-s||o>=s?-61:(ge.llseek(a,o,i),X=[a.position>>>0,(q=a.position,+Math.abs(q)>=1?q>0?(0|Math.min(+Math.floor(q/4294967296),4294967295))>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],V[r>>2]=X[0],V[r+4>>2]=X[1],a.getdents&&0===o&&0===i&&(a.getdents=null),0)}catch(e){if(void 0===ge||!(e instanceof ge.ErrnoError))throw e;return e.errno}},e:function(e,t,n,i){try{var r=Ce.getStreamFromFD(e),a=Ce.doWritev(r,t,n);return V[i>>2]=a,0}catch(e){if(void 0===ge||!(e instanceof ge.ErrnoError))throw e;return e.errno}},l:function e(t,n){e.randomDevice||(e.randomDevice=he());for(var i=0;i>0]=e.randomDevice();return 0},m:function(e,t,n,i){return function(e,t,n,i){var r=V[i+40>>2],a={tm_sec:V[i>>2],tm_min:V[i+4>>2],tm_hour:V[i+8>>2],tm_mday:V[i+12>>2],tm_mon:V[i+16>>2],tm_year:V[i+20>>2],tm_wday:V[i+24>>2],tm_yday:V[i+28>>2],tm_isdst:V[i+32>>2],tm_gmtoff:V[i+36>>2],tm_zone:r?I(r):""},o=I(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var c in s)o=o.replace(new RegExp(c,"g"),s[c]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],u=["January","February","March","April","May","June","July","August","September","October","November","December"];function d(e,t,n){for(var i="number"==typeof e?e.toString():e||"";i.length0?1:0}var i;return 0===(i=n(e.getFullYear()-t.getFullYear()))&&0===(i=n(e.getMonth()-t.getMonth()))&&(i=n(e.getDate()-t.getDate())),i}function p(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function m(e){var t=xe(new Date(e.tm_year+1900,0,1),e.tm_yday),n=new Date(t.getFullYear(),0,4),i=new Date(t.getFullYear()+1,0,4),r=p(n),a=p(i);return f(r,t)<=0?f(a,t)<=0?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var g={"%a":function(e){return l[e.tm_wday].substring(0,3)},"%A":function(e){return l[e.tm_wday]},"%b":function(e){return u[e.tm_mon].substring(0,3)},"%B":function(e){return u[e.tm_mon]},"%C":function(e){return h((e.tm_year+1900)/100|0,2)},"%d":function(e){return h(e.tm_mday,2)},"%e":function(e){return d(e.tm_mday,2," ")},"%g":function(e){return m(e).toString().substring(2)},"%G":function(e){return m(e)},"%H":function(e){return h(e.tm_hour,2)},"%I":function(e){var t=e.tm_hour;return 0==t?t=12:t>12&&(t-=12),h(t,2)},"%j":function(e){return h(e.tm_mday+ye(ve(e.tm_year+1900)?be:Me,e.tm_mon-1),3)},"%m":function(e){return h(e.tm_mon+1,2)},"%M":function(e){return h(e.tm_min,2)},"%n":function(){return"\n"},"%p":function(e){return e.tm_hour>=0&&e.tm_hour<12?"AM":"PM"},"%S":function(e){return h(e.tm_sec,2)},"%t":function(){return"\t"},"%u":function(e){return e.tm_wday||7},"%U":function(e){var t=new Date(e.tm_year+1900,0,1),n=0===t.getDay()?t:xe(t,7-t.getDay()),i=new Date(e.tm_year+1900,e.tm_mon,e.tm_mday);if(f(n,i)<0){var r=ye(ve(i.getFullYear())?be:Me,i.getMonth()-1)-31,a=31-n.getDate()+r+i.getDate();return h(Math.ceil(a/7),2)}return 0===f(n,t)?"01":"00"},"%V":function(e){var t,n=new Date(e.tm_year+1900,0,4),i=new Date(e.tm_year+1901,0,4),r=p(n),a=p(i),o=xe(new Date(e.tm_year+1900,0,1),e.tm_yday);return f(o,r)<0?"53":f(a,o)<=0?"01":(t=r.getFullYear()=0;return t=(t=Math.abs(t)/60)/60*100+t%60,(n?"+":"-")+String("0000"+t).slice(-4)},"%Z":function(e){return e.tm_zone},"%%":function(){return"%"}};for(var c in g)o.includes(c)&&(o=o.replace(new RegExp(c,"g"),g[c](a)));var C=Se(o,!1);return C.length>t?0:(function(e,t){z.set(e,t)}(C,e),C.length-1)}(e,t,n,i)}},Ee=(function(){var e={a:Le};function t(e,t){var n,i=e.exports;s.asm=i,D((L=s.asm.t).buffer),O=s.asm.H,n=s.asm.u,F.unshift(n),Z()}function n(e){t(e.instance)}function i(t){return function(){if(!_&&(y||b)){if("function"==typeof fetch&&!te(G))return fetch(G,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+G+"'";return e.arrayBuffer()})).catch((function(){return ne(G)}));if(u)return new Promise((function(e,t){u(G,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ne(G)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){w("failed to asynchronously prepare wasm: "+e),Q(e)}))}if(K(),s.instantiateWasm)try{return s.instantiateWasm(e,t)}catch(e){return w("Module.instantiateWasm callback failed with error: "+e),!1}(_||"function"!=typeof WebAssembly.instantiateStreaming||ee(G)||te(G)||"function"!=typeof fetch?i(n):fetch(G,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return w("wasm streaming compile failed: "+e),w("falling back to ArrayBuffer instantiation"),i(n)}))}))).catch(o)}(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm.u).apply(null,arguments)},s._initPoseDetectorModelBuffer=function(){return(s._initPoseDetectorModelBuffer=s.asm.v).apply(null,arguments)},s._getPoseDetectorModelBufferAddress=function(){return(s._getPoseDetectorModelBufferAddress=s.asm.w).apply(null,arguments)},s._loadPoseDetectorModel=function(){return(s._loadPoseDetectorModel=s.asm.x).apply(null,arguments)},s._initPoseLandmarkModelBuffer=function(){return(s._initPoseLandmarkModelBuffer=s.asm.y).apply(null,arguments)},s._getPoseLandmarkModelBufferAddress=function(){return(s._getPoseLandmarkModelBufferAddress=s.asm.z).apply(null,arguments)},s._loadPoseLandmarkModel=function(){return(s._loadPoseLandmarkModel=s.asm.A).apply(null,arguments)},s._initPoseInputBuffer=function(){return(s._initPoseInputBuffer=s.asm.B).apply(null,arguments)},s._getPoseInputBufferAddress=function(){return(s._getPoseInputBufferAddress=s.asm.C).apply(null,arguments)},s._getPoseOutputBufferAddress=function(){return(s._getPoseOutputBufferAddress=s.asm.D).apply(null,arguments)},s._getPoseTemporaryBufferAddress=function(){return(s._getPoseTemporaryBufferAddress=s.asm.E).apply(null,arguments)},s._execPose=function(){return(s._execPose=s.asm.F).apply(null,arguments)},s._set_pose_calculate_mode=function(){return(s._set_pose_calculate_mode=s.asm.G).apply(null,arguments)},s._initPalmDetectorModelBuffer=function(){return(s._initPalmDetectorModelBuffer=s.asm.I).apply(null,arguments)},s._getPalmDetectorModelBufferAddress=function(){return(s._getPalmDetectorModelBufferAddress=s.asm.J).apply(null,arguments)},s._loadPalmDetectorModel=function(){return(s._loadPalmDetectorModel=s.asm.K).apply(null,arguments)},s._initHandLandmarkModelBuffer=function(){return(s._initHandLandmarkModelBuffer=s.asm.L).apply(null,arguments)},s._getHandLandmarkModelBufferAddress=function(){return(s._getHandLandmarkModelBufferAddress=s.asm.M).apply(null,arguments)},s._loadHandLandmarkModel=function(){return(s._loadHandLandmarkModel=s.asm.N).apply(null,arguments)},s._initHandInputBuffer=function(){return(s._initHandInputBuffer=s.asm.O).apply(null,arguments)},s._getHandInputBufferAddress=function(){return(s._getHandInputBufferAddress=s.asm.P).apply(null,arguments)},s._getHandOutputBufferAddress=function(){return(s._getHandOutputBufferAddress=s.asm.Q).apply(null,arguments)},s._getHandTemporaryBufferAddress=function(){return(s._getHandTemporaryBufferAddress=s.asm.R).apply(null,arguments)},s._execHand=function(){return(s._execHand=s.asm.S).apply(null,arguments)},s._initFaceDetectorModelBuffer=function(){return(s._initFaceDetectorModelBuffer=s.asm.T).apply(null,arguments)},s._getFaceDetectorModelBufferAddress=function(){return(s._getFaceDetectorModelBufferAddress=s.asm.U).apply(null,arguments)},s._loadFaceDetectorModel=function(){return(s._loadFaceDetectorModel=s.asm.V).apply(null,arguments)},s._initFaceLandmarkModelBuffer=function(){return(s._initFaceLandmarkModelBuffer=s.asm.W).apply(null,arguments)},s._getFaceLandmarkModelBufferAddress=function(){return(s._getFaceLandmarkModelBufferAddress=s.asm.X).apply(null,arguments)},s._loadFaceLandmarkModel=function(){return(s._loadFaceLandmarkModel=s.asm.Y).apply(null,arguments)},s._initFaceInputBuffer=function(){return(s._initFaceInputBuffer=s.asm.Z).apply(null,arguments)},s._getFaceInputBufferAddress=function(){return(s._getFaceInputBufferAddress=s.asm._).apply(null,arguments)},s._getFaceOutputBufferAddress=function(){return(s._getFaceOutputBufferAddress=s.asm.$).apply(null,arguments)},s._getFaceTemporaryBufferAddress=function(){return(s._getFaceTemporaryBufferAddress=s.asm.aa).apply(null,arguments)},s._execFace=function(){return(s._execFace=s.asm.ba).apply(null,arguments)},s._malloc=function(){return(Ee=s._malloc=s.asm.ca).apply(null,arguments)}),Te=s.___errno_location=function(){return(Te=s.___errno_location=s.asm.da).apply(null,arguments)},ze=s._memalign=function(){return(ze=s._memalign=s.asm.ea).apply(null,arguments)};function Ae(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Ve(e){function n(){we||(we=!0,s.calledRun=!0,H||(s.noFSInit||ge.init.initialized||ge.init(),ge.ignorePermissions=!1,pe.init(),ie(F),t(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),function(){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)e=s.postRun.shift(),U.unshift(e);var e;ie(U)}()))}e=e||g,Y>0||(function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)e=s.preRun.shift(),B.unshift(e);var e;ie(B)}(),Y>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),n()}),1)):n()))}if($=function e(){we||Ve(),we||($=e)},s.run=Ve,s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return Ve(),e.ready});e.exports=o},363:e=>{"use strict";e.exports=n(363)},102:e=>{"use strict";e.exports=n(102)},914:e=>{"use strict";e.exports=n(914)},583:e=>{"use strict";e.exports=n(583)},180:e=>{"use strict";e.exports=n(180)},747:e=>{"use strict";e.exports=n(747)},81:e=>{"use strict";e.exports=n(81)},782:()=>{},384:()=>{},375:()=>{}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";i.r(a),i.d(a,{FingerLookupIndices:()=>r,MediapipeMix2WorkerManager:()=>v,NUM_KEYPOINTS:()=>l,OperationType:()=>t,PartsLookupIndices:()=>n,RefinedLeftEyePoints:()=>h,RefinedLeftIrisPoints:()=>p,RefinedLipPoints:()=>d,RefinedPoints:()=>g,RefinedRightEyePoints:()=>f,RefinedRightIrisPoints:()=>m,TRIANGULATION:()=>u});var e=i(55);const t={hand:"hand",face:"face",pose:"pose"},n={leftEye:[0,1,2,3,7],rightEye:[0,4,5,6,8],mouth:[9,10],body:[11,12,24,23,11],leftArm:[11,13,15],leftThum:[15,21],leftIndex:[15,19],leftPinly:[15,17],rightArm:[12,14,16],rightThum:[16,22],rightIndex:[16,20],rightPinly:[16,18],leftLeg:[23,25,27],leftFoot:[27,29,31],rightLeg:[24,26,28],rightFoot:[28,30,32]},r={thumb:[0,1,2,3,4],indexFinger:[0,5,6,7,8],middleFinger:[0,9,10,11,12],ringFinger:[0,13,14,15,16],pinky:[0,17,18,19,20]};var o=i(477),s=i.n(o);function c(){return s()('/*! For license information please see index.worker.js.LICENSE.txt */\n(()=>{var t={252:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BlockingQueue=void 0;var r=function(){function t(){this._resolvers=[],this._promises=[]}return t.prototype._add=function(){var t=this;this._promises.push(new Promise((function(e){t._resolvers.push(e)})))},t.prototype.enqueue=function(t){this._resolvers.length||this._add(),this._resolvers.shift()(t)},t.prototype.dequeue=function(){return this._promises.length||this._add(),this._promises.shift()},t.prototype.isEmpty=function(){return!this._promises.length},t.prototype.isBlocked=function(){return!!this._resolvers.length},Object.defineProperty(t.prototype,"length",{get:function(){return this._promises.length-this._resolvers.length},enumerable:!1,configurable:!0}),t}();e.BlockingQueue=r},289:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getBrowserType=e.BrowserTypes=void 0,e.BrowserTypes={MSIE:"MSIE",EDGE:"EDGE",CHROME:"CHROME",SAFARI:"SAFARI",FIREFOX:"FIREFOX",OPERA:"OPERA",OTHER:"OTHER"},e.getBrowserType=function(){var t=window.navigator.userAgent.toLowerCase();return-1!==t.indexOf("msie")||-1!==t.indexOf("trident")?e.BrowserTypes.MSIE:-1!==t.indexOf("edge")?e.BrowserTypes.EDGE:-1!==t.indexOf("chrome")?e.BrowserTypes.CHROME:-1!==t.indexOf("safari")?e.BrowserTypes.SAFARI:-1!==t.indexOf("firefox")?e.BrowserTypes.FIREFOX:-1!==t.indexOf("opera")?e.BrowserTypes.OPERA:e.BrowserTypes.OTHER}},187:function(t,e,r){"use strict";var n=r(764).lW,o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]100)throw new Error("queue is fulled: ".concat(this.sem.length));return[4,this.lock()];case 1:t=i.sent(),o=new Promise((function(t,o){if(!f.worker)throw new Error("worker is not activated.");f.worker.onmessage=function(e){e.data.message===u.WorkerResponse.PREDICTED?t(e.data.prediction):(console.log("Prediction something wrong..",e.data.message),o(e))},n?r instanceof Uint8ClampedArray?f.worker.postMessage({message:u.WorkerCommand.PREDICT,params:e,data:r},[r.buffer]):f.worker.postMessage({message:u.WorkerCommand.PREDICT,params:e,data:r},[r]):f.worker.postMessage({message:u.WorkerCommand.PREDICT,params:e,data:r})})),i.label=2;case 2:return i.trys.push([2,4,5,6]),[4,o];case 3:return s=i.sent(),[3,6];case 4:return a=i.sent(),console.log("worker prediction error. :",a),[3,6];case 5:return this.unlock(t),[7];case 6:return[2,s]}}))}))},this.useWorker=function(t){return!t.processOnLocal&&(!1!==t.useWorkerForSafari||(0,a.getBrowserType)()!==a.BrowserTypes.SAFARI)},this.fetchData=function(e){return o(t,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return e.startsWith("data:")?(t=e.split(",")[1],[2,n.from(t,"base64")]):[4,fetch(e,{method:"GET"})];case 1:return[4,r.sent().arrayBuffer()];case 2:return[2,r.sent()]}}))}))},this.sem.enqueue(0)};e.WorkerDispatcher=function(t){var e=this;this.imageProcessor=null,this.config=null,this.callbacks=null,this.setCallback=function(t){e.callbacks=t},this.dispach=function(t){return o(e,void 0,void 0,(function(){var e,r,n,o;return i(this,(function(i){switch(i.label){case 0:return this.callbacks?t.data.message!==u.WorkerCommand.INITIALIZE?[3,2]:(this.config=t.data.config,e=this,[4,this.callbacks.init(this.config)]):(console.warn("[worker] Dispatcher callbacks is not initialized"),[2]);case 1:return e.imageProcessor=i.sent(),this.context.postMessage({message:u.WorkerResponse.INITIALIZED}),console.log("[worker] Initialized"),[3,4];case 2:return t.data.message!==u.WorkerCommand.PREDICT?[3,4]:this.imageProcessor?this.config?(r=t.data.params,n=t.data.data,[4,this.imageProcessor.predict(this.config,r,n)]):(console.warn("[worker] Dispatcher config is not initialized"),[2]):(console.warn("[worker] ImageProcessor is not initialized"),[2]);case 3:o=i.sent(),this.context.postMessage({message:u.WorkerResponse.PREDICTED,prediction:o}),i.label=4;case 4:return[2]}}))}))},this.context=t}},301:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerResponse=e.WorkerCommand=void 0,e.WorkerCommand={INITIALIZE:"initialize",PREDICT:"predict"},e.WorkerResponse={INITIALIZED:"initialized",PREDICTED:"predicted"}},55:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(187),e),o(r(289),e)},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=u(t),s=i[0],a=i[1],f=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),l=0,c=a>0?s-4:s;for(r=0;r>16&255,f[l++]=e>>8&255,f[l++]=255&e;return 2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[l++]=255&e),1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[l++]=e>>8&255,f[l++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,a=0,u=n-o;au?u:a+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=i.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,n){for(var o,i,s=[],a=e;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(t,e,r)=>{"use strict";const n=r(742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const s=2147483647;function a(t){if(t>s)throw new RangeError(\'The value "\'+t+\'" is invalid for option "size"\');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError(\'The "string" argument must be of type string. Received type number\');return c(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|m(t,e);let n=a(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){const e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer))return h(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError(\'The "value" argument must not be of type number. Received type number\');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?a(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError(\'"size" argument must be of type number\');if(t<0)throw new RangeError(\'The value "\'+t+\'" is invalid for option "size"\')}function c(t){return l(t),a(t<0?0:0|p(t))}function d(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function m(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError(\'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type \'+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return X(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(o)return n?-1:X(t).length;e=(""+e).toLowerCase(),o=!0}}function y(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return P(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,o){let i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let n=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let s;for(n>i/2&&(n=i/2),s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function P(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function B(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],a=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){const e=t.length;if(e<=F)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError(\'"list" argument must be an Array of Buffers\');e.copy(n,o)}o+=e.length}return n},u.byteLength=m,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(G(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError(\'The "target" argument must be one of type Buffer or Uint8Array. Received type \'+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(i,s),f=this.slice(n,o),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return b(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const F=4096;function M(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError(\'"buffer" argument must be a Buffer instance\');if(e>o||et.length)throw new RangeError("Index out of range")}function H(t,e,r,n,o){j(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function S(t,e,r,n,o){j(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function T(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,i){return e=+e,r>>>=0,i||T(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Y(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||R(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J((function(t,e=0){return H(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return S(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n)}let o=0,i=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J((function(t,e=0){return H(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return S(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function j(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new C.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||Y(e,t.length-(r+1))}(n,o,i)}function W(t,e){if("number"!=typeof t)throw new C.ERR_INVALID_ARG_TYPE(e,"number",t)}function Y(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new C.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new C.ERR_BUFFER_OUT_OF_BOUNDS;throw new C.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),N("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),N("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=z(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=z(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function X(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function $(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function G(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},645:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,l=-7,c=r?o-1:0,d=r?-1:1,h=t[e+c];for(c+=d,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+t[e+c],c+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=d,l-=8);if(0===i)i=1-f;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=f}return(h?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,f=8*i-o-1,l=(1<>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?d/u:d*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*u-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));o>=8;t[r+h]=255&a,h+=p,a/=256,o-=8);for(s=s<0;t[r+h]=255&s,h+=p,s/=256,f-=8);t[r+h-p]|=128*m}},503:(t,e,r)=>{var n,o=r(764).lW,i=(n=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,i,s=void 0!==(t=t||{})?t:{},a=Object.assign;s.ready=new Promise((function(t,r){e=t,i=r}));var u,f,l,c,d,h,p=a({},s),m=[],y="./this.program",g=(t,e)=>{throw e},w="object"==typeof window,E="function"==typeof importScripts,v="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,_="";v?(_=E?r(375).dirname(_)+"/":"//",h=()=>{d||(c=r(384),d=r(375))},u=function(t,e){return h(),t=d.normalize(t),c.readFileSync(t,e?null:"utf8")},l=t=>{var e=u(t,!0);return e.buffer||(e=new Uint8Array(e)),e},f=(t,e,r)=>{h(),t=d.normalize(t),c.readFile(t,(function(t,n){t?r(t):e(n.buffer)}))},process.argv.length>1&&(y=process.argv[1].replace(/\\\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof Dt))throw t})),process.on("unhandledRejection",(function(t){throw t})),g=(t,e)=>{if(j())throw process.exitCode=t,e;var r;(r=e)instanceof Dt||k("exiting due to exception: "+r),process.exit(t)},s.inspect=function(){return"[Emscripten Module object]"}):(w||E)&&(E?_=self.location.href:"undefined"!=typeof document&&document.currentScript&&(_=document.currentScript.src),n&&(_=n),_=0!==_.indexOf("blob:")?_.substr(0,_.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},E&&(l=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,r)=>{var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?e(n.response):r()},n.onerror=r,n.send(null)});var b,A=s.print||console.log.bind(console),k=s.printErr||console.warn.bind(console);a(s,p),p=null,s.arguments&&(m=s.arguments),s.thisProgram&&(y=s.thisProgram),s.quit&&(g=s.quit),s.wasmBinary&&(b=s.wasmBinary);var P,B=s.noExitRuntime||!0;"object"!=typeof WebAssembly&&J("no native wasm support detected");var F,M,D,I,x=!1,R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function O(t,e,r){for(var n=e+r,o=e;t[o]&&!(o>=n);)++o;if(o-e>16&&t.subarray&&R)return R.decode(t.subarray(e,o));for(var i="";e>10,56320|1023&f)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i}function H(t,e){return t?O(D,t,e):""}function S(t,e,r,n){if(!(n>0))return 0;for(var o=r,i=r+n-1,s=0;s=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++s)),a<=127){if(r>=i)break;e[r++]=a}else if(a<=2047){if(r+1>=i)break;e[r++]=192|a>>6,e[r++]=128|63&a}else if(a<=65535){if(r+2>=i)break;e[r++]=224|a>>12,e[r++]=128|a>>6&63,e[r++]=128|63&a}else{if(r+3>=i)break;e[r++]=240|a>>18,e[r++]=128|a>>12&63,e[r++]=128|a>>6&63,e[r++]=128|63&a}}return e[r]=0,r-o}function T(t){for(var e=0,r=0;r=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&t.charCodeAt(++r)),n<=127?++e:e+=n<=2047?2:n<=65535?3:4}return e}function L(t){F=t,s.HEAP8=M=new Int8Array(t),s.HEAP16=new Int16Array(t),s.HEAP32=I=new Int32Array(t),s.HEAPU8=D=new Uint8Array(t),s.HEAPU16=new Uint16Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),s.HEAPF64=new Float64Array(t)}s.INITIAL_MEMORY;var U,C=[],N=[],z=[];function j(){return B||!1}var W,Y,K,X,$=0,q=null,G=null;function V(t){$++,s.monitorRunDependencies&&s.monitorRunDependencies($)}function Z(t){if($--,s.monitorRunDependencies&&s.monitorRunDependencies($),0==$&&(null!==q&&(clearInterval(q),q=null),G)){var e=G;G=null,e()}}function J(t){s.onAbort&&s.onAbort(t),k(t="Aborted("+t+")"),x=!0,t+=". Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(t);throw i(e),e}function Q(t){return t.startsWith("data:application/octet-stream;base64,")}function tt(t){return t.startsWith("file://")}function et(t){try{if(t==W&&b)return new Uint8Array(b);if(l)return l(t);throw"both async and sync fetching of the wasm failed"}catch(t){J(t)}}function rt(t){for(;t.length>0;){var e=t.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?it(r)():it(r)(e.arg):r(void 0===e.arg?null:e.arg)}else e(s)}}s.preloadedImages={},s.preloadedAudios={},Q(W="tflite-simd.wasm")||(Y=W,W=s.locateFile?s.locateFile(Y,_):_+Y);var nt,ot=[];function it(t){var e=ot[t];return e||(t>=ot.length&&(ot.length=t+1),ot[t]=e=U.get(t)),e}function st(t){this.excPtr=t,this.ptr=t-16,this.set_type=function(t){I[this.ptr+4>>2]=t},this.get_type=function(){return I[this.ptr+4>>2]},this.set_destructor=function(t){I[this.ptr+8>>2]=t},this.get_destructor=function(){return I[this.ptr+8>>2]},this.set_refcount=function(t){I[this.ptr>>2]=t},this.set_caught=function(t){t=t?1:0,M[this.ptr+12>>0]=t},this.get_caught=function(){return 0!=M[this.ptr+12>>0]},this.set_rethrown=function(t){t=t?1:0,M[this.ptr+13>>0]=t},this.get_rethrown=function(){return 0!=M[this.ptr+13>>0]},this.init=function(t,e){this.set_type(t),this.set_destructor(e),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var t=I[this.ptr>>2];I[this.ptr>>2]=t+1},this.release_ref=function(){var t=I[this.ptr>>2];return I[this.ptr>>2]=t-1,1===t}}function at(t){try{return P.grow(t-F.byteLength+65535>>>16),L(P.buffer),1}catch(t){}}nt=v?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now();var ut={};function ft(){if(!ft.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:y||"./this.program"};for(var e in ut)void 0===ut[e]?delete t[e]:t[e]=ut[e];var r=[];for(var e in t)r.push(e+"="+t[e]);ft.strings=r}return ft.strings}var lt={splitPath:function(t){return/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/.exec(t).slice(1)},normalizeArray:function(t,e){for(var r=0,n=t.length-1;n>=0;n--){var o=t[n];"."===o?t.splice(n,1):".."===o?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r;r--)t.unshift("..");return t},normalize:function(t){var e="/"===t.charAt(0),r="/"===t.substr(-1);return(t=lt.normalizeArray(t.split("/").filter((function(t){return!!t})),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t},dirname:function(t){var e=lt.splitPath(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},basename:function(t){if("/"===t)return"/";var e=(t=(t=lt.normalize(t)).replace(/\\/$/,"")).lastIndexOf("/");return-1===e?t:t.substr(e+1)},extname:function(t){return lt.splitPath(t)[3]},join:function(){var t=Array.prototype.slice.call(arguments,0);return lt.normalize(t.join("/"))},join2:function(t,e){return lt.normalize(t+"/"+e)}};function ct(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return function(){return crypto.getRandomValues(t),t[0]}}if(v)try{var e=r(782);return function(){return e.randomBytes(1)[0]}}catch(t){}return function(){J("randomDevice")}}var dt={resolve:function(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:mt.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";t=n+"/"+t,e="/"===n.charAt(0)}return(e?"/":"")+(t=lt.normalizeArray(t.split("/").filter((function(t){return!!t})),!e).join("/"))||"."},relative:function(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=dt.resolve(t).substr(1),e=dt.resolve(e).substr(1);for(var n=r(t.split("/")),o=r(e.split("/")),i=Math.min(n.length,o.length),s=i,a=0;a0?r.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\\n");if(!e)return null;t.input=At(e,!0)}return t.input.shift()},put_char:function(t,e){null===e||10===e?(A(O(t.output,0)),t.output=[]):0!=e&&t.output.push(e)},flush:function(t){t.output&&t.output.length>0&&(A(O(t.output,0)),t.output=[])}},default_tty1_ops:{put_char:function(t,e){null===e||10===e?(k(O(t.output,0)),t.output=[]):0!=e&&t.output.push(e)},flush:function(t){t.output&&t.output.length>0&&(k(O(t.output,0)),t.output=[])}}};var pt={ops_table:null,mount:function(t){return pt.createNode(null,"/",16895,0)},createNode:function(t,e,r,n){if(mt.isBlkdev(r)||mt.isFIFO(r))throw new mt.ErrnoError(63);pt.ops_table||(pt.ops_table={dir:{node:{getattr:pt.node_ops.getattr,setattr:pt.node_ops.setattr,lookup:pt.node_ops.lookup,mknod:pt.node_ops.mknod,rename:pt.node_ops.rename,unlink:pt.node_ops.unlink,rmdir:pt.node_ops.rmdir,readdir:pt.node_ops.readdir,symlink:pt.node_ops.symlink},stream:{llseek:pt.stream_ops.llseek}},file:{node:{getattr:pt.node_ops.getattr,setattr:pt.node_ops.setattr},stream:{llseek:pt.stream_ops.llseek,read:pt.stream_ops.read,write:pt.stream_ops.write,allocate:pt.stream_ops.allocate,mmap:pt.stream_ops.mmap,msync:pt.stream_ops.msync}},link:{node:{getattr:pt.node_ops.getattr,setattr:pt.node_ops.setattr,readlink:pt.node_ops.readlink},stream:{}},chrdev:{node:{getattr:pt.node_ops.getattr,setattr:pt.node_ops.setattr},stream:mt.chrdev_stream_ops}});var o=mt.createNode(t,e,r,n);return mt.isDir(o.mode)?(o.node_ops=pt.ops_table.dir.node,o.stream_ops=pt.ops_table.dir.stream,o.contents={}):mt.isFile(o.mode)?(o.node_ops=pt.ops_table.file.node,o.stream_ops=pt.ops_table.file.stream,o.usedBytes=0,o.contents=null):mt.isLink(o.mode)?(o.node_ops=pt.ops_table.link.node,o.stream_ops=pt.ops_table.link.stream):mt.isChrdev(o.mode)&&(o.node_ops=pt.ops_table.chrdev.node,o.stream_ops=pt.ops_table.chrdev.stream),o.timestamp=Date.now(),t&&(t.contents[e]=o,t.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(t){return t.contents?t.contents.subarray?t.contents.subarray(0,t.usedBytes):new Uint8Array(t.contents):new Uint8Array(0)},expandFileStorage:function(t,e){var r=t.contents?t.contents.length:0;if(!(r>=e)){e=Math.max(e,r*(r<1048576?2:1.125)>>>0),0!=r&&(e=Math.max(e,256));var n=t.contents;t.contents=new Uint8Array(e),t.usedBytes>0&&t.contents.set(n.subarray(0,t.usedBytes),0)}},resizeFileStorage:function(t,e){if(t.usedBytes!=e)if(0==e)t.contents=null,t.usedBytes=0;else{var r=t.contents;t.contents=new Uint8Array(e),r&&t.contents.set(r.subarray(0,Math.min(e,t.usedBytes))),t.usedBytes=e}},node_ops:{getattr:function(t){var e={};return e.dev=mt.isChrdev(t.mode)?t.id:1,e.ino=t.id,e.mode=t.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=t.rdev,mt.isDir(t.mode)?e.size=4096:mt.isFile(t.mode)?e.size=t.usedBytes:mt.isLink(t.mode)?e.size=t.link.length:e.size=0,e.atime=new Date(t.timestamp),e.mtime=new Date(t.timestamp),e.ctime=new Date(t.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr:function(t,e){void 0!==e.mode&&(t.mode=e.mode),void 0!==e.timestamp&&(t.timestamp=e.timestamp),void 0!==e.size&&pt.resizeFileStorage(t,e.size)},lookup:function(t,e){throw mt.genericErrors[44]},mknod:function(t,e,r,n){return pt.createNode(t,e,r,n)},rename:function(t,e,r){if(mt.isDir(t.mode)){var n;try{n=mt.lookupNode(e,r)}catch(t){}if(n)for(var o in n.contents)throw new mt.ErrnoError(55)}delete t.parent.contents[t.name],t.parent.timestamp=Date.now(),t.name=r,e.contents[r]=t,e.timestamp=t.parent.timestamp,t.parent=e},unlink:function(t,e){delete t.contents[e],t.timestamp=Date.now()},rmdir:function(t,e){var r=mt.lookupNode(t,e);for(var n in r.contents)throw new mt.ErrnoError(55);delete t.contents[e],t.timestamp=Date.now()},readdir:function(t){var e=[".",".."];for(var r in t.contents)t.contents.hasOwnProperty(r)&&e.push(r);return e},symlink:function(t,e,r){var n=pt.createNode(t,e,41471,0);return n.link=r,n},readlink:function(t){if(!mt.isLink(t.mode))throw new mt.ErrnoError(28);return t.link}},stream_ops:{read:function(t,e,r,n,o){var i=t.node.contents;if(o>=t.node.usedBytes)return 0;var s=Math.min(t.node.usedBytes-o,n);if(s>8&&i.subarray)e.set(i.subarray(o,o+s),r);else for(var a=0;a0||n+r{if(!(t=dt.resolve(mt.cwd(),t)))return{path:"",node:null};var r={follow_mount:!0,recurse_count:0};for(var n in r)void 0===e[n]&&(e[n]=r[n]);if(e.recurse_count>8)throw new mt.ErrnoError(32);for(var o=lt.normalizeArray(t.split("/").filter((t=>!!t)),!1),i=mt.root,s="/",a=0;a40)throw new mt.ErrnoError(32)}}return{path:s,node:i}},getPath:t=>{for(var e;;){if(mt.isRoot(t)){var r=t.mount.mountpoint;return e?"/"!==r[r.length-1]?r+"/"+e:r+e:r}e=e?t.name+"/"+e:t.name,t=t.parent}},hashName:(t,e)=>{for(var r=0,n=0;n>>0)%mt.nameTable.length},hashAddNode:t=>{var e=mt.hashName(t.parent.id,t.name);t.name_next=mt.nameTable[e],mt.nameTable[e]=t},hashRemoveNode:t=>{var e=mt.hashName(t.parent.id,t.name);if(mt.nameTable[e]===t)mt.nameTable[e]=t.name_next;else for(var r=mt.nameTable[e];r;){if(r.name_next===t){r.name_next=t.name_next;break}r=r.name_next}},lookupNode:(t,e)=>{var r=mt.mayLookup(t);if(r)throw new mt.ErrnoError(r,t);for(var n=mt.hashName(t.id,e),o=mt.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===t.id&&i===e)return o}return mt.lookup(t,e)},createNode:(t,e,r,n)=>{var o=new mt.FSNode(t,e,r,n);return mt.hashAddNode(o),o},destroyNode:t=>{mt.hashRemoveNode(t)},isRoot:t=>t===t.parent,isMountpoint:t=>!!t.mounted,isFile:t=>32768==(61440&t),isDir:t=>16384==(61440&t),isLink:t=>40960==(61440&t),isChrdev:t=>8192==(61440&t),isBlkdev:t=>24576==(61440&t),isFIFO:t=>4096==(61440&t),isSocket:t=>49152==(49152&t),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:t=>{var e=mt.flagModes[t];if(void 0===e)throw new Error("Unknown file open mode: "+t);return e},flagsToPermissionString:t=>{var e=["r","w","rw"][3&t];return 512&t&&(e+="w"),e},nodePermissions:(t,e)=>mt.ignorePermissions||(!e.includes("r")||292&t.mode)&&(!e.includes("w")||146&t.mode)&&(!e.includes("x")||73&t.mode)?0:2,mayLookup:t=>mt.nodePermissions(t,"x")||(t.node_ops.lookup?0:2),mayCreate:(t,e)=>{try{return mt.lookupNode(t,e),20}catch(t){}return mt.nodePermissions(t,"wx")},mayDelete:(t,e,r)=>{var n;try{n=mt.lookupNode(t,e)}catch(t){return t.errno}var o=mt.nodePermissions(t,"wx");if(o)return o;if(r){if(!mt.isDir(n.mode))return 54;if(mt.isRoot(n)||mt.getPath(n)===mt.cwd())return 10}else if(mt.isDir(n.mode))return 31;return 0},mayOpen:(t,e)=>t?mt.isLink(t.mode)?32:mt.isDir(t.mode)&&("r"!==mt.flagsToPermissionString(e)||512&e)?31:mt.nodePermissions(t,mt.flagsToPermissionString(e)):44,MAX_OPEN_FDS:4096,nextfd:(t=0,e=mt.MAX_OPEN_FDS)=>{for(var r=t;r<=e;r++)if(!mt.streams[r])return r;throw new mt.ErrnoError(33)},getStream:t=>mt.streams[t],createStream:(t,e,r)=>{mt.FSStream||(mt.FSStream=function(){},mt.FSStream.prototype={object:{get:function(){return this.node},set:function(t){this.node=t}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var n=new mt.FSStream;for(var o in t)n[o]=t[o];t=n;var i=mt.nextfd(e,r);return t.fd=i,mt.streams[i]=t,t},closeStream:t=>{mt.streams[t]=null},chrdev_stream_ops:{open:t=>{var e=mt.getDevice(t.node.rdev);t.stream_ops=e.stream_ops,t.stream_ops.open&&t.stream_ops.open(t)},llseek:()=>{throw new mt.ErrnoError(70)}},major:t=>t>>8,minor:t=>255&t,makedev:(t,e)=>t<<8|e,registerDevice:(t,e)=>{mt.devices[t]={stream_ops:e}},getDevice:t=>mt.devices[t],getMounts:t=>{for(var e=[],r=[t];r.length;){var n=r.pop();e.push(n),r.push.apply(r,n.mounts)}return e},syncfs:(t,e)=>{"function"==typeof t&&(e=t,t=!1),mt.syncFSRequests++,mt.syncFSRequests>1&&k("warning: "+mt.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var r=mt.getMounts(mt.root.mount),n=0;function o(t){return mt.syncFSRequests--,e(t)}function i(t){if(t)return i.errored?void 0:(i.errored=!0,o(t));++n>=r.length&&o(null)}r.forEach((e=>{if(!e.type.syncfs)return i(null);e.type.syncfs(e,t,i)}))},mount:(t,e,r)=>{var n,o="/"===r,i=!r;if(o&&mt.root)throw new mt.ErrnoError(10);if(!o&&!i){var s=mt.lookupPath(r,{follow_mount:!1});if(r=s.path,n=s.node,mt.isMountpoint(n))throw new mt.ErrnoError(10);if(!mt.isDir(n.mode))throw new mt.ErrnoError(54)}var a={type:t,opts:e,mountpoint:r,mounts:[]},u=t.mount(a);return u.mount=a,a.root=u,o?mt.root=u:n&&(n.mounted=a,n.mount&&n.mount.mounts.push(a)),u},unmount:t=>{var e=mt.lookupPath(t,{follow_mount:!1});if(!mt.isMountpoint(e.node))throw new mt.ErrnoError(28);var r=e.node,n=r.mounted,o=mt.getMounts(n);Object.keys(mt.nameTable).forEach((t=>{for(var e=mt.nameTable[t];e;){var r=e.name_next;o.includes(e.mount)&&mt.destroyNode(e),e=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:(t,e)=>t.node_ops.lookup(t,e),mknod:(t,e,r)=>{var n=mt.lookupPath(t,{parent:!0}).node,o=lt.basename(t);if(!o||"."===o||".."===o)throw new mt.ErrnoError(28);var i=mt.mayCreate(n,o);if(i)throw new mt.ErrnoError(i);if(!n.node_ops.mknod)throw new mt.ErrnoError(63);return n.node_ops.mknod(n,o,e,r)},create:(t,e)=>(e=void 0!==e?e:438,e&=4095,e|=32768,mt.mknod(t,e,0)),mkdir:(t,e)=>(e=void 0!==e?e:511,e&=1023,e|=16384,mt.mknod(t,e,0)),mkdirTree:(t,e)=>{for(var r=t.split("/"),n="",o=0;o(void 0===r&&(r=e,e=438),e|=8192,mt.mknod(t,e,r)),symlink:(t,e)=>{if(!dt.resolve(t))throw new mt.ErrnoError(44);var r=mt.lookupPath(e,{parent:!0}).node;if(!r)throw new mt.ErrnoError(44);var n=lt.basename(e),o=mt.mayCreate(r,n);if(o)throw new mt.ErrnoError(o);if(!r.node_ops.symlink)throw new mt.ErrnoError(63);return r.node_ops.symlink(r,n,t)},rename:(t,e)=>{var r,n,o=lt.dirname(t),i=lt.dirname(e),s=lt.basename(t),a=lt.basename(e);if(r=mt.lookupPath(t,{parent:!0}).node,n=mt.lookupPath(e,{parent:!0}).node,!r||!n)throw new mt.ErrnoError(44);if(r.mount!==n.mount)throw new mt.ErrnoError(75);var u,f=mt.lookupNode(r,s),l=dt.relative(t,i);if("."!==l.charAt(0))throw new mt.ErrnoError(28);if("."!==(l=dt.relative(e,o)).charAt(0))throw new mt.ErrnoError(55);try{u=mt.lookupNode(n,a)}catch(t){}if(f!==u){var c=mt.isDir(f.mode),d=mt.mayDelete(r,s,c);if(d)throw new mt.ErrnoError(d);if(d=u?mt.mayDelete(n,a,c):mt.mayCreate(n,a))throw new mt.ErrnoError(d);if(!r.node_ops.rename)throw new mt.ErrnoError(63);if(mt.isMountpoint(f)||u&&mt.isMountpoint(u))throw new mt.ErrnoError(10);if(n!==r&&(d=mt.nodePermissions(r,"w")))throw new mt.ErrnoError(d);mt.hashRemoveNode(f);try{r.node_ops.rename(f,n,a)}catch(t){throw t}finally{mt.hashAddNode(f)}}},rmdir:t=>{var e=mt.lookupPath(t,{parent:!0}).node,r=lt.basename(t),n=mt.lookupNode(e,r),o=mt.mayDelete(e,r,!0);if(o)throw new mt.ErrnoError(o);if(!e.node_ops.rmdir)throw new mt.ErrnoError(63);if(mt.isMountpoint(n))throw new mt.ErrnoError(10);e.node_ops.rmdir(e,r),mt.destroyNode(n)},readdir:t=>{var e=mt.lookupPath(t,{follow:!0}).node;if(!e.node_ops.readdir)throw new mt.ErrnoError(54);return e.node_ops.readdir(e)},unlink:t=>{var e=mt.lookupPath(t,{parent:!0}).node;if(!e)throw new mt.ErrnoError(44);var r=lt.basename(t),n=mt.lookupNode(e,r),o=mt.mayDelete(e,r,!1);if(o)throw new mt.ErrnoError(o);if(!e.node_ops.unlink)throw new mt.ErrnoError(63);if(mt.isMountpoint(n))throw new mt.ErrnoError(10);e.node_ops.unlink(e,r),mt.destroyNode(n)},readlink:t=>{var e=mt.lookupPath(t).node;if(!e)throw new mt.ErrnoError(44);if(!e.node_ops.readlink)throw new mt.ErrnoError(28);return dt.resolve(mt.getPath(e.parent),e.node_ops.readlink(e))},stat:(t,e)=>{var r=mt.lookupPath(t,{follow:!e}).node;if(!r)throw new mt.ErrnoError(44);if(!r.node_ops.getattr)throw new mt.ErrnoError(63);return r.node_ops.getattr(r)},lstat:t=>mt.stat(t,!0),chmod:(t,e,r)=>{var n;if(!(n="string"==typeof t?mt.lookupPath(t,{follow:!r}).node:t).node_ops.setattr)throw new mt.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&e|-4096&n.mode,timestamp:Date.now()})},lchmod:(t,e)=>{mt.chmod(t,e,!0)},fchmod:(t,e)=>{var r=mt.getStream(t);if(!r)throw new mt.ErrnoError(8);mt.chmod(r.node,e)},chown:(t,e,r,n)=>{var o;if(!(o="string"==typeof t?mt.lookupPath(t,{follow:!n}).node:t).node_ops.setattr)throw new mt.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(t,e,r)=>{mt.chown(t,e,r,!0)},fchown:(t,e,r)=>{var n=mt.getStream(t);if(!n)throw new mt.ErrnoError(8);mt.chown(n.node,e,r)},truncate:(t,e)=>{if(e<0)throw new mt.ErrnoError(28);var r;if(!(r="string"==typeof t?mt.lookupPath(t,{follow:!0}).node:t).node_ops.setattr)throw new mt.ErrnoError(63);if(mt.isDir(r.mode))throw new mt.ErrnoError(31);if(!mt.isFile(r.mode))throw new mt.ErrnoError(28);var n=mt.nodePermissions(r,"w");if(n)throw new mt.ErrnoError(n);r.node_ops.setattr(r,{size:e,timestamp:Date.now()})},ftruncate:(t,e)=>{var r=mt.getStream(t);if(!r)throw new mt.ErrnoError(8);if(0==(2097155&r.flags))throw new mt.ErrnoError(28);mt.truncate(r.node,e)},utime:(t,e,r)=>{var n=mt.lookupPath(t,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(e,r)})},open:(t,e,r,n,o)=>{if(""===t)throw new mt.ErrnoError(44);var i;if(r=void 0===r?438:r,r=64&(e="string"==typeof e?mt.modeStringToFlags(e):e)?4095&r|32768:0,"object"==typeof t)i=t;else{t=lt.normalize(t);try{i=mt.lookupPath(t,{follow:!(131072&e)}).node}catch(t){}}var a=!1;if(64&e)if(i){if(128&e)throw new mt.ErrnoError(20)}else i=mt.mknod(t,r,0),a=!0;if(!i)throw new mt.ErrnoError(44);if(mt.isChrdev(i.mode)&&(e&=-513),65536&e&&!mt.isDir(i.mode))throw new mt.ErrnoError(54);if(!a){var u=mt.mayOpen(i,e);if(u)throw new mt.ErrnoError(u)}512&e&&mt.truncate(i,0),e&=-131713;var f=mt.createStream({node:i,path:mt.getPath(i),flags:e,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1},n,o);return f.stream_ops.open&&f.stream_ops.open(f),!s.logReadFiles||1&e||(mt.readFiles||(mt.readFiles={}),t in mt.readFiles||(mt.readFiles[t]=1)),f},close:t=>{if(mt.isClosed(t))throw new mt.ErrnoError(8);t.getdents&&(t.getdents=null);try{t.stream_ops.close&&t.stream_ops.close(t)}catch(t){throw t}finally{mt.closeStream(t.fd)}t.fd=null},isClosed:t=>null===t.fd,llseek:(t,e,r)=>{if(mt.isClosed(t))throw new mt.ErrnoError(8);if(!t.seekable||!t.stream_ops.llseek)throw new mt.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new mt.ErrnoError(28);return t.position=t.stream_ops.llseek(t,e,r),t.ungotten=[],t.position},read:(t,e,r,n,o)=>{if(n<0||o<0)throw new mt.ErrnoError(28);if(mt.isClosed(t))throw new mt.ErrnoError(8);if(1==(2097155&t.flags))throw new mt.ErrnoError(8);if(mt.isDir(t.node.mode))throw new mt.ErrnoError(31);if(!t.stream_ops.read)throw new mt.ErrnoError(28);var i=void 0!==o;if(i){if(!t.seekable)throw new mt.ErrnoError(70)}else o=t.position;var s=t.stream_ops.read(t,e,r,n,o);return i||(t.position+=s),s},write:(t,e,r,n,o,i)=>{if(n<0||o<0)throw new mt.ErrnoError(28);if(mt.isClosed(t))throw new mt.ErrnoError(8);if(0==(2097155&t.flags))throw new mt.ErrnoError(8);if(mt.isDir(t.node.mode))throw new mt.ErrnoError(31);if(!t.stream_ops.write)throw new mt.ErrnoError(28);t.seekable&&1024&t.flags&&mt.llseek(t,0,2);var s=void 0!==o;if(s){if(!t.seekable)throw new mt.ErrnoError(70)}else o=t.position;var a=t.stream_ops.write(t,e,r,n,o,i);return s||(t.position+=a),a},allocate:(t,e,r)=>{if(mt.isClosed(t))throw new mt.ErrnoError(8);if(e<0||r<=0)throw new mt.ErrnoError(28);if(0==(2097155&t.flags))throw new mt.ErrnoError(8);if(!mt.isFile(t.node.mode)&&!mt.isDir(t.node.mode))throw new mt.ErrnoError(43);if(!t.stream_ops.allocate)throw new mt.ErrnoError(138);t.stream_ops.allocate(t,e,r)},mmap:(t,e,r,n,o,i)=>{if(0!=(2&o)&&0==(2&i)&&2!=(2097155&t.flags))throw new mt.ErrnoError(2);if(1==(2097155&t.flags))throw new mt.ErrnoError(2);if(!t.stream_ops.mmap)throw new mt.ErrnoError(43);return t.stream_ops.mmap(t,e,r,n,o,i)},msync:(t,e,r,n,o)=>t&&t.stream_ops.msync?t.stream_ops.msync(t,e,r,n,o):0,munmap:t=>0,ioctl:(t,e,r)=>{if(!t.stream_ops.ioctl)throw new mt.ErrnoError(59);return t.stream_ops.ioctl(t,e,r)},readFile:(t,e={})=>{if(e.flags=e.flags||0,e.encoding=e.encoding||"binary","utf8"!==e.encoding&&"binary"!==e.encoding)throw new Error(\'Invalid encoding type "\'+e.encoding+\'"\');var r,n=mt.open(t,e.flags),o=mt.stat(t).size,i=new Uint8Array(o);return mt.read(n,i,0,o,0),"utf8"===e.encoding?r=O(i,0):"binary"===e.encoding&&(r=i),mt.close(n),r},writeFile:(t,e,r={})=>{r.flags=r.flags||577;var n=mt.open(t,r.flags,r.mode);if("string"==typeof e){var o=new Uint8Array(T(e)+1),i=S(e,o,0,o.length);mt.write(n,o,0,i,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(e))throw new Error("Unsupported data type");mt.write(n,e,0,e.byteLength,void 0,r.canOwn)}mt.close(n)},cwd:()=>mt.currentPath,chdir:t=>{var e=mt.lookupPath(t,{follow:!0});if(null===e.node)throw new mt.ErrnoError(44);if(!mt.isDir(e.node.mode))throw new mt.ErrnoError(54);var r=mt.nodePermissions(e.node,"x");if(r)throw new mt.ErrnoError(r);mt.currentPath=e.path},createDefaultDirectories:()=>{mt.mkdir("/tmp"),mt.mkdir("/home"),mt.mkdir("/home/web_user")},createDefaultDevices:()=>{mt.mkdir("/dev"),mt.registerDevice(mt.makedev(1,3),{read:()=>0,write:(t,e,r,n,o)=>n}),mt.mkdev("/dev/null",mt.makedev(1,3)),ht.register(mt.makedev(5,0),ht.default_tty_ops),ht.register(mt.makedev(6,0),ht.default_tty1_ops),mt.mkdev("/dev/tty",mt.makedev(5,0)),mt.mkdev("/dev/tty1",mt.makedev(6,0));var t=ct();mt.createDevice("/dev","random",t),mt.createDevice("/dev","urandom",t),mt.mkdir("/dev/shm"),mt.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{mt.mkdir("/proc");var t=mt.mkdir("/proc/self");mt.mkdir("/proc/self/fd"),mt.mount({mount:()=>{var e=mt.createNode(t,"fd",16895,73);return e.node_ops={lookup:(t,e)=>{var r=+e,n=mt.getStream(r);if(!n)throw new mt.ErrnoError(8);var o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path}};return o.parent=o,o}},e}},{},"/proc/self/fd")},createStandardStreams:()=>{s.stdin?mt.createDevice("/dev","stdin",s.stdin):mt.symlink("/dev/tty","/dev/stdin"),s.stdout?mt.createDevice("/dev","stdout",null,s.stdout):mt.symlink("/dev/tty","/dev/stdout"),s.stderr?mt.createDevice("/dev","stderr",null,s.stderr):mt.symlink("/dev/tty1","/dev/stderr"),mt.open("/dev/stdin",0),mt.open("/dev/stdout",1),mt.open("/dev/stderr",1)},ensureErrnoError:()=>{mt.ErrnoError||(mt.ErrnoError=function(t,e){this.node=e,this.setErrno=function(t){this.errno=t},this.setErrno(t),this.message="FS error"},mt.ErrnoError.prototype=new Error,mt.ErrnoError.prototype.constructor=mt.ErrnoError,[44].forEach((t=>{mt.genericErrors[t]=new mt.ErrnoError(t),mt.genericErrors[t].stack=""})))},staticInit:()=>{mt.ensureErrnoError(),mt.nameTable=new Array(4096),mt.mount(pt,{},"/"),mt.createDefaultDirectories(),mt.createDefaultDevices(),mt.createSpecialDirectories(),mt.filesystems={MEMFS:pt}},init:(t,e,r)=>{mt.init.initialized=!0,mt.ensureErrnoError(),s.stdin=t||s.stdin,s.stdout=e||s.stdout,s.stderr=r||s.stderr,mt.createStandardStreams()},quit:()=>{mt.init.initialized=!1;for(var t=0;t{var r=0;return t&&(r|=365),e&&(r|=146),r},findObject:(t,e)=>{var r=mt.analyzePath(t,e);return r.exists?r.object:null},analyzePath:(t,e)=>{try{t=(n=mt.lookupPath(t,{follow:!e})).path}catch(t){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=mt.lookupPath(t,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=lt.basename(t),n=mt.lookupPath(t,{follow:!e}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot="/"===n.path}catch(t){r.error=t.errno}return r},createPath:(t,e,r,n)=>{t="string"==typeof t?t:mt.getPath(t);for(var o=e.split("/").reverse();o.length;){var i=o.pop();if(i){var s=lt.join2(t,i);try{mt.mkdir(s)}catch(t){}t=s}}return s},createFile:(t,e,r,n,o)=>{var i=lt.join2("string"==typeof t?t:mt.getPath(t),e),s=mt.getMode(n,o);return mt.create(i,s)},createDataFile:(t,e,r,n,o,i)=>{var s=e;t&&(t="string"==typeof t?t:mt.getPath(t),s=e?lt.join2(t,e):t);var a=mt.getMode(n,o),u=mt.create(s,a);if(r){if("string"==typeof r){for(var f=new Array(r.length),l=0,c=r.length;l{var o=lt.join2("string"==typeof t?t:mt.getPath(t),e),i=mt.getMode(!!r,!!n);mt.createDevice.major||(mt.createDevice.major=64);var s=mt.makedev(mt.createDevice.major++,0);return mt.registerDevice(s,{open:t=>{t.seekable=!1},close:t=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(t,e,n,o,i)=>{for(var s=0,a=0;a{for(var s=0;s{if(t.isDevice||t.isFolder||t.link||t.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!u)throw new Error("Cannot load without read() or XMLHttpRequest.");try{t.contents=At(u(t.url),!0),t.usedBytes=t.contents.length}catch(t){throw new mt.ErrnoError(29)}},createLazyFile:(t,e,r,n,o)=>{function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(t){if(!(t>this.length-1||t<0)){var e=t%this.chunkSize,r=t/this.chunkSize|0;return this.getter(r)[e]}},i.prototype.setDataGetter=function(t){this.getter=t},i.prototype.cacheLength=function(){var t=new XMLHttpRequest;if(t.open("HEAD",r,!1),t.send(null),!(t.status>=200&&t.status<300||304===t.status))throw new Error("Couldn\'t load "+r+". Status: "+t.status);var e,n=Number(t.getResponseHeader("Content-length")),o=(e=t.getResponseHeader("Accept-Ranges"))&&"bytes"===e,i=(e=t.getResponseHeader("Content-Encoding"))&&"gzip"===e,s=1048576;o||(s=n);var a=this;a.setDataGetter((t=>{var e=t*s,o=(t+1)*s-1;if(o=Math.min(o,n-1),void 0===a.chunks[t]&&(a.chunks[t]=((t,e)=>{if(t>e)throw new Error("invalid range ("+t+", "+e+") or no bytes requested!");if(e>n-1)throw new Error("only "+n+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),n!==s&&o.setRequestHeader("Range","bytes="+t+"-"+e),"undefined"!=typeof Uint8Array&&(o.responseType="arraybuffer"),o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn\'t load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):At(o.responseText||"",!0)})(e,o)),void 0===a.chunks[t])throw new Error("doXHR failed!");return a.chunks[t]})),!i&&n||(s=n=1,n=this.getter(0).length,s=n,A("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=s,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!E)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i;Object.defineProperties(s,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:s}}else a={isDevice:!1,url:r};var u=mt.createFile(t,e,a,n,o);a.contents?u.contents=a.contents:a.url&&(u.contents=null,u.url=a.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var f={};return Object.keys(u.stream_ops).forEach((t=>{var e=u.stream_ops[t];f[t]=function(){return mt.forceLoadFile(u),e.apply(null,arguments)}})),f.read=(t,e,r,n,o)=>{mt.forceLoadFile(u);var i=t.node.contents;if(o>=i.length)return 0;var s=Math.min(i.length-o,n);if(i.slice)for(var a=0;a{var c=e?dt.resolve(lt.join2(t,e)):t;function d(r){function f(r){l&&l(),a||mt.createDataFile(t,e,r,n,o,u),i&&i(),Z()}Browser.handledByPreloadPlugin(r,c,f,(()=>{s&&s(),Z()}))||f(r)}V(),"string"==typeof r?function(t,e,r,n){var o=n?"":"al "+t;f(t,(function(r){r||J(\'Loading data file "\'+t+\'" failed (no arrayBuffer).\'),e(new Uint8Array(r)),o&&Z()}),(function(e){if(!r)throw\'Loading data file "\'+t+\'" failed.\';r()})),o&&V()}(r,(t=>d(t)),s):d(r)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(t,e,r)=>{e=e||(()=>{}),r=r||(()=>{});var n=mt.indexedDB();try{var o=n.open(mt.DB_NAME(),mt.DB_VERSION)}catch(t){return r(t)}o.onupgradeneeded=()=>{A("creating db"),o.result.createObjectStore(mt.DB_STORE_NAME)},o.onsuccess=()=>{var n=o.result.transaction([mt.DB_STORE_NAME],"readwrite"),i=n.objectStore(mt.DB_STORE_NAME),s=0,a=0,u=t.length;function f(){0==a?e():r()}t.forEach((t=>{var e=i.put(mt.analyzePath(t).object.contents,t);e.onsuccess=()=>{++s+a==u&&f()},e.onerror=()=>{a++,s+a==u&&f()}})),n.onerror=r},o.onerror=r},loadFilesFromDB:(t,e,r)=>{e=e||(()=>{}),r=r||(()=>{});var n=mt.indexedDB();try{var o=n.open(mt.DB_NAME(),mt.DB_VERSION)}catch(t){return r(t)}o.onupgradeneeded=r,o.onsuccess=()=>{var n=o.result;try{var i=n.transaction([mt.DB_STORE_NAME],"readonly")}catch(t){return void r(t)}var s=i.objectStore(mt.DB_STORE_NAME),a=0,u=0,f=t.length;function l(){0==u?e():r()}t.forEach((t=>{var e=s.get(t);e.onsuccess=()=>{mt.analyzePath(t).exists&&mt.unlink(t),mt.createDataFile(lt.dirname(t),lt.basename(t),e.result,!0,!0,!0),++a+u==f&&l()},e.onerror=()=>{u++,a+u==f&&l()}})),i.onerror=r},o.onerror=r}},yt={mappings:{},DEFAULT_POLLMASK:5,calculateAt:function(t,e,r){if("/"===e[0])return e;var n;if(-100===t)n=mt.cwd();else{var o=mt.getStream(t);if(!o)throw new mt.ErrnoError(8);n=o.path}if(0==e.length){if(!r)throw new mt.ErrnoError(44);return n}return lt.join2(n,e)},doStat:function(t,e,r){try{var n=t(e)}catch(t){if(t&&t.node&<.normalize(e)!==lt.normalize(mt.getPath(t.node)))return-54;throw t}return I[r>>2]=n.dev,I[r+4>>2]=0,I[r+8>>2]=n.ino,I[r+12>>2]=n.mode,I[r+16>>2]=n.nlink,I[r+20>>2]=n.uid,I[r+24>>2]=n.gid,I[r+28>>2]=n.rdev,I[r+32>>2]=0,X=[n.size>>>0,(K=n.size,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],I[r+40>>2]=X[0],I[r+44>>2]=X[1],I[r+48>>2]=4096,I[r+52>>2]=n.blocks,I[r+56>>2]=n.atime.getTime()/1e3|0,I[r+60>>2]=0,I[r+64>>2]=n.mtime.getTime()/1e3|0,I[r+68>>2]=0,I[r+72>>2]=n.ctime.getTime()/1e3|0,I[r+76>>2]=0,X=[n.ino>>>0,(K=n.ino,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],I[r+80>>2]=X[0],I[r+84>>2]=X[1],0},doMsync:function(t,e,r,n,o){var i=D.slice(t,t+r);mt.msync(e,i,o,r,n)},doMkdir:function(t,e){return"/"===(t=lt.normalize(t))[t.length-1]&&(t=t.substr(0,t.length-1)),mt.mkdir(t,e,0),0},doMknod:function(t,e,r){switch(61440&e){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return mt.mknod(t,e,r),0},doReadlink:function(t,e,r){if(r<=0)return-28;var n=mt.readlink(t),o=Math.min(r,T(n)),i=M[e+o];return S(n,D,e,r+1),M[e+o]=i,o},doAccess:function(t,e){if(-8&e)return-28;var r=mt.lookupPath(t,{follow:!0}).node;if(!r)return-44;var n="";return 4&e&&(n+="r"),2&e&&(n+="w"),1&e&&(n+="x"),n&&mt.nodePermissions(r,n)?-2:0},doDup:function(t,e,r){var n=mt.getStream(r);return n&&mt.close(n),mt.open(t,e,0,r,r).fd},doReadv:function(t,e,r,n){for(var o=0,i=0;i>2],a=I[e+(8*i+4)>>2],u=mt.read(t,M,s,a,n);if(u<0)return-1;if(o+=u,u>2],a=I[e+(8*i+4)>>2],u=mt.write(t,M,s,a,n);if(u<0)return-1;o+=u}return o},varargs:void 0,get:function(){return yt.varargs+=4,I[yt.varargs-4>>2]},getStr:function(t){return H(t)},getStreamFromFD:function(t){var e=mt.getStream(t);if(!e)throw new mt.ErrnoError(8);return e},get64:function(t,e){return t}};function gt(t){return t%4==0&&(t%100!=0||t%400==0)}function wt(t,e){for(var r=0,n=0;n<=e;r+=t[n++]);return r}var Et=[31,29,31,30,31,30,31,31,30,31,30,31],vt=[31,28,31,30,31,30,31,31,30,31,30,31];function _t(t,e){for(var r=new Date(t.getTime());e>0;){var n=gt(r.getFullYear()),o=r.getMonth(),i=(n?Et:vt)[o];if(!(e>i-r.getDate()))return r.setDate(r.getDate()+e),r;e-=i-r.getDate()+1,r.setDate(1),o<11?r.setMonth(o+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1))}return r}var bt=function(t,e,r,n){t||(t=this),this.parent=t,this.mount=t.mount,this.mounted=null,this.id=mt.nextInode++,this.name=e,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n};function At(t,e,r){var n=r>0?r:T(t)+1,o=new Array(n),i=S(t,o,0,o.length);return e&&(o.length=i),o}Object.defineProperties(bt.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(t){t?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(t){t?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return mt.isDir(this.mode)}},isDevice:{get:function(){return mt.isChrdev(this.mode)}}}),mt.FSNode=bt,mt.staticInit();var kt,Pt={d:function(t){return Bt(t+16)+16},c:function(t,e,r){throw new st(t).init(e,r),t},f:function(t,e){J("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},i:function(t,e){J("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},a:function(){J("")},b:function(t,e){var r;if(0===t)r=Date.now();else{if(1!==t&&4!==t)return 28,I[Ft()>>2]=28,-1;r=nt()}return I[e>>2]=r/1e3|0,I[e+4>>2]=r%1e3*1e3*1e3|0,0},o:function(){return 2147483648},g:nt,h:function(t,e,r){D.copyWithin(t,e,e+r)},n:function(t){var e,r=D.length,n=2147483648;if((t>>>=0)>n)return!1;for(var o=1;o<=4;o*=2){var i=r*(1+.2/o);if(i=Math.min(i,t+100663296),at(Math.min(n,((e=Math.max(t,i))%65536>0&&(e+=65536-e%65536),e))))return!0}return!1},p:function(t,e){var r=0;return ft().forEach((function(n,o){var i=e+r;I[t+4*o>>2]=i,function(t,e,r){for(var n=0;n>0]=t.charCodeAt(n);M[e>>0]=0}(n,i),r+=n.length+1})),0},q:function(t,e){var r=ft();I[t>>2]=r.length;var n=0;return r.forEach((function(t){n+=t.length+1})),I[e>>2]=n,0},s:function(t){!function(t,e){var r;j(),r=t,j()||(s.onExit&&s.onExit(r),x=!0),g(r,new Dt(r))}(t)},j:function(t){try{var e=yt.getStreamFromFD(t);return mt.close(e),0}catch(t){if(void 0===mt||!(t instanceof mt.ErrnoError))throw t;return t.errno}},r:function(t,e,r,n){try{var o=yt.getStreamFromFD(t),i=yt.doReadv(o,e,r);return I[n>>2]=i,0}catch(t){if(void 0===mt||!(t instanceof mt.ErrnoError))throw t;return t.errno}},k:function(t,e,r,n,o){try{var i=yt.getStreamFromFD(t),s=4294967296*r+(e>>>0),a=9007199254740992;return s<=-a||s>=a?-61:(mt.llseek(i,s,n),X=[i.position>>>0,(K=i.position,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],I[o>>2]=X[0],I[o+4>>2]=X[1],i.getdents&&0===s&&0===n&&(i.getdents=null),0)}catch(t){if(void 0===mt||!(t instanceof mt.ErrnoError))throw t;return t.errno}},e:function(t,e,r,n){try{var o=yt.getStreamFromFD(t),i=yt.doWritev(o,e,r);return I[n>>2]=i,0}catch(t){if(void 0===mt||!(t instanceof mt.ErrnoError))throw t;return t.errno}},l:function t(e,r){t.randomDevice||(t.randomDevice=ct());for(var n=0;n>0]=t.randomDevice();return 0},m:function(t,e,r,n){return function(t,e,r,n){var o=I[n+40>>2],i={tm_sec:I[n>>2],tm_min:I[n+4>>2],tm_hour:I[n+8>>2],tm_mday:I[n+12>>2],tm_mon:I[n+16>>2],tm_year:I[n+20>>2],tm_wday:I[n+24>>2],tm_yday:I[n+28>>2],tm_isdst:I[n+32>>2],tm_gmtoff:I[n+36>>2],tm_zone:o?H(o):""},s=H(r),a={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in a)s=s.replace(new RegExp(u,"g"),a[u]);var f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],l=["January","February","March","April","May","June","July","August","September","October","November","December"];function c(t,e,r){for(var n="number"==typeof t?t.toString():t||"";n.length0?1:0}var n;return 0===(n=r(t.getFullYear()-e.getFullYear()))&&0===(n=r(t.getMonth()-e.getMonth()))&&(n=r(t.getDate()-e.getDate())),n}function p(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function m(t){var e=_t(new Date(t.tm_year+1900,0,1),t.tm_yday),r=new Date(e.getFullYear(),0,4),n=new Date(e.getFullYear()+1,0,4),o=p(r),i=p(n);return h(o,e)<=0?h(i,e)<=0?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var y={"%a":function(t){return f[t.tm_wday].substring(0,3)},"%A":function(t){return f[t.tm_wday]},"%b":function(t){return l[t.tm_mon].substring(0,3)},"%B":function(t){return l[t.tm_mon]},"%C":function(t){return d((t.tm_year+1900)/100|0,2)},"%d":function(t){return d(t.tm_mday,2)},"%e":function(t){return c(t.tm_mday,2," ")},"%g":function(t){return m(t).toString().substring(2)},"%G":function(t){return m(t)},"%H":function(t){return d(t.tm_hour,2)},"%I":function(t){var e=t.tm_hour;return 0==e?e=12:e>12&&(e-=12),d(e,2)},"%j":function(t){return d(t.tm_mday+wt(gt(t.tm_year+1900)?Et:vt,t.tm_mon-1),3)},"%m":function(t){return d(t.tm_mon+1,2)},"%M":function(t){return d(t.tm_min,2)},"%n":function(){return"\\n"},"%p":function(t){return t.tm_hour>=0&&t.tm_hour<12?"AM":"PM"},"%S":function(t){return d(t.tm_sec,2)},"%t":function(){return"\\t"},"%u":function(t){return t.tm_wday||7},"%U":function(t){var e=new Date(t.tm_year+1900,0,1),r=0===e.getDay()?e:_t(e,7-e.getDay()),n=new Date(t.tm_year+1900,t.tm_mon,t.tm_mday);if(h(r,n)<0){var o=wt(gt(n.getFullYear())?Et:vt,n.getMonth()-1)-31,i=31-r.getDate()+o+n.getDate();return d(Math.ceil(i/7),2)}return 0===h(r,e)?"01":"00"},"%V":function(t){var e,r=new Date(t.tm_year+1900,0,4),n=new Date(t.tm_year+1901,0,4),o=p(r),i=p(n),s=_t(new Date(t.tm_year+1900,0,1),t.tm_yday);return h(s,o)<0?"53":h(i,s)<=0?"01":(e=o.getFullYear()=0;return e=(e=Math.abs(e)/60)/60*100+e%60,(r?"+":"-")+String("0000"+e).slice(-4)},"%Z":function(t){return t.tm_zone},"%%":function(){return"%"}};for(var u in y)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),y[u](i)));var g=At(s,!1);return g.length>e?0:(function(t,e){M.set(t,e)}(g,t),g.length-1)}(t,e,r,n)}},Bt=(function(){var t={a:Pt};function e(t,e){var r,n=t.exports;s.asm=n,L((P=s.asm.t).buffer),U=s.asm.H,r=s.asm.u,N.unshift(r),Z()}function r(t){e(t.instance)}function n(e){return function(){if(!b&&(w||E)){if("function"==typeof fetch&&!tt(W))return fetch(W,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+W+"\'";return t.arrayBuffer()})).catch((function(){return et(W)}));if(f)return new Promise((function(t,e){f(W,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return et(W)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(t){return t})).then(e,(function(t){k("failed to asynchronously prepare wasm: "+t),J(t)}))}if(V(),s.instantiateWasm)try{return s.instantiateWasm(t,e)}catch(t){return k("Module.instantiateWasm callback failed with error: "+t),!1}(b||"function"!=typeof WebAssembly.instantiateStreaming||Q(W)||tt(W)||"function"!=typeof fetch?n(r):fetch(W,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(r,(function(t){return k("wasm streaming compile failed: "+t),k("falling back to ArrayBuffer instantiation"),n(r)}))}))).catch(i)}(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm.u).apply(null,arguments)},s._initPoseDetectorModelBuffer=function(){return(s._initPoseDetectorModelBuffer=s.asm.v).apply(null,arguments)},s._getPoseDetectorModelBufferAddress=function(){return(s._getPoseDetectorModelBufferAddress=s.asm.w).apply(null,arguments)},s._loadPoseDetectorModel=function(){return(s._loadPoseDetectorModel=s.asm.x).apply(null,arguments)},s._initPoseLandmarkModelBuffer=function(){return(s._initPoseLandmarkModelBuffer=s.asm.y).apply(null,arguments)},s._getPoseLandmarkModelBufferAddress=function(){return(s._getPoseLandmarkModelBufferAddress=s.asm.z).apply(null,arguments)},s._loadPoseLandmarkModel=function(){return(s._loadPoseLandmarkModel=s.asm.A).apply(null,arguments)},s._initPoseInputBuffer=function(){return(s._initPoseInputBuffer=s.asm.B).apply(null,arguments)},s._getPoseInputBufferAddress=function(){return(s._getPoseInputBufferAddress=s.asm.C).apply(null,arguments)},s._getPoseOutputBufferAddress=function(){return(s._getPoseOutputBufferAddress=s.asm.D).apply(null,arguments)},s._getPoseTemporaryBufferAddress=function(){return(s._getPoseTemporaryBufferAddress=s.asm.E).apply(null,arguments)},s._execPose=function(){return(s._execPose=s.asm.F).apply(null,arguments)},s._set_pose_calculate_mode=function(){return(s._set_pose_calculate_mode=s.asm.G).apply(null,arguments)},s._initPalmDetectorModelBuffer=function(){return(s._initPalmDetectorModelBuffer=s.asm.I).apply(null,arguments)},s._getPalmDetectorModelBufferAddress=function(){return(s._getPalmDetectorModelBufferAddress=s.asm.J).apply(null,arguments)},s._loadPalmDetectorModel=function(){return(s._loadPalmDetectorModel=s.asm.K).apply(null,arguments)},s._initHandLandmarkModelBuffer=function(){return(s._initHandLandmarkModelBuffer=s.asm.L).apply(null,arguments)},s._getHandLandmarkModelBufferAddress=function(){return(s._getHandLandmarkModelBufferAddress=s.asm.M).apply(null,arguments)},s._loadHandLandmarkModel=function(){return(s._loadHandLandmarkModel=s.asm.N).apply(null,arguments)},s._initHandInputBuffer=function(){return(s._initHandInputBuffer=s.asm.O).apply(null,arguments)},s._getHandInputBufferAddress=function(){return(s._getHandInputBufferAddress=s.asm.P).apply(null,arguments)},s._getHandOutputBufferAddress=function(){return(s._getHandOutputBufferAddress=s.asm.Q).apply(null,arguments)},s._getHandTemporaryBufferAddress=function(){return(s._getHandTemporaryBufferAddress=s.asm.R).apply(null,arguments)},s._execHand=function(){return(s._execHand=s.asm.S).apply(null,arguments)},s._initFaceDetectorModelBuffer=function(){return(s._initFaceDetectorModelBuffer=s.asm.T).apply(null,arguments)},s._getFaceDetectorModelBufferAddress=function(){return(s._getFaceDetectorModelBufferAddress=s.asm.U).apply(null,arguments)},s._loadFaceDetectorModel=function(){return(s._loadFaceDetectorModel=s.asm.V).apply(null,arguments)},s._initFaceLandmarkModelBuffer=function(){return(s._initFaceLandmarkModelBuffer=s.asm.W).apply(null,arguments)},s._getFaceLandmarkModelBufferAddress=function(){return(s._getFaceLandmarkModelBufferAddress=s.asm.X).apply(null,arguments)},s._loadFaceLandmarkModel=function(){return(s._loadFaceLandmarkModel=s.asm.Y).apply(null,arguments)},s._initFaceInputBuffer=function(){return(s._initFaceInputBuffer=s.asm.Z).apply(null,arguments)},s._getFaceInputBufferAddress=function(){return(s._getFaceInputBufferAddress=s.asm._).apply(null,arguments)},s._getFaceOutputBufferAddress=function(){return(s._getFaceOutputBufferAddress=s.asm.$).apply(null,arguments)},s._getFaceTemporaryBufferAddress=function(){return(s._getFaceTemporaryBufferAddress=s.asm.aa).apply(null,arguments)},s._execFace=function(){return(s._execFace=s.asm.ba).apply(null,arguments)},s._malloc=function(){return(Bt=s._malloc=s.asm.ca).apply(null,arguments)}),Ft=s.___errno_location=function(){return(Ft=s.___errno_location=s.asm.da).apply(null,arguments)},Mt=s._memalign=function(){return(Mt=s._memalign=s.asm.ea).apply(null,arguments)};function Dt(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function It(t){function r(){kt||(kt=!0,s.calledRun=!0,x||(s.noFSInit||mt.init.initialized||mt.init(),mt.ignorePermissions=!1,ht.init(),rt(N),e(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),function(){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)t=s.postRun.shift(),z.unshift(t);var t;rt(z)}()))}t=t||m,$>0||(function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)t=s.preRun.shift(),C.unshift(t);var t;rt(C)}(),$>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),r()}),1)):r()))}if(G=function t(){kt||It(),kt||(G=t)},s.run=It,s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return It(),t.ready});t.exports=i},782:()=>{},384:()=>{},375:()=>{}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(()=>{"use strict";var t=r(55);const e={lips:[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],leftEye:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],rightEye:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417],leftIris:[468,469,470,471,472],rightIris:[473,474,475,476,477]};class n extends t.ImageProcessor{constructor(){super(...arguments),this.tflite=null,this.tfliteHandInputAddress=0,this.tfliteHandOutputAddress=0,this.tfliteFaceInputAddress=0,this.tfliteFaceOutputAddress=0,this.tflitePoseInputAddress=0,this.tflitePoseOutputAddress=0,this.init=async e=>{if(e.browserType!==t.BrowserTypes.SAFARI){const t=r(503);this.tflite=await t({wasmBinary:e.wasmBin})}else console.error("This module use wasm-simd. Safari is not supported.");const n=e.palmDetectorModelTFLites[e.handModelKey];this.tflite._initPalmDetectorModelBuffer(n.byteLength);const o=this.tflite._getPalmDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(n),o),this.tflite._loadPalmDetectorModel(n.byteLength);const i=e.handLandmarkModelTFLites[e.handModelKey];this.tflite._initHandLandmarkModelBuffer(i.byteLength);const s=this.tflite._getHandLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(i),s),this.tflite._loadHandLandmarkModel(i.byteLength),this.tflite._initHandInputBuffer(e.maxProcessWidth,e.maxProcessHeight,4),this.tfliteHandInputAddress=this.tflite._getHandInputBufferAddress(),this.tfliteHandOutputAddress=this.tflite._getHandOutputBufferAddress(),console.log("Hand model is loaded successfully.",e);const a=e.faceDetectorModelTFLites[e.faceModelKey];this.tflite._initFaceDetectorModelBuffer(a.byteLength);const u=this.tflite._getFaceDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(a),u),this.tflite._loadFaceDetectorModel(a.byteLength);const f=e.faceLandmarkModelTFLites[e.faceModelKey];this.tflite._initFaceLandmarkModelBuffer(f.byteLength);const l=this.tflite._getFaceLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(f),l),this.tflite._loadFaceLandmarkModel(f.byteLength),this.tflite._initFaceInputBuffer(e.maxProcessWidth,e.maxProcessHeight,4),this.tfliteFaceInputAddress=this.tflite._getFaceInputBufferAddress(),this.tfliteFaceOutputAddress=this.tflite._getFaceOutputBufferAddress(),console.log("Face model is loaded successfully.",e);const c=e.poseDetectorModelTFLites[e.poseModelKey];this.tflite._initPoseDetectorModelBuffer(c.byteLength);const d=this.tflite._getPoseDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(c),d),this.tflite._loadPoseDetectorModel(c.byteLength);const h=e.poseLandmarkModelTFLites[e.poseModelKey];this.tflite._initPoseLandmarkModelBuffer(h.byteLength);const p=this.tflite._getPoseLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(h),p),this.tflite._loadPoseLandmarkModel(h.byteLength),this.tflite._initPoseInputBuffer(e.maxProcessWidth,e.maxProcessHeight,4),this.tflitePoseInputAddress=this.tflite._getPoseInputBufferAddress(),this.tflitePoseOutputAddress=this.tflite._getPoseOutputBufferAddress(),console.log("Pose model is loaded successfully.",e)},this.predict=async(t,e,r)=>"hand"===e.operationType?this.predictHand(t,e,r):"face"===e.operationType?this.predictFace(t,e,r):"pose"===e.operationType?this.predictPose(t,e,r):null,this.predictHand=async(t,e,r)=>{const n=new ImageData(r,e.handProcessWidth,e.handProcessHeight);this.tflite.HEAPU8.set(n.data,this.tfliteHandInputAddress),this.tflite._execHand(e.handProcessWidth,e.handProcessHeight,e.handMaxHands,e.handAffineResizedFactor);const o=this.tflite.HEAPF32[this.tfliteHandOutputAddress/4],i=[];for(let t=0;t({keypoints:[...t.landmarkKeypoints],handedness:t.handedness<.5?"Left":"Right",score:t.score})))},this.predictFace=async(t,r,n)=>{const o=new ImageData(n,r.faceProcessWidth,r.faceProcessHeight);this.tflite.HEAPU8.set(o.data,this.tfliteFaceInputAddress),this.tflite._execFace(r.faceProcessWidth,r.faceProcessHeight,r.faceMaxFaces);const i=this.tflite.HEAPF32[this.tfliteFaceOutputAddress/4],s=[];for(let t=0;t.5&&r.landmarkScore>.5&&s.push(r)}return s.map((t=>{const r={keypoints:[...t.landmarkKeypoints],box:{xMin:t.face.minX,yMin:t.face.minY,xMax:t.face.maxX,yMax:t.face.maxY,width:t.face.maxX-t.face.minX,height:t.face.maxY-t.face.maxY}};return e.lips.forEach(((e,n)=>{r.keypoints[e].x=t.landmarkLipsKeypoints[n].x,r.keypoints[e].y=t.landmarkLipsKeypoints[n].y})),e.leftEye.forEach(((e,n)=>{r.keypoints[e].x=t.landmarkLeftEyeKeypoints[n].x,r.keypoints[e].y=t.landmarkLeftEyeKeypoints[n].y})),e.rightEye.forEach(((e,n)=>{r.keypoints[e].x=t.landmarkRightEyeKeypoints[n].x,r.keypoints[e].y=t.landmarkRightEyeKeypoints[n].y})),e.leftIris.forEach(((e,n)=>{r.keypoints[e]=t.landmarkLeftIrisKeypoints[n]})),e.rightIris.forEach(((e,n)=>{r.keypoints[e]=t.landmarkRightIrisKeypoints[n]})),r}))},this.predictPose=async(t,e,r)=>{const n=new ImageData(r,e.poseProcessWidth,e.poseProcessHeight);this.tflite.HEAPU8.set(n.data,this.tflitePoseInputAddress),this.tflite._set_pose_calculate_mode(e.poseCalculateMode),this.tflite._execPose(e.poseProcessWidth,e.poseProcessHeight,e.poseMaxPoses,e.poseAffineResizedFactor,e.poseCropExt);const o=this.tflite.HEAPF32[this.tflitePoseOutputAddress/4],i=[];for(let t=0;t.1&&r.landmarkScore>0&&i.push(r)}return i.map((t=>({keypoints:[...t.landmarkKeypoints],keypoints3D:[...t.landmarkKeypoints3D],box:{xMin:t.pose.minX,yMin:t.pose.minY,xMax:t.pose.maxX,yMax:t.pose.maxY,width:t.pose.maxX-t.pose.minX,height:t.pose.maxY-t.pose.maxY}})))}}}const o=self,i=new t.WorkerDispatcher(o),s={init:async t=>{const e=new n;return await e.init(t),e}};i.setCallback(s),onmessage=i.dispach})()})();',"Worker",void 0,void 0)}const l=468,u=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255],d=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],h=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],f=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417],p=[468,469,470,471,472],m=[473,474,475,476,477],g={lips:d,leftEye:h,rightEye:f,leftIris:p,rightIris:m};class C extends e.ImageProcessor{constructor(){super(...arguments),this.tflite=null,this.tfliteHandInputAddress=0,this.tfliteHandOutputAddress=0,this.tfliteFaceInputAddress=0,this.tfliteFaceOutputAddress=0,this.tflitePoseInputAddress=0,this.tflitePoseOutputAddress=0,this.init=async t=>{if(t.browserType!==e.BrowserTypes.SAFARI){const e=i(503);this.tflite=await e({wasmBinary:t.wasmBin})}else console.error("This module use wasm-simd. Safari is not supported.");const n=t.palmDetectorModelTFLites[t.handModelKey];this.tflite._initPalmDetectorModelBuffer(n.byteLength);const r=this.tflite._getPalmDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(n),r),this.tflite._loadPalmDetectorModel(n.byteLength);const a=t.handLandmarkModelTFLites[t.handModelKey];this.tflite._initHandLandmarkModelBuffer(a.byteLength);const o=this.tflite._getHandLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(a),o),this.tflite._loadHandLandmarkModel(a.byteLength),this.tflite._initHandInputBuffer(t.maxProcessWidth,t.maxProcessHeight,4),this.tfliteHandInputAddress=this.tflite._getHandInputBufferAddress(),this.tfliteHandOutputAddress=this.tflite._getHandOutputBufferAddress(),console.log("Hand model is loaded successfully.",t);const s=t.faceDetectorModelTFLites[t.faceModelKey];this.tflite._initFaceDetectorModelBuffer(s.byteLength);const c=this.tflite._getFaceDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(s),c),this.tflite._loadFaceDetectorModel(s.byteLength);const l=t.faceLandmarkModelTFLites[t.faceModelKey];this.tflite._initFaceLandmarkModelBuffer(l.byteLength);const u=this.tflite._getFaceLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(l),u),this.tflite._loadFaceLandmarkModel(l.byteLength),this.tflite._initFaceInputBuffer(t.maxProcessWidth,t.maxProcessHeight,4),this.tfliteFaceInputAddress=this.tflite._getFaceInputBufferAddress(),this.tfliteFaceOutputAddress=this.tflite._getFaceOutputBufferAddress(),console.log("Face model is loaded successfully.",t);const d=t.poseDetectorModelTFLites[t.poseModelKey];this.tflite._initPoseDetectorModelBuffer(d.byteLength);const h=this.tflite._getPoseDetectorModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(d),h),this.tflite._loadPoseDetectorModel(d.byteLength);const f=t.poseLandmarkModelTFLites[t.poseModelKey];this.tflite._initPoseLandmarkModelBuffer(f.byteLength);const p=this.tflite._getPoseLandmarkModelBufferAddress();this.tflite.HEAPU8.set(new Uint8Array(f),p),this.tflite._loadPoseLandmarkModel(f.byteLength),this.tflite._initPoseInputBuffer(t.maxProcessWidth,t.maxProcessHeight,4),this.tflitePoseInputAddress=this.tflite._getPoseInputBufferAddress(),this.tflitePoseOutputAddress=this.tflite._getPoseOutputBufferAddress(),console.log("Pose model is loaded successfully.",t)},this.predict=async(e,n,i)=>n.operationType===t.hand?this.predictHand(e,n,i):n.operationType===t.face?this.predictFace(e,n,i):n.operationType===t.pose?this.predictPose(e,n,i):null,this.predictHand=async(e,t,n)=>{const i=new ImageData(n,t.handProcessWidth,t.handProcessHeight);this.tflite.HEAPU8.set(i.data,this.tfliteHandInputAddress),this.tflite._execHand(t.handProcessWidth,t.handProcessHeight,t.handMaxHands,t.handAffineResizedFactor);const r=this.tflite.HEAPF32[this.tfliteHandOutputAddress/4],a=[];for(let e=0;e({keypoints:[...e.landmarkKeypoints],handedness:e.handedness<.5?"Left":"Right",score:e.score})))},this.predictFace=async(e,t,n)=>{const i=new ImageData(n,t.faceProcessWidth,t.faceProcessHeight);this.tflite.HEAPU8.set(i.data,this.tfliteFaceInputAddress),this.tflite._execFace(t.faceProcessWidth,t.faceProcessHeight,t.faceMaxFaces);const r=this.tflite.HEAPF32[this.tfliteFaceOutputAddress/4],a=[];for(let e=0;e.5&&n.landmarkScore>.5&&a.push(n)}return a.map((e=>{const t={keypoints:[...e.landmarkKeypoints],box:{xMin:e.face.minX,yMin:e.face.minY,xMax:e.face.maxX,yMax:e.face.maxY,width:e.face.maxX-e.face.minX,height:e.face.maxY-e.face.maxY}};return g.lips.forEach(((n,i)=>{t.keypoints[n].x=e.landmarkLipsKeypoints[i].x,t.keypoints[n].y=e.landmarkLipsKeypoints[i].y})),g.leftEye.forEach(((n,i)=>{t.keypoints[n].x=e.landmarkLeftEyeKeypoints[i].x,t.keypoints[n].y=e.landmarkLeftEyeKeypoints[i].y})),g.rightEye.forEach(((n,i)=>{t.keypoints[n].x=e.landmarkRightEyeKeypoints[i].x,t.keypoints[n].y=e.landmarkRightEyeKeypoints[i].y})),g.leftIris.forEach(((n,i)=>{t.keypoints[n]=e.landmarkLeftIrisKeypoints[i]})),g.rightIris.forEach(((n,i)=>{t.keypoints[n]=e.landmarkRightIrisKeypoints[i]})),t}))},this.predictPose=async(e,t,n)=>{const i=new ImageData(n,t.poseProcessWidth,t.poseProcessHeight);this.tflite.HEAPU8.set(i.data,this.tflitePoseInputAddress),this.tflite._set_pose_calculate_mode(t.poseCalculateMode),this.tflite._execPose(t.poseProcessWidth,t.poseProcessHeight,t.poseMaxPoses,t.poseAffineResizedFactor,t.poseCropExt);const r=this.tflite.HEAPF32[this.tflitePoseOutputAddress/4],a=[];for(let e=0;e.1&&n.landmarkScore>0&&a.push(n)}return a.map((e=>({keypoints:[...e.landmarkKeypoints],keypoints3D:[...e.landmarkKeypoints3D],box:{xMin:e.pose.minX,yMin:e.pose.minY,xMax:e.pose.maxX,yMax:e.pose.maxY,width:e.pose.maxX-e.pose.minX,height:e.pose.maxY-e.pose.maxY}})))}}}class v extends e.WorkerManagerBase{constructor(){super(...arguments),this.imageProcessor=new C,this.config=null,this.generateDefaultConfig=async t=>{const n=t?.wasmUrl||i(81),r=this.fetchData(n),a=t?.palmDetectorModelTFLiteUrl||i(102),o=this.fetchData(a),s=t?.handLandmarkLiteTFLiteUrl||i(583),c=this.fetchData(s),l=t?.faceDetectorModelTFLiteUrl||i(363),u=this.fetchData(l),d=t?.faceLandmarkModelTFLiteUrl||i(180),h=this.fetchData(d),f=t?.poseDetectorModelTFLiteUrl||i(914),p=this.fetchData(f),m=t?.poseLandmarkModelTFLiteUrl||i(747),g=this.fetchData(m),[C,v,y,b,M,x,_]=await Promise.all([r,o,c,u,h,p,g]);return{browserType:(0,e.getBrowserType)(),processOnLocal:!0,pageUrl:window.location.href,wasmBin:C,palmDetectorModelTFLites:{lite:v},handLandmarkModelTFLites:{lite:y},handModelKey:"lite",faceDetectorModelTFLites:{lite:b},faceLandmarkModelTFLites:{lite:M},faceModelKey:"lite",poseDetectorModelTFLites:{lite:x},poseLandmarkModelTFLites:{lite:_},poseModelKey:"lite",maxProcessWidth:1024,maxProcessHeight:1024}},this.generateDefaultMediapipeMixParams=()=>({operationType:t.face,handProcessWidth:512,handProcessHeight:512,handMaxHands:2,handAffineResizedFactor:2,faceProcessWidth:512,faceProcessHeight:512,faceMaxFaces:1,faceMovingAverageWindow:5,poseProcessWidth:512,poseProcessHeight:512,poseMaxPoses:1,poseMovingAverageWindow:5,poseAffineResizedFactor:2,poseCropExt:1.3,poseCalculateMode:0}),this.init=async e=>{this.config=e||await this.generateDefaultConfig(),await this.initCommon({useWorkerForSafari:!0,processOnLocal:this.config.processOnLocal,workerJs:()=>new c},this.config),console.log("[manager] tflite worker initilizied.")},this.predict=async(e,n)=>{if(!this.config)return console.warn("config is not initialized."),null;const i={...e},r=((n,i)=>e.operationType===t.hand?this.generateTargetCanvas(i,n.handProcessWidth,n.handProcessHeight):e.operationType===t.face?this.generateTargetCanvas(i,n.faceProcessWidth,n.faceProcessHeight):this.generateTargetCanvas(i,n.poseProcessWidth,n.poseProcessHeight))(i,n);if(!this.worker){const e=r.getContext("2d").getImageData(0,0,r.width,r.height),n=await this.imageProcessor.predict(this.config,i,e.data);return i.operationType===t.hand?this.generateHandPredictionEx(this.config,i,n):i.operationType===t.face?this.generateFacePredictionEx(this.config,i,n):this.generatePosePredictionEx(this.config,i,n)}const a=r.getContext("2d").getImageData(0,0,r.width,r.height),o=await this.sendToWorker(i,a.data);return i.operationType===t.hand?this.generateHandPredictionEx(this.config,i,o):i.operationType===t.face?this.generateFacePredictionEx(this.config,i,o):this.generatePosePredictionEx(this.config,i,o)},this.generateHandPredictionEx=(e,n,i)=>{const r=i;return{operationType:t.hand,rowPrediction:r}},this.facesMV=[],this.generateFacePredictionEx=(e,n,i)=>{const r=i,a={operationType:t.face,rowPrediction:r};if(n.faceMovingAverageWindow>0){if(r)for(;this.facesMV.length>n.faceMovingAverageWindow;)this.facesMV.shift();r&&r[0]&&r[0].keypoints&&this.facesMV.push(r);const e=this.facesMV.map((e=>e[0].keypoints)).reduce(((e,t)=>{for(let n=0;ne[0].box)).reduce(((e,t)=>e.width?(e.width=e.width+t.width,e.xMax=e.xMax+t.xMax,e.xMin=e.xMin+t.xMin,e.height=e.height+t.height,e.yMax=e.yMax+t.yMax,e.yMin=e.yMin+t.yMin,e):{width:t.width,xMax:t.xMax,xMin:t.xMin,height:t.height,yMax:t.yMax,yMin:t.yMin}),{});console.log(),t.width/=this.facesMV.length,t.xMax/=this.facesMV.length,t.xMin/=this.facesMV.length,t.height/=this.facesMV.length,t.yMax/=this.facesMV.length,t.yMin/=this.facesMV.length,a.singlePersonBoxMovingAverage=t}return a},this.posesMV=[],this.generatePosePredictionEx=(e,n,i)=>{const r=i,a={operationType:t.pose,rowPrediction:r};if(n.poseMovingAverageWindow>0){if(r)for(;this.posesMV.length>n.poseMovingAverageWindow;)this.posesMV.shift();r&&r[0]&&r[0].keypoints&&this.posesMV.push(r);const e=this.posesMV.map((e=>e[0].keypoints)).reduce(((e,t)=>{for(let n=0;ne[0].keypoints3D)).reduce(((e,t)=>{for(let n=0;ne[0].box)).reduce(((e,t)=>e.width?(e.width=e.width+t.width,e.xMax=e.xMax+t.xMax,e.xMin=e.xMin+t.xMin,e.height=e.height+t.height,e.yMax=e.yMax+t.yMax,e.yMin=e.yMin+t.yMin,e):{width:t.width,xMax:t.xMax,xMin:t.xMin,height:t.height,yMax:t.yMax,yMin:t.yMin}),{});console.log(),i.width/=this.posesMV.length,i.xMax/=this.posesMV.length,i.xMin/=this.posesMV.length,i.height/=this.posesMV.length,i.yMax/=this.posesMV.length,i.yMin/=this.posesMV.length,a.singlePersonBoxMovingAverage=i}return a},this.fitCroppedArea=(e,t,n,i,r,a,o,s,c,l,u)=>{if(!e.singlePersonBoxMovingAverage)return{xmin:0,ymin:0,width:0,height:0};const d=t/i,h=n/r,f=e.singlePersonBoxMovingAverage.xMin*d,p=e.singlePersonBoxMovingAverage.xMax*d,m=e.singlePersonBoxMovingAverage.yMin*h,g=e.singlePersonBoxMovingAverage.yMax*h,C=(p+f)/2,v=(g+m)/2,y=p-C,b=g-v;let M=C-y*(1+l);M=M<0?0:M;let x=C+y*(1+u);x=x>t?t:x;let _=v-b*(1+s);_=_<0?0:_;let S=v+b*(1+c);S=S>n?n:S;const w=x-M,L=S-_,E=(x+M)/2,T=(S+_)/2,z=o/a;let A,V,H,R;return w*z>L?(A=w,V=w*z):(A=L/z,V=L),H=E-A/2<0?0:E+A/2>t?t-A:E-A/2,R=T-V/2<0?0:T+V/2>n?n-V:T-V/2,{xmin:H,ymin:R,width:A,height:V}}}}})(),a})(),e.exports=i()},698:(e,t,n)=>{"use strict";n.r(t),n.d(t,{MToonMaterial:()=>El,MToonMaterialCullMode:()=>Ml,MToonMaterialDebugMode:()=>xl,MToonMaterialOutlineColorMode:()=>_l,MToonMaterialOutlineWidthMode:()=>Sl,MToonMaterialRenderMode:()=>wl,VRM:()=>Yl,VRMBlendShapeGroup:()=>Nc,VRMBlendShapeImporter:()=>qc,VRMBlendShapeProxy:()=>jc,VRMCurveMapper:()=>al,VRMDebug:()=>du,VRMFirstPerson:()=>Kc,VRMFirstPersonImporter:()=>Zc,VRMHumanBone:()=>Qc,VRMHumanoid:()=>il,VRMHumanoidImporter:()=>rl,VRMImporter:()=>Xl,VRMLookAtApplyer:()=>ol,VRMLookAtBlendShapeApplyer:()=>sl,VRMLookAtBoneApplyer:()=>ml,VRMLookAtHead:()=>fl,VRMLookAtImporter:()=>Cl,VRMMaterialImporter:()=>zl,VRMMetaImporter:()=>Al,VRMRendererFirstPersonFlags:()=>$c,VRMSchema:()=>Dc,VRMSpringBone:()=>Ul,VRMSpringBoneDebug:()=>su,VRMSpringBoneImporter:()=>ql,VRMSpringBoneImporterDebug:()=>cu,VRMSpringBoneManager:()=>Wl,VRMUnlitMaterial:()=>Tl,VRMUnlitMaterialRenderType:()=>Ll,VRMUtils:()=>eu,VRM_GIZMO_RENDER_ORDER:()=>uu});const i="137",r=100,a=301,o=302,s=306,c=1e3,l=1001,u=1002,d=1003,h=1006,f=1008,p=1009,m=1012,g=1014,C=1015,v=1016,y=1020,b=1023,M=1026,x=1027,_=33776,S=33777,w=33778,L=33779,E=2300,T=2301,z=2302,A=2400,V=2401,H=2402,R=3e3,P=3001,I=7680,k=35044,N=35048,D="300 es",O=1035;class B{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+F[e>>16&255]+F[e>>24&255]+"-"+F[255&t]+F[t>>8&255]+"-"+F[t>>16&15|64]+F[t>>24&255]+"-"+F[63&n|128]+F[n>>8&255]+"-"+F[n>>16&255]+F[n>>24&255]+F[255&i]+F[i>>8&255]+F[i>>16&255]+F[i>>24&255]).toUpperCase()}function j(e,t,n){return Math.max(t,Math.min(n,e))}function q(e,t,n){return(1-n)*e+n*t}function X(e){return 0==(e&e-1)&&0!==e}function Y(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}class J{constructor(e=0,t=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,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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){const 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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}J.prototype.isVector2=!0;class ${constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,a,o,s,c){const l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],p=i[0],m=i[3],g=i[6],C=i[1],v=i[4],y=i[7],b=i[2],M=i[5],x=i[8];return r[0]=a*p+o*C+s*b,r[3]=a*m+o*v+s*M,r[6]=a*g+o*y+s*x,r[1]=c*p+l*C+u*b,r[4]=c*m+l*v+u*M,r[7]=c*g+l*y+u*x,r[2]=d*p+h*C+f*b,r[5]=d*m+h*v+f*M,r[8]=d*g+h*y+f*x,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*r*l+n*o*s+i*r*c-i*a*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*r,h=c*r-a*s,f=t*u+n*d+i*h;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return e[0]=u*p,e[1]=(i*c-l*n)*p,e[2]=(o*n-i*a)*p,e[3]=d*p,e[4]=(l*t-i*s)*p,e[5]=(i*r-o*t)*p,e[6]=h*p,e[7]=(n*s-c*t)*p,e[8]=(a*t-n*r)*p,this}transpose(){let e;const 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){const 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,i,r,a,o){const s=Math.cos(r),c=Math.sin(r);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-i*c,i*s,-i*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],a=i[3],o=i[6],s=i[1],c=i[4],l=i[7];return i[0]=t*r+n*s,i[3]=t*a+n*c,i[6]=t*o+n*l,i[1]=-n*r+t*s,i[4]=-n*a+t*c,i[7]=-n*o+t*l,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])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){const 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)}}function K(e){for(let t=e.length-1;t>=0;--t)if(e[t]>65535)return!0;return!1}function Z(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}$.prototype.isMatrix3=!0,Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;const Q={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},ee={h:0,s:0,l:0},te={h:0,s:0,l:0};function ne(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function ie(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function re(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class ae{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=function(e,t){return(e%1+1)%1}(e),t=j(t,0,1),n=j(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=ne(r,i,e+1/3),this.g=ne(r,i,e),this.b=ne(r,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=Q[e.toLowerCase()];return void 0!==t?this.setHex(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=ie(e.r),this.g=ie(e.g),this.b=ie(e.b),this}copyLinearToSRGB(e){return this.r=re(e.r),this.g=re(e.g),this.b=re(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),a=Math.min(t,n,i);let o,s;const c=(a+r)/2;if(a===r)o=0,s=0;else{const e=r-a;switch(s=c<=.5?e/(r+a):e/(2-r-a),r){case t:o=(n-i)/e+(n2048||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("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Z("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e1)switch(this.wrapS){case c:e.x=e.x-Math.floor(e.x);break;case l:e.x=e.x<0?0:1;break;case u:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case c:e.y=e.y-Math.floor(e.y);break;case l:e.y=e.y<0?0:1;break;case u:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function ue(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?se.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}le.DEFAULT_IMAGE=void 0,le.DEFAULT_MAPPING=300,le.prototype.isTexture=!0;class de{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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,i,r;const a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],h=s[5],f=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(l-d)s&&e>C?eC?s=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,o=Math.sin(o*a)/r}const r=o*n;if(s=s*e+d*r,c=c*e+h*r,l=l*e+f*r,u=u*e+p*r,e===1-o){const e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],s=n[i+1],c=n[i+2],l=n[i+3],u=r[a],d=r[a+1],h=r[a+2],f=r[a+3];return e[t]=o*f+l*u+s*h-c*d,e[t+1]=s*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-s*u,e[t+3]=l*f-o*u-s*d-c*h,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(i/2),u=o(r/2),d=s(n/2),h=s(i/2),f=s(r/2);switch(a){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(r-c)*e,this._z=(a-i)*e}else if(n>o&&n>u){const e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+c)/e}else if(o>u){const e=2*Math.sqrt(1+o-n-u);this._w=(r-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(s+l)/e}else{const e=2*Math.sqrt(1+u-n-o);this._w=(a-i)/e,this._x=(r+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(j(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(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,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+i*c-r*s,this._y=i*l+a*s+r*o-n*c,this._z=r*l+a*c+n*s-i*o,this._w=a*l-n*o-i*s-r*c,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}pe.prototype.isQuaternion=!0;class me{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(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,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(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 e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ce.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ce.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*i-o*n,l=s*n+o*t-r*i,u=s*i+r*n-a*t,d=-r*t-a*n-o*i;return this.x=c*s+d*-r+l*-o-u*-a,this.y=l*s+d*-a+u*-r-c*-o,this.z=u*s+d*-o+c*-a-l*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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){const 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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ge.copy(this).projectOnVector(e),this.sub(ge)}reflect(e){return this.sub(ge.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(j(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}me.prototype.isVector3=!0;const ge=new me,Ce=new pe;class ve{constructor(e=new me(1/0,1/0,1/0),t=new me(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.length;sr&&(r=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.count;sr&&(r=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,be),be.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(Te),ze.subVectors(this.max,Te),xe.subVectors(e.a,Te),_e.subVectors(e.b,Te),Se.subVectors(e.c,Te),we.subVectors(_e,xe),Le.subVectors(Se,_e),Ee.subVectors(xe,Se);let t=[0,-we.z,we.y,0,-Le.z,Le.y,0,-Ee.z,Ee.y,we.z,0,-we.x,Le.z,0,-Le.x,Ee.z,0,-Ee.x,-we.y,we.x,0,-Le.y,Le.x,0,-Ee.y,Ee.x,0];return!!He(t,xe,_e,Se,ze)&&(t=[1,0,0,0,1,0,0,0,1],!!He(t,xe,_e,Se,ze)&&(Ae.crossVectors(we,Le),t=[Ae.x,Ae.y,Ae.z],He(t,xe,_e,Se,ze)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return be.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(be).length(),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()||(ye[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ye[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ye[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ye[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ye[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ye[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ye[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ye[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ye)),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)}}ve.prototype.isBox3=!0;const ye=[new me,new me,new me,new me,new me,new me,new me,new me],be=new me,Me=new ve,xe=new me,_e=new me,Se=new me,we=new me,Le=new me,Ee=new me,Te=new me,ze=new me,Ae=new me,Ve=new me;function He(e,t,n,i,r){for(let a=0,o=e.length-3;a<=o;a+=3){Ve.fromArray(e,a);const o=r.x*Math.abs(Ve.x)+r.y*Math.abs(Ve.y)+r.z*Math.abs(Ve.z),s=t.dot(Ve),c=n.dot(Ve),l=i.dot(Ve);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const Re=new ve,Pe=new me,Ie=new me,ke=new me;class Ne{constructor(e=new me,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Re.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.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){ke.subVectors(e,this.center);const t=ke.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(ke.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?Ie.set(0,0,1).multiplyScalar(e.radius):Ie.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Pe.copy(e.center).add(Ie)),this.expandByPoint(Pe.copy(e.center).sub(Ie)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const De=new me,Oe=new me,Be=new me,Fe=new me,Ue=new me,We=new me,Ge=new me;class je{constructor(e=new me,t=new me(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,De)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=De.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(De.copy(this.direction).multiplyScalar(t).add(this.origin),De.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Oe.copy(e).add(t).multiplyScalar(.5),Be.copy(t).sub(e).normalize(),Fe.copy(this.origin).sub(Oe);const r=.5*e.distanceTo(t),a=-this.direction.dot(Be),o=Fe.dot(this.direction),s=-Fe.dot(Be),c=Fe.lengthSq(),l=Math.abs(1-a*a);let u,d,h,f;if(l>0)if(u=a*s-o,d=a*o-s,f=r*l,u>=0)if(d>=-f)if(d<=f){const e=1/l;u*=e,d*=e,h=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;else d=-r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;else d<=-f?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+c):d<=f?(u=0,d=Math.min(Math.max(-r,-s),r),h=d*(d+2*s)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(Be).multiplyScalar(d).add(Oe),h}intersectSphere(e,t){De.subVectors(e.center,this.origin);const n=De.dot(this.direction),i=De.dot(De)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,s;const c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),l>=0?(r=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(r=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,De)}intersectTriangle(e,t,n,i,r){Ue.subVectors(t,e),We.subVectors(n,e),Ge.crossVectors(Ue,We);let a,o=this.direction.dot(Ge);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Fe.subVectors(this.origin,e);const s=a*this.direction.dot(We.crossVectors(Fe,We));if(s<0)return null;const c=a*this.direction.dot(Ue.cross(Fe));if(c<0)return null;if(s+c>o)return null;const l=-a*Fe.dot(Ge);return l<0?null:this.at(l/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)}}class qe{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,a,o,s,c,l,u,d,h,f,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=h,g[7]=f,g[11]=p,g[15]=m,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 qe).fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){const t=this.elements,n=e.elements,i=1/Xe.setFromMatrixColumn(e,0).length(),r=1/Xe.setFromMatrixColumn(e,1).length(),a=1/Xe.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,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]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=a*l,n=a*u,i=o*l,r=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+i*c,t[5]=e-r*c,t[9]=-o*s,t[2]=r-e*c,t[6]=i+n*c,t[10]=a*s}else if("YXZ"===e.order){const e=s*l,n=s*u,i=c*l,r=c*u;t[0]=e+r*o,t[4]=i*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-i,t[6]=r+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*l,n=s*u,i=c*l,r=c*u;t[0]=e-r*o,t[4]=-a*u,t[8]=i+n*o,t[1]=n+i*o,t[5]=a*l,t[9]=r-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*l,n=a*u,i=o*l,r=o*u;t[0]=s*l,t[4]=i*c-n,t[8]=e*c+r,t[1]=s*u,t[5]=r*c+e,t[9]=n*c-i,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*c,i=o*s,r=o*c;t[0]=s*l,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=a*s,n=a*c,i=o*s,r=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+r,t[5]=a*l,t[9]=n*u-i,t[2]=i*u-n,t[6]=o*l,t[10]=r*u+e}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(Je,e,$e)}lookAt(e,t,n){const i=this.elements;return Qe.subVectors(e,t),0===Qe.lengthSq()&&(Qe.z=1),Qe.normalize(),Ke.crossVectors(n,Qe),0===Ke.lengthSq()&&(1===Math.abs(n.z)?Qe.x+=1e-4:Qe.z+=1e-4,Qe.normalize(),Ke.crossVectors(n,Qe)),Ke.normalize(),Ze.crossVectors(Qe,Ke),i[0]=Ke.x,i[4]=Ze.x,i[8]=Qe.x,i[1]=Ke.y,i[5]=Ze.y,i[9]=Qe.y,i[2]=Ke.z,i[6]=Ze.z,i[10]=Qe.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],p=n[6],m=n[10],g=n[14],C=n[3],v=n[7],y=n[11],b=n[15],M=i[0],x=i[4],_=i[8],S=i[12],w=i[1],L=i[5],E=i[9],T=i[13],z=i[2],A=i[6],V=i[10],H=i[14],R=i[3],P=i[7],I=i[11],k=i[15];return r[0]=a*M+o*w+s*z+c*R,r[4]=a*x+o*L+s*A+c*P,r[8]=a*_+o*E+s*V+c*I,r[12]=a*S+o*T+s*H+c*k,r[1]=l*M+u*w+d*z+h*R,r[5]=l*x+u*L+d*A+h*P,r[9]=l*_+u*E+d*V+h*I,r[13]=l*S+u*T+d*H+h*k,r[2]=f*M+p*w+m*z+g*R,r[6]=f*x+p*L+m*A+g*P,r[10]=f*_+p*E+m*V+g*I,r[14]=f*S+p*T+m*H+g*k,r[3]=C*M+v*w+y*z+b*R,r[7]=C*x+v*L+y*A+b*P,r[11]=C*_+v*E+y*V+b*I,r[15]=C*S+v*T+y*H+b*k,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+r*s*u-i*c*u-r*o*d+n*c*d+i*o*h-n*s*h)+e[7]*(+t*s*h-t*c*d+r*a*d-i*a*h+i*c*l-r*s*l)+e[11]*(+t*c*u-t*o*h-r*a*u+n*a*h+r*o*l-n*c*l)+e[15]*(-i*o*l-t*s*u+t*o*d+i*a*u-n*a*d+n*s*l)}transpose(){const e=this.elements;let 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){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],p=e[13],m=e[14],g=e[15],C=u*m*c-p*d*c+p*s*h-o*m*h-u*s*g+o*d*g,v=f*d*c-l*m*c-f*s*h+a*m*h+l*s*g-a*d*g,y=l*p*c-f*u*c+f*o*h-a*p*h-l*o*g+a*u*g,b=f*u*s-l*p*s-f*o*d+a*p*d+l*o*m-a*u*m,M=t*C+n*v+i*y+r*b;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const x=1/M;return e[0]=C*x,e[1]=(p*d*r-u*m*r-p*i*h+n*m*h+u*i*g-n*d*g)*x,e[2]=(o*m*r-p*s*r+p*i*c-n*m*c-o*i*g+n*s*g)*x,e[3]=(u*s*r-o*d*r-u*i*c+n*d*c+o*i*h-n*s*h)*x,e[4]=v*x,e[5]=(l*m*r-f*d*r+f*i*h-t*m*h-l*i*g+t*d*g)*x,e[6]=(f*s*r-a*m*r-f*i*c+t*m*c+a*i*g-t*s*g)*x,e[7]=(a*d*r-l*s*r+l*i*c-t*d*c-a*i*h+t*s*h)*x,e[8]=y*x,e[9]=(f*u*r-l*p*r-f*n*h+t*p*h+l*n*g-t*u*g)*x,e[10]=(a*p*r-f*o*r+f*n*c-t*p*c-a*n*g+t*o*g)*x,e[11]=(l*o*r-a*u*r-l*n*c+t*u*c+a*n*h-t*o*h)*x,e[12]=b*x,e[13]=(l*p*i-f*u*i+f*n*d-t*p*d-l*n*m+t*u*m)*x,e[14]=(f*o*i-a*p*i-f*n*s+t*p*s+a*n*m-t*o*m)*x,e[15]=(a*u*i-l*o*i+l*n*s-t*u*s-a*n*d+t*o*d)*x,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const 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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,s=e.z,c=r*a,l=r*o;return this.set(c*a+n,c*o-i*s,c*s+i*o,0,c*o+i*s,l*o+n,l*s-i*a,0,c*s-i*o,l*s+i*a,r*s*s+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,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,s=t._w,c=r+r,l=a+a,u=o+o,d=r*c,h=r*l,f=r*u,p=a*l,m=a*u,g=o*u,C=s*c,v=s*l,y=s*u,b=n.x,M=n.y,x=n.z;return i[0]=(1-(p+g))*b,i[1]=(h+y)*b,i[2]=(f-v)*b,i[3]=0,i[4]=(h-y)*M,i[5]=(1-(d+g))*M,i[6]=(m+C)*M,i[7]=0,i[8]=(f+v)*x,i[9]=(m-C)*x,i[10]=(1-(d+p))*x,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Xe.set(i[0],i[1],i[2]).length();const a=Xe.set(i[4],i[5],i[6]).length(),o=Xe.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Ye.copy(this);const s=1/r,c=1/a,l=1/o;return Ye.elements[0]*=s,Ye.elements[1]*=s,Ye.elements[2]*=s,Ye.elements[4]*=c,Ye.elements[5]*=c,Ye.elements[6]*=c,Ye.elements[8]*=l,Ye.elements[9]*=l,Ye.elements[10]*=l,t.setFromRotationMatrix(Ye),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*r/(t-e),c=2*r/(n-i),l=(t+e)/(t-e),u=(n+i)/(n-i),d=-(a+r)/(a-r),h=-2*a*r/(a-r);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=h,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a){const o=this.elements,s=1/(t-e),c=1/(n-i),l=1/(a-r),u=(t+e)*s,d=(n+i)*c,h=(a+r)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-h,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])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){const 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}}qe.prototype.isMatrix4=!0;const Xe=new me,Ye=new qe,Je=new me(0,0,0),$e=new me(1,1,1),Ke=new me,Ze=new me,Qe=new me,et=new qe,tt=new pe;class nt{constructor(e=0,t=0,n=0,i=nt.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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){const i=e.elements,r=i[0],a=i[4],o=i[8],s=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":this._y=Math.asin(j(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-j(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,h),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(j(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,r));break;case"ZYX":this._y=Math.asin(-j(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(j(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,h));break;case"XZY":this._z=Math.asin(-j(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return et.makeRotationFromQuaternion(e),this.setFromRotationMatrix(et,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tt.setFromEuler(this),this.setFromQuaternion(tt,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],void 0!==e[3]&&(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}toVector3(e){return e?e.set(this._x,this._y,this._z):new me(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}nt.prototype.isEuler=!0,nt.DefaultOrder="XYZ",nt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class it{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}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.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.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){vt.subVectors(i,t),yt.subVectors(n,t),bt.subVectors(e,t);const a=vt.dot(vt),o=vt.dot(yt),s=vt.dot(bt),c=yt.dot(yt),l=yt.dot(bt),u=a*c-o*o;if(0===u)return r.set(-2,-1,-1);const d=1/u,h=(c*s-o*l)*d,f=(a*l-o*s)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Mt),Mt.x>=0&&Mt.y>=0&&Mt.x+Mt.y<=1}static getUV(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,Mt),s.set(0,0),s.addScaledVector(r,Mt.x),s.addScaledVector(a,Mt.y),s.addScaledVector(o,Mt.z),s}static isFrontFacing(e,t,n,i){return vt.subVectors(n,t),yt.subVectors(e,t),vt.cross(yt).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 vt.subVectors(this.c,this.b),yt.subVectors(this.a,this.b),.5*vt.cross(yt).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Tt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Tt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return Tt.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Tt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Tt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;xt.subVectors(i,n),_t.subVectors(r,n),wt.subVectors(e,n);const s=xt.dot(wt),c=_t.dot(wt);if(s<=0&&c<=0)return t.copy(n);Lt.subVectors(e,i);const l=xt.dot(Lt),u=_t.dot(Lt);if(l>=0&&u<=l)return t.copy(i);const d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(xt,a);Et.subVectors(e,r);const h=xt.dot(Et),f=_t.dot(Et);if(f>=0&&h<=f)return t.copy(r);const p=h*c-s*f;if(p<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(_t,o);const m=l*f-h*u;if(m<=0&&u-l>=0&&h-f>=0)return St.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(St,o);const g=1/(m+p+d);return a=p*g,o=d*g,t.copy(n).addScaledVector(xt,a).addScaledVector(_t,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let zt=0;class At extends B{constructor(){super(),Object.defineProperty(this,"id",{value:zt++}),this.uuid=G(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=r,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=I,this.stencilZFail=I,this.stencilZPass=I,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(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.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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,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.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;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,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){!0===e&&this.version++}}At.prototype.isMaterial=!0;class Vt extends At{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new ae(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.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.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}}Vt.prototype.isMeshBasicMaterial=!0;const Ht=new me,Rt=new J;class Pt{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=k,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.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;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Yt.copy(n.boundingSphere),Yt.applyMatrix4(r),!1===e.ray.intersectsSphere(Yt))return;if(qt.copy(r).invert(),Xt.copy(e.ray).applyMatrix4(qt),null!==n.boundingBox&&!1===Xt.intersectsBox(n.boundingBox))return;let a;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position,s=n.morphAttributes.position,c=n.morphTargetsRelative,l=n.attributes.uv,u=n.attributes.uv2,d=n.groups,h=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,f=d.length;nn.far?null:{distance:l,point:ln.clone(),object:e}}(e,t,n,i,Jt,$t,Kt,cn);if(f){s&&(an.fromBufferAttribute(s,l),on.fromBufferAttribute(s,u),sn.fromBufferAttribute(s,d),f.uv=Tt.getUV(cn,Jt,$t,Kt,an,on,sn,new J)),c&&(an.fromBufferAttribute(c,l),on.fromBufferAttribute(c,u),sn.fromBufferAttribute(c,d),f.uv2=Tt.getUV(cn,Jt,$t,Kt,an,on,sn,new J));const e={a:l,b:u,c:d,normal:new me,materialIndex:0};Tt.getNormal(Jt,$t,Kt,e.normal),f.face=e}return f}un.prototype.isMesh=!0;class hn extends jt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const s=[],c=[],l=[],u=[];let d=0,h=0;function f(e,t,n,i,r,a,f,p,m,g,C){const v=a/m,y=f/g,b=a/2,M=f/2,x=p/2,_=m+1,S=g+1;let w=0,L=0;const E=new me;for(let a=0;a0?1:-1,l.push(E.x,E.y,E.z),u.push(s/m),u.push(1-a/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}gn.prototype.isShaderMaterial=!0;class Cn extends Ct{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}Cn.prototype.isCamera=!0;class vn extends Cn{constructor(e=50,t=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*W*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*U*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*W*Math.atan(Math.tan(.5*U*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(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=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*U*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/o,i*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}vn.prototype.isPerspectiveCamera=!0;const yn=90;class bn extends Ct{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new vn(yn,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new me(1,0,0)),this.add(i);const r=new vn(yn,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new me(-1,0,0)),this.add(r);const a=new vn(yn,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new me(0,1,0)),this.add(a);const o=new vn(yn,1,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new me(0,-1,0)),this.add(o);const s=new vn(yn,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new me(0,0,1)),this.add(s);const c=new vn(yn,1,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new me(0,0,-1)),this.add(c)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,a,o,s,c]=this.children,l=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=l,n.texture.needsPMREMUpdate=!0}}class Mn extends le{constructor(e,t,n,i,r,o,s,c,l,u){super(e=void 0!==e?e:[],t=void 0!==t?t:a,n,i,r,o,s,c,l,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Mn.prototype.isCubeTexture=!0;class xn extends he{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new Mn(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:h}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=b,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new hn(5,5,5),i=new gn({name:"CubemapFromEquirect",uniforms:fn({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});i.uniforms.tEquirect.value=t;const r=new un(n,i),a=t.minFilter;return t.minFilter===f&&(t.minFilter=h),new bn(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}xn.prototype.isWebGLCubeRenderTarget=!0;const _n=new me,Sn=new me,wn=new $;class Ln{constructor(e=new me(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=_n.subVectors(n,t).cross(Sn.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(_n),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const 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){const n=t||wn.getNormalMatrix(e),i=this.coplanarPoint(_n).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}}Ln.prototype.isPlane=!0;const En=new Ne,Tn=new me;class zn{constructor(e=new Ln,t=new Ln,n=new Ln,i=new Ln,r=new Ln,a=new Ln){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],h=n[9],f=n[10],p=n[11],m=n[12],g=n[13],C=n[14],v=n[15];return t[0].setComponents(o-i,u-s,p-d,v-m).normalize(),t[1].setComponents(o+i,u+s,p+d,v+m).normalize(),t[2].setComponents(o+r,u+c,p+h,v+g).normalize(),t[3].setComponents(o-r,u-c,p-h,v-g).normalize(),t[4].setComponents(o-a,u-l,p-f,v-C).normalize(),t[5].setComponents(o+a,u+l,p+f,v+C).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),En.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(En)}intersectsSprite(e){return En.center.set(0,0,0),En.radius=.7071067811865476,En.applyMatrix4(e.matrixWorld),this.intersectsSphere(En)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Tn.y=i.normal.y>0?e.max.y:e.min.y,Tn.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Tn)<0)return!1}return!0}containsPoint(e){const 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 An(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Vn(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid 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 ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Pn={common:{diffuse:{value:new ae(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new $},uv2Transform:{value:new $},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ae(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ae(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new $}},sprite:{diffuse:{value:new ae(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new $}}},In={basic:{uniforms:pn([Pn.common,Pn.specularmap,Pn.envmap,Pn.aomap,Pn.lightmap,Pn.fog]),vertexShader:Rn.meshbasic_vert,fragmentShader:Rn.meshbasic_frag},lambert:{uniforms:pn([Pn.common,Pn.specularmap,Pn.envmap,Pn.aomap,Pn.lightmap,Pn.emissivemap,Pn.fog,Pn.lights,{emissive:{value:new ae(0)}}]),vertexShader:Rn.meshlambert_vert,fragmentShader:Rn.meshlambert_frag},phong:{uniforms:pn([Pn.common,Pn.specularmap,Pn.envmap,Pn.aomap,Pn.lightmap,Pn.emissivemap,Pn.bumpmap,Pn.normalmap,Pn.displacementmap,Pn.fog,Pn.lights,{emissive:{value:new ae(0)},specular:{value:new ae(1118481)},shininess:{value:30}}]),vertexShader:Rn.meshphong_vert,fragmentShader:Rn.meshphong_frag},standard:{uniforms:pn([Pn.common,Pn.envmap,Pn.aomap,Pn.lightmap,Pn.emissivemap,Pn.bumpmap,Pn.normalmap,Pn.displacementmap,Pn.roughnessmap,Pn.metalnessmap,Pn.fog,Pn.lights,{emissive:{value:new ae(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Rn.meshphysical_vert,fragmentShader:Rn.meshphysical_frag},toon:{uniforms:pn([Pn.common,Pn.aomap,Pn.lightmap,Pn.emissivemap,Pn.bumpmap,Pn.normalmap,Pn.displacementmap,Pn.gradientmap,Pn.fog,Pn.lights,{emissive:{value:new ae(0)}}]),vertexShader:Rn.meshtoon_vert,fragmentShader:Rn.meshtoon_frag},matcap:{uniforms:pn([Pn.common,Pn.bumpmap,Pn.normalmap,Pn.displacementmap,Pn.fog,{matcap:{value:null}}]),vertexShader:Rn.meshmatcap_vert,fragmentShader:Rn.meshmatcap_frag},points:{uniforms:pn([Pn.points,Pn.fog]),vertexShader:Rn.points_vert,fragmentShader:Rn.points_frag},dashed:{uniforms:pn([Pn.common,Pn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Rn.linedashed_vert,fragmentShader:Rn.linedashed_frag},depth:{uniforms:pn([Pn.common,Pn.displacementmap]),vertexShader:Rn.depth_vert,fragmentShader:Rn.depth_frag},normal:{uniforms:pn([Pn.common,Pn.bumpmap,Pn.normalmap,Pn.displacementmap,{opacity:{value:1}}]),vertexShader:Rn.meshnormal_vert,fragmentShader:Rn.meshnormal_frag},sprite:{uniforms:pn([Pn.sprite,Pn.fog]),vertexShader:Rn.sprite_vert,fragmentShader:Rn.sprite_frag},background:{uniforms:{uvTransform:{value:new $},t2D:{value:null}},vertexShader:Rn.background_vert,fragmentShader:Rn.background_frag},cube:{uniforms:pn([Pn.envmap,{opacity:{value:1}}]),vertexShader:Rn.cube_vert,fragmentShader:Rn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Rn.equirect_vert,fragmentShader:Rn.equirect_frag},distanceRGBA:{uniforms:pn([Pn.common,Pn.displacementmap,{referencePosition:{value:new me},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Rn.distanceRGBA_vert,fragmentShader:Rn.distanceRGBA_frag},shadow:{uniforms:pn([Pn.lights,Pn.fog,{color:{value:new ae(0)},opacity:{value:1}}]),vertexShader:Rn.shadow_vert,fragmentShader:Rn.shadow_frag}};function kn(e,t,n,i,r,a){const o=new ae(0);let c,l,u=!0===r?0:1,d=null,h=0,f=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,p(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,p(o,u)},render:function(n,r){let a=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const g=e.xr,C=g.getSession&&g.getSession();C&&"additive"===C.environmentBlendMode&&(m=null),null===m?p(o,u):m&&m.isColor&&(p(m,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===s)?(void 0===l&&(l=new un(new hn(1,1,1),new gn({name:"BackgroundCubeMaterial",uniforms:fn(In.cube.uniforms),vertexShader:In.cube.vertexShader,fragmentShader:In.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=m,l.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,d===m&&h===m.version&&f===e.toneMapping||(l.material.needsUpdate=!0,d=m,h=m.version,f=e.toneMapping),n.unshift(l,l.geometry,l.material,0,0,null)):m&&m.isTexture&&(void 0===c&&(c=new un(new Hn(2,2),new gn({name:"BackgroundMaterial",uniforms:fn(In.background.uniforms),vertexShader:In.background.vertexShader,fragmentShader:In.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),c.material.uniforms.uvTransform.value.copy(m.matrix),d===m&&h===m.version&&f===e.toneMapping||(c.material.needsUpdate=!0,d=m,h=m.version,f=e.toneMapping),n.unshift(c,c.geometry,c.material,0,0,null))}}}function Nn(e,t,n,i){const r=e.getParameter(34921),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||null!==a,s={},c=h(null);let l=c;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function h(e){const t=[],n=[],i=[];for(let e=0;e=0){let a=c[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,o=a.itemSize,c=n.get(a);if(void 0===c)continue;const l=c.buffer,u=c.type,d=c.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,c=n.stride,h=a.offset;if(n&&n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const c=a||t.has("WEBGL_draw_buffers"),l=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),h=e.getParameter(3379),f=e.getParameter(34076),p=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),C=e.getParameter(36349),v=d>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:d,maxTextureSize:h,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:C,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:a?e.getParameter(36183):0}}function Bn(e){const t=this;let n=null,i=0,r=!1,a=!1;const o=new Ln,s=new $,c={value:null,needsUpdate:!1};function l(){c.value!==n&&(c.value=n,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,r){const a=null!==e?e.length:0;let l=null;if(0!==a){if(l=c.value,!0!==r||null===l){const t=i+4*a,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===l||l.length0){const o=new xn(a.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener("dispose",i),n(o.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}In.physical={uniforms:pn([In.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new J(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new ae(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ae(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ae(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Rn.meshphysical_vert,fragmentShader:Rn.meshphysical_frag};class Un extends Cn{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(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=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,s=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}Un.prototype.isOrthographicCamera=!0;class Wn extends gn{constructor(e){super(e),this.type="RawShaderMaterial"}}Wn.prototype.isRawShaderMaterial=!0;const Gn=Math.pow(2,8),jn=[.125,.215,.35,.446,.526,.582],qn=5+jn.length,Xn=new Un,{_lodPlanes:Yn,_sizeLods:Jn,_sigmas:$n}=function(){const e=[],t=[],n=[];let i=8;for(let r=0;r4?o=jn[r-8+4-1]:0===r&&(o=0),n.push(o);const s=1/(a-1),c=-s/2,l=1+s/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,p=2,m=1,g=new Float32Array(f*h*d),C=new Float32Array(p*h*d),v=new Float32Array(m*h*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(i,f*h*e),C.set(u,p*h*e);const r=[e,e,e,e,e,e];v.set(r,m*h*e)}const y=new jt;y.setAttribute("position",new Pt(g,f)),y.setAttribute("uv",new Pt(C,p)),y.setAttribute("faceIndex",new Pt(v,m)),e.push(y),i>4&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Kn=new ae;let Zn=null;const Qn=(1+Math.sqrt(5))/2,ei=1/Qn,ti=[new me(1,1,1),new me(-1,1,1),new me(1,1,-1),new me(-1,1,-1),new me(0,Qn,ei),new me(0,Qn,-ei),new me(ei,0,Qn),new me(-ei,0,Qn),new me(Qn,ei,0),new me(-Qn,ei,0)];class ni{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(20),n=new me(0,1,0);return new Wn({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Zn=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,i,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(){null===this._cubemapShader&&(this._cubemapShader=oi(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=ai(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e2?Gn:0,Gn,Gn),s.setRenderTarget(i),h&&s.render(d,r),s.render(e,r)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===a||e.mapping===o;i?(null===this._cubemapShader&&(this._cubemapShader=oi()),this._cubemapShader.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectShader&&(this._equirectShader=ai());const r=i?this._cubemapShader:this._equirectShader,s=new un(Yn[0],r),c=r.uniforms;c.envMap.value=e,i||c.texelSize.value.set(1/e.image.width,1/e.image.height),ri(t,0,0,3*Gn,2*Gn),n.setRenderTarget(t),n.render(s,Xn)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/f,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e4?i-8+4:0),3*C,2*C),s.setRenderTarget(t),s.render(l,Xn)}}function ii(e){const t=new he(3*Gn,3*Gn,e);return t.texture.mapping=s,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function ri(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function ai(){const e=new J(1,1);return new Wn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = texture2D ( envMap, uv ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function oi(){return new Wn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function si(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,c=303===s||304===s,l=s===a||s===o;if(c||l){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new ni(e)),i=c?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const a=r.image;if(c&&a&&a.height>0||l&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new ni(e));const a=c?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function ci(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function li(e,t,n,i){const r={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete r[s.id];const c=a.get(s);c&&(t.remove(c),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let o=0;if(null!==i){const e=i.array;o=i.version;for(let t=0,i=e.length;tt.maxTextureSize&&(S=Math.ceil(_/t.maxTextureSize),_=t.maxTextureSize);const w=new Float32Array(_*S*4*f),L=new hi(w,_,S,f);L.format=b,L.type=C,L.needsUpdate=!0;const E=4*x;for(let z=0;z0)return e;const r=t*n;let a=_i[r];if(void 0===a&&(a=new Float32Array(r),_i[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function zi(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n/gm;function Hr(e){return e.replace(Vr,Rr)}function Rr(e,t){const n=Rn[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Hr(n)}const Pr=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Ir=/#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 kr(e){return e.replace(Ir,Dr).replace(Pr,Nr)}function Nr(e,t,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Dr(0,t,n,i)}function Dr(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(v+="\n"),y=[m,g].filter(Tr).join("\n"),y.length>0&&(y+="\n")):(v=[Or(n),"#define SHADER_NAME "+n.shaderName,g,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Tr).join("\n"),y=[m,Or(n),"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+f:"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Rn.tonemapping_pars_fragment:"",0!==n.toneMapping?Er("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.transparent?"":"#define OPAQUE",Rn.encodings_pars_fragment,Lr("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Tr).join("\n")),l=Hr(l),l=zr(l,n),l=Ar(l,n),u=Hr(u),u=zr(u,n),u=Ar(u,n),l=kr(l),u=kr(u),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(b="#version 300 es\n",v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+v,y=["#define varying in",n.glslVersion===D?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===D?"":"#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("\n")+"\n"+y);const M=b+y+u,x=_r(r,35633,b+v+l),_=_r(r,35632,M);if(r.attachShader(C,x),r.attachShader(C,_),void 0!==n.index0AttributeName?r.bindAttribLocation(C,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(C,0,"position"),r.linkProgram(C),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(C).trim(),t=r.getShaderInfoLog(x).trim(),n=r.getShaderInfoLog(_).trim();let i=!0,a=!0;if(!1===r.getProgramParameter(C,35714)){i=!1;const t=wr(r,x,"vertex"),n=wr(r,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(C,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+n)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==n||(a=!1);a&&(this.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:v},fragmentShader:{log:n,prefix:y}})}let S,w;return r.deleteShader(x),r.deleteShader(_),this.getUniforms=function(){return void 0===S&&(S=new xr(r,C)),S},this.getAttributes=function(){return void 0===w&&(w=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let r=0;r0,V=a.clearcoat>0;return{isWebGL2:d,shaderID:_,shaderName:a.type,vertexShader:w,fragmentShader:L,defines:a.defines,customVertexShaderID:E,customFragmentShaderID:T,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:g,instancing:!0===y.isInstancedMesh,instancingColor:!0===y.isInstancedMesh&&null!==y.instanceColor,supportsVertexTextures:m,outputEncoding:null===z?e.outputEncoding:!0===z.isXRRenderTarget?z.texture.encoding:R,map:!!a.map,matcap:!!a.matcap,envMap:!!x,envMapMode:x&&x.mapping,envMapCubeUV:!!x&&(x.mapping===s||307===x.mapping),lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:1===a.normalMapType,tangentSpaceNormalMap:0===a.normalMapType,decodeVideoTexture:!!a.map&&!0===a.map.isVideoTexture&&a.map.encoding===P,clearcoat:V,clearcoatMap:V&&!!a.clearcoatMap,clearcoatRoughnessMap:V&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:V&&!!a.clearcoatNormalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,transparent:a.transparent,alphaMap:!!a.alphaMap,alphaTest:A,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!y.geometry&&!!y.geometry.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.geometry&&!!y.geometry.attributes.color&&4===y.geometry.attributes.color.itemSize,vertexUvs:!!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatMap||a.clearcoatRoughnessMap||a.clearcoatNormalMap||a.displacementMap||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheenColorMap||a.sheenRoughnessMap),uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!b,useFog:a.fog,fogExp2:b&&b.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===y.isSkinnedMesh&&S>0,maxBones:S,useVertexTexture:f,morphTargets:!!y.geometry&&!!y.geometry.morphAttributes.position,morphNormals:!!y.geometry&&!!y.geometry.morphAttributes.normal,morphTargetsCount:y.geometry&&y.geometry.morphAttributes.position?y.geometry.morphAttributes.position.length:0,numDirLights:c.directional.length,numPointLights:c.point.length,numSpotLights:c.spot.length,numRectAreaLights:c.rectArea.length,numHemiLights:c.hemi.length,numDirLightShadows:c.directionalShadowMap.length,numPointLightShadows:c.pointShadowMap.length,numSpotLightShadows:c.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,depthPacking:void 0!==a.depthPacking&&a.depthPacking,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||i.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.maxBones),e.push(t.morphTargetsCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection)}(n,t),function(e,t){c.disableAll(),t.isWebGL2&&c.enable(0),t.supportsVertexTextures&&c.enable(1),t.instancing&&c.enable(2),t.instancingColor&&c.enable(3),t.map&&c.enable(4),t.matcap&&c.enable(5),t.envMap&&c.enable(6),t.envMapCubeUV&&c.enable(7),t.lightMap&&c.enable(8),t.aoMap&&c.enable(9),t.emissiveMap&&c.enable(10),t.bumpMap&&c.enable(11),t.normalMap&&c.enable(12),t.objectSpaceNormalMap&&c.enable(13),t.tangentSpaceNormalMap&&c.enable(14),t.clearcoat&&c.enable(15),t.clearcoatMap&&c.enable(16),t.clearcoatRoughnessMap&&c.enable(17),t.clearcoatNormalMap&&c.enable(18),t.displacementMap&&c.enable(19),t.specularMap&&c.enable(20),t.roughnessMap&&c.enable(21),t.metalnessMap&&c.enable(22),t.gradientMap&&c.enable(23),t.alphaMap&&c.enable(24),t.alphaTest&&c.enable(25),t.vertexColors&&c.enable(26),t.vertexAlphas&&c.enable(27),t.vertexUvs&&c.enable(28),t.vertexTangents&&c.enable(29),t.uvsVertexOnly&&c.enable(30),t.fog&&c.enable(31),e.push(c.mask),c.disableAll(),t.useFog&&c.enable(0),t.flatShading&&c.enable(1),t.logarithmicDepthBuffer&&c.enable(2),t.skinning&&c.enable(3),t.useVertexTexture&&c.enable(4),t.morphTargets&&c.enable(5),t.morphNormals&&c.enable(6),t.premultipliedAlpha&&c.enable(7),t.shadowMapEnabled&&c.enable(8),t.physicallyCorrectLights&&c.enable(9),t.doubleSided&&c.enable(10),t.flipSided&&c.enable(11),t.depthPacking&&c.enable(12),t.dithering&&c.enable(13),t.specularIntensityMap&&c.enable(14),t.specularColorMap&&c.enable(15),t.transmission&&c.enable(16),t.transmissionMap&&c.enable(17),t.thicknessMap&&c.enable(18),t.sheen&&c.enable(19),t.sheenColorMap&&c.enable(20),t.sheenRoughnessMap&&c.enable(21),t.decodeVideoTexture&&c.enable(22),t.transparent&&c.enable(23),e.push(c.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=C[e.type];let n;if(t){const e=In[t];n=mn.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=u.length;e0?i.push(u):!0===o.transparent?r.push(u):n.push(u)},unshift:function(e,t,o,s,c,l){const u=a(e,t,o,s,c,l);o.transmission>0?i.unshift(u):!0===o.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||qr),i.length>1&&i.sort(t||Xr),r.length>1&&r.sort(t||Xr)}}}function Jr(){let e=new WeakMap;return{get:function(t,n){let i;return!1===e.has(t)?(i=new Yr,e.set(t,[i])):n>=e.get(t).length?(i=new Yr,e.get(t).push(i)):i=e.get(t)[n],i},dispose:function(){e=new WeakMap}}}function $r(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new me,color:new ae};break;case"SpotLight":n={position:new me,direction:new me,color:new ae,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new me,color:new ae,distance:0,decay:0};break;case"HemisphereLight":n={direction:new me,skyColor:new ae,groundColor:new ae};break;case"RectAreaLight":n={color:new ae,position:new me,halfWidth:new me,halfHeight:new me}}return e[t.id]=n,n}}}let Kr=0;function Zr(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Qr(e,t){const n=new $r,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new me);const a=new me,o=new qe,s=new qe;return{setup:function(a,o){let s=0,c=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let u=0,d=0,h=0,f=0,p=0,m=0,g=0,C=0;a.sort(Zr);const v=!0!==o?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Pn.LTC_FLOAT_1,r.rectAreaLTC2=Pn.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Pn.LTC_HALF_1,r.rectAreaLTC2=Pn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=s,r.ambient[1]=c,r.ambient[2]=l;const y=r.hash;y.directionalLength===u&&y.pointLength===d&&y.spotLength===h&&y.rectAreaLength===f&&y.hemiLength===p&&y.numDirectionalShadows===m&&y.numPointShadows===g&&y.numSpotShadows===C||(r.directional.length=u,r.spot.length=h,r.rectArea.length=f,r.point.length=d,r.hemi.length=p,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=C,r.spotShadowMap.length=C,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=C,y.directionalLength=u,y.pointLength=d,y.spotLength=h,y.rectAreaLength=f,y.hemiLength=p,y.numDirectionalShadows=m,y.numPointShadows=g,y.numSpotShadows=C,r.version=Kr++)},setupView:function(e,t){let n=0,i=0,c=0,l=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t=n.get(i).length?(a=new ea(e,t),n.get(i).push(a)):a=n.get(i)[r],a},dispose:function(){n=new WeakMap}}}class na extends At{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}na.prototype.isMeshDepthMaterial=!0;class ia extends At{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new me,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function ra(e,t,n){let i=new zn;const r=new J,a=new J,o=new de,s=new na({depthPacking:3201}),c=new ia,l={},u=n.maxTextureSize,f={0:1,1:0,2:2},p=new gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const g=new jt;g.setAttribute("position",new Pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const C=new un(g,p),v=this;function y(n,i){const r=t.update(C);p.defines.VSM_SAMPLES!==n.blurSamples&&(p.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,p,C,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,m,C,null)}function M(t,n,i,r,a,o,u){let d=null;const h=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(d=void 0!==h?h:!0===r.isPointLight?c:s,e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0){const e=d.uuid,t=i.uuid;let n=l[e];void 0===n&&(n={},l[e]=n);let r=n[t];void 0===r&&(r=d.clone(),n[t]=r),d=r}return d.visible=i.visible,d.wireframe=i.wireframe,d.side=3===u?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:f[i.side],d.alphaMap=i.alphaMap,d.alphaTest=i.alphaTest,d.clipShadows=i.clipShadows,d.clippingPlanes=i.clippingPlanes,d.clipIntersection=i.clipIntersection,d.displacementMap=i.displacementMap,d.displacementScale=i.displacementScale,d.displacementBias=i.displacementBias,d.wireframeLinewidth=i.wireframeLinewidth,d.linewidth=i.linewidth,!0===r.isPointLight&&!0===d.isMeshDistanceMaterial&&(d.referencePosition.setFromMatrixPosition(r.matrixWorld),d.nearDistance=a,d.farDistance=o),d}function x(n,r,a,o,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let c=0,l=t.length;cu||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/m.x),r.x=a.x*m.x,f.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/m.y),r.y=a.y*m.y,f.mapSize.y=a.y)),null===f.map&&!f.isPointLightShadow&&3===this.type){const e={minFilter:h,magFilter:h,format:b};f.map=new he(r.x,r.y,e),f.map.texture.name=l.name+".shadowMap",f.mapPass=new he(r.x,r.y,e),f.camera.updateProjectionMatrix()}if(null===f.map){const e={minFilter:d,magFilter:d,format:b};f.map=new he(r.x,r.y,e),f.map.texture.name=l.name+".shadowMap",f.camera.updateProjectionMatrix()}e.setRenderTarget(f.map),e.clear();const g=f.getViewportCount();for(let e=0;e=1):-1!==A.indexOf("OpenGL ES")&&(z=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),T=z>=2);let V=null,H={};const R=e.getParameter(3088),P=e.getParameter(2978),I=(new de).fromArray(R),k=(new de).fromArray(P);function N(t,n,i){const r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;ti||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?Y:Math.floor,a=i(r*e.width),o=i(r*e.height);void 0===z&&(z=V(a,o));const s=n?V(a,o):z;return s.width=a,s.height=o,s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function I(e){return X(e.width)&&X(e.height)}function k(e,t){return e.generateMipmaps&&t&&e.minFilter!==d&&e.minFilter!==h}function N(t){e.generateMipmap(t)}function D(n,i,r,a,o=!1){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let c=i;return 6403===i&&(5126===r&&(c=33326),5131===r&&(c=33325),5121===r&&(c=33321)),33319===i&&(5126===r&&(c=33328),5131===r&&(c=33327),5121===r&&(c=33323)),6408===i&&(5126===r&&(c=34836),5131===r&&(c=34842),5121===r&&(c=a===P&&!1===o?35907:32856),32819===r&&(c=32854),32820===r&&(c=32855)),33325!==c&&33326!==c&&33327!==c&&33328!==c&&34842!==c&&34836!==c||t.get("EXT_color_buffer_float"),c}function B(e,t,n){return!0===k(e,n)||e.isFramebufferTexture&&e.minFilter!==d&&e.minFilter!==h?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function F(e){return e===d||1004===e||1005===e?9728:9729}function U(t){const n=t.target;n.removeEventListener("dispose",U),function(t){const n=i.get(t);void 0!==n.__webglInit&&(e.deleteTexture(n.__webglTexture),i.remove(t))}(n),n.isVideoTexture&&T.delete(n),o.memory.textures--}function W(t){const n=t.target;n.removeEventListener("dispose",W),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(t){if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=n.length;t0&&r.__version!==e.version){const n=e.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void ee(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}function q(t,r){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,i,r){if(6!==i.image.length)return;Q(t,i),n.activeTexture(33984+r),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const o=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),c=i.image[0]&&i.image[0].isDataTexture,l=[];for(let e=0;e<6;e++)l[e]=o||c?c?i.image[e].image:i.image[e]:H(i.image[e],!1,!0,S),l[e]=ae(i,l[e]);const u=l[0],d=I(u)||s,h=a.convert(i.format,i.encoding),f=a.convert(i.type),p=D(i.internalFormat,h,f,i.encoding),m=s&&!0!==i.isVideoTexture,g=void 0===t.__version;let C,v=B(i,u,d);if(K(34067,i,d),o){m&&g&&n.texStorage2D(34067,v,p,u.width,u.height);for(let e=0;e<6;e++){C=l[e].mipmaps;for(let t=0;t0&&v++,n.texStorage2D(34067,v,p,l[0].width,l[0].height));for(let e=0;e<6;e++)if(c){m?n.texSubImage2D(34069+e,0,0,0,l[e].width,l[e].height,h,f,l[e].data):n.texImage2D(34069+e,0,p,l[e].width,l[e].height,0,h,f,l[e].data);for(let t=0;t1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function Q(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),o.memory.textures++)}function ee(t,i,r){let o=3553;i.isDataTexture2DArray&&(o=35866),i.isDataTexture3D&&(o=32879),Q(t,i),n.activeTexture(33984+r),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const c=function(e){return!s&&(e.wrapS!==l||e.wrapT!==l||e.minFilter!==d&&e.minFilter!==h)}(i)&&!1===I(i.image);let u=H(i.image,c,!1,w);u=ae(i,u);const f=I(u)||s,p=a.convert(i.format,i.encoding);let v,_=a.convert(i.type),S=D(i.internalFormat,p,_,i.encoding,i.isVideoTexture);K(o,i,f);const L=i.mipmaps,E=s&&!0!==i.isVideoTexture,T=void 0===t.__version,z=B(i,u,f);if(i.isDepthTexture)S=6402,s?S=i.type===C?36012:i.type===g?33190:i.type===y?35056:33189:i.type===C&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===M&&6402===S&&i.type!==m&&i.type!==g&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=m,_=a.convert(i.type)),i.format===x&&6402===S&&(S=34041,i.type!==y&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=y,_=a.convert(i.type))),E&&T?n.texStorage2D(3553,1,S,u.width,u.height):n.texImage2D(3553,0,S,u.width,u.height,0,p,_,null);else if(i.isDataTexture)if(L.length>0&&f){E&&T&&n.texStorage2D(3553,z,S,L[0].width,L[0].height);for(let e=0,t=L.length;e0&&f){E&&T&&n.texStorage2D(3553,z,S,L[0].width,L[0].height);for(let e=0,t=L.length;e=_&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+_),G+=1,e},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?ee(r,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?ee(r,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=q,this.rebindTextures=function(e,t,n){const r=i.get(e);void 0!==t&&te(r.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&ie(e)},this.setupRenderTarget=function(t){const c=t.texture,l=i.get(t),u=i.get(c);t.addEventListener("dispose",W),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=c.version,o.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,f=c.isDataTexture3D||c.isDataTexture2DArray,p=I(t)||s;if(d){l.__webglFramebuffer=[];for(let t=0;t<6;t++)l.__webglFramebuffer[t]=e.createFramebuffer()}else if(l.__webglFramebuffer=e.createFramebuffer(),h)if(r.drawBuffers){const n=t.texture;for(let t=0,r=n.length;ts+l?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1));return null!==o&&(o.visible=null!==i),null!==s&&(s.visible=null!==r),null!==c&&(c.visible=null!==a),this}}class ha extends le{constructor(e,t,n,i,r,a,o,s,c,l){if((l=void 0!==l?l:M)!==M&&l!==x)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===M&&(n=m),void 0===n&&l===x&&(n=y),super(null,i,r,a,o,s,l,n,c),this.image={width:e,height:t},this.magFilter=void 0!==o?o:d,this.minFilter=void 0!==s?s:d,this.flipY=!1,this.generateMipmaps=!1}}ha.prototype.isDepthTexture=!0;class fa extends B{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor";const s=e.extensions.has("WEBGL_multisampled_render_to_texture");let c=null,l=null,u=null,d=null,h=!1,f=null;const g=t.getContextAttributes();let C=null,v=null;const _=[],S=new Map,w=new vn;w.layers.enable(1),w.viewport=new de;const L=new vn;L.layers.enable(2),L.viewport=new de;const E=[w,L],T=new ca;T.layers.enable(1),T.layers.enable(2);let z=null,A=null;function V(e){const t=S.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function H(){S.forEach((function(e,t){e.disconnect(t)})),S.clear(),z=null,A=null,e.setRenderTarget(C),d=null,u=null,l=null,i=null,v=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function R(e){const t=i.inputSources;for(let e=0;e<_.length;e++)S.set(t[e],_[e]);for(let t=0;t0&&(t.alphaTest.value=n.alphaTest);const i=e.get(n).envMap;let r,a;i&&(t.envMap.value=i,t.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap?r=n.clearcoatRoughnessMap:n.specularIntensityMap?r=n.specularIntensityMap:n.specularColorMap?r=n.specularColorMap:n.transmissionMap?r=n.transmissionMap:n.thicknessMap?r=n.thicknessMap:n.sheenColorMap?r=n.sheenColorMap:n.sheenRoughnessMap&&(r=n.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),n.aoMap?a=n.aoMap:n.lightMap&&(a=n.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),t.uv2Transform.value.copy(a.matrix))}function n(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,i,r,a,o){i.isMeshBasicMaterial?t(e,i):i.isMeshLambertMaterial?(t(e,i),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,i)):i.isMeshToonMaterial?(t(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshPhongMaterial?(t(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshStandardMaterial?(t(e,i),i.isMeshPhysicalMaterial?function(e,t,i){n(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap)),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate())),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,i,o):n(e,i)):i.isMeshMatcapMaterial?(t(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshDepthMaterial?(t(e,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshDistanceMaterial?(t(e,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,i)):i.isMeshNormalMaterial?(t(e,i),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,n,i){let r;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*i,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?r=t.map:t.alphaMap&&(r=t.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,i,r,a):i.isSpriteMaterial?function(e,t){let n;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?n=t.map:t.alphaMap&&(n=t.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function ma(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=Z("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,a=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,c=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,u=void 0!==e.powerPreference?e.powerPreference:"default",h=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let m=null,g=null;const y=[],M=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=R,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const x=this;let _=!1,S=0,w=0,L=null,E=-1,T=null;const z=new de,A=new de;let V=null,H=t.width,P=t.height,I=1,k=null,N=null;const D=new de(0,0,H,P),O=new de(0,0,H,P);let B=!1;const F=new zn;let U=!1,W=!1,G=null;const j=new qe,q=new me,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===L?I:1}let J,$,K,Q,ee,te,ne,ie,re,ae,oe,se,ce,le,ue,pe,ge,Ce,ve,ye,be,Me,xe,_e=n;function Se(e,n){for(let i=0;i0&&function(e,t,n){if(null===G){const e=!0===o&&!0===$.isWebGL2;G=new(e?fe:he)(1024,1024,{generateMipmaps:!0,type:null!==Me.convert(v)?v:p,minFilter:f,magFilter:d,wrapS:l,wrapT:l,useRenderToTexture:J.has("WEBGL_multisampled_render_to_texture")})}const i=x.getRenderTarget();x.setRenderTarget(G),x.clear();const r=x.toneMapping;x.toneMapping=0,ke(e,t,n),x.toneMapping=r,te.updateMultisampleRenderTarget(G),te.updateRenderTargetMipmap(G),x.setRenderTarget(i)}(r,t,n),i&&K.viewport(z.copy(i)),r.length>0&&ke(r,t,n),a.length>0&&ke(a,t,n),s.length>0&&ke(s,t,n)}function ke(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?M[M.length-1]:null,y.pop(),m=y.length>0?y[y.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return L},this.setRenderTargetTextures=function(e,t,n){ee.get(e.texture).__webglTexture=t,ee.get(e.depthTexture).__webglTexture=n;const i=ee.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||e.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),e.useRenderToTexture=!1,e.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(e,t){const n=ee.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){L=e,S=t,w=n;let i=!0;if(e){const t=ee.get(e);void 0!==t.__useDefaultFramebuffer?(K.bindFramebuffer(36160,null),i=!1):void 0===t.__webglFramebuffer?te.setupRenderTarget(e):t.__hasExternalTextures&&te.rebindTextures(e,ee.get(e.texture).__webglTexture,ee.get(e.depthTexture).__webglTexture)}let r=null,a=!1,o=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const i=ee.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=i[t],a=!0):r=e.useRenderbuffer?ee.get(e).__webglMultisampledFramebuffer:i,z.copy(e.viewport),A.copy(e.scissor),V=e.scissorTest}else z.copy(D).multiplyScalar(I).floor(),A.copy(O).multiplyScalar(I).floor(),V=B;if(K.bindFramebuffer(36160,r)&&$.drawBuffers&&i&&K.drawBuffers(e,r),K.viewport(z),K.scissor(A),K.setScissorTest(V),a){const i=ee.get(e.texture);_e.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(o){const i=ee.get(e.texture),r=t||0;_e.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,r)}E=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=ee.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){K.bindFramebuffer(36160,s);try{const o=e.texture,s=o.format,c=o.type;if(s!==b&&Me.convert(s)!==_e.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=c===v&&(J.has("EXT_color_buffer_half_float")||$.isWebGL2&&J.has("EXT_color_buffer_float"));if(!(c===p||Me.convert(c)===_e.getParameter(35738)||c===C&&($.isWebGL2||J.has("OES_texture_float")||J.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===_e.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&_e.readPixels(t,n,i,r,Me.convert(s),Me.convert(c),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==L?ee.get(L).__webglFramebuffer:null;K.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){if(!0!==t.isFramebufferTexture)return void console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);te.setTexture2D(t,0),_e.copyTexSubImage2D(3553,n,0,0,e.x,e.y,r,a),K.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,o=Me.convert(n.format),s=Me.convert(n.type);te.setTexture2D(n,0),_e.pixelStorei(37440,n.flipY),_e.pixelStorei(37441,n.premultiplyAlpha),_e.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?_e.texSubImage2D(3553,i,e.x,e.y,r,a,o,s,t.image.data):t.isCompressedTexture?_e.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):_e.texSubImage2D(3553,i,e.x,e.y,o,s,t.image),0===i&&n.generateMipmaps&&_e.generateMipmap(3553),K.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(x.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,c=Me.convert(i.format),l=Me.convert(i.type);let u;if(i.isDataTexture3D)te.setTexture3D(i,0),u=32879;else{if(!i.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");te.setTexture2DArray(i,0),u=35866}_e.pixelStorei(37440,i.flipY),_e.pixelStorei(37441,i.premultiplyAlpha),_e.pixelStorei(3317,i.unpackAlignment);const d=_e.getParameter(3314),h=_e.getParameter(32878),f=_e.getParameter(3316),p=_e.getParameter(3315),m=_e.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;_e.pixelStorei(3314,g.width),_e.pixelStorei(32878,g.height),_e.pixelStorei(3316,e.min.x),_e.pixelStorei(3315,e.min.y),_e.pixelStorei(32877,e.min.z),n.isDataTexture||n.isDataTexture3D?_e.texSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,l,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_e.compressedTexSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,g.data)):_e.texSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,l,g),_e.pixelStorei(3314,d),_e.pixelStorei(32878,h),_e.pixelStorei(3316,f),_e.pixelStorei(3315,p),_e.pixelStorei(32877,m),0===r&&i.generateMipmaps&&_e.generateMipmap(u),K.unbindTexture()},this.initTexture=function(e){te.setTexture2D(e,0),K.unbindTexture()},this.resetState=function(){S=0,w=0,L=null,K.reset(),xe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}ma.prototype.isWebGLRenderer=!0,class extends ma{}.prototype.isWebGL1Renderer=!0;class ga{constructor(e,t=25e-5){this.name="",this.color=new ae(e),this.density=t}clone(){return new ga(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}ga.prototype.isFogExp2=!0;class Ca{constructor(e,t=1,n=1e3){this.name="",this.color=new ae(e),this.near=t,this.far=n}clone(){return new Ca(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Ca.prototype.isFog=!0;class va extends Ct{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}va.prototype.isScene=!0;class ya{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=k,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=G()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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 i=0,r=this.stride;ie.far||t.push({distance:s,point:Sa.clone(),uv:Tt.getUV(Sa,Aa,Va,Ha,Ra,Pa,Ia,new J),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}).prototype.isSprite=!0;const Na=new me,Da=new de,Oa=new de,Ba=new me,Fa=new qe;class Ua extends un{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new qe,this.bindMatrixInverse=new qe}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new de,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;ns)continue;d.applyMatrix4(this.matrixWorld);const h=e.ray.origin.distanceTo(d);he.far||t.push({distance:h,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),i=Math.min(r.count,a.start+a.count)-1;ns)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}ao.prototype.isLine=!0;const oo=new me,so=new me;class co extends ao{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;er.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}(class extends Ct{constructor(e=new jt,t=new lo){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),fo.copy(n.boundingSphere),fo.applyMatrix4(i),fo.radius+=r,!1===e.ray.intersectsSphere(fo))return;uo.copy(i).invert(),ho.copy(e.ray).applyMatrix4(uo);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position;if(null!==r)for(let n=Math.max(0,a.start),c=Math.min(r.count,a.start+a.count);n0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}).prototype.isPoints=!0,class extends le{constructor(e,t,n,i,r,a,o,s,c){super(e,t,n,i,r,a,o,s,c),this.minFilter=void 0!==a?a:h,this.magFilter=void 0!==r?r:h,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){l.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}.prototype.isVideoTexture=!0,class extends le{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=d,this.minFilter=d,this.generateMipmaps=!1,this.needsUpdate=!0}}.prototype.isFramebufferTexture=!0,class extends le{constructor(e,t,n,i,r,a,o,s,c,l,u,d){super(null,a,o,s,c,l,i,r,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}.prototype.isCompressedTexture=!0,class extends le{constructor(e,t,n,i,r,a,o,s,c){super(e,t,n,i,r,a,o,s,c),this.needsUpdate=!0}}.prototype.isCanvasTexture=!0;class go extends jt{constructor(e=1,t=1,n=1,i=8,r=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:s};const c=this;i=Math.floor(i),r=Math.floor(r);const l=[],u=[],d=[],h=[];let f=0;const p=[],m=n/2;let g=0;function C(n){const r=f,a=new J,p=new me;let C=0;const v=!0===n?e:t,y=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*y,0),d.push(0,y,0),h.push(.5,.5),f++;const b=f;for(let e=0;e<=i;e++){const t=e/i*s+o,n=Math.cos(t),r=Math.sin(t);p.x=v*r,p.y=m*y,p.z=v*n,u.push(p.x,p.y,p.z),d.push(0,y,0),a.x=.5*n+.5,a.y=.5*r*y+.5,h.push(a.x,a.y),f++}for(let e=0;e0&&C(!0),t>0&&C(!1)),this.setIndex(l),this.setAttribute("position",new Nt(u,3)),this.setAttribute("normal",new Nt(d,3)),this.setAttribute("uv",new Nt(h,2))}static fromJSON(e){return new go(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}new me,new me,new me,new Tt;class Co{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let o,s=0,c=r-1;for(;s<=c;)if(i=Math.floor(s+(c-s)/2),o=n[i]-a,o<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(i=c,n[i]===a)return i/(r-1);const l=n[i];return(i+(a-l)/(n[i+1]-l))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),s=t||(a.isVector2?new J:new me);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new me,i=[],r=[],a=[],o=new me,s=new qe;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new me)}r[0]=new me,a[0]=new me;let c=Number.MAX_VALUE;const l=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(i[t-1],i[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(j(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(j(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class vo extends Co{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new J,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(c)/r)+1)*r:0===l&&c===r-1&&(c=r-2,l=1),this.closed||c>0?o=i[(c-1)%r]:(Mo.subVectors(i[0],i[1]).add(i[0]),o=Mo);const u=i[c%r],d=i[(c+1)%r];if(this.closed||c+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Lo(o,s.x,c.x,l.x,u.x),Lo(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,a=this.curves[r],o=a.getLength(),s=0===o?0:1-e/o;return a.getPointAt(s,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);const l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Do extends No{constructor(e){super(e),this.uuid=G(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n0)for(a=t;a=t;a-=i)o=os(a,e[a],e[a+1],o);return o&&es(o,o.next)&&(ss(o),o=o.next),o}function Bo(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!es(i,i.next)&&0!==Qo(i.prev,i,i.next))i=i.next;else{if(ss(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Fo(e,t,n,i,r,a,o){if(!e)return;!o&&a&&function(e,t,n,i){let r=e;do{null===r.z&&(r.z=Jo(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(o>1)}(r)}(e,i,r,a);let s,c,l=e;for(;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Wo(e,i,r,a):Uo(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),ss(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?Fo(e=Go(Bo(e),t,n),t,n,i,r,a,2):2===o&&jo(e,t,n,i,r,a):Fo(Bo(e),t,n,i,r,a,1);break}}function Uo(e){const t=e.prev,n=e,i=e.next;if(Qo(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Ko(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Qo(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Wo(e,t,n,i){const r=e.prev,a=e,o=e.next;if(Qo(r,a,o)>=0)return!1;const s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,u=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,d=Jo(s,c,t,n,i),h=Jo(l,u,t,n,i);let f=e.prevZ,p=e.nextZ;for(;f&&f.z>=d&&p&&p.z<=h;){if(f!==e.prev&&f!==e.next&&Ko(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qo(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&Ko(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qo(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=d;){if(f!==e.prev&&f!==e.next&&Ko(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qo(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&Ko(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qo(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Go(e,t,n){let i=e;do{const r=i.prev,a=i.next.next;!es(r,a)&&ts(r,i,i.next,a)&&rs(r,a)&&rs(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),ss(i),ss(i.next),i=e=a),i=i.next}while(i!==e);return Bo(i)}function jo(e,t,n,i,r,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Zo(o,e)){let s=as(o,e);return o=Bo(o,o.next),s=Bo(s,s.next),Fo(o,t,n,i,r,a),void Fo(s,t,n,i,r,a)}e=e.next}o=o.next}while(o!==e)}function qo(e,t){return e.x-t.x}function Xo(e,t){if(t=function(e,t){let n=t;const i=e.x,r=e.y;let a,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o){if(o=e,e===i){if(r===n.y)return n;if(r===n.next.y)return n.next}a=n.x=n.x&&n.x>=c&&i!==n.x&&Ko(ra.x||n.x===a.x&&Yo(a,n)))&&(a=n,d=u)),n=n.next}while(n!==s);return a}(e,t),t){const n=as(t,e);Bo(t,t.next),Bo(n,n.next)}}function Yo(e,t){return Qo(e.prev,e,t.prev)<0&&Qo(t.next,e,e.next)<0}function Jo(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $o(e){let t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function Zo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ts(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(rs(e,t)&&rs(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(Qo(e.prev,e,t.prev)||Qo(e,t.prev,t))||es(e,t)&&Qo(e.prev,e,e.next)>0&&Qo(t.prev,t,t.next)>0)}function Qo(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function es(e,t){return e.x===t.x&&e.y===t.y}function ts(e,t,n,i){const r=is(Qo(e,t,n)),a=is(Qo(e,t,i)),o=is(Qo(n,i,e)),s=is(Qo(n,i,t));return r!==a&&o!==s||!(0!==r||!ns(e,n,t))||!(0!==a||!ns(e,i,t))||!(0!==o||!ns(n,e,i))||!(0!==s||!ns(n,t,i))}function ns(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function is(e){return e>0?1:e<0?-1:0}function rs(e,t){return Qo(e.prev,e,e.next)<0?Qo(e,t,e.next)>=0&&Qo(e,e.prev,t)>=0:Qo(e,t,e.prev)<0||Qo(e,e.next,t)<0}function as(e,t){const n=new cs(e.i,e.x,e.y),i=new cs(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function os(e,t,n,i){const r=new cs(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ss(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function cs(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ls{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){s=l=e[0],c=u=e[1];for(let t=n;tl&&(l=d),h>u&&(u=h);f=Math.max(l-s,u-c),f=0!==f?1/f:0}return Fo(a,o,n,s,c,f),o}(n,i);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function ds(e,t){for(let n=0;nNumber.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(c*c+l*l),f=t.x-s/d,p=t.y+o/d,m=((n.x-l/h-f)*l-(n.y+c/h-p)*c)/(o*l-s*c);i=f+o*m-e.x,r=p+s*m-e.y;const g=i*i+r*r;if(g<=2)return new J(i,r);a=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?c>Number.EPSILON&&(e=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(i=-s,r=o,a=Math.sqrt(u)):(i=o,r=s,a=Math.sqrt(u/2))}return new J(i/a,r/a)}const V=[];for(let e=0,t=L.length,n=t-1,i=e+1;e=0;e--){const t=e/f,n=u*Math.cos(t*Math.PI/2),i=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=L.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*f;e0)&&h.push(t,r,c),(e!==n-1||s0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=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.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.ior=e.ior,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}}.prototype.isMeshPhysicalMaterial=!0,class extends At{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new ae(16777215),this.specular=new ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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.flatShading=e.flatShading,this}}.prototype.isMeshPhongMaterial=!0,class extends At{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}.prototype.isMeshToonMaterial=!0,class extends At{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}.prototype.isMeshNormalMaterial=!0,class extends At{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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}}.prototype.isMeshLambertMaterial=!0,class extends At{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}.prototype.isMeshMatcapMaterial=!0,class extends Qa{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}.prototype.isLineDashedMaterial=!0;const Cs={arraySlice:function(e,t,n){return Cs.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,o=0;o!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[o++]=e[i+n]}return r},flattenJSON:function(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let o=a[i];if(void 0!==o)if(Array.isArray(o))do{o=a[i],void 0!==o&&(t.push(a.time),n.push.apply(n,o)),a=e[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[i],void 0!==o&&(t.push(a.time),o.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{o=a[i],void 0!==o&&(t.push(a.time),n.push(o)),a=e[r++]}while(void 0!==a)},subclip:function(e,t,n,i,r=30){const a=e.clone();a.name=t;const o=[];for(let e=0;e=i)){c.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e=i.times[d]){const e=d*c+s,t=e+c-s;h=Cs.arraySlice(i.values,e,t)}else{const e=i.createInterpolant(),t=s,n=c-s;e.evaluate(a),h=Cs.arraySlice(e.resultBuffer,t,n)}"quaternion"===r&&(new pe).fromArray(h).normalize().conjugate().toArray(h);const f=o.times.length;for(let e=0;e=r)break e;{const o=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=Cs.arraySlice(n,r,a),this.values=Cs.arraySlice(this.values,r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&Cs.isTypedArray(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Cs.arraySlice(this.times),t=Cs.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===z,r=e.length-1;let a=1;for(let o=1;o0){e[a]=e[r];for(let e=r*n,i=a*n,o=0;o!==n;++o)t[i+o]=t[e+o];++a}return a!==e.length?(this.times=Cs.arraySlice(e,0,a),this.values=Cs.arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=Cs.arraySlice(this.times,0),t=Cs.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}xs.prototype.TimeBufferType=Float32Array,xs.prototype.ValueBufferType=Float32Array,xs.prototype.DefaultInterpolation=T;class _s extends xs{}_s.prototype.ValueTypeName="bool",_s.prototype.ValueBufferType=Array,_s.prototype.DefaultInterpolation=E,_s.prototype.InterpolantFactoryMethodLinear=void 0,_s.prototype.InterpolantFactoryMethodSmooth=void 0;class Ss extends xs{}Ss.prototype.ValueTypeName="color";class ws extends xs{}ws.prototype.ValueTypeName="number";class Ls extends vs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(i-t);let c=e*o;for(let e=c+o;c!==e;c+=4)pe.slerpFlat(r,0,a,c-o,a,c,s);return r}}class Es extends xs{InterpolantFactoryMethodLinear(e){return new Ls(this.times,this.values,this.getValueSize(),e)}}Es.prototype.ValueTypeName="quaternion",Es.prototype.DefaultInterpolation=T,Es.prototype.InterpolantFactoryMethodSmooth=void 0;class Ts extends xs{}Ts.prototype.ValueTypeName="string",Ts.prototype.ValueBufferType=Array,Ts.prototype.DefaultInterpolation=E,Ts.prototype.InterpolantFactoryMethodLinear=void 0,Ts.prototype.InterpolantFactoryMethodSmooth=void 0;class zs extends xs{}zs.prototype.ValueTypeName="vector";class As{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=G(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(Vs(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(xs.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],o=[];Cs.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;const c=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Is[e])return void Is[e].push({onLoad:t,onProgress:n,onError:i});Is[e]=[],Is[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,s=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const n=Is[e],i=t.body.getReader(),r=t.headers.get("Content-Length"),a=r?parseInt(r):0,o=0!==a;let s=0;const c=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{s+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{Hs.add(e,t);const n=Is[e];delete Is[e];for(let e=0,i=n.length;e{const n=Is[e];if(void 0===n)throw this.manager.itemError(e),t;delete Is[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ns extends Ps{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Hs.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const o=Z("img");function s(){l(),Hs.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(t){l(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",s,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",c,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class Ds extends Ps{constructor(e){super(e)}load(e,t,n,i){const r=new Mn,a=new Ns(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],(function(e){r.images[n]=e,o++,6===o&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(let t=0;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){pe.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const a=this._workIndex*r;pe.multiplyQuaternionsFlat(e,a,e,t,e,n),pe.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]+e[n+a]*i}}}const nc=new RegExp("[\\[\\]\\.:\\/]","g"),ic="[^\\[\\]\\.:\\/]",rc="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",ac=/((?:WC+[\/:])*)/.source.replace("WC",ic),oc=/(WCOD+)?/.source.replace("WCOD",rc),sc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ic),cc=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ic),lc=new RegExp("^"+ac+oc+sc+cc+"$"),uc=["material","materials","bones"];class dc{constructor(e,t,n){this.path=t,this.parsedPath=n||dc.parseTrackName(t),this.node=dc.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new dc.Composite(e,t,n):new dc(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(nc,"")}static parseTrackName(e){const t=lc.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==uc.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i0){const e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const a=2202===n;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=V,i.endingEnd=V):(i.endingStart=e?this.zeroSlopeAtStart?V:A:H,i.endingEnd=t?this.zeroSlopeAtEnd?V:A:H)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}(class extends B{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName;let l=c[s];void 0===l&&(l={},c[s]=l);for(let e=0;e!==r;++e){const r=i[e],c=r.name;let u=l[c];if(void 0!==u)++u.referenceCount,a[e]=u;else{if(u=a[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new tc(dc.create(n,c,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(i,e,r,a);const o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}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}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))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return pc.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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)}}mc.prototype.isBox2=!0;const gc=new me,Cc=new qe,vc=new qe;class yc extends co{constructor(e){const t=bc(e),n=new jt,i=[],r=[],a=new ae(0,0,1),o=new ae(0,1,0);for(let e=0;e.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{_c.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(_c,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}const Ec=new Float32Array(1);function Tc(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))}function zc(e){Object.keys(e).forEach((t=>{const n=e[t];(null==n?void 0:n.isTexture)&&n.dispose()})),e.dispose()}function Ac(e){const t=e.geometry;t&&t.dispose();const n=e.material;n&&(Array.isArray(n)?n.forEach((e=>zc(e))):n&&zc(n))}var Vc,Hc;new Int32Array(Ec.buffer),Co.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Co.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},No.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},class extends co{constructor(e=10,t=10,n=4473924,i=8947848){n=new ae(n),i=new ae(i);const r=t/2,a=e/t,o=e/2,s=[],c=[];for(let e=0,l=0,u=-o;e<=t;e++,u+=a){s.push(-o,0,u,o,0,u),s.push(u,0,-o,u,0,o);const t=e===r?n:i;t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3,t.toArray(c,l),l+=3}const l=new jt;l.setAttribute("position",new Nt(s,3)),l.setAttribute("color",new Nt(c,3)),super(l,new Qa({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},yc.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Ps.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e{t.meshes.forEach((n=>{n.morphTargetInfluences&&(n.morphTargetInfluences[t.morphTargetIndex]+=e*t.weight)}))})),this._materialValues.forEach((t=>{if(void 0!==t.material[t.propertyName]){if(t.type===Vc.NUMBER){const n=t.deltaValue;t.material[t.propertyName]+=n*e}else if(t.type===Vc.VECTOR2){const n=t.deltaValue;t.material[t.propertyName].add(Rc.copy(n).multiplyScalar(e))}else if(t.type===Vc.VECTOR3){const n=t.deltaValue;t.material[t.propertyName].add(Pc.copy(n).multiplyScalar(e))}else if(t.type===Vc.VECTOR4){const n=t.deltaValue;t.material[t.propertyName].add(Ic.copy(n).multiplyScalar(e))}else if(t.type===Vc.COLOR){const n=t.deltaValue;t.material[t.propertyName].add(kc.copy(n).multiplyScalar(e))}"boolean"==typeof t.material.shouldApplyUniforms&&(t.material.shouldApplyUniforms=!0)}}))}clearAppliedWeight(){this._binds.forEach((e=>{e.meshes.forEach((t=>{t.morphTargetInfluences&&(t.morphTargetInfluences[e.morphTargetIndex]=0)}))})),this._materialValues.forEach((e=>{if(void 0!==e.material[e.propertyName]){if(e.type===Vc.NUMBER){const t=e.defaultValue;e.material[e.propertyName]=t}else if(e.type===Vc.VECTOR2){const t=e.defaultValue;e.material[e.propertyName].copy(t)}else if(e.type===Vc.VECTOR3){const t=e.defaultValue;e.material[e.propertyName].copy(t)}else if(e.type===Vc.VECTOR4){const t=e.defaultValue;e.material[e.propertyName].copy(t)}else if(e.type===Vc.COLOR){const t=e.defaultValue;e.material[e.propertyName].copy(t)}"boolean"==typeof e.material.shouldApplyUniforms&&(e.material.shouldApplyUniforms=!0)}}))}}var Dc;function Oc(e,t,n){const i=e.parser.json.nodes[t].mesh;if(null==i)return null;const r=e.parser.json.meshes[i].primitives.length,a=[];return n.traverse((e=>{a.length{const r=Oc(e,i,t);null!=r&&n.set(i,r)})),n}))}function Fc(e){return"_"!==e[0]?(console.warn(`renameMaterialProperty: Given property name "${e}" might be invalid`),e):(e=e.substring(1),/[A-Z]/.test(e[0])?e[0].toLowerCase()+e.substring(1):(console.warn(`renameMaterialProperty: Given property name "${e}" might be invalid`),e))}!function(e){var t,n,i,r,a,o;(t=e.BlendShapePresetName||(e.BlendShapePresetName={})).A="a",t.Angry="angry",t.Blink="blink",t.BlinkL="blink_l",t.BlinkR="blink_r",t.E="e",t.Fun="fun",t.I="i",t.Joy="joy",t.Lookdown="lookdown",t.Lookleft="lookleft",t.Lookright="lookright",t.Lookup="lookup",t.Neutral="neutral",t.O="o",t.Sorrow="sorrow",t.U="u",t.Unknown="unknown",(n=e.FirstPersonLookAtTypeName||(e.FirstPersonLookAtTypeName={})).BlendShape="BlendShape",n.Bone="Bone",(i=e.HumanoidBoneName||(e.HumanoidBoneName={})).Chest="chest",i.Head="head",i.Hips="hips",i.Jaw="jaw",i.LeftEye="leftEye",i.LeftFoot="leftFoot",i.LeftHand="leftHand",i.LeftIndexDistal="leftIndexDistal",i.LeftIndexIntermediate="leftIndexIntermediate",i.LeftIndexProximal="leftIndexProximal",i.LeftLittleDistal="leftLittleDistal",i.LeftLittleIntermediate="leftLittleIntermediate",i.LeftLittleProximal="leftLittleProximal",i.LeftLowerArm="leftLowerArm",i.LeftLowerLeg="leftLowerLeg",i.LeftMiddleDistal="leftMiddleDistal",i.LeftMiddleIntermediate="leftMiddleIntermediate",i.LeftMiddleProximal="leftMiddleProximal",i.LeftRingDistal="leftRingDistal",i.LeftRingIntermediate="leftRingIntermediate",i.LeftRingProximal="leftRingProximal",i.LeftShoulder="leftShoulder",i.LeftThumbDistal="leftThumbDistal",i.LeftThumbIntermediate="leftThumbIntermediate",i.LeftThumbProximal="leftThumbProximal",i.LeftToes="leftToes",i.LeftUpperArm="leftUpperArm",i.LeftUpperLeg="leftUpperLeg",i.Neck="neck",i.RightEye="rightEye",i.RightFoot="rightFoot",i.RightHand="rightHand",i.RightIndexDistal="rightIndexDistal",i.RightIndexIntermediate="rightIndexIntermediate",i.RightIndexProximal="rightIndexProximal",i.RightLittleDistal="rightLittleDistal",i.RightLittleIntermediate="rightLittleIntermediate",i.RightLittleProximal="rightLittleProximal",i.RightLowerArm="rightLowerArm",i.RightLowerLeg="rightLowerLeg",i.RightMiddleDistal="rightMiddleDistal",i.RightMiddleIntermediate="rightMiddleIntermediate",i.RightMiddleProximal="rightMiddleProximal",i.RightRingDistal="rightRingDistal",i.RightRingIntermediate="rightRingIntermediate",i.RightRingProximal="rightRingProximal",i.RightShoulder="rightShoulder",i.RightThumbDistal="rightThumbDistal",i.RightThumbIntermediate="rightThumbIntermediate",i.RightThumbProximal="rightThumbProximal",i.RightToes="rightToes",i.RightUpperArm="rightUpperArm",i.RightUpperLeg="rightUpperLeg",i.Spine="spine",i.UpperChest="upperChest",(r=e.MetaAllowedUserName||(e.MetaAllowedUserName={})).Everyone="Everyone",r.ExplicitlyLicensedPerson="ExplicitlyLicensedPerson",r.OnlyAuthor="OnlyAuthor",(a=e.MetaUssageName||(e.MetaUssageName={})).Allow="Allow",a.Disallow="Disallow",(o=e.MetaLicenseName||(e.MetaLicenseName={})).Cc0="CC0",o.CcBy="CC_BY",o.CcByNc="CC_BY_NC",o.CcByNcNd="CC_BY_NC_ND",o.CcByNcSa="CC_BY_NC_SA",o.CcByNd="CC_BY_ND",o.CcBySa="CC_BY_SA",o.Other="Other",o.RedistributionProhibited="Redistribution_Prohibited"}(Dc||(Dc={}));const Uc=new me,Wc=new me;function Gc(e,t){return e.matrixWorld.decompose(Uc,t,Wc),t}new pe;class jc{constructor(){this._blendShapeGroups={},this._blendShapePresetMap={},this._unknownGroupNames=[]}get expressions(){return Object.keys(this._blendShapeGroups)}get blendShapePresetMap(){return this._blendShapePresetMap}get unknownGroupNames(){return this._unknownGroupNames}getBlendShapeGroup(e){const t=this._blendShapePresetMap[e],n=t?this._blendShapeGroups[t]:this._blendShapeGroups[e];if(n)return n;console.warn(`no blend shape found by ${e}`)}registerBlendShapeGroup(e,t,n){this._blendShapeGroups[e]=n,t?this._blendShapePresetMap[t]=e:this._unknownGroupNames.push(e)}getValue(e){var t;const n=this.getBlendShapeGroup(e);return null!==(t=null==n?void 0:n.weight)&&void 0!==t?t:null}setValue(e,t){const n=this.getBlendShapeGroup(e);var i;n&&(n.weight=(i=t,Math.max(Math.min(i,1),0)))}getBlendShapeTrackName(e){const t=this.getBlendShapeGroup(e);return t?`${t.name}.weight`:null}update(){Object.keys(this._blendShapeGroups).forEach((e=>{this._blendShapeGroups[e].clearAppliedWeight()})),Object.keys(this._blendShapeGroups).forEach((e=>{this._blendShapeGroups[e].applyWeight()}))}}class qc{import(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.blendShapeMaster;if(!i)return null;const r=new jc,a=i.blendShapeGroups;if(!a)return r;const o={};return yield Promise.all(a.map((t=>Tc(this,void 0,void 0,(function*(){const n=t.name;if(void 0===n)return void console.warn("VRMBlendShapeImporter: One of blendShapeGroups has no name");let i;t.presetName&&t.presetName!==Dc.BlendShapePresetName.Unknown&&!o[t.presetName]&&(i=t.presetName,o[t.presetName]=n);const a=new Nc(n);e.scene.add(a),a.isBinary=t.isBinary||!1,t.binds&&t.binds.forEach((n=>Tc(this,void 0,void 0,(function*(){if(void 0===n.mesh||void 0===n.index)return;const i=[];e.parser.json.nodes.forEach(((e,t)=>{e.mesh===n.mesh&&i.push(t)}));const r=n.index;yield Promise.all(i.map((i=>Tc(this,void 0,void 0,(function*(){var o;const s=yield function(e,t){return Tc(this,void 0,void 0,(function*(){const n=yield e.parser.getDependency("node",t);return Oc(e,t,n)}))}(e,i);s.every((e=>Array.isArray(e.morphTargetInfluences)&&r{if(void 0===t.materialName||void 0===t.propertyName||void 0===t.targetValue)return;const n=[];e.scene.traverse((e=>{if(e.material){const i=e.material;Array.isArray(i)?n.push(...i.filter((e=>e.name===t.materialName&&-1===n.indexOf(e)))):i.name===t.materialName&&-1===n.indexOf(i)&&n.push(i)}})),n.forEach((e=>{a.addMaterialValue({material:e,propertyName:Fc(t.propertyName),targetValue:t.targetValue})}))})),r.registerBlendShapeGroup(n,i,a)}))))),r}))}}const Xc=Object.freeze(new me(0,0,-1)),Yc=new pe;var Jc;!function(e){e[e.Auto=0]="Auto",e[e.Both=1]="Both",e[e.ThirdPersonOnly=2]="ThirdPersonOnly",e[e.FirstPersonOnly=3]="FirstPersonOnly"}(Jc||(Jc={}));class $c{constructor(e,t){this.firstPersonFlag=$c._parseFirstPersonFlag(e),this.primitives=t}static _parseFirstPersonFlag(e){switch(e){case"Both":return Jc.Both;case"ThirdPersonOnly":return Jc.ThirdPersonOnly;case"FirstPersonOnly":return Jc.FirstPersonOnly;default:return Jc.Auto}}}class Kc{constructor(e,t,n){this._meshAnnotations=[],this._firstPersonOnlyLayer=Kc._DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=Kc._DEFAULT_THIRDPERSON_ONLY_LAYER,this._initialized=!1,this._firstPersonBone=e,this._firstPersonBoneOffset=t,this._meshAnnotations=n}get firstPersonBone(){return this._firstPersonBone}get meshAnnotations(){return this._meshAnnotations}getFirstPersonWorldDirection(e){return e.copy(Xc).applyQuaternion(Gc(this._firstPersonBone,Yc))}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}getFirstPersonBoneOffset(e){return e.copy(this._firstPersonBoneOffset)}getFirstPersonWorldPosition(e){const t=this._firstPersonBoneOffset,n=new de(t.x,t.y,t.z,1);return n.applyMatrix4(this._firstPersonBone.matrixWorld),e.set(n.x,n.y,n.z)}setup({firstPersonOnlyLayer:e=Kc._DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:t=Kc._DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initialized||(this._initialized=!0,this._firstPersonOnlyLayer=e,this._thirdPersonOnlyLayer=t,this._meshAnnotations.forEach((e=>{e.firstPersonFlag===Jc.FirstPersonOnly?e.primitives.forEach((e=>{e.layers.set(this._firstPersonOnlyLayer)})):e.firstPersonFlag===Jc.ThirdPersonOnly?e.primitives.forEach((e=>{e.layers.set(this._thirdPersonOnlyLayer)})):e.firstPersonFlag===Jc.Auto&&this._createHeadlessModel(e.primitives)})))}_excludeTriangles(e,t,n,i){let r=0;if(null!=t&&t.length>0)for(let a=0;a0&&i.includes(u[0]))continue;if(l[1]>0&&i.includes(u[1]))continue;if(l[2]>0&&i.includes(u[2]))continue;if(l[3]>0&&i.includes(u[3]))continue;const d=t[s],h=n[s];if(d[0]>0&&i.includes(h[0]))continue;if(d[1]>0&&i.includes(h[1]))continue;if(d[2]>0&&i.includes(h[2]))continue;if(d[3]>0&&i.includes(h[3]))continue;const f=t[c],p=n[c];f[0]>0&&i.includes(p[0])||f[1]>0&&i.includes(p[1])||f[2]>0&&i.includes(p[2])||f[3]>0&&i.includes(p[3])||(e[r++]=o,e[r++]=s,e[r++]=c)}return r}_createErasedMesh(e,t){const n=new Ua(e.geometry.clone(),e.material);n.name=`${e.name}(erase)`,n.frustumCulled=e.frustumCulled,n.layers.set(this._firstPersonOnlyLayer);const i=n.geometry,r=i.getAttribute("skinIndex").array,a=[];for(let e=0;e{this._isEraseTarget(e)&&n.push(t)})),!n.length)return t.layers.enable(this._thirdPersonOnlyLayer),void t.layers.enable(this._firstPersonOnlyLayer);t.layers.set(this._thirdPersonOnlyLayer);const i=this._createErasedMesh(t,n);e.add(i)}_createHeadlessModel(e){e.forEach((e=>{if("SkinnedMesh"===e.type){const t=e;this._createHeadlessModelForSkinnedMesh(t.parent,t)}else this._isEraseTarget(e)&&e.layers.set(this._thirdPersonOnlyLayer)}))}_isEraseTarget(e){return e===this._firstPersonBone||!!e.parent&&this._isEraseTarget(e.parent)}}Kc._DEFAULT_FIRSTPERSON_ONLY_LAYER=9,Kc._DEFAULT_THIRDPERSON_ONLY_LAYER=10;class Zc{import(e,t){var n;return Tc(this,void 0,void 0,(function*(){const i=null===(n=e.parser.json.extensions)||void 0===n?void 0:n.VRM;if(!i)return null;const r=i.firstPerson;if(!r)return null;const a=r.firstPersonBone;let o;if(o=void 0===a||-1===a?t.getBoneNode(Dc.HumanoidBoneName.Head):yield e.parser.getDependency("node",a),!o)return console.warn("VRMFirstPersonImporter: Could not find firstPersonBone of the VRM"),null;const s=r.firstPersonBoneOffset?new me(r.firstPersonBoneOffset.x,r.firstPersonBoneOffset.y,-r.firstPersonBoneOffset.z):new me(0,.06,0),c=[],l=yield Bc(e);return Array.from(l.entries()).forEach((([t,n])=>{const i=e.parser.json.nodes[t],a=r.meshAnnotations?r.meshAnnotations.find((e=>e.mesh===i.mesh)):void 0;c.push(new $c(null==a?void 0:a.firstPersonFlag,n))})),new Kc(o,s,c)}))}}class Qc{constructor(e,t){this.node=e,this.humanLimit=t}}function el(e){return e.invert?e.invert():e.inverse(),e}const tl=new me,nl=new pe;class il{constructor(e,t){this.restPose={},this.humanBones=this._createHumanBones(e),this.humanDescription=t,this.restPose=this.getPose()}getPose(){const e={};return Object.keys(this.humanBones).forEach((t=>{const n=this.getBoneNode(t);if(!n)return;if(e[t])return;tl.set(0,0,0),nl.identity();const i=this.restPose[t];(null==i?void 0:i.position)&&tl.fromArray(i.position).negate(),(null==i?void 0:i.rotation)&&el(nl.fromArray(i.rotation)),tl.add(n.position),nl.premultiply(n.quaternion),e[t]={position:tl.toArray(),rotation:nl.toArray()}}),{}),e}setPose(e){Object.keys(e).forEach((t=>{const n=e[t],i=this.getBoneNode(t);if(!i)return;const r=this.restPose[t];r&&(n.position&&(i.position.fromArray(n.position),r.position&&i.position.add(tl.fromArray(r.position))),n.rotation&&(i.quaternion.fromArray(n.rotation),r.rotation&&i.quaternion.multiply(nl.fromArray(r.rotation))))}))}resetPose(){Object.entries(this.restPose).forEach((([e,t])=>{const n=this.getBoneNode(e);n&&((null==t?void 0:t.position)&&n.position.fromArray(t.position),(null==t?void 0:t.rotation)&&n.quaternion.fromArray(t.rotation))}))}getBone(e){var t;return null!==(t=this.humanBones[e][0])&&void 0!==t?t:void 0}getBones(e){var t;return null!==(t=this.humanBones[e])&&void 0!==t?t:[]}getBoneNode(e){var t,n;return null!==(n=null===(t=this.humanBones[e][0])||void 0===t?void 0:t.node)&&void 0!==n?n:null}getBoneNodes(e){var t,n;return null!==(n=null===(t=this.humanBones[e])||void 0===t?void 0:t.map((e=>e.node)))&&void 0!==n?n:[]}_createHumanBones(e){const t=Object.values(Dc.HumanoidBoneName).reduce(((e,t)=>(e[t]=[],e)),{});return e.forEach((e=>{t[e.name].push(e.bone)})),t}}class rl{import(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.humanoid;if(!i)return null;const r=[];i.humanBones&&(yield Promise.all(i.humanBones.map((t=>Tc(this,void 0,void 0,(function*(){if(!t.bone||null==t.node)return;const n=yield e.parser.getDependency("node",t.node);r.push({name:t.bone,bone:new Qc(n,{axisLength:t.axisLength,center:t.center&&new me(t.center.x,t.center.y,t.center.z),max:t.max&&new me(t.max.x,t.max.y,t.max.z),min:t.min&&new me(t.min.x,t.min.y,t.min.z),useDefaultValues:t.useDefaultValues})})}))))));const a={armStretch:i.armStretch,legStretch:i.legStretch,upperArmTwist:i.upperArmTwist,lowerArmTwist:i.lowerArmTwist,upperLegTwist:i.upperLegTwist,lowerLegTwist:i.lowerLegTwist,feetSpacing:i.feetSpacing,hasTranslationDoF:i.hasTranslationDoF};return new il(r,a)}))}}class al{constructor(e,t,n){this.curve=[0,0,0,1,1,1,1,0],this.curveXRangeDegree=90,this.curveYRangeDegree=10,void 0!==e&&(this.curveXRangeDegree=e),void 0!==t&&(this.curveYRangeDegree=t),void 0!==n&&(this.curve=n)}map(e){const t=Math.min(Math.max(e,0),this.curveXRangeDegree)/this.curveXRangeDegree;return this.curveYRangeDegree*((e,t)=>{if(e.length<8)throw new Error("evaluateCurve: Invalid curve detected! (Array length must be 8 at least)");if(e.length%4!=0)throw new Error("evaluateCurve: Invalid curve detected! (Array length must be multiples of 4");let n;for(n=0;;n++){if(e.length<=4*n)return e[4*n-3];if(t<=e[4*n])break}const i=n-1;if(i<0)return e[4*i+5];const r=e[4*i],a=(t-r)/(e[4*n]-r);return((e,t,n,i,r)=>{const a=r*r*r,o=r*r;return e+(t-e)*(-2*a+3*o)+n*(a-2*o+r)+i*(a-o)})(e[4*i+1],e[4*n+1],e[4*i+3],e[4*n+2],a)})(this.curve,t)}}class ol{}class sl extends ol{constructor(e,t,n,i){super(),this.type=Dc.FirstPersonLookAtTypeName.BlendShape,this._curveHorizontal=t,this._curveVerticalDown=n,this._curveVerticalUp=i,this._blendShapeProxy=e}name(){return Dc.FirstPersonLookAtTypeName.BlendShape}lookAt(e){const t=e.x,n=e.y;t<0?(this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookup,0),this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookdown,this._curveVerticalDown.map(-t))):(this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookdown,0),this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookup,this._curveVerticalUp.map(t))),n<0?(this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookleft,0),this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookright,this._curveHorizontal.map(-n))):(this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookright,0),this._blendShapeProxy.setValue(Dc.BlendShapePresetName.Lookleft,this._curveHorizontal.map(n)))}}const cl=Object.freeze(new me(0,0,-1)),ll=new me,ul=new me,dl=new me,hl=new pe;class fl{constructor(e,t){this.autoUpdate=!0,this._euler=new nt(0,0,0,fl.EULER_ORDER),this.firstPerson=e,this.applyer=t}getLookAtWorldDirection(e){const t=Gc(this.firstPerson.firstPersonBone,hl);return e.copy(cl).applyEuler(this._euler).applyQuaternion(t)}lookAt(e){this._calcEuler(this._euler,e),this.applyer&&this.applyer.lookAt(this._euler)}update(e){this.target&&this.autoUpdate&&(this.lookAt(this.target.getWorldPosition(ll)),this.applyer&&this.applyer.lookAt(this._euler))}_calcEuler(e,t){const n=this.firstPerson.getFirstPersonWorldPosition(ul),i=dl.copy(t).sub(n).normalize();return i.applyQuaternion(el(Gc(this.firstPerson.firstPersonBone,hl))),e.x=Math.atan2(i.y,Math.sqrt(i.x*i.x+i.z*i.z)),e.y=Math.atan2(-i.x,-i.z),e}}fl.EULER_ORDER="YXZ";const pl=new nt(0,0,0,fl.EULER_ORDER);class ml extends ol{constructor(e,t,n,i,r){super(),this.type=Dc.FirstPersonLookAtTypeName.Bone,this._curveHorizontalInner=t,this._curveHorizontalOuter=n,this._curveVerticalDown=i,this._curveVerticalUp=r,this._leftEye=e.getBoneNode(Dc.HumanoidBoneName.LeftEye),this._rightEye=e.getBoneNode(Dc.HumanoidBoneName.RightEye)}lookAt(e){const t=e.x,n=e.y;this._leftEye&&(pl.x=t<0?-this._curveVerticalDown.map(-t):this._curveVerticalUp.map(t),pl.y=n<0?-this._curveHorizontalInner.map(-n):this._curveHorizontalOuter.map(n),this._leftEye.quaternion.setFromEuler(pl)),this._rightEye&&(pl.x=t<0?-this._curveVerticalDown.map(-t):this._curveVerticalUp.map(t),pl.y=n<0?-this._curveHorizontalOuter.map(-n):this._curveHorizontalInner.map(n),this._rightEye.quaternion.setFromEuler(pl))}}const gl=Math.PI/180;class Cl{import(e,t,n,i){var r;const a=null===(r=e.parser.json.extensions)||void 0===r?void 0:r.VRM;if(!a)return null;const o=a.firstPerson;if(!o)return null;const s=this._importApplyer(o,n,i);return new fl(t,s||void 0)}_importApplyer(e,t,n){const i=e.lookAtHorizontalInner,r=e.lookAtHorizontalOuter,a=e.lookAtVerticalDown,o=e.lookAtVerticalUp;switch(e.lookAtTypeName){case Dc.FirstPersonLookAtTypeName.Bone:return void 0===i||void 0===r||void 0===a||void 0===o?null:new ml(n,this._importCurveMapperBone(i),this._importCurveMapperBone(r),this._importCurveMapperBone(a),this._importCurveMapperBone(o));case Dc.FirstPersonLookAtTypeName.BlendShape:return void 0===r||void 0===a||void 0===o?null:new sl(t,this._importCurveMapperBlendShape(r),this._importCurveMapperBlendShape(a),this._importCurveMapperBlendShape(o));default:return null}}_importCurveMapperBone(e){return new al("number"==typeof e.xRange?gl*e.xRange:void 0,"number"==typeof e.yRange?gl*e.yRange:void 0,e.curve)}_importCurveMapperBlendShape(e){return new al("number"==typeof e.xRange?gl*e.xRange:void 0,e.yRange,e.curve)}}var vl='// #define PHONG\n\n#ifdef BLENDMODE_CUTOUT\n uniform float cutoff;\n#endif\n\nuniform vec3 color;\nuniform float colorAlpha;\nuniform vec3 shadeColor;\n#ifdef USE_SHADETEXTURE\n uniform sampler2D shadeTexture;\n#endif\n\nuniform float receiveShadowRate;\n#ifdef USE_RECEIVESHADOWTEXTURE\n uniform sampler2D receiveShadowTexture;\n#endif\n\nuniform float shadingGradeRate;\n#ifdef USE_SHADINGGRADETEXTURE\n uniform sampler2D shadingGradeTexture;\n#endif\n\nuniform float shadeShift;\nuniform float shadeToony;\nuniform float lightColorAttenuation;\nuniform float indirectLightIntensity;\n\n#ifdef USE_RIMTEXTURE\n uniform sampler2D rimTexture;\n#endif\nuniform vec3 rimColor;\nuniform float rimLightingMix;\nuniform float rimFresnelPower;\nuniform float rimLift;\n\n#ifdef USE_SPHEREADD\n uniform sampler2D sphereAdd;\n#endif\n\nuniform vec3 emissionColor;\n\nuniform vec3 outlineColor;\nuniform float outlineLightingMix;\n\n#ifdef USE_UVANIMMASKTEXTURE\n uniform sampler2D uvAnimMaskTexture;\n#endif\n\nuniform float uvAnimOffsetX;\nuniform float uvAnimOffsetY;\nuniform float uvAnimTheta;\n\n#include \n#include \n#include \n#include \n\n// #include \n#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif\n\n#include \n#include \n// #include \n#include \n// #include \n#include \n// #include \n// #include \n// #include \n#include \n\n// #include \nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\n\n#include \n\n// #include \nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n\nstruct MToonMaterial {\n vec3 diffuseColor;\n vec3 shadeColor;\n float shadingGrade;\n float receiveShadow;\n};\n\n#define Material_LightProbeLOD( material ) (0)\n\n#include \n// #include \n\n// #include \n#ifdef USE_NORMALMAP\n\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n uniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && defined ( TANGENTSPACE_NORMALMAP )\n\n // Per-Pixel Tangent Space Normal Mapping\n // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n // three-vrm specific change: it requires `uv` as an input in order to support uv scrolls\n\n // Temporary compat against shader change @ Three.js r126\n // See: #21205, #21307, #21299\n #if THREE_VRM_THREE_REVISION >= 126\n\n vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = normalize( surf_norm );\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0\n // TODO: Is this still required? Or shall I make a PR about it?\n if ( length( T ) == 0.0 || length( B ) == 0.0 ) {\n return surf_norm;\n }\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\n return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\n }\n\n #else\n\n vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n vec3 S = ( q0 * st1.t - q1 * st0.t ) * scale;\n vec3 T = ( - q0 * st1.s + q1 * st0.s ) * scale;\n\n // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0\n // TODO: Is this still required? Or shall I make a PR about it?\n\n if ( length( S ) == 0.0 || length( T ) == 0.0 ) {\n return surf_norm;\n }\n\n S = normalize( S );\n T = normalize( T );\n vec3 N = normalize( surf_norm );\n\n #ifdef DOUBLE_SIDED\n\n // Workaround for Adreno GPUs gl_FrontFacing bug. See #15850 and #10331\n\n bool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\n mapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\n #else\n\n mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n #endif\n\n mat3 tsn = mat3( S, T, N );\n return normalize( tsn * mapN );\n\n }\n\n #endif\n\n#endif\n\n// #include \n#include \n#include \n\n// == lighting stuff ===========================================================\nfloat getLightIntensity(\n const in IncidentLight directLight,\n const in GeometricContext geometry,\n const in float shadow,\n const in float shadingGrade\n) {\n float lightIntensity = dot( geometry.normal, directLight.direction );\n lightIntensity = 0.5 + 0.5 * lightIntensity;\n lightIntensity = lightIntensity * shadow;\n lightIntensity = lightIntensity * shadingGrade;\n lightIntensity = lightIntensity * 2.0 - 1.0;\n return shadeToony == 1.0\n ? step( shadeShift, lightIntensity )\n : smoothstep( shadeShift, shadeShift + ( 1.0 - shadeToony ), lightIntensity );\n}\n\nvec3 getLighting( const in vec3 lightColor ) {\n vec3 lighting = lightColor;\n lighting = mix(\n lighting,\n vec3( max( 0.001, max( lighting.x, max( lighting.y, lighting.z ) ) ) ),\n lightColorAttenuation\n );\n\n #if THREE_VRM_THREE_REVISION < 132\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lighting *= PI;\n #endif\n #endif\n\n return lighting;\n}\n\nvec3 getDiffuse(\n const in MToonMaterial material,\n const in float lightIntensity,\n const in vec3 lighting\n) {\n #ifdef DEBUG_LITSHADERATE\n return vec3( BRDF_Lambert( lightIntensity * lighting ) );\n #endif\n\n return lighting * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, lightIntensity ) );\n}\n\n// == post correction ==========================================================\nvoid postCorrection() {\n #include \n #include \n #include \n #include \n #include \n}\n\n// == main procedure ===========================================================\nvoid main() {\n #include \n\n vec2 uv = vec2(0.5, 0.5);\n\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n uv = vUv;\n\n float uvAnimMask = 1.0;\n #ifdef USE_UVANIMMASKTEXTURE\n uvAnimMask = texture2D( uvAnimMaskTexture, uv ).x;\n #endif\n\n uv = uv + vec2( uvAnimOffsetX, uvAnimOffsetY ) * uvAnimMask;\n float uvRotCos = cos( uvAnimTheta * uvAnimMask );\n float uvRotSin = sin( uvAnimTheta * uvAnimMask );\n uv = mat2( uvRotCos, uvRotSin, -uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;\n #endif\n\n #ifdef DEBUG_UV\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n gl_FragColor = vec4( uv, 0.0, 1.0 );\n #endif\n return;\n #endif\n\n vec4 diffuseColor = vec4( color, colorAlpha );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissionColor;\n\n #include \n\n // #include \n #ifdef USE_MAP\n #if THREE_VRM_THREE_REVISION >= 137\n vec4 sampledDiffuseColor = texture2D( map, uv );\n #ifdef DECODE_VIDEO_TEXTURE\n 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 );\n #endif\n diffuseColor *= sampledDiffuseColor;\n #else\n // COMPAT: pre-r137\n diffuseColor *= mapTexelToLinear( texture2D( map, uv ) );\n #endif\n #endif\n\n #include \n // #include \n\n // -- MToon: alpha -----------------------------------------------------------\n // #include \n #ifdef BLENDMODE_CUTOUT\n if ( diffuseColor.a <= cutoff ) { discard; }\n diffuseColor.a = 1.0;\n #endif\n\n #ifdef BLENDMODE_OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n #if defined( OUTLINE ) && defined( OUTLINE_COLOR_FIXED ) // omitting DebugMode\n gl_FragColor = vec4( outlineColor, diffuseColor.a );\n postCorrection();\n return;\n #endif\n\n // #include \n #include \n\n #ifdef OUTLINE\n normal *= -1.0;\n #endif\n\n // #include \n\n #ifdef OBJECTSPACE_NORMALMAP\n\n normal = texture2D( normalMap, uv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n #ifdef FLIP_SIDED\n\n normal = - normal;\n\n #endif\n\n #ifdef DOUBLE_SIDED\n\n // Temporary compat against shader change @ Three.js r126\n // See: #21205, #21307, #21299\n #if THREE_VRM_THREE_REVISION >= 126\n\n normal = normal * faceDirection;\n\n #else\n\n normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n #endif\n\n #endif\n\n normal = normalize( normalMatrix * normal );\n\n #elif defined( TANGENTSPACE_NORMALMAP )\n\n vec3 mapN = texture2D( normalMap, uv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n\n #ifdef USE_TANGENT\n\n normal = normalize( vTBN * mapN );\n\n #else\n\n // Temporary compat against shader change @ Three.js r126\n // See: #21205, #21307, #21299\n #if THREE_VRM_THREE_REVISION >= 126\n\n normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );\n\n #else\n\n normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN );\n\n #endif\n\n #endif\n\n #endif\n\n // #include \n #ifdef USE_EMISSIVEMAP\n #if THREE_VRM_THREE_REVISION >= 137\n totalEmissiveRadiance *= texture2D( emissiveMap, uv ).rgb;\n #else\n // COMPAT: pre-r137\n totalEmissiveRadiance *= emissiveMapTexelToLinear( texture2D( emissiveMap, uv ) ).rgb;\n #endif\n #endif\n\n #ifdef DEBUG_NORMAL\n gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );\n return;\n #endif\n\n // -- MToon: lighting --------------------------------------------------------\n // accumulation\n // #include \n MToonMaterial material;\n\n material.diffuseColor = diffuseColor.rgb;\n\n material.shadeColor = shadeColor;\n #ifdef USE_SHADETEXTURE\n #if THREE_VRM_THREE_REVISION >= 137\n material.shadeColor *= texture2D( shadeTexture, uv ).rgb;\n #else\n // COMPAT: pre-r137\n material.shadeColor *= shadeTextureTexelToLinear( texture2D( shadeTexture, uv ) ).rgb;\n #endif\n #endif\n\n material.shadingGrade = 1.0;\n #ifdef USE_SHADINGGRADETEXTURE\n material.shadingGrade = 1.0 - shadingGradeRate * ( 1.0 - texture2D( shadingGradeTexture, uv ).r );\n #endif\n\n material.receiveShadow = receiveShadowRate;\n #ifdef USE_RECEIVESHADOWTEXTURE\n material.receiveShadow *= texture2D( receiveShadowTexture, uv ).a;\n #endif\n\n // #include \n GeometricContext geometry;\n\n geometry.position = - vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n IncidentLight directLight;\n vec3 lightingSum = vec3( 0.0 );\n\n // since these variables will be used in unrolled loop, we have to define in prior\n float atten, shadow, lightIntensity;\n vec3 lighting;\n\n #if ( NUM_POINT_LIGHTS > 0 )\n PointLight pointLight;\n\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n\n #if THREE_VRM_THREE_REVISION >= 132\n getPointLightInfo( pointLight, geometry, directLight );\n #else\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n #endif\n\n atten = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n atten = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n\n shadow = 1.0 - material.receiveShadow * ( 1.0 - ( 0.5 + 0.5 * atten ) );\n lightIntensity = getLightIntensity( directLight, geometry, shadow, material.shadingGrade );\n lighting = getLighting( directLight.color );\n reflectedLight.directDiffuse += getDiffuse( material, lightIntensity, lighting );\n lightingSum += lighting;\n }\n #pragma unroll_loop_end\n #endif\n\n #if ( NUM_SPOT_LIGHTS > 0 )\n SpotLight spotLight;\n\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n\n #if THREE_VRM_THREE_REVISION >= 132\n getSpotLightInfo( spotLight, geometry, directLight );\n #else\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n #endif\n\n atten = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n atten = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n shadow = 1.0 - material.receiveShadow * ( 1.0 - ( 0.5 + 0.5 * atten ) );\n lightIntensity = getLightIntensity( directLight, geometry, shadow, material.shadingGrade );\n lighting = getLighting( directLight.color );\n reflectedLight.directDiffuse += getDiffuse( material, lightIntensity, lighting );\n lightingSum += lighting;\n }\n #pragma unroll_loop_end\n #endif\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n\n #if THREE_VRM_THREE_REVISION >= 132\n getDirectionalLightInfo( directionalLight, geometry, directLight );\n #else\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n #endif\n\n atten = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n atten = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n shadow = 1.0 - material.receiveShadow * ( 1.0 - ( 0.5 + 0.5 * atten ) );\n lightIntensity = getLightIntensity( directLight, geometry, shadow, material.shadingGrade );\n lighting = getLighting( directLight.color );\n reflectedLight.directDiffuse += getDiffuse( material, lightIntensity, lighting );\n lightingSum += lighting;\n }\n #pragma unroll_loop_end\n #endif\n\n // #if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if THREE_VRM_THREE_REVISION >= 133\n irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n #else\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n #if THREE_VRM_THREE_REVISION >= 133\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n #else\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #endif\n }\n #pragma unroll_loop_end\n #endif\n // #endif\n\n // #include \n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vUv2 );\n #if THREE_VRM_THREE_REVISION >= 137\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n #else\n // COMPAT: pre-r137\n vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n #endif\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n\n // #include \n // RE_IndirectDiffuse here\n reflectedLight.indirectDiffuse += indirectLightIntensity * irradiance * BRDF_Lambert( material.diffuseColor );\n\n // modulation\n #include \n\n vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\n // The "comment out if you want to PBR absolutely" line\n #ifndef DEBUG_LITSHADERATE\n col = min(col, material.diffuseColor);\n #endif\n\n #if defined( OUTLINE ) && defined( OUTLINE_COLOR_MIXED )\n gl_FragColor = vec4(\n outlineColor.rgb * mix( vec3( 1.0 ), col, outlineLightingMix ),\n diffuseColor.a\n );\n postCorrection();\n return;\n #endif\n\n #ifdef DEBUG_LITSHADERATE\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n return;\n #endif\n\n // -- MToon: parametric rim lighting -----------------------------------------\n vec3 viewDir = normalize( vViewPosition );\n vec3 rimMix = mix( vec3( 1.0 ), lightingSum + indirectLightIntensity * irradiance, rimLightingMix );\n vec3 rim = rimColor * pow( saturate( 1.0 - dot( viewDir, normal ) + rimLift ), rimFresnelPower );\n #ifdef USE_RIMTEXTURE\n #if THREE_VRM_THREE_REVISION >= 137\n rim *= texture2D( rimTexture, uv ).rgb;\n #else\n // COMPAT: pre-r137\n rim *= rimTextureTexelToLinear( texture2D( rimTexture, uv ) ).rgb;\n #endif\n #endif\n col += rim;\n\n // -- MToon: additive matcap -------------------------------------------------\n #ifdef USE_SPHEREADD\n {\n vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );\n vec3 y = cross( viewDir, x ); // guaranteed to be normalized\n vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );\n #if THREE_VRM_THREE_REVISION >= 137\n vec3 matcap = texture2D( sphereAdd, sphereUv ).xyz;\n #else\n // COMPAT: pre-r137\n vec3 matcap = sphereAddTexelToLinear( texture2D( sphereAdd, sphereUv ) ).xyz;\n #endif\n col += matcap;\n }\n #endif\n\n // -- MToon: Emission --------------------------------------------------------\n col += totalEmissiveRadiance;\n\n // #include \n\n // -- Almost done! -----------------------------------------------------------\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n}';const yl=(e,t)=>{const n=(e=>{if(parseInt(i,10)>=136)switch(e){case R:return["Linear","( value )"];case P:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}else switch(e){case R:return["Linear","( value )"];case P:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}})(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"},bl=2*Math.PI;var Ml,xl,_l,Sl,wl,Ll;!function(e){e[e.Off=0]="Off",e[e.Front=1]="Front",e[e.Back=2]="Back"}(Ml||(Ml={})),function(e){e[e.None=0]="None",e[e.Normal=1]="Normal",e[e.LitShadeRate=2]="LitShadeRate",e[e.UV=3]="UV"}(xl||(xl={})),function(e){e[e.FixedColor=0]="FixedColor",e[e.MixedLighting=1]="MixedLighting"}(_l||(_l={})),function(e){e[e.None=0]="None",e[e.WorldCoordinates=1]="WorldCoordinates",e[e.ScreenCoordinates=2]="ScreenCoordinates"}(Sl||(Sl={})),function(e){e[e.Opaque=0]="Opaque",e[e.Cutout=1]="Cutout",e[e.Transparent=2]="Transparent",e[e.TransparentWithZWrite=3]="TransparentWithZWrite"}(wl||(wl={}));class El extends gn{constructor(e={}){super(),this.isMToonMaterial=!0,this.cutoff=.5,this.color=new de(1,1,1,1),this.shadeColor=new de(.97,.81,.86,1),this.map=null,this.mainTex_ST=new de(0,0,1,1),this.shadeTexture=null,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.receiveShadowRate=1,this.receiveShadowTexture=null,this.shadingGradeRate=1,this.shadingGradeTexture=null,this.shadeShift=0,this.shadeToony=.9,this.lightColorAttenuation=0,this.indirectLightIntensity=.1,this.rimTexture=null,this.rimColor=new de(0,0,0,1),this.rimLightingMix=0,this.rimFresnelPower=1,this.rimLift=0,this.sphereAdd=null,this.emissionColor=new de(0,0,0,1),this.emissiveMap=null,this.outlineWidthTexture=null,this.outlineWidth=.5,this.outlineScaledMaxDistance=1,this.outlineColor=new de(0,0,0,1),this.outlineLightingMix=1,this.uvAnimMaskTexture=null,this.uvAnimScrollX=0,this.uvAnimScrollY=0,this.uvAnimRotation=0,this.shouldApplyUniforms=!0,this._debugMode=xl.None,this._blendMode=wl.Opaque,this._outlineWidthMode=Sl.None,this._outlineColorMode=_l.FixedColor,this._cullMode=Ml.Back,this._outlineCullMode=Ml.Front,this._isOutline=!1,this._uvAnimOffsetX=0,this._uvAnimOffsetY=0,this._uvAnimPhase=0,this.encoding=e.encoding||R,this.encoding!==R&&this.encoding!==P&&console.warn("The specified color encoding does not work properly with MToonMaterial. You might want to use THREE.sRGBEncoding instead."),["mToonVersion","shadeTexture_ST","bumpMap_ST","receiveShadowTexture_ST","shadingGradeTexture_ST","rimTexture_ST","sphereAdd_ST","emissionMap_ST","outlineWidthTexture_ST","uvAnimMaskTexture_ST","srcBlend","dstBlend"].forEach((t=>{void 0!==e[t]&&delete e[t]})),e.fog=!0,e.lights=!0,e.clipping=!0,parseInt(i,10)<129&&(e.skinning=e.skinning||!1),parseInt(i,10)<131&&(e.morphTargets=e.morphTargets||!1,e.morphNormals=e.morphNormals||!1),e.uniforms=mn.merge([Pn.common,Pn.normalmap,Pn.emissivemap,Pn.fog,Pn.lights,{cutoff:{value:.5},color:{value:new ae(1,1,1)},colorAlpha:{value:1},shadeColor:{value:new ae(.97,.81,.86)},mainTex_ST:{value:new de(0,0,1,1)},shadeTexture:{value:null},receiveShadowRate:{value:1},receiveShadowTexture:{value:null},shadingGradeRate:{value:1},shadingGradeTexture:{value:null},shadeShift:{value:0},shadeToony:{value:.9},lightColorAttenuation:{value:0},indirectLightIntensity:{value:.1},rimTexture:{value:null},rimColor:{value:new ae(0,0,0)},rimLightingMix:{value:0},rimFresnelPower:{value:1},rimLift:{value:0},sphereAdd:{value:null},emissionColor:{value:new ae(0,0,0)},outlineWidthTexture:{value:null},outlineWidth:{value:.5},outlineScaledMaxDistance:{value:1},outlineColor:{value:new ae(0,0,0)},outlineLightingMix:{value:1},uvAnimMaskTexture:{value:null},uvAnimOffsetX:{value:0},uvAnimOffsetY:{value:0},uvAnimTheta:{value:0}}]),this.setValues(e),this._updateShaderCode(),this._applyUniforms()}get mainTex(){return this.map}set mainTex(e){this.map=e}get bumpMap(){return this.normalMap}set bumpMap(e){this.normalMap=e}get bumpScale(){return this.normalScale.x}set bumpScale(e){this.normalScale.set(e,e)}get emissionMap(){return this.emissiveMap}set emissionMap(e){this.emissiveMap=e}get blendMode(){return this._blendMode}set blendMode(e){this._blendMode=e,this.depthWrite=this._blendMode!==wl.Transparent,this.transparent=this._blendMode===wl.Transparent||this._blendMode===wl.TransparentWithZWrite,this._updateShaderCode()}get debugMode(){return this._debugMode}set debugMode(e){this._debugMode=e,this._updateShaderCode()}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(e){this._outlineWidthMode=e,this._updateShaderCode()}get outlineColorMode(){return this._outlineColorMode}set outlineColorMode(e){this._outlineColorMode=e,this._updateShaderCode()}get cullMode(){return this._cullMode}set cullMode(e){this._cullMode=e,this._updateCullFace()}get outlineCullMode(){return this._outlineCullMode}set outlineCullMode(e){this._outlineCullMode=e,this._updateCullFace()}get zWrite(){return this.depthWrite?1:0}set zWrite(e){this.depthWrite=.5<=e}get isOutline(){return this._isOutline}set isOutline(e){this._isOutline=e,this._updateShaderCode(),this._updateCullFace()}updateVRMMaterials(e){this._uvAnimOffsetX=this._uvAnimOffsetX+e*this.uvAnimScrollX,this._uvAnimOffsetY=this._uvAnimOffsetY-e*this.uvAnimScrollY,this._uvAnimPhase=this._uvAnimPhase+e*this.uvAnimRotation,this._applyUniforms()}copy(e){return super.copy(e),this.cutoff=e.cutoff,this.color.copy(e.color),this.shadeColor.copy(e.shadeColor),this.map=e.map,this.mainTex_ST.copy(e.mainTex_ST),this.shadeTexture=e.shadeTexture,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(this.normalScale),this.receiveShadowRate=e.receiveShadowRate,this.receiveShadowTexture=e.receiveShadowTexture,this.shadingGradeRate=e.shadingGradeRate,this.shadingGradeTexture=e.shadingGradeTexture,this.shadeShift=e.shadeShift,this.shadeToony=e.shadeToony,this.lightColorAttenuation=e.lightColorAttenuation,this.indirectLightIntensity=e.indirectLightIntensity,this.rimTexture=e.rimTexture,this.rimColor.copy(e.rimColor),this.rimLightingMix=e.rimLightingMix,this.rimFresnelPower=e.rimFresnelPower,this.rimLift=e.rimLift,this.sphereAdd=e.sphereAdd,this.emissionColor.copy(e.emissionColor),this.emissiveMap=e.emissiveMap,this.outlineWidthTexture=e.outlineWidthTexture,this.outlineWidth=e.outlineWidth,this.outlineScaledMaxDistance=e.outlineScaledMaxDistance,this.outlineColor.copy(e.outlineColor),this.outlineLightingMix=e.outlineLightingMix,this.uvAnimMaskTexture=e.uvAnimMaskTexture,this.uvAnimScrollX=e.uvAnimScrollX,this.uvAnimScrollY=e.uvAnimScrollY,this.uvAnimRotation=e.uvAnimRotation,this.debugMode=e.debugMode,this.blendMode=e.blendMode,this.outlineWidthMode=e.outlineWidthMode,this.outlineColorMode=e.outlineColorMode,this.cullMode=e.cullMode,this.outlineCullMode=e.outlineCullMode,this.isOutline=e.isOutline,this}_applyUniforms(){this.uniforms.uvAnimOffsetX.value=this._uvAnimOffsetX,this.uniforms.uvAnimOffsetY.value=this._uvAnimOffsetY,this.uniforms.uvAnimTheta.value=bl*this._uvAnimPhase,this.shouldApplyUniforms&&(this.shouldApplyUniforms=!1,this.uniforms.cutoff.value=this.cutoff,this.uniforms.color.value.setRGB(this.color.x,this.color.y,this.color.z),this.uniforms.colorAlpha.value=this.color.w,this.uniforms.shadeColor.value.setRGB(this.shadeColor.x,this.shadeColor.y,this.shadeColor.z),this.uniforms.map.value=this.map,this.uniforms.mainTex_ST.value.copy(this.mainTex_ST),this.uniforms.shadeTexture.value=this.shadeTexture,this.uniforms.normalMap.value=this.normalMap,this.uniforms.normalScale.value.copy(this.normalScale),this.uniforms.receiveShadowRate.value=this.receiveShadowRate,this.uniforms.receiveShadowTexture.value=this.receiveShadowTexture,this.uniforms.shadingGradeRate.value=this.shadingGradeRate,this.uniforms.shadingGradeTexture.value=this.shadingGradeTexture,this.uniforms.shadeShift.value=this.shadeShift,this.uniforms.shadeToony.value=this.shadeToony,this.uniforms.lightColorAttenuation.value=this.lightColorAttenuation,this.uniforms.indirectLightIntensity.value=this.indirectLightIntensity,this.uniforms.rimTexture.value=this.rimTexture,this.uniforms.rimColor.value.setRGB(this.rimColor.x,this.rimColor.y,this.rimColor.z),this.uniforms.rimLightingMix.value=this.rimLightingMix,this.uniforms.rimFresnelPower.value=this.rimFresnelPower,this.uniforms.rimLift.value=this.rimLift,this.uniforms.sphereAdd.value=this.sphereAdd,this.uniforms.emissionColor.value.setRGB(this.emissionColor.x,this.emissionColor.y,this.emissionColor.z),this.uniforms.emissiveMap.value=this.emissiveMap,this.uniforms.outlineWidthTexture.value=this.outlineWidthTexture,this.uniforms.outlineWidth.value=this.outlineWidth,this.uniforms.outlineScaledMaxDistance.value=this.outlineScaledMaxDistance,this.uniforms.outlineColor.value.setRGB(this.outlineColor.x,this.outlineColor.y,this.outlineColor.z),this.uniforms.outlineLightingMix.value=this.outlineLightingMix,this.uniforms.uvAnimMaskTexture.value=this.uvAnimMaskTexture,this.encoding===P&&(this.uniforms.color.value.convertSRGBToLinear(),this.uniforms.shadeColor.value.convertSRGBToLinear(),this.uniforms.rimColor.value.convertSRGBToLinear(),this.uniforms.emissionColor.value.convertSRGBToLinear(),this.uniforms.outlineColor.value.convertSRGBToLinear()),this._updateCullFace())}_updateShaderCode(){const e=null!==this.outlineWidthTexture,t=null!==this.map||null!==this.shadeTexture||null!==this.receiveShadowTexture||null!==this.shadingGradeTexture||null!==this.rimTexture||null!==this.uvAnimMaskTexture;if(this.defines={THREE_VRM_THREE_REVISION:parseInt(i,10),OUTLINE:this._isOutline,BLENDMODE_OPAQUE:this._blendMode===wl.Opaque,BLENDMODE_CUTOUT:this._blendMode===wl.Cutout,BLENDMODE_TRANSPARENT:this._blendMode===wl.Transparent||this._blendMode===wl.TransparentWithZWrite,MTOON_USE_UV:e||t,MTOON_UVS_VERTEX_ONLY:e&&!t,USE_SHADETEXTURE:null!==this.shadeTexture,USE_RECEIVESHADOWTEXTURE:null!==this.receiveShadowTexture,USE_SHADINGGRADETEXTURE:null!==this.shadingGradeTexture,USE_RIMTEXTURE:null!==this.rimTexture,USE_SPHEREADD:null!==this.sphereAdd,USE_OUTLINEWIDTHTEXTURE:null!==this.outlineWidthTexture,USE_UVANIMMASKTEXTURE:null!==this.uvAnimMaskTexture,DEBUG_NORMAL:this._debugMode===xl.Normal,DEBUG_LITSHADERATE:this._debugMode===xl.LitShadeRate,DEBUG_UV:this._debugMode===xl.UV,OUTLINE_WIDTH_WORLD:this._outlineWidthMode===Sl.WorldCoordinates,OUTLINE_WIDTH_SCREEN:this._outlineWidthMode===Sl.ScreenCoordinates,OUTLINE_COLOR_FIXED:this._outlineColorMode===_l.FixedColor,OUTLINE_COLOR_MIXED:this._outlineColorMode===_l.MixedLighting},this.vertexShader="// #define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n\n#include \n\n// #include \n#ifdef MTOON_USE_UV\n #ifdef MTOON_UVS_VERTEX_ONLY\n vec2 vUv;\n #else\n varying vec2 vUv;\n #endif\n\n uniform vec4 mainTex_ST;\n#endif\n\n#include \n// #include \n// #include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef USE_OUTLINEWIDTHTEXTURE\n uniform sampler2D outlineWidthTexture;\n#endif\n\nuniform float outlineWidth;\nuniform float outlineScaledMaxDistance;\n\nvoid main() {\n\n // #include \n #ifdef MTOON_USE_UV\n vUv = uv;\n vUv.y = 1.0 - vUv.y; // uv.y is opposite from UniVRM's\n vUv = mainTex_ST.st + mainTex_ST.pq * vUv;\n vUv.y = 1.0 - vUv.y; // reverting the previous flip\n #endif\n\n #include \n #include \n\n #include \n #include \n #include \n #include \n\n // we need this to compute the outline properly\n objectNormal = normalize( objectNormal );\n\n #include \n\n #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n\n #include \n\n #include \n #include \n // #include \n #include \n #include \n #include \n\n vViewPosition = - mvPosition.xyz;\n\n float outlineTex = 1.0;\n\n #ifdef OUTLINE\n #ifdef USE_OUTLINEWIDTHTEXTURE\n outlineTex = texture2D( outlineWidthTexture, vUv ).r;\n #endif\n\n #ifdef OUTLINE_WIDTH_WORLD\n float worldNormalLength = length( transformedNormal );\n vec3 outlineOffset = 0.01 * outlineWidth * outlineTex * worldNormalLength * objectNormal;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );\n #endif\n\n #ifdef OUTLINE_WIDTH_SCREEN\n vec3 clipNormal = ( projectionMatrix * modelViewMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n vec2 projectedNormal = normalize( clipNormal.xy );\n projectedNormal *= min( gl_Position.w, outlineScaledMaxDistance );\n projectedNormal.x *= projectionMatrix[ 0 ].x / projectionMatrix[ 1 ].y;\n gl_Position.xy += 0.01 * outlineWidth * outlineTex * projectedNormal.xy;\n #endif\n\n gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic\n #endif\n\n #include \n // #include \n #include \n #include \n\n}",this.fragmentShader=vl,parseInt(i,10)<137){const e=(null!==this.shadeTexture?yl("shadeTextureTexelToLinear",this.shadeTexture.encoding)+"\n":"")+(null!==this.sphereAdd?yl("sphereAddTexelToLinear",this.sphereAdd.encoding)+"\n":"")+(null!==this.rimTexture?yl("rimTextureTexelToLinear",this.rimTexture.encoding)+"\n":"");this.fragmentShader=e+vl}this.needsUpdate=!0}_updateCullFace(){this.isOutline?this.outlineCullMode===Ml.Off?this.side=2:this.outlineCullMode===Ml.Front?this.side=1:this.outlineCullMode===Ml.Back&&(this.side=0):this.cullMode===Ml.Off?this.side=2:this.cullMode===Ml.Front?this.side=1:this.cullMode===Ml.Back&&(this.side=0)}}!function(e){e[e.Opaque=0]="Opaque",e[e.Cutout=1]="Cutout",e[e.Transparent=2]="Transparent",e[e.TransparentWithZWrite=3]="TransparentWithZWrite"}(Ll||(Ll={}));class Tl extends gn{constructor(e){super(),this.isVRMUnlitMaterial=!0,this.cutoff=.5,this.map=null,this.mainTex_ST=new de(0,0,1,1),this._renderType=Ll.Opaque,this.shouldApplyUniforms=!0,void 0===e&&(e={}),e.fog=!0,e.clipping=!0,parseInt(i,10)<129&&(e.skinning=e.skinning||!1),parseInt(i,10)<131&&(e.morphTargets=e.morphTargets||!1,e.morphNormals=e.morphNormals||!1),e.uniforms=mn.merge([Pn.common,Pn.fog,{cutoff:{value:.5},mainTex_ST:{value:new de(0,0,1,1)}}]),this.setValues(e),this._updateShaderCode(),this._applyUniforms()}get mainTex(){return this.map}set mainTex(e){this.map=e}get renderType(){return this._renderType}set renderType(e){this._renderType=e,this.depthWrite=this._renderType!==Ll.Transparent,this.transparent=this._renderType===Ll.Transparent||this._renderType===Ll.TransparentWithZWrite,this._updateShaderCode()}updateVRMMaterials(e){this._applyUniforms()}copy(e){return super.copy(e),this.cutoff=e.cutoff,this.map=e.map,this.mainTex_ST.copy(e.mainTex_ST),this.renderType=e.renderType,this}_applyUniforms(){this.shouldApplyUniforms&&(this.shouldApplyUniforms=!1,this.uniforms.cutoff.value=this.cutoff,this.uniforms.map.value=this.map,this.uniforms.mainTex_ST.value.copy(this.mainTex_ST))}_updateShaderCode(){this.defines={RENDERTYPE_OPAQUE:this._renderType===Ll.Opaque,RENDERTYPE_CUTOUT:this._renderType===Ll.Cutout,RENDERTYPE_TRANSPARENT:this._renderType===Ll.Transparent||this._renderType===Ll.TransparentWithZWrite},this.vertexShader="#include \n\n// #include \n#ifdef USE_MAP\n varying vec2 vUv;\n uniform vec4 mainTex_ST;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n // #include \n #ifdef USE_MAP\n vUv = vec2( mainTex_ST.p * uv.x + mainTex_ST.s, mainTex_ST.q * uv.y + mainTex_ST.t );\n #endif\n\n #include \n #include \n #include \n\n #ifdef USE_ENVMAP\n\n #include \n #include \n #include \n #include \n\n #endif\n\n #include \n #include \n #include \n #include \n #include \n\n #include \n #include \n #include \n #include \n\n}",this.fragmentShader="#ifdef RENDERTYPE_CUTOUT\n uniform float cutoff;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n// #include \n// #include \n// #include \n// #include \n#include \n// #include \n#include \n#include \n\n// == main procedure ===========================================================\nvoid main() {\n #include \n\n vec4 diffuseColor = vec4( 1.0 );\n\n #include \n\n #include \n #include \n // #include \n\n // MToon: alpha\n // #include \n #ifdef RENDERTYPE_CUTOUT\n if ( diffuseColor.a <= cutoff ) { discard; }\n diffuseColor.a = 1.0;\n #endif\n\n #ifdef RENDERTYPE_OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n // #include \n\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n // accumulation (baked indirect lighting only)\n #ifdef USE_LIGHTMAP\n reflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n\n // modulation\n // #include \n\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n // #include \n\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n #include \n #include \n #include \n #include \n}",this.needsUpdate=!0}}class zl{constructor(e={}){this._encoding=e.encoding||R,this._encoding!==R&&this._encoding!==P&&console.warn("The specified color encoding might not work properly with VRMMaterialImporter. You might want to use THREE.sRGBEncoding instead."),this._requestEnvMap=e.requestEnvMap}convertGLTFMaterials(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.materialProperties;if(!i)return null;const r=yield Bc(e),a={},o=[];return yield Promise.all(Array.from(r.entries()).map((([t,n])=>Tc(this,void 0,void 0,(function*(){const r=e.parser.json.nodes[t],s=e.parser.json.meshes[r.mesh];yield Promise.all(n.map(((t,n)=>Tc(this,void 0,void 0,(function*(){const r=s.primitives[n];if(!r)return;const c=t.geometry,l=c.index?c.index.count:c.attributes.position.count/3;Array.isArray(t.material)||(t.material=[t.material],c.addGroup(0,l,0));const u=r.material;let d,h=i[u];h||(console.warn(`VRMMaterialImporter: There are no material definition for material #${u} on VRM extension.`),h={shader:"VRM_USE_GLTFSHADER"}),a[u]?d=a[u]:(d=yield this.createVRMMaterials(t.material[0],h,e),a[u]=d,o.push(d.surface),d.outline&&o.push(d.outline)),t.material[0]=d.surface,this._requestEnvMap&&d.surface.isMeshStandardMaterial&&this._requestEnvMap().then((e=>{d.surface.envMap=e,d.surface.needsUpdate=!0})),t.renderOrder=h.renderQueue||2e3,d.outline&&(t.material[1]=d.outline,c.addGroup(0,l,1))})))))}))))),o}))}createVRMMaterials(e,t,n){return Tc(this,void 0,void 0,(function*(){let i,r;if("VRM/MToon"===t.shader){const a=yield this._extractMaterialProperties(e,t,n);["srcBlend","dstBlend","isFirstSetup"].forEach((e=>{void 0!==a[e]&&delete a[e]})),["mainTex","shadeTexture","emissionMap","sphereAdd","rimTexture"].forEach((e=>{void 0!==a[e]&&(a[e].encoding=this._encoding)})),a.encoding=this._encoding,i=new El(a),a.outlineWidthMode!==Sl.None&&(a.isOutline=!0,r=new El(a))}else if("VRM/UnlitTexture"===t.shader){const r=yield this._extractMaterialProperties(e,t,n);r.renderType=Ll.Opaque,i=new Tl(r)}else if("VRM/UnlitCutout"===t.shader){const r=yield this._extractMaterialProperties(e,t,n);r.renderType=Ll.Cutout,i=new Tl(r)}else if("VRM/UnlitTransparent"===t.shader){const r=yield this._extractMaterialProperties(e,t,n);r.renderType=Ll.Transparent,i=new Tl(r)}else if("VRM/UnlitTransparentZWrite"===t.shader){const r=yield this._extractMaterialProperties(e,t,n);r.renderType=Ll.TransparentWithZWrite,i=new Tl(r)}else"VRM_USE_GLTFSHADER"!==t.shader&&console.warn(`Unknown shader detected: "${t.shader}"`),i=this._convertGLTFMaterial(e.clone());return i.name=e.name,i.userData=JSON.parse(JSON.stringify(e.userData)),i.userData.vrmMaterialProperties=t,r&&(r.name=e.name+" (Outline)",r.userData=JSON.parse(JSON.stringify(e.userData)),r.userData.vrmMaterialProperties=t),{surface:i,outline:r}}))}_renameMaterialProperty(e){return"_"!==e[0]?(console.warn(`VRMMaterials: Given property name "${e}" might be invalid`),e):(e=e.substring(1),/[A-Z]/.test(e[0])?e[0].toLowerCase()+e.substring(1):(console.warn(`VRMMaterials: Given property name "${e}" might be invalid`),e))}_convertGLTFMaterial(e){if(e.isMeshStandardMaterial){const t=e;t.map&&(t.map.encoding=this._encoding),t.emissiveMap&&(t.emissiveMap.encoding=this._encoding),this._encoding===R&&(t.color.convertLinearToSRGB(),t.emissive.convertLinearToSRGB())}if(e.isMeshBasicMaterial){const t=e;t.map&&(t.map.encoding=this._encoding),this._encoding===R&&t.color.convertLinearToSRGB()}return e}_extractMaterialProperties(e,t,n){const r=[],a={};if(t.textureProperties)for(const e of Object.keys(t.textureProperties)){const i=this._renameMaterialProperty(e),o=t.textureProperties[e];r.push(n.parser.getDependency("texture",o).then((e=>{a[i]=e})))}if(t.floatProperties)for(const e of Object.keys(t.floatProperties)){const n=this._renameMaterialProperty(e);a[n]=t.floatProperties[e]}if(t.vectorProperties)for(const e of Object.keys(t.vectorProperties)){let n=this._renameMaterialProperty(e);["_MainTex","_ShadeTexture","_BumpMap","_ReceiveShadowTexture","_ShadingGradeTexture","_RimTexture","_SphereAdd","_EmissionMap","_OutlineWidthTexture","_UvAnimMaskTexture"].some((t=>e===t))&&(n+="_ST"),a[n]=new de(...t.vectorProperties[e])}return parseInt(i,10)<129&&(a.skinning=e.skinning||!1),parseInt(i,10)<131&&(a.morphTargets=e.morphTargets||!1,a.morphNormals=e.morphNormals||!1),Promise.all(r).then((()=>a))}}class Al{constructor(e){var t;this.ignoreTexture=null!==(t=null==e?void 0:e.ignoreTexture)&&void 0!==t&&t}import(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.meta;if(!i)return null;let r;return this.ignoreTexture||null==i.texture||-1===i.texture||(r=yield e.parser.getDependency("texture",i.texture)),{allowedUserName:i.allowedUserName,author:i.author,commercialUssageName:i.commercialUssageName,contactInformation:i.contactInformation,licenseName:i.licenseName,otherLicenseUrl:i.otherLicenseUrl,otherPermissionUrl:i.otherPermissionUrl,reference:i.reference,sexualUssageName:i.sexualUssageName,texture:null!=r?r:void 0,title:i.title,version:i.version,violentUssageName:i.violentUssageName}}))}}const Vl=new qe;function Hl(e){return e.invert?e.invert():e.getInverse(Vl.copy(e)),e}class Rl{constructor(e){this._inverseCache=new qe,this._shouldUpdateInverse=!0,this.matrix=e;const t={set:(e,t,n)=>(this._shouldUpdateInverse=!0,e[t]=n,!0)};this._originalElements=e.elements,e.elements=new Proxy(e.elements,t)}get inverse(){return this._shouldUpdateInverse&&(Hl(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}}const Pl=Object.freeze(new qe),Il=Object.freeze(new pe),kl=new me,Nl=new me,Dl=new me,Ol=new pe,Bl=new qe,Fl=new qe;class Ul{constructor(e,t={}){var n,i,r,a,o,s;if(this._currentTail=new me,this._prevTail=new me,this._nextTail=new me,this._boneAxis=new me,this._centerSpacePosition=new me,this._center=null,this._parentWorldRotation=new pe,this._initialLocalMatrix=new qe,this._initialLocalRotation=new pe,this._initialLocalChildPosition=new me,this.bone=e,this.bone.matrixAutoUpdate=!1,this.radius=null!==(n=t.radius)&&void 0!==n?n:.02,this.stiffnessForce=null!==(i=t.stiffnessForce)&&void 0!==i?i:1,this.gravityDir=t.gravityDir?(new me).copy(t.gravityDir):(new me).set(0,-1,0),this.gravityPower=null!==(r=t.gravityPower)&&void 0!==r?r:0,this.dragForce=null!==(a=t.dragForce)&&void 0!==a?a:.4,this.colliders=null!==(o=t.colliders)&&void 0!==o?o:[],this._centerSpacePosition.setFromMatrixPosition(this.bone.matrixWorld),this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),0===this.bone.children.length)this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);else{const e=this.bone.children[0];this._initialLocalChildPosition.copy(e.position)}this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)),this._prevTail.copy(this._currentTail),this._nextTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize(),this._centerSpaceBoneLength=kl.copy(this._initialLocalChildPosition).applyMatrix4(this.bone.matrixWorld).sub(this._centerSpacePosition).length(),this.center=null!==(s=t.center)&&void 0!==s?s:null}get center(){return this._center}set center(e){var t;this._getMatrixCenterToWorld(Bl),this._currentTail.applyMatrix4(Bl),this._prevTail.applyMatrix4(Bl),this._nextTail.applyMatrix4(Bl),(null===(t=this._center)||void 0===t?void 0:t.userData.inverseCacheProxy)&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=e,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new Rl(this._center.matrixWorld))),this._getMatrixWorldToCenter(Bl),this._currentTail.applyMatrix4(Bl),this._prevTail.applyMatrix4(Bl),this._nextTail.applyMatrix4(Bl),Bl.multiply(this.bone.matrixWorld),this._centerSpacePosition.setFromMatrixPosition(Bl),this._centerSpaceBoneLength=kl.copy(this._initialLocalChildPosition).applyMatrix4(Bl).sub(this._centerSpacePosition).length()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._getParentMatrixWorld(),this.bone.matrix),this._centerSpacePosition.setFromMatrixPosition(this.bone.matrixWorld),this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)),this._prevTail.copy(this._currentTail),this._nextTail.copy(this._currentTail)}update(e){if(e<=0)return;this.bone.parent?Gc(this.bone.parent,this._parentWorldRotation):this._parentWorldRotation.copy(Il),this._getMatrixWorldToCenter(Bl),Bl.multiply(this.bone.matrixWorld),this._centerSpacePosition.setFromMatrixPosition(Bl),this._getMatrixWorldToCenter(Fl),Fl.multiply(this._getParentMatrixWorld());const t=this.stiffnessForce*e,n=Nl.copy(this.gravityDir).multiplyScalar(this.gravityPower*e);this._nextTail.copy(this._currentTail).add(kl.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.dragForce)).add(kl.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(Fl).sub(this._centerSpacePosition).normalize().multiplyScalar(t)).add(n),this._nextTail.sub(this._centerSpacePosition).normalize().multiplyScalar(this._centerSpaceBoneLength).add(this._centerSpacePosition),this._collision(this._nextTail),this._prevTail.copy(this._currentTail),this._currentTail.copy(this._nextTail);const i=Hl(Bl.copy(Fl.multiply(this._initialLocalMatrix))),r=Ol.setFromUnitVectors(this._boneAxis,kl.copy(this._nextTail).applyMatrix4(i).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(r),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._getParentMatrixWorld(),this.bone.matrix)}_collision(e){this.colliders.forEach((t=>{this._getMatrixWorldToCenter(Bl),Bl.multiply(t.matrixWorld);const n=kl.setFromMatrixPosition(Bl),i=t.geometry.boundingSphere.radius,r=this.radius+i;if(e.distanceToSquared(n)<=r*r){const t=Nl.subVectors(e,n).normalize(),i=Dl.addVectors(n,t.multiplyScalar(r));e.copy(i.sub(this._centerSpacePosition).normalize().multiplyScalar(this._centerSpaceBoneLength).add(this._centerSpacePosition))}}))}_getMatrixCenterToWorld(e){return this._center?e.copy(this._center.matrixWorld):e.identity(),e}_getMatrixWorldToCenter(e){return this._center?e.copy(this._center.userData.inverseCacheProxy.inverse):e.identity(),e}_getParentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Pl}}class Wl{constructor(e,t){this.colliderGroups=[],this.springBoneGroupList=[],this.colliderGroups=e,this.springBoneGroupList=t}setCenter(e){this.springBoneGroupList.forEach((t=>{t.forEach((t=>{t.center=e}))}))}lateUpdate(e){const t=new Set;this.springBoneGroupList.forEach((n=>{n.forEach((n=>{this._updateWorldMatrix(t,n.bone),n.update(e)}))}))}reset(){const e=new Set;this.springBoneGroupList.forEach((t=>{t.forEach((t=>{this._updateWorldMatrix(e,t.bone),t.reset()}))}))}_updateWorldMatrix(e,t){e.has(t)||(t.parent&&this._updateWorldMatrix(e,t.parent),t.updateWorldMatrix(!1,!1),e.add(t))}}const Gl=new me,jl=new Vt({visible:!1});class ql{import(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.secondaryAnimation;if(!i)return null;const r=yield this._importColliderMeshGroups(e,i),a=yield this._importSpringBoneGroupList(e,i,r);return new Wl(r,a)}))}_createSpringBone(e,t={}){return new Ul(e,t)}_importSpringBoneGroupList(e,t,n){return Tc(this,void 0,void 0,(function*(){const i=t.boneGroups||[],r=[];return yield Promise.all(i.map((t=>Tc(this,void 0,void 0,(function*(){if(void 0===t.stiffiness||void 0===t.gravityDir||void 0===t.gravityDir.x||void 0===t.gravityDir.y||void 0===t.gravityDir.z||void 0===t.gravityPower||void 0===t.dragForce||void 0===t.hitRadius||void 0===t.colliderGroups||void 0===t.bones||void 0===t.center)return;const i=t.stiffiness,a=new me(t.gravityDir.x,t.gravityDir.y,-t.gravityDir.z),o=t.gravityPower,s=t.dragForce,c=t.hitRadius,l=[];t.colliderGroups.forEach((e=>{l.push(...n[e].colliders)}));const u=[];yield Promise.all(t.bones.map((n=>Tc(this,void 0,void 0,(function*(){const r=yield e.parser.getDependency("node",n),d=-1!==t.center?yield e.parser.getDependency("node",t.center):null;r&&r.traverse((e=>{const t=this._createSpringBone(e,{radius:c,stiffnessForce:i,gravityDir:a,gravityPower:o,dragForce:s,colliders:l,center:d});u.push(t)}))}))))),r.push(u)}))))),r}))}_importColliderMeshGroups(e,t){return Tc(this,void 0,void 0,(function*(){const n=t.colliderGroups;if(void 0===n)return[];const i=[];return n.forEach((t=>Tc(this,void 0,void 0,(function*(){if(void 0===t.node||void 0===t.colliders)return;const n=yield e.parser.getDependency("node",t.node),r=[];t.colliders.forEach((e=>{if(void 0===e.offset||void 0===e.offset.x||void 0===e.offset.y||void 0===e.offset.z||void 0===e.radius)return;const t=Gl.set(e.offset.x,e.offset.y,-e.offset.z),i=this._createColliderMesh(e.radius,t);n.add(i),r.push(i)}));const a={node:t.node,colliders:r};i.push(a)})))),i}))}_createColliderMesh(e,t){const n=new un(new ms(e,8,4),jl);return n.position.copy(t),n.name="vrmColliderSphere",n.geometry.computeBoundingSphere(),n}}class Xl{constructor(e={}){this._metaImporter=e.metaImporter||new Al,this._blendShapeImporter=e.blendShapeImporter||new qc,this._lookAtImporter=e.lookAtImporter||new Cl,this._humanoidImporter=e.humanoidImporter||new rl,this._firstPersonImporter=e.firstPersonImporter||new Zc,this._materialImporter=e.materialImporter||new zl,this._springBoneImporter=e.springBoneImporter||new ql}import(e){return Tc(this,void 0,void 0,(function*(){if(void 0===e.parser.json.extensions||void 0===e.parser.json.extensions.VRM)throw new Error("Could not find VRM extension on the GLTF");const t=e.scene;t.updateMatrixWorld(!1),t.traverse((e=>{e.isMesh&&(e.frustumCulled=!1)}));const n=(yield this._metaImporter.import(e))||void 0,i=(yield this._materialImporter.convertGLTFMaterials(e))||void 0,r=(yield this._humanoidImporter.import(e))||void 0,a=r&&(yield this._firstPersonImporter.import(e,r))||void 0,o=(yield this._blendShapeImporter.import(e))||void 0,s=a&&o&&r&&(yield this._lookAtImporter.import(e,a,o,r))||void 0,c=(yield this._springBoneImporter.import(e))||void 0;return new Yl({scene:e.scene,meta:n,materials:i,humanoid:r,firstPerson:a,blendShapeProxy:o,lookAt:s,springBoneManager:c})}))}}class Yl{constructor(e){this.scene=e.scene,this.humanoid=e.humanoid,this.blendShapeProxy=e.blendShapeProxy,this.firstPerson=e.firstPerson,this.lookAt=e.lookAt,this.materials=e.materials,this.springBoneManager=e.springBoneManager,this.meta=e.meta}static from(e,t={}){return Tc(this,void 0,void 0,(function*(){const n=new Xl(t);return yield n.import(e)}))}update(e){this.lookAt&&this.lookAt.update(e),this.blendShapeProxy&&this.blendShapeProxy.update(),this.springBoneManager&&this.springBoneManager.lateUpdate(e),this.materials&&this.materials.forEach((t=>{t.updateVRMMaterials&&t.updateVRMMaterials(e)}))}dispose(){var e,t;const n=this.scene;n&&n.traverse(Ac),null===(t=null===(e=this.meta)||void 0===e?void 0:e.texture)||void 0===t||t.dispose()}}const Jl=new J,$l=new Un(-1,1,-1,1,-1,1),Kl=new Vt({color:16777215,side:2}),Zl=new un(new Hn(2,2),Kl),Ql=new va;Ql.add(Zl);class eu{constructor(){}}eu.extractThumbnailBlob=function(e,t,n=512){var i;const r=null===(i=t.meta)||void 0===i?void 0:i.texture;if(!r)throw new Error("extractThumbnailBlob: This VRM does not have a thumbnail");const a=e.getContext().canvas;e.getSize(Jl);const o=Jl.x,s=Jl.y;return e.setSize(n,n,!1),Kl.map=r,e.render(Ql,$l),Kl.map=null,a instanceof OffscreenCanvas?a.convertToBlob().finally((()=>{e.setSize(o,s,!1)})):new Promise(((t,n)=>{a.toBlob((i=>{e.setSize(o,s,!1),null==i?n("extractThumbnailBlob: Failed to create a blob"):t(i)}))}))},eu.removeUnnecessaryJoints=function(e){const t=new Map;e.traverse((e=>{if("SkinnedMesh"!==e.type)return;const n=e,i=n.geometry.getAttribute("skinIndex");let r=t.get(i);if(!r){const e=[],a=[],o={},s=i.array;for(let t=0;t{var n,i,r,a;if(!e.isMesh)return;const o=e,s=o.geometry,c=s.index;if(null==c)return;const l=t.get(s);if(null!=l)return void(o.geometry=l);const u=new jt;u.name=s.name,u.morphTargetsRelative=s.morphTargetsRelative,s.groups.forEach((e=>{u.addGroup(e.start,e.count,e.materialIndex)})),u.boundingBox=null!==(i=null===(n=s.boundingBox)||void 0===n?void 0:n.clone())&&void 0!==i?i:null,u.boundingSphere=null!==(a=null===(r=s.boundingSphere)||void 0===r?void 0:r.clone())&&void 0!==a?a:null,u.setDrawRange(s.drawRange.start,s.drawRange.count),u.userData=s.userData,t.set(s,u);const d=[],h=[];{const e=c.array,t=new e.constructor(e.length);let n=0;for(let i=0;i{const t=s.attributes[e];if(t.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const n=t.array,{itemSize:i,normalized:r}=t,a=new n.constructor(h.length*i);h.forEach(((e,t)=>{for(let r=0;r{u.morphAttributes[e]=[];const t=s.morphAttributes[e];for(let n=0;n{for(let n=0;n0===e)),u.morphAttributes[e][n]=new Pt(s,a,o)}})),f&&(u.morphAttributes={}),o.geometry=u})),Array.from(t.keys()).forEach((e=>{e.dispose()}))};const tu=new me;class nu extends fl{setupHelper(e,t){t.disableFaceDirectionHelper||(this._faceDirectionHelper=new Lc(new me(0,0,-1),new me(0,0,0),.5,16711935),e.add(this._faceDirectionHelper))}update(e){super.update(e),this._faceDirectionHelper&&(this.firstPerson.getFirstPersonWorldPosition(this._faceDirectionHelper.position),this._faceDirectionHelper.setDirection(this.getLookAtWorldDirection(tu)))}}class iu extends Cl{import(e,t,n,i){var r;const a=null===(r=e.parser.json.extensions)||void 0===r?void 0:r.VRM;if(!a)return null;const o=a.firstPerson;if(!o)return null;const s=this._importApplyer(o,n,i);return new nu(t,s||void 0)}}const ru=new Vt({color:16711935,wireframe:!0,transparent:!0,depthTest:!1});class au extends Wl{setupHelper(e,t){t.disableSpringBoneHelper||(this.springBoneGroupList.forEach((t=>{t.forEach((t=>{if(t.getGizmo){const n=t.getGizmo();e.add(n)}}))})),this.colliderGroups.forEach((e=>{e.colliders.forEach((e=>{e.material=ru,e.renderOrder=uu}))})))}}const ou=new me;class su extends Ul{constructor(e,t){super(e,t)}getGizmo(){if(this._gizmo)return this._gizmo;const e=ou.copy(this._nextTail).sub(this._centerSpacePosition),t=e.length();return this._gizmo=new Lc(e.normalize(),this._centerSpacePosition,t,16776960,this.radius,this.radius),this._gizmo.line.renderOrder=uu,this._gizmo.cone.renderOrder=uu,this._gizmo.line.material.depthTest=!1,this._gizmo.line.material.transparent=!0,this._gizmo.cone.material.depthTest=!1,this._gizmo.cone.material.transparent=!0,this._gizmo}update(e){super.update(e),this._updateGizmo()}_updateGizmo(){if(!this._gizmo)return;const e=ou.copy(this._currentTail).sub(this._centerSpacePosition),t=e.length();this._gizmo.setDirection(e.normalize()),this._gizmo.setLength(t,this.radius,this.radius),this._gizmo.position.copy(this._centerSpacePosition)}}class cu extends ql{import(e){var t;return Tc(this,void 0,void 0,(function*(){const n=null===(t=e.parser.json.extensions)||void 0===t?void 0:t.VRM;if(!n)return null;const i=n.secondaryAnimation;if(!i)return null;const r=yield this._importColliderMeshGroups(e,i),a=yield this._importSpringBoneGroupList(e,i,r);return new au(r,a)}))}_createSpringBone(e,t){return new su(e,t)}}class lu extends Xl{constructor(e={}){e.lookAtImporter=e.lookAtImporter||new iu,e.springBoneImporter=e.springBoneImporter||new cu,super(e)}import(e,t={}){return Tc(this,void 0,void 0,(function*(){if(void 0===e.parser.json.extensions||void 0===e.parser.json.extensions.VRM)throw new Error("Could not find VRM extension on the GLTF");const n=e.scene;n.updateMatrixWorld(!1),n.traverse((e=>{e.isMesh&&(e.frustumCulled=!1)}));const i=(yield this._metaImporter.import(e))||void 0,r=(yield this._materialImporter.convertGLTFMaterials(e))||void 0,a=(yield this._humanoidImporter.import(e))||void 0,o=a&&(yield this._firstPersonImporter.import(e,a))||void 0,s=(yield this._blendShapeImporter.import(e))||void 0,c=o&&s&&a&&(yield this._lookAtImporter.import(e,o,s,a))||void 0;c.setupHelper&&c.setupHelper(n,t);const l=(yield this._springBoneImporter.import(e))||void 0;return l.setupHelper&&l.setupHelper(n,t),new du({scene:e.scene,meta:i,materials:r,humanoid:a,firstPerson:o,blendShapeProxy:s,lookAt:c,springBoneManager:l},t)}))}}const uu=1e4;class du extends Yl{static from(e,t={},n={}){return Tc(this,void 0,void 0,(function*(){const i=new lu(t);return yield i.import(e,n)}))}constructor(e,t={}){super(e),t.disableBoxHelper||this.scene.add(new xc(this.scene)),t.disableSkeletonHelper||this.scene.add(new yc(this.scene))}update(e){super.update(e)}}},696:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.MediapipeAvator=void 0;var o=n(698),s=n(314),c=a(n(232)),l=function(){function e(e,t,n){void 0===n&&(n={x:0,y:0,z:0});var i=this;this.enableFace=!0,this.enableUpperBody=!0,this.enableLegs=!0,this.enableHands=!0,this.oldLookTarget=new c.Euler,this.LEFT_LOWER_ARM_TARGET_COLOR="rgba(255, 0, 0, 0.5)",this.LEFT_UPPER_ARM_TARGET_COLOR="rgba(0, 255, 0, 0.5)",this.RIGHT_LOWER_ARM_TARGET_COLOR="rgba(255, 0, 255, 0.5)",this.RIGHT_UPPER_ARM_TARGET_COLOR="rgba(0, 255, 255, 0.5)",this.INVISIBLE="rgba(0, 0, 0, 0)",this.leftLowerArmTarget=new c.Mesh(new c.SphereGeometry(.05),new c.MeshBasicMaterial({color:this.LEFT_LOWER_ARM_TARGET_COLOR})),this.leftUpperArmTarget=new c.Mesh(new c.SphereGeometry(.05),new c.MeshBasicMaterial({color:this.LEFT_UPPER_ARM_TARGET_COLOR})),this.rightLowerArmTarget=new c.Mesh(new c.SphereGeometry(.05),new c.MeshBasicMaterial({color:this.RIGHT_LOWER_ARM_TARGET_COLOR})),this.rightUpperArmTarget=new c.Mesh(new c.SphereGeometry(.05),new c.MeshBasicMaterial({color:this.RIGHT_UPPER_ARM_TARGET_COLOR})),this.initialize=function(e,t,n){void 0===n&&(n={x:0,y:0,z:0}),i.avatar=e,i.scene=t,i.offset=n,t.add(i.leftLowerArmTarget),t.add(i.leftUpperArmTarget),t.add(i.rightLowerArmTarget),t.add(i.rightUpperArmTarget)},this._isTargetVisible=!0,this.useSlerp=!1,this.rigRotation=function(e,t,n,r){void 0===t&&(t={x:0,y:0,z:0}),void 0===n&&(n=1),void 0===r&&(r=.3);var a=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName[e]);if(a){var s=new c.Euler(t.x*n,t.y*n,t.z*n),l=(new c.Quaternion).setFromEuler(s);a.quaternion.slerp(l,r)}},this.rigPosition=function(e,t,n,r){void 0===t&&(t={x:0,y:0,z:0}),void 0===n&&(n=1),void 0===r&&(r=.3);var a=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName[e]);if(a){var s=new c.Vector3(t.x*n,t.y*n,t.z*n);a.position.lerp(s,r)}},this.rigFace=function(e){var t=JSON.parse(JSON.stringify(e));i.rigRotation("Neck",t.head,.7);var n=i.avatar.blendShapeProxy,r=o.VRMSchema.BlendShapePresetName;t.eye.l=s.Vector.lerp(s.Utils.clamp(1-t.eye.l,0,1),n.getValue(r.Blink),.5),t.eye.r=s.Vector.lerp(s.Utils.clamp(1-t.eye.r,0,1),n.getValue(r.Blink),.5),t.eye=s.Face.stabilizeBlink(t.eye,t.head.y),n.setValue(r.Blink,t.eye.l),n.setValue(r.I,s.Vector.lerp(t.mouth.shape.I,n.getValue(r.I),.5)),n.setValue(r.A,s.Vector.lerp(t.mouth.shape.A,n.getValue(r.A),.5)),n.setValue(r.E,s.Vector.lerp(t.mouth.shape.E,n.getValue(r.E),.5)),n.setValue(r.O,s.Vector.lerp(t.mouth.shape.O,n.getValue(r.O),.5)),n.setValue(r.U,s.Vector.lerp(t.mouth.shape.U,n.getValue(r.U),.5));var a=new c.Euler(s.Vector.lerp(i.oldLookTarget.x,t.pupil.y,.4),s.Vector.lerp(i.oldLookTarget.y,t.pupil.x,.4),0,"XYZ");i.oldLookTarget.copy(a),i.avatar.lookAt.applyer.lookAt(a),i.avatar.blendShapeProxy.update()},this.rigUpperBody=function(e){i.rigRotation("Hips",e.Hips.rotation,.7),i.rigPosition("Hips",{x:e.Hips.position.x,y:e.Hips.position.y+1,z:-e.Hips.position.z},1,.07),i.rigRotation("Chest",e.Spine,.25,.3),i.rigRotation("Spine",e.Spine,.45,.3),i.rigRotation("RightUpperArm",e.RightUpperArm,1,.3),i.rigRotation("RightLowerArm",e.RightLowerArm,1,.3),i.rigRotation("LeftUpperArm",e.LeftUpperArm,1,.3),i.rigRotation("LeftLowerArm",e.LeftLowerArm,1,.3)},this.rigLegs=function(e){i.rigRotation("LeftUpperLeg",e.LeftUpperLeg,1,.3),i.rigRotation("LeftLowerLeg",e.LeftLowerLeg,1,.3),i.rigRotation("RightUpperLeg",e.RightUpperLeg,1,.3),i.rigRotation("RightLowerLeg",e.RightLowerLeg,1,.3)},this.rigLeftHand=function(e,t){i.rigRotation("LeftHand",{z:t.LeftHand.z,y:e.LeftWrist.y,x:e.LeftWrist.x}),i.rigRotation("LeftRingProximal",e.LeftRingProximal),i.rigRotation("LeftRingIntermediate",e.LeftRingIntermediate),i.rigRotation("LeftRingDistal",e.LeftRingDistal),i.rigRotation("LeftIndexProximal",e.LeftIndexProximal),i.rigRotation("LeftIndexIntermediate",e.LeftIndexIntermediate),i.rigRotation("LeftIndexDistal",e.LeftIndexDistal),i.rigRotation("LeftMiddleProximal",e.LeftMiddleProximal),i.rigRotation("LeftMiddleIntermediate",e.LeftMiddleIntermediate),i.rigRotation("LeftMiddleDistal",e.LeftMiddleDistal),i.rigRotation("LeftThumbProximal",e.LeftThumbProximal),i.rigRotation("LeftThumbIntermediate",e.LeftThumbIntermediate),i.rigRotation("LeftThumbDistal",e.LeftThumbDistal),i.rigRotation("LeftLittleProximal",e.LeftLittleProximal),i.rigRotation("LeftLittleIntermediate",e.LeftLittleIntermediate),i.rigRotation("LeftLittleDistal",e.LeftLittleDistal)},this.rigRightHand=function(e,t){i.rigRotation("RightHand",{z:t.RightHand.z,y:e.RightWrist.y,x:e.RightWrist.x}),i.rigRotation("RightRingProximal",e.RightRingProximal),i.rigRotation("RightRingIntermediate",e.RightRingIntermediate),i.rigRotation("RightRingDistal",e.RightRingDistal),i.rigRotation("RightIndexProximal",e.RightIndexProximal),i.rigRotation("RightIndexIntermediate",e.RightIndexIntermediate),i.rigRotation("RightIndexDistal",e.RightIndexDistal),i.rigRotation("RightMiddleProximal",e.RightMiddleProximal),i.rigRotation("RightMiddleIntermediate",e.RightMiddleIntermediate),i.rigRotation("RightMiddleDistal",e.RightMiddleDistal),i.rigRotation("RightThumbProximal",e.RightThumbProximal),i.rigRotation("RightThumbIntermediate",e.RightThumbIntermediate),i.rigRotation("RightThumbDistal",e.RightThumbDistal),i.rigRotation("RightLittleProximal",e.RightLittleProximal),i.rigRotation("RightLittleIntermediate",e.RightLittleIntermediate),i.rigRotation("RightLittleDistal",e.RightLittleDistal)},this.updatePose=function(e,t,n,r){i.enableFace&&e&&i.rigFace(e),i.enableUpperBody&&t&&i.rigUpperBody(t),i.enableLegs&&t&&i.rigLegs(t),i.enableHands&&t&&(n&&i.rigLeftHand(n,t),r&&i.rigRightHand(r,t))},this.rigUpperShaft=function(e){i.rigRotation("Hips",e.Hips.rotation,.7),i.rigPosition("Hips",{x:e.Hips.position.x,y:e.Hips.position.y+1,z:-e.Hips.position.z},1,.07),i.rigRotation("Chest",e.Spine,.25,.3),i.rigRotation("Spine",e.Spine,.45,.3)},this.getArmPointTFList=function(e,t,n,i){var r=e.singlePersonKeypoints3DMovingAverage;return[t,n,i].map((function(e){return new c.Vector4(r[e].x,r[e].y,r[e].z,r[e].score)}))},this.getTargetVectorFromShoulderTF=function(e,t){var n=t.clone().sub(e);return new c.Vector3(n.x,-1*n.y,1*n.z)},this.getTargetPosition=function(e,t,n){var i;if(!(i="Left"==t?e.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.LeftShoulder):e.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.RightShoulder)))return null;var r=new c.Vector3;i.getWorldPosition(r);var a=i.worldToLocal(r.clone()).clone().add(n);return i.localToWorld(a.clone())},this.getTargetPosition2=function(e,t,n){var i=e.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.LeftShoulder),r=e.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.RightShoulder);if(!i||!r)return null;var a=new c.Vector3;i.getWorldPosition(a);var s=new c.Vector3;r.getWorldPosition(s);var l=a.add(s).divideScalar(2),u=i.worldToLocal(l.clone()).clone().add(n);return i.localToWorld(u.clone())},this.moveArm=function(e,t,n,i){var r=new c.Vector3(n.x,n.y,n.z),a=new c.Vector3,o=new c.Quaternion,s=new c.Vector3;e.matrixWorld.decompose(a,o,s),o.invert();var l=new c.Vector3,u=new c.Vector3;t.getWorldPosition(l),u.subVectors(l,a),u.applyQuaternion(o),u.normalize();var d=new c.Vector3;d.subVectors(r,a),d.applyQuaternion(o),d.normalize();var h=d.dot(u);if(h>1?h=1:h<-1&&(h=-1),!((h=Math.acos(h))<1e-5)){var f=new c.Vector3;f.crossVectors(u,d),f.normalize();var p=new c.Quaternion;p.setFromAxisAngle(f,h);var m=e.clone();return m.quaternion.multiply(p),i?e.quaternion.slerp(p,.3):e.quaternion.multiply(p),m}},this.updatePoseWithRawInternal2=function(e){var t=i.getArmPointTFList(e,12,14,16),n=i.getArmPointTFList(e,11,13,15),r=t[0].add(n[0]).divideScalar(2),a=i.getTargetVectorFromShoulderTF(r,t[1]),s=i.getTargetVectorFromShoulderTF(r,t[2]),c=i.getTargetVectorFromShoulderTF(r,n[1]),l=i.getTargetVectorFromShoulderTF(r,n[2]),u=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.LeftUpperArm),d=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.LeftLowerArm),h=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.LeftHand),f=i.getTargetPosition2(i.avatar,"Left",a);f&&(i.moveArm(u,d,f,i.useSlerp),i.leftUpperArmTarget.position.set(f.x,f.y,f.z));var p=i.getTargetPosition2(i.avatar,"Left",s);p&&(i.moveArm(d,h,p,i.useSlerp),i.leftLowerArmTarget.position.set(p.x,p.y,p.z));var m=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.RightUpperArm),g=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.RightLowerArm),C=i.avatar.humanoid.getBoneNode(o.VRMSchema.HumanoidBoneName.RightHand);(f=i.getTargetPosition(i.avatar,"Right",c))&&(i.moveArm(m,g,f,i.useSlerp),i.rightUpperArmTarget.position.set(f.x,f.y,f.z)),(p=i.getTargetPosition(i.avatar,"Right",l))&&(i.moveArm(g,C,p,i.useSlerp),i.rightLowerArmTarget.position.set(p.x,p.y,p.z))},this.updatePoseWithRaw=function(e,t,n,r,a){i.enableFace&&e&&i.rigFace(e),i.enableUpperBody&&t&&i.rigUpperShaft(t),a&&a.singlePersonKeypoints3DMovingAverage&&i.updatePoseWithRawInternal2(a),i.enableHands&&t&&(n&&i.rigLeftHand(n,t),r&&i.rigRightHand(r,t))},e&&(this.avatar=e),t&&(this.scene=t,t.add(this.leftLowerArmTarget),t.add(this.leftUpperArmTarget),t.add(this.rightLowerArmTarget),t.add(this.rightUpperArmTarget)),this.offset=n}return e.prototype.setOffset=function(e){this.offset=e},Object.defineProperty(e.prototype,"isTargetVisible",{get:function(){return this._isTargetVisible},set:function(e){e?(this.scene.add(this.leftUpperArmTarget),this.scene.add(this.leftLowerArmTarget),this.scene.add(this.rightUpperArmTarget),this.scene.add(this.rightLowerArmTarget)):(this.scene.remove(this.leftUpperArmTarget),this.scene.remove(this.leftLowerArmTarget),this.scene.remove(this.rightUpperArmTarget),this.scene.remove(this.rightLowerArmTarget)),this._isTargetVisible=e},enumerable:!1,configurable:!0}),e}();t.MediapipeAvator=l},375:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},o=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,i,r,a,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0?[4,Promise.race(e)]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return n=i.sent(),console.log("catch error:::",n),[3,5];case 5:return[2,{hands:this.latestHands,faces:this.latestFaces,poses:this.latestPoses,leftHandRig:this.latestLeftHandRig,rightHandRig:this.latestRightHandRig,faceRig:this.latestFaceRig,poseRig:this.latestPoseRig}]}}))}))},this.count=0,this.predictFaces=function(t){return o(e,void 0,void 0,(function(){var e,n,i;return s(this,(function(r){switch(r.label){case 0:if(!this.faceDetector)return this.faceProcessing=!1,[2,"predictFaces"];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this,[4,this.faceDetector.predict(this.faceParams,t)];case 2:return e.latestFaces=r.sent(),[3,4];case 3:return n=r.sent(),console.log("predictFaces:",n),[3,4];case 4:return this.latestFaces&&this.latestFaces.rowPrediction&&this.latestFaces.rowPrediction.length>0&&this.latestFaces.rowPrediction[0].keypoints&&(i=c.Face.solve(this.latestFaces.singlePersonKeypointsMovingAverage,{runtime:"mediapipe",imageSize:{height:t.height,width:t.width},smoothBlink:!0}),this.latestFaceRig=JSON.parse(JSON.stringify(i))),this.faceProcessing=!1,[2,"predictFaces"]}}))}))},this.predictHands=function(t){return o(e,void 0,void 0,(function(){var e,n,i,r,a;return s(this,(function(o){switch(o.label){case 0:if(!this.handDetector)return this.handProcessing=!1,[2,"predictHands"];o.label=1;case 1:return o.trys.push([1,3,,4]),e=this,[4,this.handDetector.predict(this.handParams,t)];case 2:return e.latestHands=o.sent(),[3,4];case 3:return n=o.sent(),console.log("predictHands:",n),[3,4];case 4:if(this.latestHands&&this.latestHands.rowPrediction&&this.latestHands.rowPrediction.length>0)for(i=0;i0&&(this.latestPoses.singlePersonKeypointsMovingAverage.forEach((function(e){e.x*=t.width,e.y*=t.height,e.z*=t.width})),this.latestPoses.singlePersonKeypoints3DMovingAverage.forEach((function(e){e.x/=2,e.y/=2})),i=c.Pose.solve(this.latestPoses.singlePersonKeypoints3DMovingAverage,this.latestPoses.singlePersonKeypointsMovingAverage,{runtime:"tfjs",imageSize:{height:t.height,width:t.width},smoothLandmarks:!0}),this.latestPoseRig=JSON.parse(JSON.stringify(i))),this.poseProcessing=!1,[2,"predictPoses"]}}))}))}}},950:function(e,t,n){"use strict";var i,r,a,o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.calcBrow=t.getBrowRaise=t.calcPupils=t.calcEyes=t.stabilizeBlink=t.pupilPos=t.eyeLidRatio=t.getEyeOpen=void 0;var s=o(n(360)),c=n(652),l=n(147),u={eye:(i={},i[l.LEFT]=[130,133,160,159,158,144,145,153],i[l.RIGHT]=[263,362,387,386,385,373,374,380],i),brow:(r={},r[l.LEFT]=[35,244,63,105,66,229,230,231],r[l.RIGHT]=[265,464,293,334,296,449,450,451],r),pupil:(a={},a[l.LEFT]=[468,469,470,471,472],a[l.RIGHT]=[473,474,475,476,477],a)};t.getEyeOpen=function(e,n,i){void 0===n&&(n=l.LEFT);var r=void 0===i?{}:i,a=r.high,o=void 0===a?.85:a,s=r.low,d=void 0===s?.55:s,h=u.eye[n],f=(0,t.eyeLidRatio)(e[h[0]],e[h[1]],e[h[2]],e[h[3]],e[h[4]],e[h[5]],e[h[6]],e[h[7]]),p=(0,c.clamp)(f/.285,0,2);return{norm:(0,c.remap)(p,d,o),raw:p}},t.eyeLidRatio=function(e,t,n,i,r,a,o,c){e=new s.default(e),t=new s.default(t),n=new s.default(n),i=new s.default(i),r=new s.default(r),a=new s.default(a),o=new s.default(o),c=new s.default(c);var l=e.distance(t,2);return(n.distance(a,2)+i.distance(o,2)+r.distance(c,2))/3/l},t.pupilPos=function(e,t){void 0===t&&(t=l.LEFT);var n=new s.default(e[u.eye[t][0]]),i=new s.default(e[u.eye[t][1]]),r=n.distance(i,2),a=n.lerp(i,.5),o=new s.default(e[u.pupil[t][0]]),c=(a.x-o.x)/(r/2),d=(a.y-.075*r-o.y)/(r/4);return{x:c*=4,y:d*=4}},t.stabilizeBlink=function(e,t,n){var i=void 0===n?{}:n,r=i.enableWink,a=void 0===r||r,o=i.maxRot,l=void 0===o?.5:o;e.r=(0,c.clamp)(e.r,0,1),e.l=(0,c.clamp)(e.l,0,1);var u=Math.abs(e.l-e.r),d=a?.8:1.2,h=e.l<.3&&e.r<.3,f=e.l>.6&&e.r>.6;return t>l?{l:e.r,r:e.r}:t<-l?{l:e.l,r:e.l}:{l:u>=d&&!h&&!f?e.l:e.r>e.l?s.default.lerp(e.r,e.l,.95):s.default.lerp(e.r,e.l,.05),r:u>=d&&!h&&!f?e.r:e.r>e.l?s.default.lerp(e.r,e.l,.95):s.default.lerp(e.r,e.l,.05)}},t.calcEyes=function(e,n){var i=void 0===n?{}:n,r=i.high,a=void 0===r?.85:r,o=i.low,s=void 0===o?.55:o;if(478!==e.length)return{l:1,r:1};var c=(0,t.getEyeOpen)(e,l.LEFT,{high:a,low:s}),u=(0,t.getEyeOpen)(e,l.RIGHT,{high:a,low:s});return{l:c.norm||0,r:u.norm||0}},t.calcPupils=function(e){if(478!==e.length)return{x:0,y:0};var n=(0,t.pupilPos)(e,l.LEFT),i=(0,t.pupilPos)(e,l.RIGHT);return{x:.5*(n.x+i.x)||0,y:.5*(n.y+i.y)||0}},t.getBrowRaise=function(e,n){void 0===n&&(n=l.LEFT);var i=u.brow[n],r=.07,a=(0,t.eyeLidRatio)(e[i[0]],e[i[1]],e[i[2]],e[i[3]],e[i[4]],e[i[5]],e[i[6]],e[i[7]])/1.15-1;return((0,c.clamp)(a,r,.125)-r)/(.125-r)},t.calcBrow=function(e){return 478!==e.length?0:((0,t.getBrowRaise)(e,l.LEFT)+(0,t.getBrowRaise)(e,l.RIGHT))/2||0}},519:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.calcHead=t.createEulerPlane=void 0;var r=i(n(360)),a=n(147);t.createEulerPlane=function(e){var t=new r.default(e[21]),n=new r.default(e[251]),i=new r.default(e[397]),a=new r.default(e[172]);return{vector:[t,n,i.lerp(a,.5)],points:[t,n,i,a]}},t.calcHead=function(e){var n=(0,t.createEulerPlane)(e).vector,i=r.default.rollPitchYaw(n[0],n[1],n[2]),o=n[0].lerp(n[1],.5),s=n[0].distance(n[1]),c=o.distance(n[2]);return i.x*=-1,i.z*=-1,{y:i.y*a.PI,x:i.x*a.PI,z:i.z*a.PI,width:s,height:c,position:o.lerp(n[2],.5),normalized:{y:i.y,x:i.x,z:i.z},degrees:{y:180*i.y,x:180*i.x,z:180*i.z}}}},935:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.calcMouth=void 0;var r=i(n(360)),a=n(652);t.calcMouth=function(e){var t=new r.default(e[133]),n=new r.default(e[362]),i=new r.default(e[130]),o=new r.default(e[263]),s=t.distance(n),c=i.distance(o),l=new r.default(e[13]),u=new r.default(e[14]),d=new r.default(e[61]),h=new r.default(e[291]),f=l.distance(u),p=f/s,m=d.distance(h)/c;p=(0,a.remap)(p,.15,.7);var g=m=2*((m=(0,a.remap)(m,.45,.9))-.3),C=(0,a.remap)(f/s,.17,.5),v=(0,a.clamp)(2*(0,a.remap)(g,0,1)*(0,a.remap)(C,.2,.7),0,1),y=.4*C+C*(1-v)*.6,b=C*(0,a.remap)(1-v,0,.3)*.1;return{x:m||0,y:p||0,shape:{A:y||0,E:(0,a.remap)(b,.2,1)*(1-v)*.3||0,I:v||0,O:(1-v)*(0,a.remap)(C,.3,1)*.4||0,U:b||0}}}},417:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FaceSolver=void 0;var i=n(519),r=n(950),a=n(935),o=function(){function e(){}return e.solve=function(e,t){var n=void 0===t?{}:t,o=n.runtime,s=void 0===o?"tfjs":o,c=n.video,l=void 0===c?null:c,u=n.imageSize,d=void 0===u?null:u,h=n.smoothBlink,f=void 0!==h&&h,p=n.blinkSettings,m=void 0===p?[]:p;if(e){if(l){var g="string"==typeof l?document.querySelector(l):l;d={width:g.videoWidth,height:g.videoHeight}}if("mediapipe"===s&&d)for(var C=0,v=e;C0?m:"tfjs"===s?[.55,.85]:[.35,.5];var x=(0,r.calcEyes)(e,{high:m[1],low:m[0]});f&&(x=(0,r.stabilizeBlink)(x,b.y));var _=(0,r.calcPupils)(e);return{head:b,eye:x,brow:(0,r.calcBrow)(e),pupil:_,mouth:M}}console.error("Need Face Landmarks")},e.stabilizeBlink=r.stabilizeBlink,e}();t.FaceSolver=o},702:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HandSolver=void 0;var r=i(n(360)),a=n(652),o=n(147),s=n(147),c=function(){function e(){}return e.solve=function(e,t){if(void 0===t&&(t=o.RIGHT),e){var n=[new r.default(e[0]),new r.default(e[t===o.RIGHT?17:5]),new r.default(e[t===o.RIGHT?5:17])],i=r.default.rollPitchYaw(n[0],n[1],n[2]);i.y=i.z,i.y-=(o.LEFT,.4);var a={};return a[t+"Wrist"]={x:i.x,y:i.y,z:i.z},a[t+"RingProximal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[0],e[13],e[14])},a[t+"RingIntermediate"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[13],e[14],e[15])},a[t+"RingDistal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[14],e[15],e[16])},a[t+"IndexProximal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[0],e[5],e[6])},a[t+"IndexIntermediate"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[5],e[6],e[7])},a[t+"IndexDistal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[6],e[7],e[8])},a[t+"MiddleProximal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[0],e[9],e[10])},a[t+"MiddleIntermediate"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[9],e[10],e[11])},a[t+"MiddleDistal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[10],e[11],e[12])},a[t+"ThumbProximal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[0],e[1],e[2])},a[t+"ThumbIntermediate"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[1],e[2],e[3])},a[t+"ThumbDistal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[2],e[3],e[4])},a[t+"LittleProximal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[0],e[17],e[18])},a[t+"LittleIntermediate"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[17],e[18],e[19])},a[t+"LittleDistal"]={x:0,y:0,z:r.default.angleBetween3DCoords(e[18],e[19],e[20])},l(a,t)}console.error("Need Hand Landmarks")},e}();t.HandSolver=c;var l=function(e,t){void 0===t&&(t=o.RIGHT);var n=t===o.RIGHT?1:-1,i=["Proximal","Intermediate","Distal"];return e[t+"Wrist"].x=(0,a.clamp)(2*e[t+"Wrist"].x*n,-.3,.3),e[t+"Wrist"].y=(0,a.clamp)(2.3*e[t+"Wrist"].y,t===o.RIGHT?-1.2:-.6,t===o.RIGHT?.6:1.6),e[t+"Wrist"].z=-2.3*e[t+"Wrist"].z*n,["Ring","Index","Little","Thumb","Middle"].forEach((function(r){i.forEach((function(i){var c=e[t+r+i];if("Thumb"===r){var l={x:"Proximal"===i?2.2:0,y:"Proximal"===i?2.2:"Intermediate"===i?.7:1,z:.5},u={x:"Proximal"===i?1.2:-.2,y:"Proximal"===i?1.1*n:.1*n,z:.2*n},d={x:0,y:0,z:0};"Proximal"===i?(d.z=(0,a.clamp)(u.z+c.z*-s.PI*l.z*n,t===o.RIGHT?-.6:-.3,t===o.RIGHT?.3:.6),d.x=(0,a.clamp)(u.x+c.z*-s.PI*l.x,-.6,.3),d.y=(0,a.clamp)(u.y+c.z*-s.PI*l.y*n,t===o.RIGHT?-1:-.3,t===o.RIGHT?.3:1)):(d.z=(0,a.clamp)(u.z+c.z*-s.PI*l.z*n,-2,2),d.x=(0,a.clamp)(u.x+c.z*-s.PI*l.x,-2,2),d.y=(0,a.clamp)(u.y+c.z*-s.PI*l.y*n,-2,2)),c.x=d.x,c.y=d.y,c.z=d.z}else c.z=(0,a.clamp)(c.z*-s.PI*n,t===o.RIGHT?-s.PI:0,t===o.RIGHT?0:s.PI)}))})),e}},95:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rigArm=t.calcArms=void 0;var r=i(n(360)),a=n(652),o=n(147),s=n(147);t.calcArms=function(e){var n={r:r.default.findRotation(e[11],e[13]),l:r.default.findRotation(e[12],e[14])};n.r.y=r.default.angleBetween3DCoords(e[12],e[11],e[13]),n.l.y=r.default.angleBetween3DCoords(e[11],e[12],e[14]);var i={r:r.default.findRotation(e[13],e[15]),l:r.default.findRotation(e[14],e[16])};i.r.y=r.default.angleBetween3DCoords(e[11],e[13],e[15]),i.l.y=r.default.angleBetween3DCoords(e[12],e[14],e[16]),i.r.z=(0,a.clamp)(i.r.z,-2.14,0),i.l.z=(0,a.clamp)(i.l.z,-2.14,0);var s={r:r.default.findRotation(r.default.fromArray(e[15]),r.default.lerp(r.default.fromArray(e[17]),r.default.fromArray(e[19]),.5)),l:r.default.findRotation(r.default.fromArray(e[16]),r.default.lerp(r.default.fromArray(e[18]),r.default.fromArray(e[20]),.5))},c=(0,t.rigArm)(n.r,i.r,s.r,o.RIGHT),l=(0,t.rigArm)(n.l,i.l,s.l,o.LEFT);return{UpperArm:{r:c.UpperArm,l:l.UpperArm},LowerArm:{r:c.LowerArm,l:l.LowerArm},Hand:{r:c.Hand,l:l.Hand},Unscaled:{UpperArm:n,LowerArm:i,Hand:s}}},t.rigArm=function(e,t,n,i){void 0===i&&(i=o.RIGHT);var r=i===o.RIGHT?1:-1;return e.z*=-2.3*r,e.y*=s.PI*r,e.y-=Math.max(t.x),e.y-=-r*Math.max(t.z,0),e.x-=.3*r,t.z*=-2.14*r,t.y*=2.14*r,t.x*=2.14*r,e.x=(0,a.clamp)(e.x,-.5,s.PI),t.x=(0,a.clamp)(t.x,-.3,.3),n.y=(0,a.clamp)(2*n.z,-.6,.6),n.z=-2.3*n.z*r,{UpperArm:e,LowerArm:t,Hand:n}}},699:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rigHips=t.calcHips=void 0;var r=i(n(360)),a=n(652),o=n(147);t.calcHips=function(e,n){var i=r.default.fromArray(n[23]),o=r.default.fromArray(n[24]),s=r.default.fromArray(n[11]),c=r.default.fromArray(n[12]),l=i.lerp(o,1),u=s.lerp(c,1),d=l.distance(u),h={position:{x:(0,a.clamp)(l.x-.4,-1,1),y:0,z:(0,a.clamp)(d-1,-2,0)}};h.worldPosition={x:h.position.x,y:0,z:h.position.z*Math.pow(-2*h.position.z,2)},h.worldPosition.x*=h.worldPosition.z,h.rotation=r.default.rollPitchYaw(e[23],e[24]),h.rotation.y>.5&&(h.rotation.y-=2),h.rotation.y+=.5,h.rotation.z>0&&(h.rotation.z=1-h.rotation.z),h.rotation.z<0&&(h.rotation.z=-1-h.rotation.z);var f=(0,a.remap)(Math.abs(h.rotation.y),.2,.4);h.rotation.z*=1-f,h.rotation.x=0;var p=r.default.rollPitchYaw(e[11],e[12]);p.y>.5&&(p.y-=2),p.y+=.5,p.z>0&&(p.z=1-p.z),p.z<0&&(p.z=-1-p.z);var m=(0,a.remap)(Math.abs(p.y),.2,.4);return p.z*=1-m,p.x=0,(0,t.rigHips)(h,p)},t.rigHips=function(e,t){return e.rotation&&(e.rotation.x*=Math.PI,e.rotation.y*=Math.PI,e.rotation.z*=Math.PI),t.x*=o.PI,t.y*=o.PI,t.z*=o.PI,{Hips:e,Spine:t}}},581:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.rigLeg=t.calcLegs=t.offsets=void 0;var r=i(n(360)),a=i(n(945)),o=n(652),s=n(147),c=n(147);t.offsets={upperLeg:{z:.1}},t.calcLegs=function(e){var n=r.default.getSphericalCoords(e[23],e[25],{x:"y",y:"z",z:"x"}),i=r.default.getSphericalCoords(e[24],e[26],{x:"y",y:"z",z:"x"}),a=r.default.getRelativeSphericalCoords(e[23],e[25],e[27],{x:"y",y:"z",z:"x"}),o=r.default.getRelativeSphericalCoords(e[24],e[26],e[28],{x:"y",y:"z",z:"x"}),c=r.default.findRotation(e[23],e[24]),l={r:new r.default({x:n.theta,y:a.phi,z:n.phi-c.z}),l:new r.default({x:i.theta,y:o.phi,z:i.phi-c.z})},u={r:new r.default({x:-Math.abs(a.theta),y:0,z:0}),l:new r.default({x:-Math.abs(o.theta),y:0,z:0})},d=(0,t.rigLeg)(l.r,u.r,s.RIGHT),h=(0,t.rigLeg)(l.l,u.l,s.LEFT);return{UpperLeg:{r:d.UpperLeg,l:h.UpperLeg},LowerLeg:{r:d.LowerLeg,l:h.LowerLeg},Unscaled:{UpperLeg:l,LowerLeg:u}}},t.rigLeg=function(e,n,i){void 0===i&&(i=s.RIGHT);var r=i===s.RIGHT?1:-1;return{UpperLeg:new a.default({x:(0,o.clamp)(e.x,0,.5)*c.PI,y:(0,o.clamp)(e.y,-.25,.25)*c.PI,z:(0,o.clamp)(e.z,-.5,.5)*c.PI+r*t.offsets.upperLeg.z,rotationOrder:"XYZ"}),LowerLeg:new a.default({x:n.x*c.PI,y:n.y*c.PI,z:n.z*c.PI})}}},201:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PoseSolver=void 0;var i=n(652),r=n(95),a=n(699),o=n(581),s=function(){function e(){}return e.solve=function(e,t,n){var s,c,l,u,d=void 0===n?{}:n,h=d.runtime,f=void 0===h?"mediapipe":h,p=d.video,m=void 0===p?null:p,g=d.imageSize,C=void 0===g?null:g,v=d.enableLegs,y=void 0===v||v;if(e||t){if(m){var b="string"==typeof m?document.querySelector(m):m;C={width:b.videoWidth,height:b.videoHeight}}if("tfjs"===f&&C){for(var M=0,x=e;M1||(null!==(s=e[15].visibility)&&void 0!==s?s:0)<.7,A=e[16].y>1||(null!==(c=e[16].visibility)&&void 0!==c?c:0)<.7,V=e[23].y>.1||(null!==(l=e[23].visibility)&&void 0!==l?l:0)<.8||E.Hips.position.z>-.4,H=e[24].y>.1||(null!==(u=e[24].visibility)&&void 0!==u?u:0)<.8||E.Hips.position.z>-.4;return L.UpperArm.l=L.UpperArm.l.multiply(A?0:1),L.UpperArm.l.z=A?i.RestingDefault.Pose.LeftUpperArm.z:L.UpperArm.l.z,L.UpperArm.r=L.UpperArm.r.multiply(z?0:1),L.UpperArm.r.z=z?i.RestingDefault.Pose.RightUpperArm.z:L.UpperArm.r.z,L.LowerArm.l=L.LowerArm.l.multiply(A?0:1),L.LowerArm.r=L.LowerArm.r.multiply(z?0:1),L.Hand.l=L.Hand.l.multiply(A?0:1),L.Hand.r=L.Hand.r.multiply(z?0:1),T&&(T.UpperLeg.l=T.UpperLeg.l.multiply(H?0:1),T.UpperLeg.r=T.UpperLeg.r.multiply(V?0:1),T.LowerLeg.l=T.LowerLeg.l.multiply(H?0:1),T.LowerLeg.r=T.LowerLeg.r.multiply(V?0:1)),{RightUpperArm:L.UpperArm.r,RightLowerArm:L.LowerArm.r,LeftUpperArm:L.UpperArm.l,LeftLowerArm:L.LowerArm.l,RightHand:L.Hand.r,LeftHand:L.Hand.l,RightUpperLeg:T?T.UpperLeg.r:i.RestingDefault.Pose.RightUpperLeg,RightLowerLeg:T?T.LowerLeg.r:i.RestingDefault.Pose.RightLowerLeg,LeftUpperLeg:T?T.UpperLeg.l:i.RestingDefault.Pose.LeftUpperLeg,LeftLowerLeg:T?T.LowerLeg.l:i.RestingDefault.Pose.LeftLowerLeg,Hips:E.Hips,Spine:E.Spine}}console.error("Need both World Pose and Pose Landmarks")},e.calcArms=r.calcArms,e.calcHips=a.calcHips,e.calcLegs=o.calcLegs,e}();t.PoseSolver=s},431:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},147:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TWO_PI=t.PI=t.LEFT=t.RIGHT=void 0,t.RIGHT="Right",t.LEFT="Left",t.PI=Math.PI,t.TWO_PI=2*Math.PI},314:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Utils=t.Vector=t.Face=t.Hand=t.Pose=void 0;var c=n(201);Object.defineProperty(t,"Pose",{enumerable:!0,get:function(){return c.PoseSolver}});var l=n(702);Object.defineProperty(t,"Hand",{enumerable:!0,get:function(){return l.HandSolver}});var u=n(417);Object.defineProperty(t,"Face",{enumerable:!0,get:function(){return u.FaceSolver}});var d=n(360);Object.defineProperty(t,"Vector",{enumerable:!0,get:function(){return s(d).default}}),t.Utils=a(n(652)),o(n(431),t)},945:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,n,i){var r,a,o,s;if(e&&"object"==typeof e)return this.x=null!==(r=e.x)&&void 0!==r?r:0,this.y=null!==(a=e.y)&&void 0!==a?a:0,this.z=null!==(o=e.z)&&void 0!==o?o:0,void(this.rotationOrder=null!==(s=e.rotationOrder)&&void 0!==s?s:"XYZ");this.x=null!=e?e:0,this.y=null!=t?t:0,this.z=null!=n?n:0,this.rotationOrder=null!=i?i:"XYZ"}return e.prototype.multiply=function(t){return new e(this.x*t,this.y*t,this.z*t,this.rotationOrder)},e}();t.default=n},652:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RestingDefault=t.remap=t.clamp=void 0,t.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},t.remap=function(e,n,i){return((0,t.clamp)(e,n,i)-n)/(i-n)},t.RestingDefault={Face:{eye:{l:1,r:1},mouth:{x:0,y:0,shape:{A:0,E:0,I:0,O:0,U:0}},head:{x:0,y:0,z:0,width:.3,height:.6,position:{x:.5,y:.5,z:0}},brow:0,pupil:{x:0,y:0}},Pose:{RightUpperArm:{x:0,y:0,z:-1.25},LeftUpperArm:{x:0,y:0,z:1.25},RightLowerArm:{x:0,y:0,z:0},LeftLowerArm:{x:0,y:0,z:0},LeftUpperLeg:{x:0,y:0,z:0},RightUpperLeg:{x:0,y:0,z:0},RightLowerLeg:{x:0,y:0,z:0},LeftLowerLeg:{x:0,y:0,z:0},LeftHand:{x:0,y:0,z:0},RightHand:{x:0,y:0,z:0},Spine:{x:0,y:0,z:0},Hips:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}}},RightHand:{RightWrist:{x:-.13,y:-.07,z:-1.04},RightRingProximal:{x:0,y:0,z:-.13},RightRingIntermediate:{x:0,y:0,z:-.4},RightRingDistal:{x:0,y:0,z:-.04},RightIndexProximal:{x:0,y:0,z:-.24},RightIndexIntermediate:{x:0,y:0,z:-.25},RightIndexDistal:{x:0,y:0,z:-.06},RightMiddleProximal:{x:0,y:0,z:-.09},RightMiddleIntermediate:{x:0,y:0,z:-.44},RightMiddleDistal:{x:0,y:0,z:-.06},RightThumbProximal:{x:-.23,y:-.33,z:-.12},RightThumbIntermediate:{x:-.2,y:-.199,z:-.0139},RightThumbDistal:{x:-.2,y:.002,z:.15},RightLittleProximal:{x:0,y:0,z:-.09},RightLittleIntermediate:{x:0,y:0,z:-.225},RightLittleDistal:{x:0,y:0,z:-.1}},LeftHand:{LeftWrist:{x:-.13,y:-.07,z:-1.04},LeftRingProximal:{x:0,y:0,z:.13},LeftRingIntermediate:{x:0,y:0,z:.4},LeftRingDistal:{x:0,y:0,z:.049},LeftIndexProximal:{x:0,y:0,z:.24},LeftIndexIntermediate:{x:0,y:0,z:.25},LeftIndexDistal:{x:0,y:0,z:.06},LeftMiddleProximal:{x:0,y:0,z:.09},LeftMiddleIntermediate:{x:0,y:0,z:.44},LeftMiddleDistal:{x:0,y:0,z:.066},LeftThumbProximal:{x:-.23,y:.33,z:.12},LeftThumbIntermediate:{x:-.2,y:.25,z:.05},LeftThumbDistal:{x:-.2,y:.17,z:-.06},LeftLittleProximal:{x:0,y:0,z:.17},LeftLittleIntermediate:{x:0,y:0,z:.4},LeftLittleDistal:{x:0,y:0,z:.1}}}},360:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(147),r=function(){function e(e,t,n){var i,r,a,o,s,c;return Array.isArray(e)?(this.x=null!==(i=e[0])&&void 0!==i?i:0,this.y=null!==(r=e[1])&&void 0!==r?r:0,void(this.z=null!==(a=e[2])&&void 0!==a?a:0)):e&&"object"==typeof e?(this.x=null!==(o=e.x)&&void 0!==o?o:0,this.y=null!==(s=e.y)&&void 0!==s?s:0,void(this.z=null!==(c=e.z)&&void 0!==c?c:0)):(this.x=null!=e?e:0,this.y=null!=t?t:0,void(this.z=null!=n?n:0))}return e.prototype.negative=function(){return new e(-this.x,-this.y,-this.z)},e.prototype.add=function(t){return t instanceof e?new e(this.x+t.x,this.y+t.y,this.z+t.z):new e(this.x+t,this.y+t,this.z+t)},e.prototype.subtract=function(t){return t instanceof e?new e(this.x-t.x,this.y-t.y,this.z-t.z):new e(this.x-t,this.y-t,this.z-t)},e.prototype.multiply=function(t){return t instanceof e?new e(this.x*t.x,this.y*t.y,this.z*t.z):new e(this.x*t,this.y*t,this.z*t)},e.prototype.divide=function(t){return t instanceof e?new e(this.x/t.x,this.y/t.y,this.z/t.z):new e(this.x/t,this.y/t,this.z/t)},e.prototype.equals=function(e){return this.x==e.x&&this.y==e.y&&this.z==e.z},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},e.prototype.cross=function(t){return new e(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)},e.prototype.length=function(){return Math.sqrt(this.dot(this))},e.prototype.distance=function(e,t){return void 0===t&&(t=3),2===t?Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2)):Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2)+Math.pow(this.z-e.z,2))},e.prototype.lerp=function(e,t){return e.subtract(this).multiply(t).add(this)},e.prototype.unit=function(){return this.divide(this.length())},e.prototype.min=function(){return Math.min(Math.min(this.x,this.y),this.z)},e.prototype.max=function(){return Math.max(Math.max(this.x,this.y),this.z)},e.prototype.toSphericalCoords=function(e){return void 0===e&&(e={x:"x",y:"y",z:"z"}),{theta:Math.atan2(this[e.y],this[e.x]),phi:Math.acos(this[e.z]/this.length())}},e.prototype.angleTo=function(e){return Math.acos(this.dot(e)/(this.length()*e.length()))},e.prototype.toArray=function(e){return[this.x,this.y,this.z].slice(0,e||3)},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.prototype.init=function(e,t,n){return this.x=e,this.y=t,this.z=n,this},e.negative=function(t,n){return void 0===n&&(n=new e),n.x=-t.x,n.y=-t.y,n.z=-t.z,n},e.add=function(t,n,i){return void 0===i&&(i=new e),n instanceof e?(i.x=t.x+n.x,i.y=t.y+n.y,i.z=t.z+n.z):(i.x=t.x+n,i.y=t.y+n,i.z=t.z+n),i},e.subtract=function(t,n,i){return void 0===i&&(i=new e),n instanceof e?(i.x=t.x-n.x,i.y=t.y-n.y,i.z=t.z-n.z):(i.x=t.x-n,i.y=t.y-n,i.z=t.z-n),i},e.multiply=function(t,n,i){return void 0===i&&(i=new e),n instanceof e?(i.x=t.x*n.x,i.y=t.y*n.y,i.z=t.z*n.z):(i.x=t.x*n,i.y=t.y*n,i.z=t.z*n),i},e.divide=function(t,n,i){return void 0===i&&(i=new e),n instanceof e?(i.x=t.x/n.x,i.y=t.y/n.y,i.z=t.z/n.z):(i.x=t.x/n,i.y=t.y/n,i.z=t.z/n),i},e.cross=function(t,n,i){return void 0===i&&(i=new e),i.x=t.y*n.z-t.z*n.y,i.y=t.z*n.x-t.x*n.z,i.z=t.x*n.y-t.y*n.x,i},e.unit=function(e,t){var n=e.length();return t.x=e.x/n,t.y=e.y/n,t.z=e.z/n,t},e.fromAngles=function(t,n){return new e(Math.cos(t)*Math.cos(n),Math.sin(n),Math.sin(t)*Math.cos(n))},e.randomDirection=function(){return e.fromAngles(Math.random()*i.TWO_PI,Math.asin(2*Math.random()-1))},e.min=function(t,n){return new e(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z))},e.max=function(t,n){return new e(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))},e.lerp=function(t,n,i){return n instanceof e?n.subtract(t).multiply(i).add(t):(n-t)*i+t},e.fromArray=function(t){return Array.isArray(t)?new e(t[0],t[1],t[2]):new e(t.x,t.y,t.z)},e.angleBetween=function(e,t){return e.angleTo(t)},e.distance=function(e,t,n){return 2===n?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)+Math.pow(e.z-t.z,2))},e.toDegrees=function(e){return e*(180/i.PI)},e.normalizeAngle=function(e){var t=e%i.TWO_PI;return(t=t>i.PI?t-i.TWO_PI:t<-i.PI?i.TWO_PI+t:t)/i.PI},e.normalizeRadians=function(e){return e>=i.PI/2&&(e-=i.TWO_PI),e<=-i.PI/2&&(e+=i.TWO_PI,e=i.PI-e),e/i.PI},e.find2DAngle=function(e,t,n,i){var r=i-t,a=n-e;return Math.atan2(r,a)},e.findRotation=function(t,n,i){return void 0===i&&(i=!0),i?new e(e.normalizeRadians(e.find2DAngle(t.z,t.x,n.z,n.x)),e.normalizeRadians(e.find2DAngle(t.z,t.y,n.z,n.y)),e.normalizeRadians(e.find2DAngle(t.x,t.y,n.x,n.y))):new e(e.find2DAngle(t.z,t.x,n.z,n.x),e.find2DAngle(t.z,t.y,n.z,n.y),e.find2DAngle(t.x,t.y,n.x,n.y))},e.rollPitchYaw=function(t,n,i){if(!i)return new e(e.normalizeAngle(e.find2DAngle(t.z,t.y,n.z,n.y)),e.normalizeAngle(e.find2DAngle(t.z,t.x,n.z,n.x)),e.normalizeAngle(e.find2DAngle(t.x,t.y,n.x,n.y)));var r=n.subtract(t),a=i.subtract(t),o=r.cross(a).unit(),s=r.unit(),c=o.cross(s),l=Math.asin(o.x)||0,u=Math.atan2(-o.y,o.z)||0,d=Math.atan2(-c.x,s.x)||0;return new e(e.normalizeAngle(u),e.normalizeAngle(l),e.normalizeAngle(d))},e.angleBetween3DCoords=function(t,n,i){t instanceof e||(t=new e(t),n=new e(n),i=new e(i));var r=t.subtract(n),a=i.subtract(n),o=r.unit(),s=a.unit(),c=o.dot(s),l=Math.acos(c);return e.normalizeRadians(l)},e.getRelativeSphericalCoords=function(t,n,i,r){t instanceof e||(t=new e(t),n=new e(n),i=new e(i));var a=n.subtract(t),o=i.subtract(n),s=a.unit(),c=o.unit(),l=s.toSphericalCoords(r),u=l.theta,d=l.phi,h=c.toSphericalCoords(r),f=u-h.theta,p=d-h.phi;return{theta:e.normalizeAngle(f),phi:e.normalizeAngle(p)}},e.getSphericalCoords=function(t,n,r){void 0===r&&(r={x:"x",y:"y",z:"z"}),t instanceof e||(t=new e(t),n=new e(n));var a=n.subtract(t).unit().toSphericalCoords(r),o=a.theta,s=a.phi;return{theta:e.normalizeAngle(-o),phi:e.normalizeAngle(i.PI/2-s)}},e}();t.default=r},363:e=>{"use strict";e.exports=n(8992)},102:e=>{"use strict";e.exports=n(4470)},914:e=>{"use strict";e.exports=n(9537)},583:e=>{"use strict";e.exports=n(7979)},180:e=>{"use strict";e.exports=n(5173)},747:e=>{"use strict";e.exports=n(7644)},81:e=>{"use strict";e.exports=n(4570)},232:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n="137",i=100,r=300,a=301,o=302,s=303,c=304,l=306,u=307,d=1e3,h=1001,f=1002,p=1003,m=1004,g=1005,C=1006,v=1007,y=1008,b=1009,M=1012,x=1014,_=1015,S=1016,w=1020,L=1023,E=1026,T=1027,z=33776,A=33777,V=33778,H=33779,R=35840,P=35841,I=35842,k=35843,N=37492,D=37496,O=37808,B=37809,F=37810,U=37811,W=37812,G=37813,j=37814,q=37815,X=37816,Y=37817,J=37818,$=37819,K=37820,Z=37821,Q=36492,ee=2300,te=2301,ne=2302,ie=2400,re=2401,ae=2402,oe=2501,se=3e3,ce=3001,le=7680,ue=35044,de=35048,he="300 es",fe=1035;class pe{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+me[e>>16&255]+me[e>>24&255]+"-"+me[255&t]+me[t>>8&255]+"-"+me[t>>16&15|64]+me[t>>24&255]+"-"+me[63&n|128]+me[n>>8&255]+"-"+me[n>>16&255]+me[n>>24&255]+me[255&i]+me[i>>8&255]+me[i>>16&255]+me[i>>24&255]).toUpperCase()}function be(e,t,n){return Math.max(t,Math.min(n,e))}function Me(e,t){return(e%t+t)%t}function xe(e,t,n){return(1-n)*e+n*t}function _e(e){return 0==(e&e-1)&&0!==e}function Se(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function we(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var Le=Object.freeze({__proto__:null,DEG2RAD:Ce,RAD2DEG:ve,generateUUID:ye,clamp:be,euclideanModulo:Me,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:xe,damp:function(e,t,n,i){return xe(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(Me(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(ge=e%2147483647),ge=16807*ge%2147483647,(ge-1)/2147483646},degToRad:function(e){return e*Ce},radToDeg:function(e){return e*ve},isPowerOfTwo:_e,ceilPowerOfTwo:Se,floorPowerOfTwo:we,setQuaternionFromProperEuler:function(e,t,n,i,r){const a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+i)/2),u=o((t+i)/2),d=a((t-i)/2),h=o((t-i)/2),f=a((i-t)/2),p=o((i-t)/2);switch(r){case"XYX":e.set(s*u,c*d,c*h,s*l);break;case"YZY":e.set(c*h,s*u,c*d,s*l);break;case"ZXZ":e.set(c*d,c*h,s*u,s*l);break;case"XZX":e.set(s*u,c*p,c*f,s*l);break;case"YXY":e.set(c*f,s*u,c*p,s*l);break;case"ZYZ":e.set(c*p,c*f,s*u,s*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class Ee{constructor(e=0,t=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,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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){const 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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Ee.prototype.isVector2=!0;class Te{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,a,o,s,c){const l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],p=i[0],m=i[3],g=i[6],C=i[1],v=i[4],y=i[7],b=i[2],M=i[5],x=i[8];return r[0]=a*p+o*C+s*b,r[3]=a*m+o*v+s*M,r[6]=a*g+o*y+s*x,r[1]=c*p+l*C+u*b,r[4]=c*m+l*v+u*M,r[7]=c*g+l*y+u*x,r[2]=d*p+h*C+f*b,r[5]=d*m+h*v+f*M,r[8]=d*g+h*y+f*x,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*r*l+n*o*s+i*r*c-i*a*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*r,h=c*r-a*s,f=t*u+n*d+i*h;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return e[0]=u*p,e[1]=(i*c-l*n)*p,e[2]=(o*n-i*a)*p,e[3]=d*p,e[4]=(l*t-i*s)*p,e[5]=(i*r-o*t)*p,e[6]=h*p,e[7]=(n*s-c*t)*p,e[8]=(a*t-n*r)*p,this}transpose(){let e;const 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){const 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,i,r,a,o){const s=Math.cos(r),c=Math.sin(r);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-i*c,i*s,-i*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],a=i[3],o=i[6],s=i[1],c=i[4],l=i[7];return i[0]=t*r+n*s,i[3]=t*a+n*c,i[6]=t*o+n*l,i[1]=-n*r+t*s,i[4]=-n*a+t*c,i[7]=-n*o+t*l,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])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){const 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)}}function ze(e){for(let t=e.length-1;t>=0;--t)if(e[t]>65535)return!0;return!1}Te.prototype.isMatrix3=!0;const Ae={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ve(e,t){return new Ae[e](t)}function He(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Re={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},Pe={h:0,s:0,l:0},Ie={h:0,s:0,l:0};function ke(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Ne(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function De(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Oe{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=Me(e,1),t=be(t,0,1),n=be(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=ke(r,i,e+1/3),this.g=ke(r,i,e),this.b=ke(r,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=Re[e.toLowerCase()];return void 0!==t?this.setHex(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=Ne(e.r),this.g=Ne(e.g),this.b=Ne(e.b),this}copyLinearToSRGB(e){return this.r=De(e.r),this.g=De(e.g),this.b=De(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),a=Math.min(t,n,i);let o,s;const c=(a+r)/2;if(a===r)o=0,s=0;else{const e=r-a;switch(s=c<=.5?e/(r+a):e/(2-r-a),r){case t:o=(n-i)/e+(n2048||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("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=He("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e1)switch(this.wrapS){case d:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case f:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case d:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case f:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function Ge(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Fe.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}We.DEFAULT_IMAGE=void 0,We.DEFAULT_MAPPING=r,We.prototype.isTexture=!0;class je{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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,i,r;const a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],h=s[5],f=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(l-d)s&&e>C?eC?s=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,o=Math.sin(o*a)/r}const r=o*n;if(s=s*e+d*r,c=c*e+h*r,l=l*e+f*r,u=u*e+p*r,e===1-o){const e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],s=n[i+1],c=n[i+2],l=n[i+3],u=r[a],d=r[a+1],h=r[a+2],f=r[a+3];return e[t]=o*f+l*u+s*h-c*d,e[t+1]=s*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-s*u,e[t+3]=l*f-o*u-s*d-c*h,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(i/2),u=o(r/2),d=s(n/2),h=s(i/2),f=s(r/2);switch(a){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(r-c)*e,this._z=(a-i)*e}else if(n>o&&n>u){const e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+c)/e}else if(o>u){const e=2*Math.sqrt(1+o-n-u);this._w=(r-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(s+l)/e}else{const e=2*Math.sqrt(1+u-n-o);this._w=(a-i)/e,this._x=(r+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(be(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(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,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+i*c-r*s,this._y=i*l+a*s+r*o-n*c,this._z=r*l+a*c+n*s-i*o,this._w=a*l-n*o-i*s-r*c,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Je.prototype.isQuaternion=!0;class $e{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(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,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(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 e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ze.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ze.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*i-o*n,l=s*n+o*t-r*i,u=s*i+r*n-a*t,d=-r*t-a*n-o*i;return this.x=c*s+d*-r+l*-o-u*-a,this.y=l*s+d*-a+u*-r-c*-o,this.z=u*s+d*-o+c*-a-l*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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){const 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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ke.copy(this).projectOnVector(e),this.sub(Ke)}reflect(e){return this.sub(Ke.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}$e.prototype.isVector3=!0;const Ke=new $e,Ze=new Je;class Qe{constructor(e=new $e(1/0,1/0,1/0),t=new $e(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.length;sr&&(r=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,c=e.count;sr&&(r=c),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,tt),tt.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(lt),ut.subVectors(this.max,lt),it.subVectors(e.a,lt),rt.subVectors(e.b,lt),at.subVectors(e.c,lt),ot.subVectors(rt,it),st.subVectors(at,rt),ct.subVectors(it,at);let t=[0,-ot.z,ot.y,0,-st.z,st.y,0,-ct.z,ct.y,ot.z,0,-ot.x,st.z,0,-st.x,ct.z,0,-ct.x,-ot.y,ot.x,0,-st.y,st.x,0,-ct.y,ct.x,0];return!!ft(t,it,rt,at,ut)&&(t=[1,0,0,0,1,0,0,0,1],!!ft(t,it,rt,at,ut)&&(dt.crossVectors(ot,st),t=[dt.x,dt.y,dt.z],ft(t,it,rt,at,ut)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return tt.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(tt).length(),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()||(et[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),et[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),et[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),et[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),et[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),et[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),et[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),et[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(et)),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)}}Qe.prototype.isBox3=!0;const et=[new $e,new $e,new $e,new $e,new $e,new $e,new $e,new $e],tt=new $e,nt=new Qe,it=new $e,rt=new $e,at=new $e,ot=new $e,st=new $e,ct=new $e,lt=new $e,ut=new $e,dt=new $e,ht=new $e;function ft(e,t,n,i,r){for(let a=0,o=e.length-3;a<=o;a+=3){ht.fromArray(e,a);const o=r.x*Math.abs(ht.x)+r.y*Math.abs(ht.y)+r.z*Math.abs(ht.z),s=t.dot(ht),c=n.dot(ht),l=i.dot(ht);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const pt=new Qe,mt=new $e,gt=new $e,Ct=new $e;class vt{constructor(e=new $e,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):pt.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.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){Ct.subVectors(e,this.center);const t=Ct.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(Ct.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?gt.set(0,0,1).multiplyScalar(e.radius):gt.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(mt.copy(e.center).add(gt)),this.expandByPoint(mt.copy(e.center).sub(gt)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const yt=new $e,bt=new $e,Mt=new $e,xt=new $e,_t=new $e,St=new $e,wt=new $e;class Lt{constructor(e=new $e,t=new $e(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=yt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yt.copy(this.direction).multiplyScalar(t).add(this.origin),yt.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){bt.copy(e).add(t).multiplyScalar(.5),Mt.copy(t).sub(e).normalize(),xt.copy(this.origin).sub(bt);const r=.5*e.distanceTo(t),a=-this.direction.dot(Mt),o=xt.dot(this.direction),s=-xt.dot(Mt),c=xt.lengthSq(),l=Math.abs(1-a*a);let u,d,h,f;if(l>0)if(u=a*s-o,d=a*o-s,f=r*l,u>=0)if(d>=-f)if(d<=f){const e=1/l;u*=e,d*=e,h=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;else d=-r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;else d<=-f?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+c):d<=f?(u=0,d=Math.min(Math.max(-r,-s),r),h=d*(d+2*s)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),h=-u*u+d*(d+2*s)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(Mt).multiplyScalar(d).add(bt),h}intersectSphere(e,t){yt.subVectors(e.center,this.origin);const n=yt.dot(this.direction),i=yt.dot(yt)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,s;const c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),l>=0?(r=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(r=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,yt)}intersectTriangle(e,t,n,i,r){_t.subVectors(t,e),St.subVectors(n,e),wt.crossVectors(_t,St);let a,o=this.direction.dot(wt);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}xt.subVectors(this.origin,e);const s=a*this.direction.dot(St.crossVectors(xt,St));if(s<0)return null;const c=a*this.direction.dot(_t.cross(xt));if(c<0)return null;if(s+c>o)return null;const l=-a*xt.dot(wt);return l<0?null:this.at(l/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)}}class Et{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,a,o,s,c,l,u,d,h,f,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=h,g[7]=f,g[11]=p,g[15]=m,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 Et).fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){const t=this.elements,n=e.elements,i=1/Tt.setFromMatrixColumn(e,0).length(),r=1/Tt.setFromMatrixColumn(e,1).length(),a=1/Tt.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,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]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=a*l,n=a*u,i=o*l,r=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+i*c,t[5]=e-r*c,t[9]=-o*s,t[2]=r-e*c,t[6]=i+n*c,t[10]=a*s}else if("YXZ"===e.order){const e=s*l,n=s*u,i=c*l,r=c*u;t[0]=e+r*o,t[4]=i*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-i,t[6]=r+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*l,n=s*u,i=c*l,r=c*u;t[0]=e-r*o,t[4]=-a*u,t[8]=i+n*o,t[1]=n+i*o,t[5]=a*l,t[9]=r-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*l,n=a*u,i=o*l,r=o*u;t[0]=s*l,t[4]=i*c-n,t[8]=e*c+r,t[1]=s*u,t[5]=r*c+e,t[9]=n*c-i,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*c,i=o*s,r=o*c;t[0]=s*l,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=a*s,n=a*c,i=o*s,r=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+r,t[5]=a*l,t[9]=n*u-i,t[2]=i*u-n,t[6]=o*l,t[10]=r*u+e}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(At,e,Vt)}lookAt(e,t,n){const i=this.elements;return Pt.subVectors(e,t),0===Pt.lengthSq()&&(Pt.z=1),Pt.normalize(),Ht.crossVectors(n,Pt),0===Ht.lengthSq()&&(1===Math.abs(n.z)?Pt.x+=1e-4:Pt.z+=1e-4,Pt.normalize(),Ht.crossVectors(n,Pt)),Ht.normalize(),Rt.crossVectors(Pt,Ht),i[0]=Ht.x,i[4]=Rt.x,i[8]=Pt.x,i[1]=Ht.y,i[5]=Rt.y,i[9]=Pt.y,i[2]=Ht.z,i[6]=Rt.z,i[10]=Pt.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],p=n[6],m=n[10],g=n[14],C=n[3],v=n[7],y=n[11],b=n[15],M=i[0],x=i[4],_=i[8],S=i[12],w=i[1],L=i[5],E=i[9],T=i[13],z=i[2],A=i[6],V=i[10],H=i[14],R=i[3],P=i[7],I=i[11],k=i[15];return r[0]=a*M+o*w+s*z+c*R,r[4]=a*x+o*L+s*A+c*P,r[8]=a*_+o*E+s*V+c*I,r[12]=a*S+o*T+s*H+c*k,r[1]=l*M+u*w+d*z+h*R,r[5]=l*x+u*L+d*A+h*P,r[9]=l*_+u*E+d*V+h*I,r[13]=l*S+u*T+d*H+h*k,r[2]=f*M+p*w+m*z+g*R,r[6]=f*x+p*L+m*A+g*P,r[10]=f*_+p*E+m*V+g*I,r[14]=f*S+p*T+m*H+g*k,r[3]=C*M+v*w+y*z+b*R,r[7]=C*x+v*L+y*A+b*P,r[11]=C*_+v*E+y*V+b*I,r[15]=C*S+v*T+y*H+b*k,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+r*s*u-i*c*u-r*o*d+n*c*d+i*o*h-n*s*h)+e[7]*(+t*s*h-t*c*d+r*a*d-i*a*h+i*c*l-r*s*l)+e[11]*(+t*c*u-t*o*h-r*a*u+n*a*h+r*o*l-n*c*l)+e[15]*(-i*o*l-t*s*u+t*o*d+i*a*u-n*a*d+n*s*l)}transpose(){const e=this.elements;let 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){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],p=e[13],m=e[14],g=e[15],C=u*m*c-p*d*c+p*s*h-o*m*h-u*s*g+o*d*g,v=f*d*c-l*m*c-f*s*h+a*m*h+l*s*g-a*d*g,y=l*p*c-f*u*c+f*o*h-a*p*h-l*o*g+a*u*g,b=f*u*s-l*p*s-f*o*d+a*p*d+l*o*m-a*u*m,M=t*C+n*v+i*y+r*b;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const x=1/M;return e[0]=C*x,e[1]=(p*d*r-u*m*r-p*i*h+n*m*h+u*i*g-n*d*g)*x,e[2]=(o*m*r-p*s*r+p*i*c-n*m*c-o*i*g+n*s*g)*x,e[3]=(u*s*r-o*d*r-u*i*c+n*d*c+o*i*h-n*s*h)*x,e[4]=v*x,e[5]=(l*m*r-f*d*r+f*i*h-t*m*h-l*i*g+t*d*g)*x,e[6]=(f*s*r-a*m*r-f*i*c+t*m*c+a*i*g-t*s*g)*x,e[7]=(a*d*r-l*s*r+l*i*c-t*d*c-a*i*h+t*s*h)*x,e[8]=y*x,e[9]=(f*u*r-l*p*r-f*n*h+t*p*h+l*n*g-t*u*g)*x,e[10]=(a*p*r-f*o*r+f*n*c-t*p*c-a*n*g+t*o*g)*x,e[11]=(l*o*r-a*u*r-l*n*c+t*u*c+a*n*h-t*o*h)*x,e[12]=b*x,e[13]=(l*p*i-f*u*i+f*n*d-t*p*d-l*n*m+t*u*m)*x,e[14]=(f*o*i-a*p*i-f*n*s+t*p*s+a*n*m-t*o*m)*x,e[15]=(a*u*i-l*o*i+l*n*s-t*u*s-a*n*d+t*o*d)*x,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const 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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,s=e.z,c=r*a,l=r*o;return this.set(c*a+n,c*o-i*s,c*s+i*o,0,c*o+i*s,l*o+n,l*s-i*a,0,c*s-i*o,l*s+i*a,r*s*s+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,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,s=t._w,c=r+r,l=a+a,u=o+o,d=r*c,h=r*l,f=r*u,p=a*l,m=a*u,g=o*u,C=s*c,v=s*l,y=s*u,b=n.x,M=n.y,x=n.z;return i[0]=(1-(p+g))*b,i[1]=(h+y)*b,i[2]=(f-v)*b,i[3]=0,i[4]=(h-y)*M,i[5]=(1-(d+g))*M,i[6]=(m+C)*M,i[7]=0,i[8]=(f+v)*x,i[9]=(m-C)*x,i[10]=(1-(d+p))*x,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Tt.set(i[0],i[1],i[2]).length();const a=Tt.set(i[4],i[5],i[6]).length(),o=Tt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],zt.copy(this);const s=1/r,c=1/a,l=1/o;return zt.elements[0]*=s,zt.elements[1]*=s,zt.elements[2]*=s,zt.elements[4]*=c,zt.elements[5]*=c,zt.elements[6]*=c,zt.elements[8]*=l,zt.elements[9]*=l,zt.elements[10]*=l,t.setFromRotationMatrix(zt),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*r/(t-e),c=2*r/(n-i),l=(t+e)/(t-e),u=(n+i)/(n-i),d=-(a+r)/(a-r),h=-2*a*r/(a-r);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=h,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a){const o=this.elements,s=1/(t-e),c=1/(n-i),l=1/(a-r),u=(t+e)*s,d=(n+i)*c,h=(a+r)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-h,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])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){const 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}}Et.prototype.isMatrix4=!0;const Tt=new $e,zt=new Et,At=new $e(0,0,0),Vt=new $e(1,1,1),Ht=new $e,Rt=new $e,Pt=new $e,It=new Et,kt=new Je;class Nt{constructor(e=0,t=0,n=0,i=Nt.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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){const i=e.elements,r=i[0],a=i[4],o=i[8],s=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":this._y=Math.asin(be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-be(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,h),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(be(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,r));break;case"ZYX":this._y=Math.asin(-be(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(be(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,h));break;case"XZY":this._z=Math.asin(-be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return It.makeRotationFromQuaternion(e),this.setFromRotationMatrix(It,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return kt.setFromEuler(this),this.setFromQuaternion(kt,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],void 0!==e[3]&&(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}toVector3(e){return e?e.set(this._x,this._y,this._z):new $e(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Nt.prototype.isEuler=!0,Nt.DefaultOrder="XYZ",Nt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Dt{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}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.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.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Qt.subVectors(i,t),en.subVectors(n,t),tn.subVectors(e,t);const a=Qt.dot(Qt),o=Qt.dot(en),s=Qt.dot(tn),c=en.dot(en),l=en.dot(tn),u=a*c-o*o;if(0===u)return r.set(-2,-1,-1);const d=1/u,h=(c*s-o*l)*d,f=(a*l-o*s)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,nn),nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1}static getUV(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,nn),s.set(0,0),s.addScaledVector(r,nn.x),s.addScaledVector(a,nn.y),s.addScaledVector(o,nn.z),s}static isFrontFacing(e,t,n,i){return Qt.subVectors(n,t),en.subVectors(e,t),Qt.cross(en).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Qt.subVectors(this.c,this.b),en.subVectors(this.a,this.b),.5*Qt.cross(en).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return un.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return un.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return un.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;rn.subVectors(i,n),an.subVectors(r,n),sn.subVectors(e,n);const s=rn.dot(sn),c=an.dot(sn);if(s<=0&&c<=0)return t.copy(n);cn.subVectors(e,i);const l=rn.dot(cn),u=an.dot(cn);if(l>=0&&u<=l)return t.copy(i);const d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(rn,a);ln.subVectors(e,r);const h=rn.dot(ln),f=an.dot(ln);if(f>=0&&h<=f)return t.copy(r);const p=h*c-s*f;if(p<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(an,o);const m=l*f-h*u;if(m<=0&&u-l>=0&&h-f>=0)return on.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(on,o);const g=1/(m+p+d);return a=p*g,o=d*g,t.copy(n).addScaledVector(rn,a).addScaledVector(an,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let dn=0;class hn extends pe{constructor(){super(),Object.defineProperty(this,"id",{value:dn++}),this.uuid=ye(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=le,this.stencilZFail=le,this.stencilZPass=le,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(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.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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,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.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;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,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){!0===e&&this.version++}}hn.prototype.isMaterial=!0;class fn extends hn{constructor(e){super(),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.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.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}}fn.prototype.isMeshBasicMaterial=!0;const pn=new $e,mn=new Ee;class gn{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=ue,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.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;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Nn.copy(n.boundingSphere),Nn.applyMatrix4(r),!1===e.ray.intersectsSphere(Nn))return;if(In.copy(r).invert(),kn.copy(e.ray).applyMatrix4(In),null!==n.boundingBox&&!1===kn.intersectsBox(n.boundingBox))return;let a;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position,s=n.morphAttributes.position,c=n.morphTargetsRelative,l=n.attributes.uv,u=n.attributes.uv2,d=n.groups,h=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,f=d.length;nn.far?null:{distance:l,point:Kn.clone(),object:e}}(e,t,n,i,Dn,On,Bn,$n);if(f){s&&(Xn.fromBufferAttribute(s,l),Yn.fromBufferAttribute(s,u),Jn.fromBufferAttribute(s,d),f.uv=un.getUV($n,Dn,On,Bn,Xn,Yn,Jn,new Ee)),c&&(Xn.fromBufferAttribute(c,l),Yn.fromBufferAttribute(c,u),Jn.fromBufferAttribute(c,d),f.uv2=un.getUV($n,Dn,On,Bn,Xn,Yn,Jn,new Ee));const e={a:l,b:u,c:d,normal:new $e,materialIndex:0};un.getNormal(Dn,On,Bn,e.normal),f.face=e}return f}Zn.prototype.isMesh=!0;class ei extends Pn{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const s=[],c=[],l=[],u=[];let d=0,h=0;function f(e,t,n,i,r,a,f,p,m,g,C){const v=a/m,y=f/g,b=a/2,M=f/2,x=p/2,_=m+1,S=g+1;let w=0,L=0;const E=new $e;for(let a=0;a0?1:-1,l.push(E.x,E.y,E.z),u.push(s/m),u.push(1-a/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}ri.prototype.isShaderMaterial=!0;class ai extends Zt{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}ai.prototype.isCamera=!0;class oi extends ai{constructor(e=50,t=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ve*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ce*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ve*Math.atan(Math.tan(.5*Ce*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(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=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ce*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/o,i*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}oi.prototype.isPerspectiveCamera=!0;const si=90;class ci extends Zt{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new oi(si,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new $e(1,0,0)),this.add(i);const r=new oi(si,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new $e(-1,0,0)),this.add(r);const a=new oi(si,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new $e(0,1,0)),this.add(a);const o=new oi(si,1,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new $e(0,-1,0)),this.add(o);const s=new oi(si,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new $e(0,0,1)),this.add(s);const c=new oi(si,1,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new $e(0,0,-1)),this.add(c)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,a,o,s,c]=this.children,l=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=l,n.texture.needsPMREMUpdate=!0}}class li extends We{constructor(e,t,n,i,r,o,s,c,l,u){super(e=void 0!==e?e:[],t=void 0!==t?t:a,n,i,r,o,s,c,l,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}li.prototype.isCubeTexture=!0;class ui extends qe{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new li(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:C}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=L,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new ei(5,5,5),i=new ri({name:"CubemapFromEquirect",uniforms:ti({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});i.uniforms.tEquirect.value=t;const r=new Zn(n,i),a=t.minFilter;return t.minFilter===y&&(t.minFilter=C),new ci(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}ui.prototype.isWebGLCubeRenderTarget=!0;const di=new $e,hi=new $e,fi=new Te;class pi{constructor(e=new $e(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=di.subVectors(n,t).cross(hi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(di),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const 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){const n=t||fi.getNormalMatrix(e),i=this.coplanarPoint(di).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}}pi.prototype.isPlane=!0;const mi=new vt,gi=new $e;class Ci{constructor(e=new pi,t=new pi,n=new pi,i=new pi,r=new pi,a=new pi){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],h=n[9],f=n[10],p=n[11],m=n[12],g=n[13],C=n[14],v=n[15];return t[0].setComponents(o-i,u-s,p-d,v-m).normalize(),t[1].setComponents(o+i,u+s,p+d,v+m).normalize(),t[2].setComponents(o+r,u+c,p+h,v+g).normalize(),t[3].setComponents(o-r,u-c,p-h,v-g).normalize(),t[4].setComponents(o-a,u-l,p-f,v-C).normalize(),t[5].setComponents(o+a,u+l,p+f,v+C).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(mi)}intersectsSprite(e){return mi.center.set(0,0,0),mi.radius=.7071067811865476,mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(mi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,gi.y=i.normal.y>0?e.max.y:e.min.y,gi.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(gi)<0)return!1}return!0}containsPoint(e){const 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 vi(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function yi(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid 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 ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},xi={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Te},uv2Transform:{value:new Te},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},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:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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},alphaTest:{value:0},uvTransform:{value:new Te}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Te}}},_i={basic:{uniforms:ni([xi.common,xi.specularmap,xi.envmap,xi.aomap,xi.lightmap,xi.fog]),vertexShader:Mi.meshbasic_vert,fragmentShader:Mi.meshbasic_frag},lambert:{uniforms:ni([xi.common,xi.specularmap,xi.envmap,xi.aomap,xi.lightmap,xi.emissivemap,xi.fog,xi.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Mi.meshlambert_vert,fragmentShader:Mi.meshlambert_frag},phong:{uniforms:ni([xi.common,xi.specularmap,xi.envmap,xi.aomap,xi.lightmap,xi.emissivemap,xi.bumpmap,xi.normalmap,xi.displacementmap,xi.fog,xi.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30}}]),vertexShader:Mi.meshphong_vert,fragmentShader:Mi.meshphong_frag},standard:{uniforms:ni([xi.common,xi.envmap,xi.aomap,xi.lightmap,xi.emissivemap,xi.bumpmap,xi.normalmap,xi.displacementmap,xi.roughnessmap,xi.metalnessmap,xi.fog,xi.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mi.meshphysical_vert,fragmentShader:Mi.meshphysical_frag},toon:{uniforms:ni([xi.common,xi.aomap,xi.lightmap,xi.emissivemap,xi.bumpmap,xi.normalmap,xi.displacementmap,xi.gradientmap,xi.fog,xi.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Mi.meshtoon_vert,fragmentShader:Mi.meshtoon_frag},matcap:{uniforms:ni([xi.common,xi.bumpmap,xi.normalmap,xi.displacementmap,xi.fog,{matcap:{value:null}}]),vertexShader:Mi.meshmatcap_vert,fragmentShader:Mi.meshmatcap_frag},points:{uniforms:ni([xi.points,xi.fog]),vertexShader:Mi.points_vert,fragmentShader:Mi.points_frag},dashed:{uniforms:ni([xi.common,xi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mi.linedashed_vert,fragmentShader:Mi.linedashed_frag},depth:{uniforms:ni([xi.common,xi.displacementmap]),vertexShader:Mi.depth_vert,fragmentShader:Mi.depth_frag},normal:{uniforms:ni([xi.common,xi.bumpmap,xi.normalmap,xi.displacementmap,{opacity:{value:1}}]),vertexShader:Mi.meshnormal_vert,fragmentShader:Mi.meshnormal_frag},sprite:{uniforms:ni([xi.sprite,xi.fog]),vertexShader:Mi.sprite_vert,fragmentShader:Mi.sprite_frag},background:{uniforms:{uvTransform:{value:new Te},t2D:{value:null}},vertexShader:Mi.background_vert,fragmentShader:Mi.background_frag},cube:{uniforms:ni([xi.envmap,{opacity:{value:1}}]),vertexShader:Mi.cube_vert,fragmentShader:Mi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mi.equirect_vert,fragmentShader:Mi.equirect_frag},distanceRGBA:{uniforms:ni([xi.common,xi.displacementmap,{referencePosition:{value:new $e},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mi.distanceRGBA_vert,fragmentShader:Mi.distanceRGBA_frag},shadow:{uniforms:ni([xi.lights,xi.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Mi.shadow_vert,fragmentShader:Mi.shadow_frag}};function Si(e,t,n,i,r,a){const o=new Oe(0);let s,c,u=!0===r?0:1,d=null,h=0,f=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,p(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,p(o,u)},render:function(n,r){let a=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const g=e.xr,C=g.getSession&&g.getSession();C&&"additive"===C.environmentBlendMode&&(m=null),null===m?p(o,u):m&&m.isColor&&(p(m,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===c&&(c=new Zn(new ei(1,1,1),new ri({name:"BackgroundCubeMaterial",uniforms:ti(_i.cube.uniforms),vertexShader:_i.cube.vertexShader,fragmentShader:_i.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=m,c.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,d===m&&h===m.version&&f===e.toneMapping||(c.material.needsUpdate=!0,d=m,h=m.version,f=e.toneMapping),n.unshift(c,c.geometry,c.material,0,0,null)):m&&m.isTexture&&(void 0===s&&(s=new Zn(new bi(2,2),new ri({name:"BackgroundMaterial",uniforms:ti(_i.background.uniforms),vertexShader:_i.background.vertexShader,fragmentShader:_i.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),d===m&&h===m.version&&f===e.toneMapping||(s.material.needsUpdate=!0,d=m,h=m.version,f=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null))}}}function wi(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||null!==a,s={},c=h(null);let l=c;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function h(e){const t=[],n=[],i=[];for(let e=0;e=0){let a=c[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,o=a.itemSize,c=n.get(a);if(void 0===c)continue;const l=c.buffer,u=c.type,d=c.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,c=n.stride,h=a.offset;if(n&&n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const c=a||t.has("WEBGL_draw_buffers"),l=!0===n.logarithmicDepthBuffer,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),f=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),C=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=d>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:d,maxTextureSize:h,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:C,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Ti(e){const t=this;let n=null,i=0,r=!1,a=!1;const o=new pi,s=new Te,c={value:null,needsUpdate:!1};function l(){c.value!==n&&(c.value=n,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,r){const a=null!==e?e.length:0;let l=null;if(0!==a){if(l=c.value,!0!==r||null===l){const t=i+4*a,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===l||l.length0){const o=new ui(a.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener("dispose",i),n(o.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}_i.physical={uniforms:ni([_i.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Mi.meshphysical_vert,fragmentShader:Mi.meshphysical_frag};class Ai extends ai{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(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=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,s=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}Ai.prototype.isOrthographicCamera=!0;class Vi extends ri{constructor(e){super(e),this.type="RawShaderMaterial"}}Vi.prototype.isRawShaderMaterial=!0;const Hi=Math.pow(2,8),Ri=[.125,.215,.35,.446,.526,.582],Pi=5+Ri.length,Ii=new Ai,{_lodPlanes:ki,_sizeLods:Ni,_sigmas:Di}=function(){const e=[],t=[],n=[];let i=8;for(let r=0;r4?o=Ri[r-8+4-1]:0===r&&(o=0),n.push(o);const s=1/(a-1),c=-s/2,l=1+s/2,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,p=2,m=1,g=new Float32Array(f*h*d),C=new Float32Array(p*h*d),v=new Float32Array(m*h*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(i,f*h*e),C.set(u,p*h*e);const r=[e,e,e,e,e,e];v.set(r,m*h*e)}const y=new Pn;y.setAttribute("position",new gn(g,f)),y.setAttribute("uv",new gn(C,p)),y.setAttribute("faceIndex",new gn(v,m)),e.push(y),i>4&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Oi=new Oe;let Bi=null;const Fi=(1+Math.sqrt(5))/2,Ui=1/Fi,Wi=[new $e(1,1,1),new $e(-1,1,1),new $e(1,1,-1),new $e(-1,1,-1),new $e(0,Fi,Ui),new $e(0,Fi,-Ui),new $e(Ui,0,Fi),new $e(-Ui,0,Fi),new $e(Fi,Ui,0),new $e(-Fi,Ui,0)];class Gi{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(20),n=new $e(0,1,0);return new Vi({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Bi=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,i,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(){null===this._cubemapShader&&(this._cubemapShader=Yi(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Xi(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e2?Hi:0,Hi,Hi),s.setRenderTarget(i),h&&s.render(d,r),s.render(e,r)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===a||e.mapping===o;i?(null===this._cubemapShader&&(this._cubemapShader=Yi()),this._cubemapShader.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectShader&&(this._equirectShader=Xi());const r=i?this._cubemapShader:this._equirectShader,s=new Zn(ki[0],r),c=r.uniforms;c.envMap.value=e,i||c.texelSize.value.set(1/e.image.width,1/e.image.height),qi(t,0,0,3*Hi,2*Hi),n.setRenderTarget(t),n.render(s,Ii)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/f,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e4?i-8+4:0),3*C,2*C),s.setRenderTarget(t),s.render(l,Ii)}}function ji(e){const t=new qe(3*Hi,3*Hi,e);return t.texture.mapping=l,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function qi(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Xi(){const e=new Ee(1,1);return new Vi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = texture2D ( envMap, uv ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Yi(){return new Vi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ji(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const l=r.mapping,u=l===s||l===c,d=l===a||l===o;if(u||d){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Gi(e)),i=u?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const a=r.image;if(u&&a&&a.height>0||d&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new Gi(e));const a=u?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function $i(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ki(e,t,n,i){const r={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete r[s.id];const c=a.get(s);c&&(t.remove(c),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let o=0;if(null!==i){const e=i.array;o=i.version;for(let t=0,i=e.length;tt.maxTextureSize&&(x=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const S=new Float32Array(M*x*4*f),w=new er(S,M,x,f);w.format=L,w.type=_,w.needsUpdate=!0;const E=4*b;for(let z=0;z0)return e;const r=t*n;let a=dr[r];if(void 0===a&&(a=new Float32Array(r),dr[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Cr(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n/gm;function ba(e){return e.replace(ya,Ma)}function Ma(e,t){const n=Mi[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return ba(n)}const xa=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,_a=/#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 Sa(e){return e.replace(_a,La).replace(xa,wa)}function wa(e,t,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),La(0,t,n,i)}function La(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(y+="\n"),b=[g,C].filter(ga).join("\n"),b.length>0&&(b+="\n")):(y=[Ea(n),"#define SHADER_NAME "+n.shaderName,C,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ga).join("\n"),b=[g,Ea(n),"#define SHADER_NAME "+n.shaderName,C,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.envMap?"#define "+p:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Mi.tonemapping_pars_fragment:"",0!==n.toneMapping?ma("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.transparent?"":"#define OPAQUE",Mi.encodings_pars_fragment,pa("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ga).join("\n")),c=ba(c),c=Ca(c,n),c=va(c,n),d=ba(d),d=Ca(d,n),d=va(d,n),c=Sa(c),d=Sa(d),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(M="#version 300 es\n",y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,b=["#define varying in",n.glslVersion===he?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===he?"":"#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("\n")+"\n"+b);const x=M+y+c,_=M+b+d,S=da(r,r.VERTEX_SHADER,x),w=da(r,r.FRAGMENT_SHADER,_);if(r.attachShader(v,S),r.attachShader(v,w),void 0!==n.index0AttributeName?r.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(v).trim(),t=r.getShaderInfoLog(S).trim(),n=r.getShaderInfoLog(w).trim();let i=!0,a=!0;if(!1===r.getProgramParameter(v,r.LINK_STATUS)){i=!1;const t=fa(r,S,"vertex"),n=fa(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+n)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==n||(a=!1);a&&(this.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:y},fragmentShader:{log:n,prefix:b}})}let L,E;return r.deleteShader(S),r.deleteShader(w),this.getUniforms=function(){return void 0===L&&(L=new ua(r,v)),L},this.getAttributes=function(){return void 0===E&&(E=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,H=a.clearcoat>0;return{isWebGL2:h,shaderID:S,shaderName:a.type,vertexShader:L,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:z,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:C,instancing:!0===b.isInstancedMesh,instancingColor:!0===b.isInstancedMesh&&null!==b.instanceColor,supportsVertexTextures:g,outputEncoding:null===A?e.outputEncoding:!0===A.isXRRenderTarget?A.texture.encoding:se,map:!!a.map,matcap:!!a.matcap,envMap:!!_,envMapMode:_&&_.mapping,envMapCubeUV:!!_&&(_.mapping===l||_.mapping===u),lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:1===a.normalMapType,tangentSpaceNormalMap:0===a.normalMapType,decodeVideoTexture:!!a.map&&!0===a.map.isVideoTexture&&a.map.encoding===ce,clearcoat:H,clearcoatMap:H&&!!a.clearcoatMap,clearcoatRoughnessMap:H&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:H&&!!a.clearcoatNormalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,transparent:a.transparent,alphaMap:!!a.alphaMap,alphaTest:V,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!b.geometry&&!!b.geometry.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!b.geometry&&!!b.geometry.attributes.color&&4===b.geometry.attributes.color.itemSize,vertexUvs:!!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatMap||a.clearcoatRoughnessMap||a.clearcoatNormalMap||a.displacementMap||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheenColorMap||a.sheenRoughnessMap),uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!M,useFog:a.fog,fogExp2:M&&M.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:f,skinning:!0===b.isSkinnedMesh&&w>0,maxBones:w,useVertexTexture:p,morphTargets:!!b.geometry&&!!b.geometry.morphAttributes.position,morphNormals:!!b.geometry&&!!b.geometry.morphAttributes.normal,morphTargetsCount:b.geometry&&b.geometry.morphAttributes.position?b.geometry.morphAttributes.position.length:0,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&d.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,depthPacking:void 0!==a.depthPacking&&a.depthPacking,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.maxBones),e.push(t.morphTargetsCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0),t.supportsVertexTextures&&s.enable(1),t.instancing&&s.enable(2),t.instancingColor&&s.enable(3),t.map&&s.enable(4),t.matcap&&s.enable(5),t.envMap&&s.enable(6),t.envMapCubeUV&&s.enable(7),t.lightMap&&s.enable(8),t.aoMap&&s.enable(9),t.emissiveMap&&s.enable(10),t.bumpMap&&s.enable(11),t.normalMap&&s.enable(12),t.objectSpaceNormalMap&&s.enable(13),t.tangentSpaceNormalMap&&s.enable(14),t.clearcoat&&s.enable(15),t.clearcoatMap&&s.enable(16),t.clearcoatRoughnessMap&&s.enable(17),t.clearcoatNormalMap&&s.enable(18),t.displacementMap&&s.enable(19),t.specularMap&&s.enable(20),t.roughnessMap&&s.enable(21),t.metalnessMap&&s.enable(22),t.gradientMap&&s.enable(23),t.alphaMap&&s.enable(24),t.alphaTest&&s.enable(25),t.vertexColors&&s.enable(26),t.vertexAlphas&&s.enable(27),t.vertexUvs&&s.enable(28),t.vertexTangents&&s.enable(29),t.uvsVertexOnly&&s.enable(30),t.fog&&s.enable(31),e.push(s.mask),s.disableAll(),t.useFog&&s.enable(0),t.flatShading&&s.enable(1),t.logarithmicDepthBuffer&&s.enable(2),t.skinning&&s.enable(3),t.useVertexTexture&&s.enable(4),t.morphTargets&&s.enable(5),t.morphNormals&&s.enable(6),t.premultipliedAlpha&&s.enable(7),t.shadowMapEnabled&&s.enable(8),t.physicallyCorrectLights&&s.enable(9),t.doubleSided&&s.enable(10),t.flipSided&&s.enable(11),t.depthPacking&&s.enable(12),t.dithering&&s.enable(13),t.specularIntensityMap&&s.enable(14),t.specularColorMap&&s.enable(15),t.transmission&&s.enable(16),t.transmissionMap&&s.enable(17),t.thicknessMap&&s.enable(18),t.sheen&&s.enable(19),t.sheenColorMap&&s.enable(20),t.sheenRoughnessMap&&s.enable(21),t.decodeVideoTexture&&s.enable(22),t.transparent&&s.enable(23),e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=v[e.type];let n;if(t){const e=_i[t];n=ii.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=d.length;e0?i.push(u):!0===o.transparent?r.push(u):n.push(u)},unshift:function(e,t,o,s,c,l){const u=a(e,t,o,s,c,l);o.transmission>0?i.unshift(u):!0===o.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Pa),i.length>1&&i.sort(t||Ia),r.length>1&&r.sort(t||Ia)}}}function Na(){let e=new WeakMap;return{get:function(t,n){let i;return!1===e.has(t)?(i=new ka,e.set(t,[i])):n>=e.get(t).length?(i=new ka,e.get(t).push(i)):i=e.get(t)[n],i},dispose:function(){e=new WeakMap}}}function Da(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new $e,color:new Oe};break;case"SpotLight":n={position:new $e,direction:new $e,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new $e,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new $e,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new $e,halfWidth:new $e,halfHeight:new $e}}return e[t.id]=n,n}}}let Oa=0;function Ba(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Fa(e,t){const n=new Da,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new $e);const a=new $e,o=new Et,s=new Et;return{setup:function(a,o){let s=0,c=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let u=0,d=0,h=0,f=0,p=0,m=0,g=0,C=0;a.sort(Ba);const v=!0!==o?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=xi.LTC_FLOAT_1,r.rectAreaLTC2=xi.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=xi.LTC_HALF_1,r.rectAreaLTC2=xi.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=s,r.ambient[1]=c,r.ambient[2]=l;const y=r.hash;y.directionalLength===u&&y.pointLength===d&&y.spotLength===h&&y.rectAreaLength===f&&y.hemiLength===p&&y.numDirectionalShadows===m&&y.numPointShadows===g&&y.numSpotShadows===C||(r.directional.length=u,r.spot.length=h,r.rectArea.length=f,r.point.length=d,r.hemi.length=p,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=C,r.spotShadowMap.length=C,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=C,y.directionalLength=u,y.pointLength=d,y.spotLength=h,y.rectAreaLength=f,y.hemiLength=p,y.numDirectionalShadows=m,y.numPointShadows=g,y.numSpotShadows=C,r.version=Oa++)},setupView:function(e,t){let n=0,i=0,c=0,l=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t=n.get(i).length?(a=new Ua(e,t),n.get(i).push(a)):a=n.get(i)[r],a},dispose:function(){n=new WeakMap}}}class Ga extends hn{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}Ga.prototype.isMeshDepthMaterial=!0;class ja extends hn{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new $e,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function qa(e,t,n){let i=new Ci;const r=new Ee,a=new Ee,o=new je,s=new Ga({depthPacking:3201}),c=new ja,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},h=new ri({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const m=new Pn;m.setAttribute("position",new gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Zn(m,h),v=this;function y(n,i){const r=t.update(g);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,f.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,h,g,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,f,g,null)}function b(t,n,i,r,a,o,u){let h=null;const f=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(h=void 0!==f?f:!0===r.isPointLight?c:s,e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0){const e=h.uuid,t=i.uuid;let n=l[e];void 0===n&&(n={},l[e]=n);let r=n[t];void 0===r&&(r=h.clone(),n[t]=r),h=r}return h.visible=i.visible,h.wireframe=i.wireframe,h.side=3===u?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],h.alphaMap=i.alphaMap,h.alphaTest=i.alphaTest,h.clipShadows=i.clipShadows,h.clippingPlanes=i.clippingPlanes,h.clipIntersection=i.clipIntersection,h.displacementMap=i.displacementMap,h.displacementScale=i.displacementScale,h.displacementBias=i.displacementBias,h.wireframeLinewidth=i.wireframeLinewidth,h.linewidth=i.linewidth,!0===r.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(r.matrixWorld),h.nearDistance=a,h.farDistance=o),h}function M(n,r,a,o,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let c=0,l=t.length;cu||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/f.x),r.x=a.x*f.x,d.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/f.y),r.y=a.y*f.y,d.mapSize.y=a.y)),null===d.map&&!d.isPointLightShadow&&3===this.type){const e={minFilter:C,magFilter:C,format:L};d.map=new qe(r.x,r.y,e),d.map.texture.name=l.name+".shadowMap",d.mapPass=new qe(r.x,r.y,e),d.camera.updateProjectionMatrix()}if(null===d.map){const e={minFilter:p,magFilter:p,format:L};d.map=new qe(r.x,r.y,e),d.map.texture.name=l.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const m=d.getViewportCount();for(let e=0;e=1):-1!==A.indexOf("OpenGL ES")&&(z=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),T=z>=2);let V=null,H={};const R=e.getParameter(e.SCISSOR_BOX),P=e.getParameter(e.VIEWPORT),I=(new je).fromArray(R),k=(new je).fromArray(P);function N(t,n,i){const r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let t=0;ti||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?we:Math.floor,a=i(r*e.width),o=i(r*e.height);void 0===H&&(H=P(a,o));const s=n?P(a,o):H;return s.width=a,s.height=o,s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function k(e){return _e(e.width)&&_e(e.height)}function N(e,t){return e.generateMipmaps&&t&&e.minFilter!==p&&e.minFilter!==C}function D(t){e.generateMipmap(t)}function O(n,i,r,a,o=!1){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let c=i;return i===e.RED&&(r===e.FLOAT&&(c=e.R32F),r===e.HALF_FLOAT&&(c=e.R16F),r===e.UNSIGNED_BYTE&&(c=e.R8)),i===e.RG&&(r===e.FLOAT&&(c=e.RG32F),r===e.HALF_FLOAT&&(c=e.RG16F),r===e.UNSIGNED_BYTE&&(c=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(c=e.RGBA32F),r===e.HALF_FLOAT&&(c=e.RGBA16F),r===e.UNSIGNED_BYTE&&(c=a===ce&&!1===o?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)),c!==e.R16F&&c!==e.R32F&&c!==e.RG16F&&c!==e.RG32F&&c!==e.RGBA16F&&c!==e.RGBA32F||t.get("EXT_color_buffer_float"),c}function B(e,t,n){return!0===N(e,n)||e.isFramebufferTexture&&e.minFilter!==p&&e.minFilter!==C?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function F(t){return t===p||t===m||t===g?e.NEAREST:e.LINEAR}function U(t){const n=t.target;n.removeEventListener("dispose",U),function(t){const n=i.get(t);void 0!==n.__webglInit&&(e.deleteTexture(n.__webglTexture),i.remove(t))}(n),n.isVideoTexture&&V.delete(n),o.memory.textures--}function W(t){const n=t.target;n.removeEventListener("dispose",W),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(t){if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=n.length;t0&&a.__version!==t.version){const e=t.image;if(void 0===e)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==e.complete)return void K(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function q(t,r){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,i,r){if(6!==i.image.length)return;$(t,i),n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const o=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),c=i.image[0]&&i.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=o||c?c?i.image[e].image:i.image[e]:I(i.image[e],!1,!0,l),u[e]=ne(i,u[e]);const d=u[0],h=k(d)||s,f=a.convert(i.format,i.encoding),p=a.convert(i.type),m=O(i.internalFormat,f,p,i.encoding),g=s&&!0!==i.isVideoTexture,C=void 0===t.__version;let v,y=B(i,d,h);if(J(e.TEXTURE_CUBE_MAP,i,h),o){g&&C&&n.texStorage2D(e.TEXTURE_CUBE_MAP,y,m,d.width,d.height);for(let t=0;t<6;t++){v=u[t].mipmaps;for(let r=0;r0&&y++,n.texStorage2D(e.TEXTURE_CUBE_MAP,y,m,u[0].width,u[0].height));for(let t=0;t<6;t++)if(c){g?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,u[t].width,u[t].height,f,p,u[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,m,u[t].width,u[t].height,0,f,p,u[t].data);for(let i=0;i1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function $(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),o.memory.textures++)}function K(t,i,r){let o=e.TEXTURE_2D;i.isDataTexture2DArray&&(o=e.TEXTURE_2D_ARRAY),i.isDataTexture3D&&(o=e.TEXTURE_3D),$(t,i),n.activeTexture(e.TEXTURE0+r),n.bindTexture(o,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const c=function(e){return!s&&(e.wrapS!==h||e.wrapT!==h||e.minFilter!==p&&e.minFilter!==C)}(i)&&!1===k(i.image);let l=I(i.image,c,!1,u);l=ne(i,l);const d=k(l)||s,f=a.convert(i.format,i.encoding);let m,g=a.convert(i.type),v=O(i.internalFormat,f,g,i.encoding,i.isVideoTexture);J(o,i,d);const y=i.mipmaps,b=s&&!0!==i.isVideoTexture,S=void 0===t.__version,z=B(i,l,d);if(i.isDepthTexture)v=e.DEPTH_COMPONENT,s?v=i.type===_?e.DEPTH_COMPONENT32F:i.type===x?e.DEPTH_COMPONENT24:i.type===w?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:i.type===_&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===E&&v===e.DEPTH_COMPONENT&&i.type!==M&&i.type!==x&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=M,g=a.convert(i.type)),i.format===T&&v===e.DEPTH_COMPONENT&&(v=e.DEPTH_STENCIL,i.type!==w&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=w,g=a.convert(i.type))),b&&S?n.texStorage2D(e.TEXTURE_2D,1,v,l.width,l.height):n.texImage2D(e.TEXTURE_2D,0,v,l.width,l.height,0,f,g,null);else if(i.isDataTexture)if(y.length>0&&d){b&&S&&n.texStorage2D(e.TEXTURE_2D,z,v,y[0].width,y[0].height);for(let t=0,i=y.length;t0&&d){b&&S&&n.texStorage2D(e.TEXTURE_2D,z,v,y[0].width,y[0].height);for(let t=0,i=y.length;t=c&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+c),G+=1,e},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?K(a,t,r):(n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture))},this.setTexture3D=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?K(a,t,r):(n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_3D,a.__webglTexture))},this.setTextureCube=q,this.rebindTextures=function(t,n,r){const a=i.get(t);void 0!==n&&Z(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==r&&ee(t)},this.setupRenderTarget=function(t){const c=t.texture,l=i.get(t),u=i.get(c);t.addEventListener("dispose",W),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=c.version,o.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,f=c.isDataTexture3D||c.isDataTexture2DArray,p=k(t)||s;if(d){l.__webglFramebuffer=[];for(let t=0;t<6;t++)l.__webglFramebuffer[t]=e.createFramebuffer()}else if(l.__webglFramebuffer=e.createFramebuffer(),h)if(r.drawBuffers){const n=t.texture;for(let t=0,r=n.length;ts+l?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1));return null!==o&&(o.visible=null!==i),null!==s&&(s.visible=null!==r),null!==c&&(c.visible=null!==a),this}}class eo extends We{constructor(e,t,n,i,r,a,o,s,c,l){if((l=void 0!==l?l:E)!==E&&l!==T)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===E&&(n=M),void 0===n&&l===T&&(n=w),super(null,i,r,a,o,s,l,n,c),this.image={width:e,height:t},this.magFilter=void 0!==o?o:p,this.minFilter=void 0!==s?s:p,this.flipY=!1,this.generateMipmaps=!1}}eo.prototype.isDepthTexture=!0;class to extends pe{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor";const s=e.extensions.has("WEBGL_multisampled_render_to_texture");let c=null,l=null,u=null,d=null,h=!1,f=null;const p=t.getContextAttributes();let m=null,g=null;const C=[],v=new Map,y=new oi;y.layers.enable(1),y.viewport=new je;const x=new oi;x.layers.enable(2),x.viewport=new je;const _=[y,x],S=new $a;S.layers.enable(1),S.layers.enable(2);let z=null,A=null;function V(e){const t=v.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function H(){v.forEach((function(e,t){e.disconnect(t)})),v.clear(),z=null,A=null,e.setRenderTarget(m),d=null,u=null,l=null,i=null,g=null,D.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function R(e){const t=i.inputSources;for(let e=0;e0&&(t.alphaTest.value=n.alphaTest);const i=e.get(n).envMap;let r,a;i&&(t.envMap.value=i,t.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap?r=n.clearcoatRoughnessMap:n.specularIntensityMap?r=n.specularIntensityMap:n.specularColorMap?r=n.specularColorMap:n.transmissionMap?r=n.transmissionMap:n.thicknessMap?r=n.thicknessMap:n.sheenColorMap?r=n.sheenColorMap:n.sheenRoughnessMap&&(r=n.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),n.aoMap?a=n.aoMap:n.lightMap&&(a=n.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),t.uv2Transform.value.copy(a.matrix))}function n(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,i,r,a,o){i.isMeshBasicMaterial?t(e,i):i.isMeshLambertMaterial?(t(e,i),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,i)):i.isMeshToonMaterial?(t(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshPhongMaterial?(t(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshStandardMaterial?(t(e,i),i.isMeshPhysicalMaterial?function(e,t,i){n(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap)),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate())),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,i,o):n(e,i)):i.isMeshMatcapMaterial?(t(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshDepthMaterial?(t(e,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isMeshDistanceMaterial?(t(e,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,i)):i.isMeshNormalMaterial?(t(e,i),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,i)):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,n,i){let r;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*i,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?r=t.map:t.alphaMap&&(r=t.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,i,r,a):i.isSpriteMaterial?function(e,t){let n;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?n=t.map:t.alphaMap&&(n=t.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function io(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=He("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,a=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,c=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let d=null,f=null;const m=[],g=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=se,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const C=this;let v=!1,M=0,x=0,w=null,E=-1,T=null;const z=new je,A=new je;let V=null,H=t.width,R=t.height,P=1,I=null,k=null;const N=new je(0,0,H,R),D=new je(0,0,H,R);let O=!1;const B=new Ci;let F=!1,U=!1,W=null;const G=new Et,j=new $e,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return null===w?P:1}let Y,J,$,K,Z,Q,ee,te,ne,ie,re,ae,oe,ce,le,ue,de,he,fe,pe,me,ge,Ce,ve=n;function ye(e,n){for(let i=0;i0&&function(e,t,n){if(null===W){const e=!0===o&&!0===J.isWebGL2;W=new(e?Ye:qe)(1024,1024,{generateMipmaps:!0,type:null!==ge.convert(S)?S:b,minFilter:y,magFilter:p,wrapS:h,wrapT:h,useRenderToTexture:Y.has("WEBGL_multisampled_render_to_texture")})}const i=C.getRenderTarget();C.setRenderTarget(W),C.clear();const r=C.toneMapping;C.toneMapping=0,Ve(e,t,n),C.toneMapping=r,Q.updateMultisampleRenderTarget(W),Q.updateRenderTargetMipmap(W),C.setRenderTarget(i)}(r,t,n),i&&$.viewport(z.copy(i)),r.length>0&&Ve(r,t,n),a.length>0&&Ve(a,t,n),s.length>0&&Ve(s,t,n)}function Ve(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?g[g.length-1]:null,m.pop(),d=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){Z.get(e.texture).__webglTexture=t,Z.get(e.depthTexture).__webglTexture=n;const i=Z.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||e.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),e.useRenderToTexture=!1,e.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(e,t){const n=Z.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){w=e,M=t,x=n;let i=!0;if(e){const t=Z.get(e);void 0!==t.__useDefaultFramebuffer?($.bindFramebuffer(ve.FRAMEBUFFER,null),i=!1):void 0===t.__webglFramebuffer?Q.setupRenderTarget(e):t.__hasExternalTextures&&Q.rebindTextures(e,Z.get(e.texture).__webglTexture,Z.get(e.depthTexture).__webglTexture)}let r=null,a=!1,o=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const i=Z.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=i[t],a=!0):r=e.useRenderbuffer?Z.get(e).__webglMultisampledFramebuffer:i,z.copy(e.viewport),A.copy(e.scissor),V=e.scissorTest}else z.copy(N).multiplyScalar(P).floor(),A.copy(D).multiplyScalar(P).floor(),V=O;if($.bindFramebuffer(ve.FRAMEBUFFER,r)&&J.drawBuffers&&i&&$.drawBuffers(e,r),$.viewport(z),$.scissor(A),$.setScissorTest(V),a){const i=Z.get(e.texture);ve.framebufferTexture2D(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,ve.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(o){const i=Z.get(e.texture),r=t||0;ve.framebufferTextureLayer(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}E=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=Z.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){$.bindFramebuffer(ve.FRAMEBUFFER,s);try{const o=e.texture,s=o.format,c=o.type;if(s!==L&&ge.convert(s)!==ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=c===S&&(Y.has("EXT_color_buffer_half_float")||J.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(c===b||ge.convert(c)===ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_TYPE)||c===_&&(J.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");ve.checkFramebufferStatus(ve.FRAMEBUFFER)===ve.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ve.readPixels(t,n,i,r,ge.convert(s),ge.convert(c),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==w?Z.get(w).__webglFramebuffer:null;$.bindFramebuffer(ve.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){if(!0!==t.isFramebufferTexture)return void console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);Q.setTexture2D(t,0),ve.copyTexSubImage2D(ve.TEXTURE_2D,n,0,0,e.x,e.y,r,a),$.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,o=ge.convert(n.format),s=ge.convert(n.type);Q.setTexture2D(n,0),ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,n.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?ve.texSubImage2D(ve.TEXTURE_2D,i,e.x,e.y,r,a,o,s,t.image.data):t.isCompressedTexture?ve.compressedTexSubImage2D(ve.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):ve.texSubImage2D(ve.TEXTURE_2D,i,e.x,e.y,o,s,t.image),0===i&&n.generateMipmaps&&ve.generateMipmap(ve.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(C.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,c=ge.convert(i.format),l=ge.convert(i.type);let u;if(i.isDataTexture3D)Q.setTexture3D(i,0),u=ve.TEXTURE_3D;else{if(!i.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),u=ve.TEXTURE_2D_ARRAY}ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,i.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,i.unpackAlignment);const d=ve.getParameter(ve.UNPACK_ROW_LENGTH),h=ve.getParameter(ve.UNPACK_IMAGE_HEIGHT),f=ve.getParameter(ve.UNPACK_SKIP_PIXELS),p=ve.getParameter(ve.UNPACK_SKIP_ROWS),m=ve.getParameter(ve.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;ve.pixelStorei(ve.UNPACK_ROW_LENGTH,g.width),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,g.height),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,e.min.x),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,e.min.y),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isDataTexture3D?ve.texSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,l,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ve.compressedTexSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,g.data)):ve.texSubImage3D(u,r,t.x,t.y,t.z,a,o,s,c,l,g),ve.pixelStorei(ve.UNPACK_ROW_LENGTH,d),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,h),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,f),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,p),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&ve.generateMipmap(u),$.unbindTexture()},this.initTexture=function(e){Q.setTexture2D(e,0),$.unbindTexture()},this.resetState=function(){M=0,x=0,w=null,$.reset(),Ce.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}io.prototype.isWebGLRenderer=!0;class ro extends io{}ro.prototype.isWebGL1Renderer=!0;class ao{constructor(e,t=25e-5){this.name="",this.color=new Oe(e),this.density=t}clone(){return new ao(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}ao.prototype.isFogExp2=!0;class oo{constructor(e,t=1,n=1e3){this.name="",this.color=new Oe(e),this.near=t,this.far=n}clone(){return new oo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}oo.prototype.isFog=!0;class so extends Zt{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}so.prototype.isScene=!0;class co{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ue,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ye()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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 i=0,r=this.stride;ie.far||t.push({distance:s,point:po.clone(),uv:un.getUV(po,bo,Mo,xo,_o,So,wo,new Ee),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Eo(e,t,n,i,r,a){Co.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(vo.x=a*Co.x-r*Co.y,vo.y=r*Co.x+a*Co.y):vo.copy(Co),e.copy(t),e.x+=vo.x,e.y+=vo.y,e.applyMatrix4(yo)}Lo.prototype.isSprite=!0;const To=new $e,zo=new $e;class Ao extends Zt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){To.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(To);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){To.setFromMatrixPosition(e.matrixWorld),zo.setFromMatrixPosition(this.matrixWorld);const n=To.distanceTo(zo)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;is)continue;d.applyMatrix4(this.matrixWorld);const h=e.ray.origin.distanceTo(d);he.far||t.push({distance:h,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),i=Math.min(r.count,a.start+a.count)-1;ns)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}es.prototype.isLine=!0;const ts=new $e,ns=new $e;class is extends es{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function ds(e,t,n,i,r,a,o){const s=ss.distanceSqToPoint(e);if(sr.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}us.prototype.isPoints=!0;class hs extends We{constructor(e,t,n,i,r,a,o,s,c){super(e,t,n,i,r,a,o,s,c),this.minFilter=void 0!==a?a:C,this.magFilter=void 0!==r?r:C,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){l.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}hs.prototype.isVideoTexture=!0;class fs extends We{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=p,this.minFilter=p,this.generateMipmaps=!1,this.needsUpdate=!0}}fs.prototype.isFramebufferTexture=!0;class ps extends We{constructor(e,t,n,i,r,a,o,s,c,l,u,d){super(null,a,o,s,c,l,i,r,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}ps.prototype.isCompressedTexture=!0;class ms extends We{constructor(e,t,n,i,r,a,o,s,c){super(e,t,n,i,r,a,o,s,c),this.needsUpdate=!0}}ms.prototype.isCanvasTexture=!0;class gs extends Pn{constructor(e=1,t=8,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],s=[],c=new $e,l=new Ee;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const d=n+r/t*i;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new wn(a,3)),this.setAttribute("normal",new wn(o,3)),this.setAttribute("uv",new wn(s,2))}static fromJSON(e){return new gs(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Cs extends Pn{constructor(e=1,t=1,n=1,i=8,r=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:s};const c=this;i=Math.floor(i),r=Math.floor(r);const l=[],u=[],d=[],h=[];let f=0;const p=[],m=n/2;let g=0;function C(n){const r=f,a=new Ee,p=new $e;let C=0;const v=!0===n?e:t,y=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*y,0),d.push(0,y,0),h.push(.5,.5),f++;const b=f;for(let e=0;e<=i;e++){const t=e/i*s+o,n=Math.cos(t),r=Math.sin(t);p.x=v*r,p.y=m*y,p.z=v*n,u.push(p.x,p.y,p.z),d.push(0,y,0),a.x=.5*n+.5,a.y=.5*r*y+.5,h.push(a.x,a.y),f++}for(let e=0;e0&&C(!0),t>0&&C(!1)),this.setIndex(l),this.setAttribute("position",new wn(u,3)),this.setAttribute("normal",new wn(d,3)),this.setAttribute("uv",new wn(h,2))}static fromJSON(e){return new Cs(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class vs extends Cs{constructor(e=1,t=1,n=8,i=1,r=!1,a=0,o=2*Math.PI){super(0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new vs(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ys extends Pn{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function o(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const o=e.clone().lerp(n,i/r),s=t.clone().lerp(n,i/r),c=r-i;for(let e=0;e<=c;e++)a[i][e]=0===e&&i===r?o:o.clone().lerp(s,e/c)}for(let e=0;e.9&&o<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new wn(r,3)),this.setAttribute("normal",new wn(r.slice(),3)),this.setAttribute("uv",new wn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new ys(e.vertices,e.indices,e.radius,e.details)}}class bs extends ys{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new bs(e.radius,e.detail)}}const Ms=new $e,xs=new $e,_s=new $e,Ss=new un;class ws extends Pn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(Ce*t),a=e.getIndex(),o=e.getAttribute("position"),s=a?a.count:o.count,c=[0,0,0],l=["a","b","c"],u=new Array(3),d={},h=[];for(let e=0;e0)){c=i;break}c=i-1}if(i=c,n[i]===a)return i/(r-1);const l=n[i];return(i+(a-l)/(n[i+1]-l))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),s=t||(a.isVector2?new Ee:new $e);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new $e,i=[],r=[],a=[],o=new $e,s=new Et;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new $e)}r[0]=new $e,a[0]=new $e;let c=Number.MAX_VALUE;const l=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(i[t-1],i[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(be(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(be(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Es extends Ls{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new Ee,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(c)/r)+1)*r:0===l&&c===r-1&&(c=r-2,l=1),this.closed||c>0?o=i[(c-1)%r]:(As.subVectors(i[0],i[1]).add(i[0]),o=As);const u=i[c%r],d=i[(c+1)%r];if(this.closed||c+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Is(o,s.x,c.x,l.x,u.x),Is(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,a=this.curves[r],o=a.getLength(),s=0===o?0:1-e/o;return a.getPointAt(s,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);const l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ys extends Xs{constructor(e){super(e),this.uuid=ye(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n0)for(a=t;a=t;a-=i)o=gc(a,e[a],e[a+1],o);return o&&uc(o,o.next)&&(Cc(o),o=o.next),o}function $s(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!uc(i,i.next)&&0!==lc(i.prev,i,i.next))i=i.next;else{if(Cc(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Ks(e,t,n,i,r,a,o){if(!e)return;!o&&a&&function(e,t,n,i){let r=e;do{null===r.z&&(r.z=ac(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(o>1)}(r)}(e,i,r,a);let s,c,l=e;for(;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Qs(e,i,r,a):Zs(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),Cc(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?Ks(e=ec($s(e),t,n),t,n,i,r,a,2):2===o&&tc(e,t,n,i,r,a):Ks($s(e),t,n,i,r,a,1);break}}function Zs(e){const t=e.prev,n=e,i=e.next;if(lc(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(sc(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&lc(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Qs(e,t,n,i){const r=e.prev,a=e,o=e.next;if(lc(r,a,o)>=0)return!1;const s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,u=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,d=ac(s,c,t,n,i),h=ac(l,u,t,n,i);let f=e.prevZ,p=e.nextZ;for(;f&&f.z>=d&&p&&p.z<=h;){if(f!==e.prev&&f!==e.next&&sc(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&lc(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&sc(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&lc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=d;){if(f!==e.prev&&f!==e.next&&sc(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&lc(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&sc(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&lc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function ec(e,t,n){let i=e;do{const r=i.prev,a=i.next.next;!uc(r,a)&&dc(r,i,i.next,a)&&pc(r,a)&&pc(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Cc(i),Cc(i.next),i=e=a),i=i.next}while(i!==e);return $s(i)}function tc(e,t,n,i,r,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&cc(o,e)){let s=mc(o,e);return o=$s(o,o.next),s=$s(s,s.next),Ks(o,t,n,i,r,a),void Ks(s,t,n,i,r,a)}e=e.next}o=o.next}while(o!==e)}function nc(e,t){return e.x-t.x}function ic(e,t){if(t=function(e,t){let n=t;const i=e.x,r=e.y;let a,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o){if(o=e,e===i){if(r===n.y)return n;if(r===n.next.y)return n.next}a=n.x=n.x&&n.x>=c&&i!==n.x&&sc(ra.x||n.x===a.x&&rc(a,n)))&&(a=n,d=u)),n=n.next}while(n!==s);return a}(e,t),t){const n=mc(t,e);$s(t,t.next),$s(n,n.next)}}function rc(e,t){return lc(e.prev,e,t.prev)<0&&lc(t.next,e,e.next)<0}function ac(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function oc(e){let t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function cc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&dc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(pc(e,t)&&pc(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(lc(e.prev,e,t.prev)||lc(e,t.prev,t))||uc(e,t)&&lc(e.prev,e,e.next)>0&&lc(t.prev,t,t.next)>0)}function lc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function uc(e,t){return e.x===t.x&&e.y===t.y}function dc(e,t,n,i){const r=fc(lc(e,t,n)),a=fc(lc(e,t,i)),o=fc(lc(n,i,e)),s=fc(lc(n,i,t));return r!==a&&o!==s||!(0!==r||!hc(e,n,t))||!(0!==a||!hc(e,i,t))||!(0!==o||!hc(n,e,i))||!(0!==s||!hc(n,t,i))}function hc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function fc(e){return e>0?1:e<0?-1:0}function pc(e,t){return lc(e.prev,e,e.next)<0?lc(e,t,e.next)>=0&&lc(e,e.prev,t)>=0:lc(e,t,e.prev)<0||lc(e,e.next,t)<0}function mc(e,t){const n=new vc(e.i,e.x,e.y),i=new vc(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function gc(e,t,n,i){const r=new vc(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Cc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function vc(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class yc{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){s=l=e[0],c=u=e[1];for(let t=n;tl&&(l=d),h>u&&(u=h);f=Math.max(l-s,u-c),f=0!==f?1/f:0}return Ks(a,o,n,s,c,f),o}(n,i);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function Mc(e,t){for(let n=0;nNumber.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(c*c+l*l),f=t.x-s/d,p=t.y+o/d,m=((n.x-l/h-f)*l-(n.y+c/h-p)*c)/(o*l-s*c);i=f+o*m-e.x,r=p+s*m-e.y;const g=i*i+r*r;if(g<=2)return new Ee(i,r);a=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?c>Number.EPSILON&&(e=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(i=-s,r=o,a=Math.sqrt(u)):(i=o,r=s,a=Math.sqrt(u/2))}return new Ee(i/a,r/a)}const V=[];for(let e=0,t=L.length,n=t-1,i=e+1;e=0;e--){const t=e/f,n=u*Math.cos(t*Math.PI/2),i=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=L.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*f;e0)&&h.push(t,r,c),(e!==n-1||s0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=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.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.ior=e.ior,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}}Oc.prototype.isMeshPhysicalMaterial=!0;class Bc extends hn{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Oe(16777215),this.specular=new Oe(1118481),this.shininess=30,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=0,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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.flatShading=e.flatShading,this}}Bc.prototype.isMeshPhongMaterial=!0;class Fc extends hn{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Oe(16777215),this.map=null,this.gradientMap=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=0,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Fc.prototype.isMeshToonMaterial=!0;class Uc extends hn{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}Uc.prototype.isMeshNormalMaterial=!0;class Wc extends hn{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Oe(16777215),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.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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}}Wc.prototype.isMeshLambertMaterial=!0;class Gc extends hn{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Oe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}Gc.prototype.isMeshMatcapMaterial=!0;class jc extends Yo{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}jc.prototype.isLineDashedMaterial=!0;var qc=Object.freeze({__proto__:null,ShadowMaterial:Nc,SpriteMaterial:ho,RawShaderMaterial:Vi,ShaderMaterial:ri,PointsMaterial:as,MeshPhysicalMaterial:Oc,MeshStandardMaterial:Dc,MeshPhongMaterial:Bc,MeshToonMaterial:Fc,MeshNormalMaterial:Uc,MeshLambertMaterial:Wc,MeshDepthMaterial:Ga,MeshDistanceMaterial:ja,MeshBasicMaterial:fn,MeshMatcapMaterial:Gc,LineDashedMaterial:jc,LineBasicMaterial:Yo,Material:hn});const Xc={arraySlice:function(e,t,n){return Xc.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,o=0;o!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[o++]=e[i+n]}return r},flattenJSON:function(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let o=a[i];if(void 0!==o)if(Array.isArray(o))do{o=a[i],void 0!==o&&(t.push(a.time),n.push.apply(n,o)),a=e[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[i],void 0!==o&&(t.push(a.time),o.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{o=a[i],void 0!==o&&(t.push(a.time),n.push(o)),a=e[r++]}while(void 0!==a)},subclip:function(e,t,n,i,r=30){const a=e.clone();a.name=t;const o=[];for(let e=0;e=i)){c.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e=i.times[d]){const e=d*c+s,t=e+c-s;h=Xc.arraySlice(i.values,e,t)}else{const e=i.createInterpolant(),t=s,n=c-s;e.evaluate(a),h=Xc.arraySlice(e.resultBuffer,t,n)}"quaternion"===r&&(new Je).fromArray(h).normalize().conjugate().toArray(h);const f=o.times.length;for(let e=0;e=r)break e;{const o=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=Xc.arraySlice(n,r,a),this.values=Xc.arraySlice(this.values,r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&Xc.isTypedArray(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Xc.arraySlice(this.times),t=Xc.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===ne,r=e.length-1;let a=1;for(let o=1;o0){e[a]=e[r];for(let e=r*n,i=a*n,o=0;o!==n;++o)t[i+o]=t[e+o];++a}return a!==e.length?(this.times=Xc.arraySlice(e,0,a),this.values=Xc.arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=Xc.arraySlice(this.times,0),t=Xc.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Zc.prototype.TimeBufferType=Float32Array,Zc.prototype.ValueBufferType=Float32Array,Zc.prototype.DefaultInterpolation=te;class Qc extends Zc{}Qc.prototype.ValueTypeName="bool",Qc.prototype.ValueBufferType=Array,Qc.prototype.DefaultInterpolation=ee,Qc.prototype.InterpolantFactoryMethodLinear=void 0,Qc.prototype.InterpolantFactoryMethodSmooth=void 0;class el extends Zc{}el.prototype.ValueTypeName="color";class tl extends Zc{}tl.prototype.ValueTypeName="number";class nl extends Yc{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(i-t);let c=e*o;for(let e=c+o;c!==e;c+=4)Je.slerpFlat(r,0,a,c-o,a,c,s);return r}}class il extends Zc{InterpolantFactoryMethodLinear(e){return new nl(this.times,this.values,this.getValueSize(),e)}}il.prototype.ValueTypeName="quaternion",il.prototype.DefaultInterpolation=te,il.prototype.InterpolantFactoryMethodSmooth=void 0;class rl extends Zc{}rl.prototype.ValueTypeName="string",rl.prototype.ValueBufferType=Array,rl.prototype.DefaultInterpolation=ee,rl.prototype.InterpolantFactoryMethodLinear=void 0,rl.prototype.InterpolantFactoryMethodSmooth=void 0;class al extends Zc{}al.prototype.ValueTypeName="vector";class ol{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ye(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(sl(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Zc.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],o=[];Xc.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;const c=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==hl[e])return void hl[e].push({onLoad:t,onProgress:n,onError:i});hl[e]=[],hl[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,s=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const n=hl[e],i=t.body.getReader(),r=t.headers.get("Content-Length"),a=r?parseInt(r):0,o=0!==a;let s=0;const c=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{s+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{cl.add(e,t);const n=hl[e];delete hl[e];for(let e=0,i=n.length;e{const n=hl[e];if(void 0===n)throw this.manager.itemError(e),t;delete hl[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class pl extends dl{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=cl.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const o=He("img");function s(){l(),cl.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(t){l(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",s,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",c,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class ml extends dl{constructor(e){super(e)}load(e,t,n,i){const r=new li,a=new pl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],(function(e){r.images[n]=e,o++,6===o&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(let t=0;t0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new Oe).setHex(r.value);break;case"v2":i.uniforms[t].value=(new Ee).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new $e).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new je).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new Te).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new Et).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Ee).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Ee).fromArray(e.clearcoatNormalScale)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}}class Dl{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Je.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const a=this._workIndex*r;Je.multiplyQuaternionsFlat(e,a,e,t,e,n),Je.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]+e[n+a]*i}}}const hu=new RegExp("[\\[\\]\\.:\\/]","g"),fu="[^\\[\\]\\.:\\/]",pu="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",mu=/((?:WC+[\/:])*)/.source.replace("WC",fu),gu=/(WCOD+)?/.source.replace("WCOD",pu),Cu=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fu),vu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fu),yu=new RegExp("^"+mu+gu+Cu+vu+"$"),bu=["material","materials","bones"];class Mu{constructor(e,t,n){this.path=t,this.parsedPath=n||Mu.parseTrackName(t),this.node=Mu.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Mu.Composite(e,t,n):new Mu(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hu,"")}static parseTrackName(e){const t=yu.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==bu.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=r){const a=r++,l=e[a];t[l.uuid]=c,e[c]=l,t[s]=a,e[a]=o;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],r=t[c];t[c]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o].uuid,c=t[s];if(void 0!==c)if(delete t[s],c0&&(t[o.uuid]=c),e[c]=o,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[c]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,u=new Array(c);i=r.length,n[e]=i,a.push(e),o.push(t),r.push(u);for(let n=l,i=s.length;n!==i;++n){const i=s[n];u[n]=new Mu(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];t[e[o]]=n,a[n]=s,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}xu.prototype.isAnimationObjectGroup=!0;class _u{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,o=new Array(a),s={endingStart:ie,endingEnd:ie};for(let e=0;e!==a;++e){const t=r[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,c=o.sampleValues;return s[0]=r,s[1]=r+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===oe)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const a=2202===n;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=re,i.endingEnd=re):(i.endingStart=e?this.zeroSlopeAtStart?re:ie:ae,i.endingEnd=t?this.zeroSlopeAtEnd?re:ie:ae)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}class Su extends pe{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName;let l=c[s];void 0===l&&(l={},c[s]=l);for(let e=0;e!==r;++e){const r=i[e],c=r.name;let u=l[c];if(void 0!==u)++u.referenceCount,a[e]=u;else{if(u=a[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,c));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new du(Mu.create(n,c,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,c),a[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o)t[o]._update(i,e,r,a);const o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}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}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))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Au.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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)}}Vu.prototype.isBox2=!0;const Hu=new $e,Ru=new $e;class Pu{constructor(e=new $e,t=new $e){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Hu.subVectors(e,this.start),Ru.subVectors(this.end,this.start);const n=Ru.dot(Ru);let i=Ru.dot(Hu)/n;return t&&(i=be(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Iu=new $e,ku=new $e,Nu=new Et,Du=new Et;class Ou extends is{constructor(e){const t=Bu(e),n=new Pn,i=[],r=[],a=new Oe(0,0,1),o=new Oe(0,1,0);for(let e=0;e.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Qu.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Qu,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},t.Audio=au,t.AudioAnalyser=uu,t.AudioContext=ql,t.AudioListener=class extends Zt{constructor(){super(),this.type="AudioListener",this.context=ql.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ql}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(tu,nu,iu),ru.set(0,0,-1).applyQuaternion(nu),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(tu.x,e),t.positionY.linearRampToValueAtTime(tu.y,e),t.positionZ.linearRampToValueAtTime(tu.z,e),t.forwardX.linearRampToValueAtTime(ru.x,e),t.forwardY.linearRampToValueAtTime(ru.y,e),t.forwardZ.linearRampToValueAtTime(ru.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(tu.x,tu.y,tu.z),t.setOrientation(ru.x,ru.y,ru.z,n.x,n.y,n.z)}},t.AudioLoader=Xl,t.AxesHelper=nd,t.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new nd(e)},t.BackSide=1,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new gl(e)},t.Bone=No,t.BooleanKeyframeTrack=Qc,t.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Zu(e,t)},t.Box2=Vu,t.Box3=Qe,t.Box3Helper=class extends is{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Pn;i.setIndex(new gn(n,1)),i.setAttribute("position",new wn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Yo({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}},t.BoxBufferGeometry=ei,t.BoxGeometry=ei,t.BoxHelper=Zu,t.BufferAttribute=gn,t.BufferGeometry=Pn,t.BufferGeometryLoader=Bl,t.ByteType=1010,t.Cache=cl,t.Camera=ai,t.CameraHelper=class extends is{constructor(e){const t=new Pn,n=new Yo({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={},o=new Oe(16755200),s=new Oe(16711680),c=new Oe(43775),l=new Oe(16777215),u=new Oe(3355443);function d(e,t,n){h(e,n),h(t,n)}function h(e,t){i.push(0,0,0),r.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(i.length/3-1)}d("n1","n2",o),d("n2","n4",o),d("n4","n3",o),d("n3","n1",o),d("f1","f2",o),d("f2","f4",o),d("f4","f3",o),d("f3","f1",o),d("n1","f1",o),d("n2","f2",o),d("n3","f3",o),d("n4","f4",o),d("p","n1",s),d("p","n2",s),d("p","n3",s),d("p","n4",s),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c),d("c","t",l),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u),t.setAttribute("position",new wn(i,3)),t.setAttribute("color",new wn(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){const e=this.geometry,t=this.pointMap;Ju.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),$u("c",t,e,Ju,0,0,-1),$u("t",t,e,Ju,0,0,1),$u("n1",t,e,Ju,-1,-1,-1),$u("n2",t,e,Ju,1,-1,-1),$u("n3",t,e,Ju,-1,1,-1),$u("n4",t,e,Ju,1,1,-1),$u("f1",t,e,Ju,-1,-1,1),$u("f2",t,e,Ju,1,-1,1),$u("f3",t,e,Ju,-1,1,1),$u("f4",t,e,Ju,1,1,1),$u("u1",t,e,Ju,.7,1.1,-1),$u("u2",t,e,Ju,-.7,1.1,-1),$u("u3",t,e,Ju,0,2,-1),$u("cf1",t,e,Ju,-1,0,1),$u("cf2",t,e,Ju,1,0,1),$u("cf3",t,e,Ju,0,-1,1),$u("cf4",t,e,Ju,0,1,1),$u("cn1",t,e,Ju,-1,0,-1),$u("cn2",t,e,Ju,1,0,-1),$u("cn3",t,e,Ju,0,-1,-1),$u("cn4",t,e,Ju,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},t.CanvasTexture=ms,t.CatmullRomCurve3=Ps,t.CineonToneMapping=3,t.CircleBufferGeometry=gs,t.CircleGeometry=gs,t.ClampToEdgeWrapping=h,t.Clock=Ql,t.Color=Oe,t.ColorKeyframeTrack=el,t.CompressedTexture=ps,t.CompressedTextureLoader=class extends dl{constructor(e){super(e)}load(e,t,n,i){const r=this,a=[],o=new ps,s=new fl(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials);let c=0;function l(l){s.load(e[l],(function(e){const n=r.parse(e,!0);a[l]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},c+=1,6===c&&(1===n.mipmapCount&&(o.minFilter=C),o.image=a,o.format=n.format,o.needsUpdate=!0,t&&t(o))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t65504&&(console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."),e=65504),id[0]=e;const t=rd[0];let n=t>>16&32768,i=t>>12&2047;const r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t,n):r<113?(i|=2048,n|=(i>>114-r)+(i>>113-r&1),n):(n|=r-112<<10|i>>1,n+=1&i,n)}},t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=ul,t.DepthFormat=E,t.DepthStencilFormat=T,t.DepthTexture=eo,t.DirectionalLight=Hl,t.DirectionalLightHelper=class extends Zt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let i=new Pn;i.setAttribute("position",new wn([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Yo({fog:!1,toneMapped:!1});this.lightPlane=new es(i,r),this.add(this.lightPlane),i=new Pn,i.setAttribute("position",new wn([0,0,0,0,0,1],3)),this.targetLine=new es(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ju.setFromMatrixPosition(this.light.matrixWorld),qu.setFromMatrixPosition(this.light.target.matrixWorld),Xu.subVectors(qu,ju),this.lightPlane.lookAt(qu),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qu),this.targetLine.scale.z=Xu.length()}},t.DiscreteInterpolant=Kc,t.DodecahedronBufferGeometry=bs,t.DodecahedronGeometry=bs,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new gn(e,t).setUsage(de)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=de,t.DynamicReadUsage=35049,t.EdgesGeometry=ws,t.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new is(new ws(e.geometry),new Yo({color:void 0!==t?t:16777215}))},t.EllipseCurve=Es,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=s,t.EquirectangularRefractionMapping=c,t.Euler=Nt,t.EventDispatcher=pe,t.ExtrudeBufferGeometry=xc,t.ExtrudeGeometry=xc,t.FaceColors=1,t.FileLoader=fl,t.FlatShading=1,t.Float16BufferAttribute=Sn,t.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new wn(e,t)},t.Float32BufferAttribute=wn,t.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new Ln(e,t)},t.Float64BufferAttribute=Ln,t.FloatType=_,t.Fog=oo,t.FogExp2=ao,t.Font=function(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")},t.FontLoader=function(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")},t.FramebufferTexture=fs,t.FrontSide=0,t.Frustum=Ci,t.GLBufferAttribute=Eu,t.GLSL1="100",t.GLSL3=he,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Gu,t.Group=Ka,t.HalfFloatType=S,t.HemisphereLight=yl,t.HemisphereLightHelper=class extends Zt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const i=new Lc(t);i.rotateY(.5*Math.PI),this.material=new fn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),a=new Float32Array(3*r.count);i.setAttribute("color",new gn(a,3)),this.add(new Zn(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Uu.copy(this.light.color),Wu.copy(this.light.groundColor);for(let e=0,n=t.count;e0){const n=new ll(t);r=new pl(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new pl(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;tNumber.EPSILON){if(c<0&&(n=t[a],s=-s,o=t[r],c=-c),e.yo.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=c*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return i}const r=yc.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);let o,s,c;const l=[];if(1===a.length)return s=a[0],c=new Ys,c.curves=s.curves,l.push(c),l;let u=!r(a[0].getPoints());u=e?!u:u;const d=[],h=[];let f,p,m=[],g=0;h[g]=void 0,m[g]=[];for(let t=0,n=a.length;t1){let e=!1;const t=[];for(let e=0,t=h.length;e0&&(e||(m=d))}for(let e=0,t=h.length;e{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.MediapipeAvator=e.MotionDetector=void 0;var t=i(375);Object.defineProperty(e,"MotionDetector",{enumerable:!0,get:function(){return t.MotionDetector}});var n=i(696);Object.defineProperty(e,"MediapipeAvator",{enumerable:!0,get:function(){return n.MediapipeAvator}})})(),a})(),e.exports=i()},4537:e=>{"use strict";e.exports=function(e,t){for(var n=new Array(arguments.length-1),i=0,r=2,a=!0;r{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var i=new Array(64),r=new Array(123),a=0;a<64;)r[i[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;n.encode=function(e,t,n){for(var r,a=null,o=[],s=0,c=0;t>2],r=(3&l)<<4,c=1;break;case 1:o[s++]=i[r|l>>4],r=(15&l)<<2,c=2;break;case 2:o[s++]=i[r|l>>6],o[s++]=i[63&l],c=0}s>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,o)),s=0)}return c&&(o[s++]=i[r],o[s++]=61,1===c&&(o[s++]=61)),a?(s&&a.push(String.fromCharCode.apply(String,o.slice(0,s))),a.join("")):String.fromCharCode.apply(String,o.slice(0,s))};var o="invalid encoding";n.decode=function(e,t,n){for(var i,a=n,s=0,c=0;c1)break;if(void 0===(l=r[l]))throw Error(o);switch(s){case 0:i=l,s=1;break;case 1:t[n++]=i<<2|(48&l)>>4,i=l,s=2;break;case 2:t[n++]=(15&i)<<4|(60&l)>>2,i=l,s=3;break;case 3:t[n++]=(3&i)<<6|l,s=0}}if(1===s)throw Error(o);return n-a},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},9211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],i=0;i{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),i=128===n[3];function r(e,i,r){t[0]=e,i[r]=n[0],i[r+1]=n[1],i[r+2]=n[2],i[r+3]=n[3]}function a(e,i,r){t[0]=e,i[r]=n[3],i[r+1]=n[2],i[r+2]=n[1],i[r+3]=n[0]}function o(e,i){return n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],n[3]=e[i+3],t[0]}function s(e,i){return n[3]=e[i],n[2]=e[i+1],n[1]=e[i+2],n[0]=e[i+3],t[0]}e.writeFloatLE=i?r:a,e.writeFloatBE=i?a:r,e.readFloatLE=i?o:s,e.readFloatBE=i?s:o}():function(){function t(e,t,n,i){var r=t<0?1:0;if(r&&(t=-t),0===t)e(1/t>0?0:2147483648,n,i);else if(isNaN(t))e(2143289344,n,i);else if(t>34028234663852886e22)e((r<<31|2139095040)>>>0,n,i);else if(t<11754943508222875e-54)e((r<<31|Math.round(t/1401298464324817e-60))>>>0,n,i);else{var a=Math.floor(Math.log(t)/Math.LN2);e((r<<31|a+127<<23|8388607&Math.round(t*Math.pow(2,-a)*8388608))>>>0,n,i)}}function o(e,t,n){var i=e(t,n),r=2*(i>>31)+1,a=i>>>23&255,o=8388607&i;return 255===a?o?NaN:r*(1/0):0===a?1401298464324817e-60*r*o:r*Math.pow(2,a-150)*(o+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,i),e.readFloatLE=o.bind(null,r),e.readFloatBE=o.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),i=128===n[7];function r(e,i,r){t[0]=e,i[r]=n[0],i[r+1]=n[1],i[r+2]=n[2],i[r+3]=n[3],i[r+4]=n[4],i[r+5]=n[5],i[r+6]=n[6],i[r+7]=n[7]}function a(e,i,r){t[0]=e,i[r]=n[7],i[r+1]=n[6],i[r+2]=n[5],i[r+3]=n[4],i[r+4]=n[3],i[r+5]=n[2],i[r+6]=n[1],i[r+7]=n[0]}function o(e,i){return n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],n[3]=e[i+3],n[4]=e[i+4],n[5]=e[i+5],n[6]=e[i+6],n[7]=e[i+7],t[0]}function s(e,i){return n[7]=e[i],n[6]=e[i+1],n[5]=e[i+2],n[4]=e[i+3],n[3]=e[i+4],n[2]=e[i+5],n[1]=e[i+6],n[0]=e[i+7],t[0]}e.writeDoubleLE=i?r:a,e.writeDoubleBE=i?a:r,e.readDoubleLE=i?o:s,e.readDoubleBE=i?s:o}():function(){function t(e,t,n,i,r,a){var o=i<0?1:0;if(o&&(i=-i),0===i)e(0,r,a+t),e(1/i>0?0:2147483648,r,a+n);else if(isNaN(i))e(0,r,a+t),e(2146959360,r,a+n);else if(i>17976931348623157e292)e(0,r,a+t),e((o<<31|2146435072)>>>0,r,a+n);else{var s;if(i<22250738585072014e-324)e((s=i/5e-324)>>>0,r,a+t),e((o<<31|s/4294967296)>>>0,r,a+n);else{var c=Math.floor(Math.log(i)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(s=i*Math.pow(2,-c))>>>0,r,a+t),e((o<<31|c+1023<<20|1048576*s&1048575)>>>0,r,a+n)}}}function o(e,t,n,i,r){var a=e(i,r+t),o=e(i,r+n),s=2*(o>>31)+1,c=o>>>20&2047,l=4294967296*(1048575&o)+a;return 2047===c?l?NaN:s*(1/0):0===c?5e-324*s*l:s*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,i,4,0),e.readDoubleLE=o.bind(null,r,0,4),e.readDoubleBE=o.bind(null,a,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function i(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function r(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},7199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},6662:e=>{"use strict";e.exports=function(e,t,n){var i=n||8192,r=i>>>1,a=null,o=i;return function(n){if(n<1||n>r)return e(n);o+n>i&&(a=e(i),o=0);var s=t.call(a,o,o+=n);return 7&o&&(o=1+(7|o)),s}}},4997:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,i=0;i191&&i<224?a[o++]=(31&i)<<6|63&e[t++]:i>239&&i<365?(i=((7&i)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,a[o++]=55296+(i>>10),a[o++]=56320+(1023&i)):a[o++]=(15&i)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,a)),o=0);return r?(o&&r.push(String.fromCharCode.apply(String,a.slice(0,o))),r.join("")):String.fromCharCode.apply(String,a.slice(0,o))},n.write=function(e,t,n){for(var i,r,a=n,o=0;o>6|192,t[n++]=63&i|128):55296==(64512&i)&&56320==(64512&(r=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&r),++o,t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128);return n-a}},8599:e=>{"use strict";const{AbortController:t,AbortSignal:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;e.exports=t,e.exports.AbortSignal=n,e.exports.default=t},8320:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3922);t.default=class{constructor(e,t,n,i=1e3,r=200){this.realtimeController=e,this.selfAttendeeId=t,this.hasBandwidthPriorityCallback=n,this.waitIntervalMs=i,this.updateIntervalMs=r,this.speakerScores={},this.speakerMuteState={},this.detectorCallbackToHandler=new Map,this.detectorCallbackToScoresTimer=new Map,this.detectorCallbackToActivityTimer=new Map,this.hasBandwidthPriority=!1,this.mostRecentUpdateTimestamp={}}needUpdate(e){return!this.activeSpeakers||0===this.speakerScores[e]&&this.activeSpeakers.includes(e)||this.speakerScores[e]>0&&!this.activeSpeakers.includes(e)}updateActiveSpeakers(e,t,n){if(!this.needUpdate(n))return;const i=[],r=Object.keys(this.speakerScores);for(let e=0;et.activeScore-e.activeScore)).filter((function(e){return e.activeScore>0})).map((function(e){return e.attendeeId}));this.activeSpeakers=a,t(a);const o=a.length>0&&a[0]===this.selfAttendeeId&&e.prioritizeVideoSendBandwidthForActiveSpeaker();this.hasBandwidthPriority!==o&&(this.hasBandwidthPriority=o,this.hasBandwidthPriorityCallback(o))}updateScore(e,t,n,i,r){const a=e.calculateScore(n,i,r);this.speakerScores[n]!==a&&(this.speakerScores[n]=a,this.mostRecentUpdateTimestamp[n]=Date.now(),this.updateActiveSpeakers(e,t,n))}subscribe(e,t,n,i){const a=(n,i)=>{if(!i)return this.speakerScores[n]=0,this.mostRecentUpdateTimestamp[n]=Date.now(),void this.updateActiveSpeakers(e,t,n);this.realtimeController.realtimeSubscribeToVolumeIndicator(n,((n,i,r,a)=>{this.mostRecentUpdateTimestamp[n]=Date.now(),null!==r&&(this.speakerMuteState[n]=r),this.updateScore(e,t,n,i,r)}))};this.detectorCallbackToHandler.set(t,a);const o=new r.default(this.updateIntervalMs);if(o.start((()=>{for(const n in this.speakerScores)Date.now()-this.mostRecentUpdateTimestamp[n]>this.waitIntervalMs&&this.updateScore(e,t,n,0,this.speakerMuteState[n])})),this.detectorCallbackToActivityTimer.set(t,o),n&&i){const e=new r.default(i);e.start((()=>{n(this.speakerScores)})),this.detectorCallbackToScoresTimer.set(t,e)}this.realtimeController.realtimeSubscribeToAttendeeIdPresence(a)}unsubscribe(e){const t=this.detectorCallbackToHandler.get(e);this.detectorCallbackToHandler.delete(e),t&&this.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(t);const n=this.detectorCallbackToActivityTimer.get(e);n&&(n.stop(),this.detectorCallbackToActivityTimer.delete(e));const i=this.detectorCallbackToScoresTimer.get(e);i&&(i.stop(),this.detectorCallbackToHandler.delete(e))}destroy(){return i(this,void 0,void 0,(function*(){for(const e of this.detectorCallbackToHandler.values())this.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(e);for(const e of this.detectorCallbackToActivityTimer.values())e.stop();for(const e of this.detectorCallbackToScoresTimer.values())e.stop();this.detectorCallbackToHandler.clear(),this.detectorCallbackToActivityTimer.clear(),this.detectorCallbackToScoresTimer.clear()}))}}},2363:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e=.9,t=.01,n=.2,i=.2){this.speakerWeight=e,this.cutoffThreshold=t,this.silenceThreshold=n,this.takeoverRate=i,this.volumes={}}calculateScore(e,t,n){(n||null===t)&&(t=0),this.volumes.hasOwnProperty(e)||(this.volumes[e]=0),t=t>this.silenceThreshold?1:0;const i=this.volumes[e]*this.speakerWeight+t*(1-this.speakerWeight);this.volumes[e]=i;for(const n in this.volumes)n!==e&&(this.volumes[n]=Math.max(this.volumes[n]-this.takeoverRate*t,0));return i{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e,t){this.appName=e,this.appVersion=t}static create(e,t){const i=/^[a-zA-Z0-9]+[a-zA-Z0-9_-]*[a-zA-Z0-9]+$/g;if(!e||e.length>32)throw new Error("appName should be a valid string and 1 to 32 characters in length");if(!i.test(e))throw new Error(`appName must satisfy ${i} regular expression`);if(!t||t.length>32)throw new Error("appVersion should be a valid string and 1 to 32 characters in length");if(!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/gm.test(t))throw new Error("appVersion must satisfy Semantic Versioning format");return new n(e,t)}}t.default=n},7602:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},6802:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543),a=n(7797);t.default=class{constructor(e){this.logger=e,this.audioDevice=null,this.audioElement=null,this.audioStream=null,this.browserBehavior=new r.default,this.observers=new Set}bindAudioElement(e){return i(this,void 0,void 0,(function*(){if(!e)throw new Error(`Cannot bind audio element: ${e}`);return this.audioElement=e,this.audioElement.autoplay=!0,this.bindAudioMix()}))}unbindAudioElement(){this.audioElement&&(this.audioElement.srcObject=null,this.audioElement=null,this.forEachObserver((e=>{this.audioStream&&e.meetingAudioStreamBecameInactive(this.audioStream)})))}bindAudioStream(e){return i(this,void 0,void 0,(function*(){if(e){this.audioStream=e;try{yield this.bindAudioMix()}catch(e){this.logger&&this.logger.warn(`Failed to bind audio stream: ${e}`)}}}))}bindAudioDevice(e){return i(this,void 0,void 0,(function*(){if(e&&!this.browserBehavior.supportsSetSinkId())throw new Error("Cannot select audio output device. This browser does not support setSinkId.");return this.audioDevice=e,this.bindAudioMix()}))}forEachObserver(e){for(const t of this.observers)a.default.nextTick((()=>{e(t)}))}bindAudioMix(){var e,t;return i(this,void 0,void 0,(function*(){if(!this.audioElement)return;const n=this.audioElement.srcObject;this.audioStream&&(this.audioElement.srcObject=this.audioStream),n!==this.audioStream&&this.forEachObserver((e=>{n&&e.meetingAudioStreamBecameInactive(n),this.audioStream&&e.meetingAudioStreamBecameActive(this.audioStream)}));const i=(null===(e=this.audioDevice)||void 0===e?void 0:e.deviceId)!==this.audioElement.sinkId;if(i&&void 0===this.audioElement.sinkId)throw new Error("Cannot select audio output device. This browser does not support setSinkId.");const r=this.audioDevice?this.audioDevice.deviceId:"";if(r===this.audioElement.sinkId)return;const a=this.audioElement,o=this.audioStream;if(this.browserBehavior.hasChromiumWebRTC()&&(a.srcObject=null),i)try{yield a.setSinkId(r)}catch(e){throw null===(t=this.logger)||void 0===t||t.error(`Failed to set sinkId for audio element: ${e}`),e}this.browserBehavior.hasChromiumWebRTC()&&(a.srcObject=o)}))}getCurrentMeetingAudioStream(){return i(this,void 0,void 0,(function*(){return this.audioStream}))}addAudioMixObserver(e){return i(this,void 0,void 0,(function*(){this.observers.add(e)}))}removeAudioMixObserver(e){return i(this,void 0,void 0,(function*(){this.observers.delete(e)}))}audioOutputDidChange(e){return i(this,void 0,void 0,(function*(){return this.logger.info("Receive an audio output change event"),this.bindAudioDevice(e)}))}}},3765:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e=null){this.audioBitrateBps=e}static fullbandSpeechMono(){return new n(4e4)}static fullbandMusicMono(){return new n(64e3)}static fullbandMusicStereo(){return new n(128e3)}isStereo(){return 128e3===this.audioBitrateBps}}t.default=n},1876:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.logger=null,this.browserBehavior=null,this.signalingClient=null,this.meetingSessionConfiguration=null,this.peer=null,this.previousSdpOffer=null,this.sdpOfferInit=null,this.audioVideoController=null,this.realtimeController=null,this.videoTileController=null,this.mediaStreamBroker=null,this.audioMixController=null,this.activeAudioInput=void 0,this.activeVideoInput=void 0,this.transceiverController=null,this.indexFrame=null,this.iceCandidates=[],this.iceCandidateHandler=null,this.iceGatheringStateEventHandler=null,this.sdpAnswer=null,this.turnCredentials=null,this.reconnectController=null,this.removableObservers=[],this.audioProfile=null,this.videoStreamIndex=null,this.videoDownlinkBandwidthPolicy=null,this.videoUplinkBandwidthPolicy=null,this.lastKnownVideoAvailability=null,this.videoCaptureAndEncodeParameter=null,this.videosToReceive=null,this.lastVideosToReceive=null,this.videoSubscriptions=null,this.videoSubscriptionLimit=25,this.previousSdpAnswerAsString="",this.serverSupportsCompression=!1,this.videoSendCodecPreferences=[],this.meetingSupportedVideoSendCodecPreferences=void 0,this.videosPaused=null,this.videoDuplexMode=null,this.volumeIndicatorAdapter=null,this.statsCollector=null,this.connectionMonitor=null,this.videoInputAttachedTimestampMs=0,this.audioDeviceInformation={},this.videoDeviceInformation={},this.enableSimulcast=!1,this.eventController=null,this.signalingOpenDurationMs=null,this.iceGatheringDurationMs=null,this.startAudioVideoTimestamp=null,this.attendeePresenceDurationMs=null,this.meetingStartDurationMs=null,this.poorConnectionCount=0,this.maxVideoTileCount=0,this.startTimeMs=null}}},9059:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(8320),a=n(6802),o=n(3765),s=n(543),c=n(6688),l=n(8581),u=n(3789),d=n(5687),h=n(5723),f=n(214),p=n(7500),m=n(983),g=n(7797),C=n(9678),v=n(3860),y=n(9553),b=n(3013),M=n(1208),x=n(9416),_=n(9101),S=n(289),w=n(8597),L=n(8358),E=n(3216),T=n(7408),z=n(5482),A=n(1129),V=n(6240),H=n(1960),R=n(6180),P=n(2748),I=n(1981),k=n(4543),N=n(8556),D=n(9945),O=n(1209),B=n(5547),F=n(120),U=n(9560),W=n(9485),G=n(7079),j=n(4833),q=n(5275),X=n(5924),Y=n(250),J=n(6171),$=n(365),K=n(7377),Z=n(5785),Q=n(9354),ee=n(8660),te=n(1133),ne=n(5185),ie=n(2880),re=n(1508),ae=n(1318),oe=n(4242),se=n(2958),ce=n(4922),le=n(4450),ue=n(4442),de=n(9751),he=n(1876);class fe{constructor(e,t,n,i,r,s){this._audioProfile=new o.default,this.connectionHealthData=new c.default,this.observerQueue=new Set,this.meetingSessionContext=new he.default,this.enableSimulcast=!1,this.useUpdateTransceiverControllerForUplink=!1,this.totalRetryCount=0,this.startAudioVideoTimestamp=0,this.mayNeedRenegotiationForSimulcastLayerChange=!1,this.promotedToPrimaryMeeting=!1,this.hasGetRTCPeerConnectionStatsDeprecationMessageBeenSent=!1,this.receiveIndexTask=void 0,this.monitorTask=void 0,this.destroyed=!1,this.usePromises=!0,this._logger=t,this.sessionStateController=new C.default(this._logger),this._configuration=e,this._webSocketAdapter=n,this._realtimeController=new m.default(i),this._realtimeController.realtimeSetLocalAttendeeId(e.credentials.attendeeId,e.credentials.externalUserId),this._mediaStreamBroker=i,this._reconnectController=r,this._videoTileController=new se.default(new ce.default,this,this._logger),this._audioMixController=new a.default(this._logger),this._mediaStreamBroker.addMediaStreamBrokerObserver(this._audioMixController),this.meetingSessionContext.logger=this._logger,this._eventController=s}destroy(){return i(this,void 0,void 0,(function*(){this.observerQueue.clear(),this._mediaStreamBroker.removeMediaStreamBrokerObserver(this._audioMixController),this.destroyed=!0}))}get configuration(){return this._configuration}get realtimeController(){return this._realtimeController}get activeSpeakerDetector(){return this._activeSpeakerDetector||(this._activeSpeakerDetector=new r.default(this._realtimeController,this._configuration.credentials.attendeeId,this.handleHasBandwidthPriority.bind(this))),this._activeSpeakerDetector}get videoTileController(){return this._videoTileController}get audioMixController(){return this._audioMixController}get logger(){return this._logger}get rtcPeerConnection(){return this.meetingSessionContext&&this.meetingSessionContext.peer||null}get mediaStreamBroker(){return this._mediaStreamBroker}get eventController(){return this._eventController}getRTCPeerConnectionStats(e){return this.hasGetRTCPeerConnectionStatsDeprecationMessageBeenSent||(this.logger.warn("The `getRTCPeerConnectionStats()` is on its way to be deprecated. It makes an additional call to the `getStats` API and therefore may cause slight performance degradation. Please use the new API `clientMetricReport.getRTCStatsReport()` returned by `metricsDidReceive(clientMetricReport)` callback instead."),this.hasGetRTCPeerConnectionStatsDeprecationMessageBeenSent=!0),this.rtcPeerConnection?this.rtcPeerConnection.getStats(e):null}setAudioProfile(e){this._audioProfile=e}addObserver(e){this.logger.info("adding meeting observer"),this.observerQueue.add(e)}removeObserver(e){this.logger.info("removing meeting observer"),this.observerQueue.delete(e)}forEachObserver(e){for(const t of this.observerQueue)g.default.nextTick((()=>{this.observerQueue.has(t)&&e(t)}))}initSignalingClient(){this.meetingSessionContext.signalingClient||(this.connectionHealthData.reset(),this.meetingSessionContext=new he.default,this.meetingSessionContext.logger=this.logger,this.meetingSessionContext.eventController=this.eventController,this.meetingSessionContext.browserBehavior=new s.default,this.meetingSessionContext.videoSendCodecPreferences=this.videoSendCodecPreferences,this.meetingSessionContext.meetingSessionConfiguration=this.configuration,this.meetingSessionContext.signalingClient=new M.default(this._webSocketAdapter,this.logger))}uninstallPreStartObserver(){var e;null===(e=this.meetingSessionContext.signalingClient)||void 0===e||e.removeObserver(this.preStartObserver),this.preStartObserver=void 0}prestart(){return this.logger.info("Pre-connecting signaling connection."),this.createOrReuseSignalingTask().run().then((()=>{const e=()=>i(this,void 0,void 0,(function*(){this.logger.info("Early connection closed; discarding signaling task."),this.signalingTask=void 0,this.uninstallPreStartObserver()}));this.preStartObserver={handleSignalingClientEvent(t){t.type===x.default.WebSocketClosed&&e()}},this.meetingSessionContext.signalingClient.registerObserver(this.preStartObserver)})).catch((e=>{this.logger.error(`Signaling task pre-start failed: ${e}`),this.signalingTask=void 0}))}start(e){this.startReturningPromise(e).then((()=>{this.logger.info("start completed")})).catch((e=>{this.logger.error(`start failed: ${e}`)}))}startReturningPromise(e){return!0===(null==e?void 0:e.signalingOnly)?this.prestart():(this.activeSpeakerDetector,new Promise(((e,t)=>{this.sessionStateController.perform(v.default.Connect,(()=>{this.actionConnect(!1).then(e).catch(t)}))})))}connectWithPromises(e){const t=this.meetingSessionContext;this.monitorTask=new I.default(t,this.configuration.connectionHealthPolicyConfiguration,this.connectionHealthData);const n=this.monitorTask.once(),i=new O.default(t).once();this.receiveIndexTask=new U.default(t),this.monitorTask.pauseResubscribeCheck(),this.receiveIndexTask.pauseIngestion();const r=new G.default(this.logger,"Signaling",[this.createOrReuseSignalingTask(),new P.default(t),new W.default(t),new H.default(t),new B.default(t),this.receiveIndexTask]).once(),a=new z.default(t).once(r),o=new L.default(t).once(a,i),s=new A.default(t).once(o),c=new j.default(t).once(s),l=new V.default(t).once(c),u=new X.default(t).once(l);return new G.default(this.logger,this.wrapTaskName("AudioVideoStart"),[n,((e,t)=>new Y.default(this.logger,t,e))(this.configuration.connectionTimeoutMs,new G.default(this.logger,"Peer",[u,e?new Y.default(this.logger,new N.default(this.logger,"FinalizeConnection",[new J.default(t),new q.default(t)]),this.meetingSessionContext.meetingSessionConfiguration.attendeePresenceTimeoutMs):new q.default(t)]))])}connectWithTasks(e){return this.receiveIndexTask=new U.default(this.meetingSessionContext),this.monitorTask=new I.default(this.meetingSessionContext,this.configuration.connectionHealthPolicyConfiguration,this.connectionHealthData),this.receiveIndexTask.pauseIngestion(),this.monitorTask.pauseResubscribeCheck(),new G.default(this.logger,this.wrapTaskName("AudioVideoStart"),[this.monitorTask,new O.default(this.meetingSessionContext),new Y.default(this.logger,new G.default(this.logger,"Media",[new G.default(this.logger,"Signaling",[new k.default(this.meetingSessionContext),new P.default(this.meetingSessionContext),new W.default(this.meetingSessionContext),new H.default(this.meetingSessionContext),new B.default(this.meetingSessionContext),this.receiveIndexTask]),new G.default(this.logger,"Peer",[new z.default(this.meetingSessionContext),new L.default(this.meetingSessionContext),new A.default(this.meetingSessionContext),new j.default(this.meetingSessionContext),new V.default(this.meetingSessionContext),new X.default(this.meetingSessionContext),e?new Y.default(this.logger,new N.default(this.logger,"FinalizeConnection",[new J.default(this.meetingSessionContext),new q.default(this.meetingSessionContext)]),this.meetingSessionContext.meetingSessionConfiguration.attendeePresenceTimeoutMs):new q.default(this.meetingSessionContext)])]),this.configuration.connectionTimeoutMs)])}actionConnect(e){var t;return i(this,void 0,void 0,(function*(){this.initSignalingClient(),this.uninstallPreStartObserver(),this.meetingSessionContext.mediaStreamBroker=this._mediaStreamBroker,this.meetingSessionContext.realtimeController=this._realtimeController,this.meetingSessionContext.audioMixController=this._audioMixController,this.meetingSessionContext.audioVideoController=this,this.enableSimulcast=this.configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers&&(new s.default).hasChromiumWebRTC();const n=!!this.configuration.urls.audioHostURL;if(n?this.enableSimulcast?(this.logger.info("Using transceiver controller with simulcast support"),new f.default(this.configuration.credentials.attendeeId).hasModality(f.default.MODALITY_CONTENT)?this.meetingSessionContext.transceiverController=new K.default(this.logger,this.meetingSessionContext.browserBehavior):this.meetingSessionContext.transceiverController=new Z.default(this.logger,this.meetingSessionContext.browserBehavior)):(this.logger.info("Using default transceiver controller"),this.meetingSessionContext.transceiverController=new $.default(this.logger,this.meetingSessionContext.browserBehavior)):(this.logger.info("Using video only transceiver controller"),this.meetingSessionContext.transceiverController=new Q.default(this.logger,this.meetingSessionContext.browserBehavior)),this.meetingSessionContext.volumeIndicatorAdapter=new de.default(this.logger,this._realtimeController,fe.MIN_VOLUME_DECIBELS,fe.MAX_VOLUME_DECIBELS,this.configuration.credentials.attendeeId),this.meetingSessionContext.videoTileController=this._videoTileController,this.meetingSessionContext.videoDownlinkBandwidthPolicy=this.configuration.videoDownlinkBandwidthPolicy,this.meetingSessionContext.videoUplinkBandwidthPolicy=this.configuration.videoUplinkBandwidthPolicy,this.meetingSessionContext.enableSimulcast=this.enableSimulcast,this.enableSimulcast){let e=this.meetingSessionContext.videoUplinkBandwidthPolicy;e||(e=new le.default(this.configuration.credentials.attendeeId,this.meetingSessionContext.logger),this.meetingSessionContext.videoUplinkBandwidthPolicy=e),e.addObserver(this),this.meetingSessionContext.videoDownlinkBandwidthPolicy||(this.meetingSessionContext.videoDownlinkBandwidthPolicy=new ie.default(this.meetingSessionContext.logger)),this.meetingSessionContext.videoStreamIndex=new oe.default(this.logger)}else this.meetingSessionContext.enableSimulcast=!1,this.meetingSessionContext.videoStreamIndex=new ae.default(this.logger),this.meetingSessionContext.videoUplinkBandwidthPolicy||(this.meetingSessionContext.videoUplinkBandwidthPolicy=new ue.default(this.configuration.credentials.attendeeId,!this.meetingSessionContext.browserBehavior.disableResolutionScaleDown(),this.meetingSessionContext.logger,this.meetingSessionContext.browserBehavior)),this.meetingSessionContext.videoDownlinkBandwidthPolicy||(this.meetingSessionContext.videoDownlinkBandwidthPolicy=new ne.default(this.configuration.credentials.attendeeId)),this.meetingSessionContext.videoUplinkBandwidthPolicy.setTransceiverController&&this.meetingSessionContext.videoUplinkBandwidthPolicy.updateTransceiverController&&(this.useUpdateTransceiverControllerForUplink=!0,this.meetingSessionContext.videoUplinkBandwidthPolicy.setTransceiverController(this.meetingSessionContext.transceiverController)),this.meetingSessionContext.audioProfile=this._audioProfile;this.meetingSessionContext.videoUplinkBandwidthPolicy&&this.maxUplinkBandwidthKbps&&this.meetingSessionContext.videoUplinkBandwidthPolicy.setIdealMaxBandwidthKbps(this.maxUplinkBandwidthKbps),this.meetingSessionContext.videoDownlinkBandwidthPolicy.bindToTileController&&this.meetingSessionContext.videoDownlinkBandwidthPolicy.bindToTileController(this._videoTileController),this.meetingSessionContext.lastKnownVideoAvailability=new h.default,this.meetingSessionContext.videoCaptureAndEncodeParameter=new te.default(0,0,0,0,!1),this.meetingSessionContext.videosToReceive=new re.default,this.meetingSessionContext.videosPaused=new re.default,this.meetingSessionContext.statsCollector=new w.default(this,this.logger),this.meetingSessionContext.connectionMonitor=new l.default(this,this._realtimeController,this.connectionHealthData,new p.default(this.meetingSessionContext.signalingClient,fe.PING_PONG_INTERVAL_MS,this.logger),this.meetingSessionContext.statsCollector),this.meetingSessionContext.reconnectController=this._reconnectController,this.meetingSessionContext.videoDeviceInformation={},e||(this.totalRetryCount=0,this._reconnectController.reset(),this.startAudioVideoTimestamp=Date.now(),this.forEachObserver((e=>{ee.Maybe.of(e.audioVideoDidStartConnecting).map((t=>t.bind(e)(!1)))})),null===(t=this.eventController)||void 0===t||t.publishEvent("meetingStartRequested")),this.meetingSessionContext.startAudioVideoTimestamp=this.startAudioVideoTimestamp,this._reconnectController.hasStartedConnectionAttempt()?this._reconnectController.startedConnectionAttempt(!1):this._reconnectController.startedConnectionAttempt(!0);const r=n&&this.meetingSessionContext.meetingSessionConfiguration.attendeePresenceTimeoutMs>0;let a;this.logger.info("Needs to wait for attendee presence? "+r),a=this.usePromises?this.connectWithPromises(r):this.connectWithTasks(r);try{yield a.run(),this.connectionHealthData.setConnectionStartTime(),this._mediaStreamBroker.addMediaStreamBrokerObserver(this),this.sessionStateController.perform(v.default.FinishConnecting,(()=>{this.eventController&&(this.meetingSessionContext.meetingStartDurationMs=Date.now()-this.startAudioVideoTimestamp,this.eventController.publishEvent("meetingStartSucceeded",{maxVideoTileCount:this.meetingSessionContext.maxVideoTileCount,poorConnectionCount:this.meetingSessionContext.poorConnectionCount,retryCount:this.totalRetryCount,signalingOpenDurationMs:this.meetingSessionContext.signalingOpenDurationMs,iceGatheringDurationMs:this.meetingSessionContext.iceGatheringDurationMs,meetingStartDurationMs:this.meetingSessionContext.meetingStartDurationMs})),this.meetingSessionContext.startTimeMs=Date.now(),this.actionFinishConnecting()}))}catch(e){this.signalingTask=void 0;const t=new u.default(this.getMeetingStatusCode(e)||d.default.TaskFailed);if(this.logger.info(`Start failed: ${t} due to error ${e}.`),this.sessionStateController.state()===y.default.NotConnected)return void this.logger.info("Start failed and not connected. Not cleaning up.");this.sessionStateController.perform(v.default.Fail,(()=>i(this,void 0,void 0,(function*(){yield this.actionDisconnect(t,!0,e),this.handleMeetingSessionStatus(t,e)||this.notifyStop(t,e)}))))}}))}createOrReuseSignalingTask(){return this.signalingTask||(this.initSignalingClient(),this.signalingTask=new Y.default(this.logger,new k.default(this.meetingSessionContext),this.configuration.connectionTimeoutMs).once()),this.signalingTask}actionFinishConnecting(){this.signalingTask=void 0,this.meetingSessionContext.videoDuplexMode=S.SdkStreamServiceType.RX,this.meetingSessionContext.enableSimulcast||(this.useUpdateTransceiverControllerForUplink?this.meetingSessionContext.videoUplinkBandwidthPolicy.updateTransceiverController():this.enforceBandwidthLimitationForSender(this.meetingSessionContext.videoCaptureAndEncodeParameter.encodeBitrates()[0])),this.forEachObserver((e=>{ee.Maybe.of(e.audioVideoDidStart).map((t=>t.bind(e)()))})),this._reconnectController.reset(),this.receiveIndexTask.resumeIngestion(),this.monitorTask.resumeResubscribeCheck()}stopReturningPromise(){var e;return this.sessionStateController.state()===y.default.NotConnected?(null===(e=this.meetingSessionContext.signalingClient)||void 0===e||e.closeConnection(),this.meetingSessionContext.signalingClient=null,this.cleanUpMediaStreamsAfterStop(),Promise.resolve()):new Promise(((e,t)=>{this.sessionStateController.perform(v.default.Disconnect,(()=>{this._reconnectController.disableReconnect(),this.logger.info("attendee left meeting, session will not be reconnected"),this.actionDisconnect(new u.default(d.default.Left),!1,null).then(e).catch(t)}))}))}stop(){this.stopReturningPromise()}actionDisconnect(e,t,n){return i(this,void 0,void 0,(function*(){try{yield new G.default(this.logger,this.wrapTaskName("AudioVideoStop"),[new Y.default(this.logger,new R.default(this.meetingSessionContext),this.configuration.connectionTimeoutMs)]).run()}catch(e){this.logger.info("fail to stop")}try{const e=[new Y.default(this.logger,new T.default(this.meetingSessionContext),this.configuration.connectionTimeoutMs)];this.cleanUpMediaStreamsAfterStop(),yield new G.default(this.logger,this.wrapTaskName("AudioVideoClean"),e).run()}catch(e){this.logger.info("fail to clean")}this.sessionStateController.perform(v.default.FinishDisconnecting,(()=>{t||(this.meetingSessionContext.signalingClient=null,this.notifyStop(e,n))}))}))}update(e={needsRenegotiation:!0}){let t=e.needsRenegotiation;if(t||(t=void 0===this.meetingSessionContext.peer),t||(t=!this.updateRemoteVideosFromLastVideosToReceive()),t||(t=!this.updateLocalVideoFromPolicy()),this.meetingSessionContext.lastVideosToReceive=this.meetingSessionContext.videosToReceive,!t)return this.logger.info("Update request does not require resubscribe"),this.actionFinishUpdating(),!0;this.logger.info("Update request requires resubscribe");const n=this.sessionStateController.perform(v.default.Update,(()=>{this.actionUpdateWithRenegotiation(!0)}));return n===b.default.Transitioned||n===b.default.DeferredTransition}updateRemoteVideosFromLastVideosToReceive(){var e,t;const n=this.meetingSessionContext;if((null===(e=n.videosToReceive)||void 0===e?void 0:e.empty())||(null===(t=n.lastVideosToReceive)||void 0===t?void 0:t.empty()))return!1;if(!(n.transceiverController&&n.transceiverController.getMidForStreamId&&n.transceiverController.setStreamIdForMid&&n.videosToReceive.forEach&&n.signalingClient.remoteVideoUpdate&&n.videoStreamIndex.overrideStreamIdMappings))return!1;let i=[];const r=new Map;let a=[];if(null===n.lastVideosToReceive)i=n.videosToReceive.array();else{const e=n.videoStreamIndex;n.videosToReceive.forEach((t=>{if(n.lastVideosToReceive.contain(t))return;let a=!1;n.lastVideosToReceive.forEach((n=>{a||e.StreamIdsInSameGroup(n,t)&&(r.set(n,t),a=!0)})),a||i.push(t)})),a=n.lastVideosToReceive.array().filter((e=>{const t=n.videosToReceive.contain(e),i=r.has(e);return!t&&!i}))}this.logger.info(`Request to update remote videos with added: ${i}, updated: ${[...r.entries()]}, removed: ${a}`);const o=[];for(const[e,t]of r.entries()){const i=new _.default;if(i.streamId=t,i.attendeeId=n.videoStreamIndex.attendeeIdForStreamId(t),i.mid=n.transceiverController.getMidForStreamId(e),void 0===i.mid)return this.logger.info(`No MID found for stream ID ${e}, cannot update stream without renegotiation`),!1;if(o.push(i),n.transceiverController.setStreamIdForMid(i.mid,t),n.videoStreamIndex.overrideStreamIdMappings(e,t),n.videoTileController.haveVideoTileForAttendeeId(i.attendeeId)){const e=n.videoTileController.getVideoTileForAttendeeId(i.attendeeId);if(!e.setStreamId)return!1;e.setStreamId(t)}}return 0!==o.length&&n.signalingClient.remoteVideoUpdate(o,[]),0===i.length&&0===a.length}updateLocalVideoFromPolicy(){if(this.meetingSessionContext.enableSimulcast){const e=this.meetingSessionContext.videoUplinkBandwidthPolicy.chooseEncodingParameters();if(this.mayNeedRenegotiationForSimulcastLayerChange&&!this.negotiatedBitrateLayersAllocationRtpHeaderExtension())return this.logger.info("Needs regenotiation for local video simulcast layer change"),this.mayNeedRenegotiationForSimulcastLayerChange=!1,!1;this.meetingSessionContext.transceiverController.setEncodingParameters(e)}else this.meetingSessionContext.videoCaptureAndEncodeParameter=this.meetingSessionContext.videoUplinkBandwidthPolicy.chooseCaptureAndEncodeParameters();return this.logger.info("Updated local video from policy without renegotiation"),!0}negotiatedBitrateLayersAllocationRtpHeaderExtension(){if(!this.meetingSessionContext.transceiverController.localVideoTransceiver())return!1;const e=this.meetingSessionContext.transceiverController.localVideoTransceiver().sender.getParameters();return!(!e||!e.headerExtensions)&&e.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00"===e.uri))}restartLocalVideo(e){const t=()=>i(this,void 0,void 0,(function*(){this._videoTileController.hasStartedLocalVideoTile()&&(this.logger.info("stopping local video tile prior to local video restart"),this._videoTileController.stopLocalVideoTile(),this.logger.info("preparing local video restart update"),yield this.actionUpdateWithRenegotiation(!1),this.logger.info("starting local video tile for local video restart"),this._videoTileController.startLocalVideoTile()),this.logger.info("finalizing local video restart update"),yield this.actionUpdateWithRenegotiation(!0),e()})),n=this.sessionStateController.perform(v.default.Update,(()=>{t()}));return n===b.default.Transitioned||n===b.default.DeferredTransition}replaceLocalVideo(e){return i(this,void 0,void 0,(function*(){if(!e||e.getVideoTracks().length<1)throw new Error("could not acquire video track");if(!this.meetingSessionContext||!this.meetingSessionContext.peer)throw new Error("no active meeting and peer connection");const t=this.meetingSessionContext.videoTileController.getLocalVideoTile();if(t){const n=t.state(),i=e.getVideoTracks()[0].getSettings();t.bindVideoStream(n.boundAttendeeId,!0,e,i.width,i.height,n.streamId,n.boundExternalUserId)}yield this.meetingSessionContext.transceiverController.setVideoInput(e.getVideoTracks()[0]),this.meetingSessionContext.activeVideoInput=e,this.logger.info("Local video input is updated")}))}replaceLocalAudio(e){return i(this,void 0,void 0,(function*(){if(!e||e.getAudioTracks().length<1)throw new Error("could not acquire audio track");if(!this.meetingSessionContext||!this.meetingSessionContext.peer)throw new Error("no active meeting and peer connection");if(this.connectionHealthData.reset(),this.connectionHealthData.setConnectionStartTime(),!(yield this.meetingSessionContext.transceiverController.replaceAudioTrack(e.getAudioTracks()[0])))throw new Error("Failed to replace audio track");this.meetingSessionContext.activeAudioInput=e,this.logger.info("Local audio input is updated")}))}actionUpdateWithRenegotiation(e){return i(this,void 0,void 0,(function*(){this.monitorTask.pauseResubscribeCheck(),this.receiveIndexTask.pauseIngestion();try{yield new G.default(this.logger,this.wrapTaskName("AudioVideoUpdate"),[new F.default(this.meetingSessionContext),new Y.default(this.logger,new G.default(this.logger,"UpdateSession",[new L.default(this.meetingSessionContext),new A.default(this.meetingSessionContext),new j.default(this.meetingSessionContext),new V.default(this.meetingSessionContext),new X.default(this.meetingSessionContext),new q.default(this.meetingSessionContext)]),this.configuration.connectionTimeoutMs)]).run(),e&&this.sessionStateController.perform(v.default.FinishUpdating,(()=>{this.actionFinishUpdating()}))}catch(e){this.sessionStateController.perform(v.default.FinishUpdating,(()=>{const t=new u.default(this.getMeetingStatusCode(e)||d.default.TaskFailed);t.statusCode()!==d.default.IncompatibleSDP&&this.logger.info("failed to update audio-video session"),this.handleMeetingSessionStatus(t,e)}))}}))}notifyStop(e,t){var n;if(this.forEachObserver((t=>{ee.Maybe.of(t.audioVideoDidStop).map((n=>n.bind(t)(e)))})),this.promotedToPrimaryMeeting&&t&&this.forEachObserver((e=>{this.promotedToPrimaryMeeting=!1,ee.Maybe.of(e.audioVideoWasDemotedFromPrimaryMeeting).map((t=>t.bind(e)(new u.default(d.default.SignalingInternalServerError))))})),this.eventController){const{signalingOpenDurationMs:i,poorConnectionCount:r,startTimeMs:a,iceGatheringDurationMs:o,attendeePresenceDurationMs:s,meetingStartDurationMs:c}=this.meetingSessionContext,l={maxVideoTileCount:this.meetingSessionContext.maxVideoTileCount,meetingDurationMs:null===a?0:Math.round(Date.now()-a),meetingStatus:d.default[e.statusCode()],signalingOpenDurationMs:i,iceGatheringDurationMs:o,attendeePresenceDurationMs:s,poorConnectionCount:r,meetingStartDurationMs:c,retryCount:this.totalRetryCount},u=t&&t.message||(null===(n=e.toString)||void 0===n?void 0:n.call(e))||"";0===l.meetingDurationMs?(l.meetingErrorMessage=u,delete l.meetingDurationMs,delete l.attendeePresenceDurationMs,delete l.meetingStartDurationMs,this.eventController.publishEvent("meetingStartFailed",l)):e.isFailure()||e.isAudioConnectionFailure()?(l.meetingErrorMessage=u,this.eventController.publishEvent("meetingFailed",l)):this.eventController.publishEvent("meetingEnded",l)}}actionFinishUpdating(){if(!this.meetingSessionContext.enableSimulcast)if(this.useUpdateTransceiverControllerForUplink)this.meetingSessionContext.videoUplinkBandwidthPolicy.updateTransceiverController();else{const e=this.meetingSessionContext.videoCaptureAndEncodeParameter.encodeBitrates()[0];this.enforceBandwidthLimitationForSender(e)}this.monitorTask.resumeResubscribeCheck(),this.receiveIndexTask.resumeIngestion(),this.logger.info("updated audio-video session")}reconnect(e,t){const n=this._reconnectController.retryWithBackoff((()=>i(this,void 0,void 0,(function*(){this.sessionStateController.state()===y.default.NotConnected?this.sessionStateController.perform(v.default.Connect,(()=>{this.actionConnect(!0)})):this.sessionStateController.perform(v.default.Reconnect,(()=>{this.actionReconnect(e)})),this.totalRetryCount+=1}))),(()=>{this.logger.info("canceled retry")}));return n||this.sessionStateController.perform(v.default.Fail,(()=>{this.actionDisconnect(e,!1,t)})),n}actionReconnect(e){return i(this,void 0,void 0,(function*(){this._reconnectController.hasStartedConnectionAttempt()||(this._reconnectController.startedConnectionAttempt(!1),this.forEachObserver((e=>{ee.Maybe.of(e.audioVideoDidStartConnecting).map((t=>t.bind(e)(!0)))}))),this.meetingSessionContext.volumeIndicatorAdapter.onReconnect(),this.connectionHealthData.reset();try{yield new G.default(this.logger,this.wrapTaskName("AudioVideoReconnect"),[new Y.default(this.logger,new G.default(this.logger,"Media",[new E.default(this.meetingSessionContext),new G.default(this.logger,"Signaling",[new k.default(this.meetingSessionContext),new H.default(this.meetingSessionContext),new B.default(this.meetingSessionContext)]),new z.default(this.meetingSessionContext)]),this.configuration.connectionTimeoutMs),new F.default(this.meetingSessionContext),new Y.default(this.logger,new G.default(this.logger,"UpdateSession",[new L.default(this.meetingSessionContext),new A.default(this.meetingSessionContext),new j.default(this.meetingSessionContext),new V.default(this.meetingSessionContext),new X.default(this.meetingSessionContext),new q.default(this.meetingSessionContext)]),this.configuration.connectionTimeoutMs)]).run(),this.sessionStateController.perform(v.default.FinishConnecting,(()=>{if(this.eventController){const{signalingOpenDurationMs:t,poorConnectionCount:n,startTimeMs:i,iceGatheringDurationMs:r,attendeePresenceDurationMs:a,meetingStartDurationMs:o}=this.meetingSessionContext,s={maxVideoTileCount:this.meetingSessionContext.maxVideoTileCount,meetingDurationMs:Math.round(Date.now()-i),meetingStatus:d.default[e.statusCode()],signalingOpenDurationMs:t,iceGatheringDurationMs:r,attendeePresenceDurationMs:a,poorConnectionCount:n,meetingStartDurationMs:o,retryCount:this.totalRetryCount};this.eventController.publishEvent("meetingReconnected",s)}this.actionFinishConnecting()}))}catch(e){this.sessionStateController.perform(v.default.FinishConnecting,(()=>{this.logger.info("failed to reconnect audio-video session");const t=new u.default(this.getMeetingStatusCode(e)||d.default.TaskFailed);this.handleMeetingSessionStatus(t,e)}))}this.connectionHealthData.setConnectionStartTime()}))}wrapTaskName(e){return`${e}/${this.configuration.meetingId}/${this.configuration.credentials.attendeeId}`}cleanUpMediaStreamsAfterStop(){this._mediaStreamBroker.removeMediaStreamBrokerObserver(this),this.meetingSessionContext.activeAudioInput=void 0,this.meetingSessionContext.activeVideoInput=void 0}getMeetingStatusCode(e){const t=/the meeting status code: (\d+)/.exec(e&&e.message);return t&&t.length>1?Number.parseInt(t[1],10):null}enforceBandwidthLimitationForSender(e){return i(this,void 0,void 0,(function*(){yield this.meetingSessionContext.transceiverController.setVideoSendingBitrateKbps(e)}))}handleMeetingSessionStatus(e,t){if(this.logger.info(`handling status: ${d.default[e.statusCode()]}`),e.isTerminal()||this.meetingSessionContext.statsCollector&&this.meetingSessionContext.statsCollector.logMeetingSessionStatus(e),e.statusCode()===d.default.IncompatibleSDP)return this.restartLocalVideo((()=>{this.logger.info("handled incompatible SDP by attempting to restart video")})),!0;if(e.statusCode()===d.default.VideoCallSwitchToViewOnly)return this._videoTileController.removeLocalVideoTile(),this.forEachObserver((e=>{ee.Maybe.of(e.videoSendDidBecomeUnavailable).map((t=>t.bind(e)()))})),!1;if(e.statusCode()===d.default.AudioVideoWasRemovedFromPrimaryMeeting)return this.forEachObserver((t=>{ee.Maybe.of(t.audioVideoWasDemotedFromPrimaryMeeting).map((n=>n.bind(t)(e)))})),!1;if(e.isTerminal()&&(this.logger.error("session will not be reconnected"),this.meetingSessionContext.reconnectController&&this.meetingSessionContext.reconnectController.disableReconnect()),(e.isFailure()||e.isTerminal())&&this.meetingSessionContext.reconnectController){const n=this.reconnect(e,t);return n?this.logger.warn(`will retry due to status code ${d.default[e.statusCode()]}${t?` and error: ${t.message}`:""}`):this.logger.error(`failed with status code ${d.default[e.statusCode()]}${t?` and error: ${t.message}`:""}`),n}return!1}setVideoMaxBandwidthKbps(e){if(e<=0)throw new Error("Max bandwidth kbps has to be greater than 0");this.meetingSessionContext&&this.meetingSessionContext.videoUplinkBandwidthPolicy&&(this.logger.info(`video send has ideal max bandwidth ${e} kbps`),this.meetingSessionContext.videoUplinkBandwidthPolicy.setIdealMaxBandwidthKbps(e)),this.maxUplinkBandwidthKbps=e}handleHasBandwidthPriority(e){return i(this,void 0,void 0,(function*(){if(this.meetingSessionContext&&this.meetingSessionContext.videoUplinkBandwidthPolicy&&!this.meetingSessionContext.enableSimulcast){if(this.useUpdateTransceiverControllerForUplink)return this.meetingSessionContext.videoUplinkBandwidthPolicy.setHasBandwidthPriority(e),void(yield this.meetingSessionContext.videoUplinkBandwidthPolicy.updateTransceiverController());const t=this.meetingSessionContext.videoUplinkBandwidthPolicy.maxBandwidthKbps();this.meetingSessionContext.videoUplinkBandwidthPolicy.setHasBandwidthPriority(e);const n=this.meetingSessionContext.videoUplinkBandwidthPolicy.maxBandwidthKbps();t!==n&&(this.logger.info(`video send bandwidth priority ${e} max has changed from ${t} kbps to ${n} kbps`),yield this.enforceBandwidthLimitationForSender(n))}}))}pauseReceivingStream(e){this.meetingSessionContext&&this.meetingSessionContext.signalingClient&&this.meetingSessionContext.signalingClient.pause([e])}resumeReceivingStream(e){this.meetingSessionContext&&this.meetingSessionContext.signalingClient&&this.meetingSessionContext.signalingClient.resume([e])}setVideoCodecSendPreferences(e){this.videoSendCodecPreferences=e,this.meetingSessionContext.videoSendCodecPreferences=e,this.update({needsRenegotiation:!0})}getRemoteVideoSources(){const{videoStreamIndex:e}=this.meetingSessionContext;if(!e)return this.logger.info("meeting has not started"),[];const t=this.configuration.credentials.attendeeId;return e.allVideoSendingSourcesExcludingSelf(t)}encodingSimulcastLayersDidChange(e){this.mayNeedRenegotiationForSimulcastLayerChange=!0,this.forEachObserver((t=>{ee.Maybe.of(t.encodingSimulcastLayersDidChange).map((n=>n.bind(t)(e)))}))}promoteToPrimaryMeeting(e){return this.actionPromoteToPrimaryMeeting(e)}actionPromoteToPrimaryMeeting(e){return i(this,void 0,void 0,(function*(){let t=new u.default(d.default.SignalingRequestFailed);return yield new G.default(this.logger,this.wrapTaskName("PromoteToPrimaryMeeting"),[new Y.default(this.logger,new D.default(this.meetingSessionContext,e,(e=>{t=e})),this.configuration.connectionTimeoutMs)]).run(),this.promotedToPrimaryMeeting=t.statusCode()===d.default.OK,t}))}demoteFromPrimaryMeeting(){this.meetingSessionContext.signalingClient.demoteFromPrimaryMeeting(),this.forEachObserver((e=>{ee.Maybe.of(e.audioVideoWasDemotedFromPrimaryMeeting).map((t=>t.bind(e)(new u.default(d.default.OK))))}))}videoInputDidChange(e){return i(this,void 0,void 0,(function*(){this.logger.info("Receive a video input change event"),this.meetingSessionContext&&this.meetingSessionContext.peer?this._videoTileController.hasStartedLocalVideoTile()&&(e?yield this.replaceLocalVideo(e):this._videoTileController.stopLocalVideoTile()):this.logger.info("Skip updating video input because there is no active meeting and peer connection")}))}audioInputDidChange(e){return i(this,void 0,void 0,(function*(){if(this.logger.info("Receive an audio input change event"),this.meetingSessionContext&&this.meetingSessionContext.peer){if(!e)try{e=yield this.mediaStreamBroker.acquireAudioInputStream()}catch(e){return void this.logger.error("Could not acquire audio track from mediaStreamBroker")}yield this.replaceLocalAudio(e)}else this.logger.info("Skip updating audio input because there is no active meeting and peer connection")}))}}t.default=fe,fe.MIN_VOLUME_DECIBELS=-42,fe.MAX_VOLUME_DECIBELS=-14,fe.PING_PONG_INTERVAL_MS=1e4},9836:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8434),r=n(3831),a=n(209),o=n(4015),s=n(589),c=n(8015),l=n(3789),u=n(5687),d=n(6057),h=n(9141),f=n(7631),p=n(9059);class m extends p.default{constructor(e){const t=new s.default;t.meetingId="",t.externalMeetingId="",t.credentials=new c.default,t.credentials.attendeeId="",t.credentials.joinToken="",t.urls=new d.default,t.urls.turnControlURL="",t.urls.audioHostURL="",t.urls.signalingURL="wss://localhost/";const n=new a.default;super(e||t,n,new f.default(new a.default),new o.default,new h.default(0,new i.default(0,0,0)),new r.default(e||t,n))}setAudioProfile(e){}start(){}stop(){}promoteToPrimaryMeeting(e){return Promise.resolve(new l.default(u.default.OK))}demoteFromPrimaryMeeting(){}}t.default=m},8538:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(7170);t.default=class{constructor(e,t,n,i,r,a){this.audioVideoController=e,this.videoTileController=t,this.realtimeController=n,this.audioMixController=i,this.deviceController=r,this.contentShareController=a}addObserver(e){this.audioVideoController.addObserver(e),this.trace("addObserver")}removeObserver(e){this.audioVideoController.removeObserver(e),this.trace("removeObserver")}setAudioProfile(e){this.trace("setAudioProfile",e),this.audioVideoController.setAudioProfile(e)}start(e){this.audioVideoController.start(e),this.trace("start")}stop(){this.audioVideoController.stop(),this.trace("stop")}getRTCPeerConnectionStats(e){return this.trace("getRTCPeerConnectionStats",e?e.id:null),this.audioVideoController.getRTCPeerConnectionStats(e)}bindAudioElement(e){const t=this.audioMixController.bindAudioElement(e);return this.trace("bindAudioElement",e.id,t),t}unbindAudioElement(){this.audioMixController.unbindAudioElement(),this.trace("unbindAudioElement")}getCurrentMeetingAudioStream(){return this.trace("getCurrentConferenceStream"),this.audioMixController.getCurrentMeetingAudioStream()}addAudioMixObserver(e){this.trace("addAudioMixObserver"),this.audioMixController.addAudioMixObserver(e)}removeAudioMixObserver(e){this.trace("removeAudioMixObserver"),this.audioMixController.removeAudioMixObserver(e)}bindVideoElement(e,t){this.videoTileController.bindVideoElement(e,t),this.trace("bindVideoElement",{tileId:e,videoElementId:t.id})}unbindVideoElement(e,t=!0){this.videoTileController.unbindVideoElement(e,t),this.trace("unbindVideoElement",{tileId:e,cleanUpVideoElement:t})}startLocalVideoTile(){const e=this.videoTileController.startLocalVideoTile();return this.trace("startLocalVideoTile",null,e),e}stopLocalVideoTile(){this.videoTileController.stopLocalVideoTile(),this.trace("stopLocalVideoTile")}hasStartedLocalVideoTile(){const e=this.videoTileController.hasStartedLocalVideoTile();return this.trace("hasStartedLocalVideoTile",null,e),e}removeLocalVideoTile(){this.videoTileController.removeLocalVideoTile(),this.trace("removeLocalVideoTile")}getLocalVideoTile(){const e=this.videoTileController.getLocalVideoTile();return this.trace("getLocalVideoTile"),e}pauseVideoTile(e){this.videoTileController.pauseVideoTile(e),this.trace("pauseVideoTile",e)}unpauseVideoTile(e){this.videoTileController.unpauseVideoTile(e),this.trace("unpauseVideoTile",e)}getVideoTile(e){const t=this.videoTileController.getVideoTile(e);return this.trace("getVideoTile",e),t}getAllRemoteVideoTiles(){const e=this.videoTileController.getAllRemoteVideoTiles();return this.trace("getAllRemoteVideoTiles"),e}getAllVideoTiles(){const e=this.videoTileController.getAllVideoTiles();return this.trace("getAllVideoTiles"),e}addVideoTile(){const e=this.videoTileController.addVideoTile();return this.trace("addVideoTile",null,e.state()),e}removeVideoTile(e){this.videoTileController.removeVideoTile(e),this.trace("removeVideoTile",e)}removeVideoTilesByAttendeeId(e){const t=this.videoTileController.removeVideoTilesByAttendeeId(e);return this.trace("removeVideoTilesByAttendeeId",e,t),t}removeAllVideoTiles(){this.videoTileController.removeAllVideoTiles(),this.trace("removeAllVideoTiles")}captureVideoTile(e){const t=this.videoTileController.captureVideoTile(e);return this.trace("captureVideoTile",e),t}realtimeSubscribeToAttendeeIdPresence(e){this.realtimeController.realtimeSubscribeToAttendeeIdPresence(e),this.trace("realtimeSubscribeToAttendeeIdPresence")}realtimeUnsubscribeToAttendeeIdPresence(e){this.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(e),this.trace("realtimeUnsubscribeToAttendeeIdPresence")}realtimeSetCanUnmuteLocalAudio(e){this.realtimeController.realtimeSetCanUnmuteLocalAudio(e),this.trace("realtimeSetCanUnmuteLocalAudio",e)}realtimeSubscribeToSetCanUnmuteLocalAudio(e){this.realtimeController.realtimeSubscribeToSetCanUnmuteLocalAudio(e),this.trace("realtimeSubscribeToSetCanUnmuteLocalAudio")}realtimeUnsubscribeToSetCanUnmuteLocalAudio(e){this.realtimeController.realtimeUnsubscribeToSetCanUnmuteLocalAudio(e),this.trace("realtimeUnsubscribeToSetCanUnmuteLocalAudio")}realtimeCanUnmuteLocalAudio(){const e=this.realtimeController.realtimeCanUnmuteLocalAudio();return this.trace("realtimeCanUnmuteLocalAudio",null,e),e}realtimeMuteLocalAudio(){this.realtimeController.realtimeMuteLocalAudio(),this.trace("realtimeMuteLocalAudio")}realtimeUnmuteLocalAudio(){const e=this.realtimeController.realtimeUnmuteLocalAudio();return this.trace("realtimeUnmuteLocalAudio"),e}realtimeSubscribeToMuteAndUnmuteLocalAudio(e){this.realtimeController.realtimeSubscribeToMuteAndUnmuteLocalAudio(e),this.trace("realtimeSubscribeToMuteAndUnmuteLocalAudio")}realtimeUnsubscribeToMuteAndUnmuteLocalAudio(e){this.realtimeController.realtimeUnsubscribeToMuteAndUnmuteLocalAudio(e),this.trace("realtimeUnsubscribeToMuteAndUnmuteLocalAudio")}realtimeIsLocalAudioMuted(){const e=this.realtimeController.realtimeIsLocalAudioMuted();return this.trace("realtimeIsLocalAudioMuted"),e}realtimeSubscribeToVolumeIndicator(e,t){this.realtimeController.realtimeSubscribeToVolumeIndicator(e,t),this.trace("realtimeSubscribeToVolumeIndicator",e)}realtimeUnsubscribeFromVolumeIndicator(e,t){this.realtimeController.realtimeUnsubscribeFromVolumeIndicator(e,t),this.trace("realtimeUnsubscribeFromVolumeIndicator",e,t)}realtimeSubscribeToLocalSignalStrengthChange(e){this.realtimeController.realtimeSubscribeToLocalSignalStrengthChange(e),this.trace("realtimeSubscribeToLocalSignalStrengthChange")}realtimeUnsubscribeToLocalSignalStrengthChange(e){this.realtimeController.realtimeUnsubscribeToLocalSignalStrengthChange(e),this.trace("realtimeUnsubscribeToLocalSignalStrengthChange")}realtimeSendDataMessage(e,t,n){this.realtimeController.realtimeSendDataMessage(e,t,n),this.trace("realtimeSendDataMessage")}realtimeSubscribeToReceiveDataMessage(e,t){this.realtimeController.realtimeSubscribeToReceiveDataMessage(e,t),this.trace("realtimeSubscribeToReceiveDataMessage")}realtimeUnsubscribeFromReceiveDataMessage(e){this.realtimeController.realtimeUnsubscribeFromReceiveDataMessage(e),this.trace("realtimeUnsubscribeFromReceiveDataMessage")}realtimeSubscribeToFatalError(e){this.realtimeController.realtimeSubscribeToFatalError(e),this.trace("realtimeSubscribeToFatalError")}realtimeUnsubscribeToFatalError(e){this.realtimeController.realtimeUnsubscribeToFatalError(e),this.trace("realtimeUnsubscribeToFatalError")}subscribeToActiveSpeakerDetector(e,t,n,i){this.audioVideoController.activeSpeakerDetector.subscribe(e,t,n,i),this.trace("subscribeToActiveSpeakerDetector")}unsubscribeFromActiveSpeakerDetector(e){this.audioVideoController.activeSpeakerDetector.unsubscribe(e),this.trace("unsubscribeFromActiveSpeakerDetector")}listAudioInputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.deviceController.listAudioInputDevices(e);return this.trace("listAudioInputDevices",e,t),t}))}listVideoInputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.deviceController.listVideoInputDevices(e);return this.trace("listVideoInputDevices",e,t),t}))}listAudioOutputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.deviceController.listAudioOutputDevices(e);return this.trace("listAudioOutputDevices",e,t),t}))}startAudioInput(e){return i(this,void 0,void 0,(function*(){return this.trace("startAudioInput",e),this.deviceController.startAudioInput(e)}))}stopAudioInput(){return i(this,void 0,void 0,(function*(){return this.trace("stopAudioInput"),this.deviceController.stopAudioInput()}))}startVideoInput(e){return i(this,void 0,void 0,(function*(){return r.isVideoTransformDevice(e)?this.trace("startVideoInput with transform device"):this.trace("startVideoInput",e),this.deviceController.startVideoInput(e)}))}stopVideoInput(){return i(this,void 0,void 0,(function*(){return this.trace("stopVideoInput"),this.deviceController.stopVideoInput()}))}chooseAudioOutput(e){const t=this.deviceController.chooseAudioOutput(e);return this.trace("chooseAudioOutput",e),t}addDeviceChangeObserver(e){this.deviceController.addDeviceChangeObserver(e),this.trace("addDeviceChangeObserver")}removeDeviceChangeObserver(e){this.deviceController.removeDeviceChangeObserver(e),this.trace("removeDeviceChangeObserver")}createAnalyserNodeForAudioInput(){const e=this.deviceController.createAnalyserNodeForAudioInput();return this.trace("createAnalyserNodeForAudioInput"),e}startVideoPreviewForVideoInput(e){this.deviceController.startVideoPreviewForVideoInput(e),this.trace("startVideoPreviewForVideoInput",e.id)}stopVideoPreviewForVideoInput(e){this.deviceController.stopVideoPreviewForVideoInput(e),this.trace("stopVideoPreviewForVideoInput",e.id)}setDeviceLabelTrigger(e){this.deviceController.setDeviceLabelTrigger(e),this.trace("setDeviceLabelTrigger")}mixIntoAudioInput(e){const t=this.deviceController.mixIntoAudioInput(e);return this.trace("mixIntoAudioInput",e.id),t}chooseVideoInputQuality(e,t,n){this.deviceController.chooseVideoInputQuality(e,t,n),this.trace("chooseVideoInputQuality",{width:e,height:t,frameRate:n})}setVideoMaxBandwidthKbps(e){this.audioVideoController.setVideoMaxBandwidthKbps(e),this.trace("setVideoMaxBandwidthKbps",e)}setVideoCodecSendPreferences(e){this.audioVideoController.setVideoCodecSendPreferences(e),this.trace("setVideoCodecSendPreferences",e)}getVideoInputQualitySettings(){const e=this.deviceController.getVideoInputQualitySettings();return this.trace("getVideoInputQualitySettings"),e}setContentAudioProfile(e){this.trace("setContentAudioProfile",e),this.contentShareController.setContentAudioProfile(e)}enableSimulcastForContentShare(e,t){this.trace("enableSimulcastForContentShare"),this.contentShareController.enableSimulcastForContentShare(e,t)}startContentShare(e){const t=this.contentShareController.startContentShare(e);return this.trace("startContentShare"),t}startContentShareFromScreenCapture(e,t){const n=this.contentShareController.startContentShareFromScreenCapture(e,t);return this.trace("startContentShareFromScreenCapture"),n}pauseContentShare(){this.contentShareController.pauseContentShare(),this.trace("pauseContentShare")}unpauseContentShare(){this.contentShareController.unpauseContentShare(),this.trace("unpauseContentShare")}stopContentShare(){this.contentShareController.stopContentShare(),this.trace("stopContentShare")}addContentShareObserver(e){this.contentShareController.addContentShareObserver(e),this.trace("addContentShareObserver")}removeContentShareObserver(e){this.contentShareController.removeContentShareObserver(e),this.trace("removeContentShareObserver")}setContentShareVideoCodecPreferences(e){this.contentShareController.setContentShareVideoCodecPreferences(e),this.trace("setContentShareVideoCodecPreferences")}trace(e,t,n){let i=`API/DefaultAudioVideoFacade/${this.audioVideoController.configuration.meetingId}/${this.audioVideoController.configuration.credentials.attendeeId}/${e}`;void 0!==t&&(i+=` ${JSON.stringify(t)}`),void 0!==n&&(i+=` -> ${JSON.stringify(n)}`),this.audioVideoController.logger.info(i)}getRemoteVideoSources(){const e=this.audioVideoController.getRemoteVideoSources();return this.trace("getRemoteVideoSources",null,e),e}get transcriptionController(){return this.realtimeController.transcriptionController}promoteToPrimaryMeeting(e){this.audioVideoController.removeObserver(this),this.audioVideoController.addObserver(this);const t=this.audioVideoController.promoteToPrimaryMeeting(e);return this.trace("promoteToPrimaryMeeting",null,t),t}demoteFromPrimaryMeeting(){this.trace("demoteFromPrimaryMeeting"),this.audioVideoController.demoteFromPrimaryMeeting()}audioVideoWasDemotedFromPrimaryMeeting(e){this.contentShareController.stopContentShare(),this.audioVideoController.removeObserver(this)}}},179:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(8074),a=n(9734);class o extends r.default{constructor(e,t){super(e,t),this.blurCanvas=document.createElement("canvas"),this.blurCanvasCtx=this.blurCanvas.getContext("2d"),this.blurCanvas.width=this.spec.model.input.width,this.blurCanvas.height=this.spec.model.input.height,this.logger.info("BackgroundBlur processor using builtin blur")}drawImageWithMask(e,t){const n=this.blurredImage,{canvasCtx:i,targetCanvas:r}=this,{width:a,height:o}=r;t&&n?(this.scaledCanvas.getContext("2d").putImageData(t,0,0),this.blurCanvasCtx.putImageData(this.blurredImage,0,0),i.save(),i.clearRect(0,0,a,o),i.drawImage(this.scaledCanvas,0,0,a,o),i.globalCompositeOperation="source-in",i.drawImage(e,0,0,a,o),i.globalCompositeOperation="destination-over",i.drawImage(this.blurCanvas,0,0,a,o),i.restore()):i.clearRect(0,0,a,o)}setBlurStrength(e){if(super.setBlurStrength(e),this.worker){this.modelInitialized=!1,this.worker.postMessage({msg:"destroy"});const e=this.spec.model;this.worker.postMessage({msg:"loadModel",payload:{modelUrl:e.path,inputHeight:e.input.height,inputWidth:e.input.width,inputChannels:4,modelRangeMin:e.input.range[0],modelRangeMax:e.input.range[1],blurPixels:this.blurAmount}})}}setBlurPixels(){this.blurAmount=a.BlurStrengthMapper.getBlurAmount(this._blurStrength,{height:540}),this.logger.info(`background blur amount set to ${this.blurAmount}`)}handleInitialize(e){if(this.logger.info(`received initialize message: ${this.stringify(e)}`),!e.payload)return this.logger.error("failed to initialize module"),void this.initWorkerPromise.reject(new Error("failed to initialize the module"));const t=this.spec.model;this.worker.postMessage({msg:"loadModel",payload:{modelUrl:t.path,inputHeight:t.input.height,inputWidth:t.input.width,inputChannels:4,modelRangeMin:t.input.range[0],modelRangeMax:t.input.range[1],blurPixels:this.blurAmount}}),this.initWorkerPromise.resolve({})}handlePredict(e){this.blurredImage=e.payload.blurOutput,super.handlePredict(e)}destroy(){const e=Object.create(null,{destroy:{get:()=>super.destroy}});var t;return i(this,void 0,void 0,(function*(){e.destroy.call(this),null===(t=this.blurCanvas)||void 0===t||t.remove(),this.blurCanvas=void 0}))}}t.default=o},8074:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1851),a=n(9734),o=n(9852);class s extends r.default{constructor(e,t){super("background blur",e,t,new o.default),this.blurAmount=0,this.setBlurStrength(t.blurStrength),this.logger.info("BackgroundBlur processor successfully created"),this.logger.info(`BackgroundBlur spec: ${this.stringify(this.spec)}`),this.logger.info(`BackgroundBlur options: ${this.stringify(t)}`)}validateOptions(e){if(super.validateOptions(e),!e.blurStrength)throw new Error("processor has null options - blurStrength")}initOnFirstExecution(){this.setBlurPixels()}drawImageWithMask(e,t){t||(t=new ImageData(this.spec.model.input.width,this.spec.model.input.height)),this.scaledCanvas.getContext("2d").putImageData(t,0,0);const{canvasCtx:n,targetCanvas:i}=this,{width:r,height:a}=i;n.save(),n.clearRect(0,0,r,a),n.drawImage(this.scaledCanvas,0,0,r,a),n.globalCompositeOperation="source-in",n.drawImage(e,0,0,r,a),n.globalCompositeOperation="destination-over",n.filter=`blur(${this.blurAmount}px)`,n.drawImage(e,0,0,i.width,i.height),n.restore()}setBlurStrength(e){this._blurStrength=e,this.logger.info(`blur strength set to ${this._blurStrength}`),this.setBlurPixels()}setBlurPixels(){this.blurAmount=a.BlurStrengthMapper.getBlurAmount(this._blurStrength,{height:this.sourceHeight}),this.logger.info(`background blur amount set to ${this.blurAmount}`)}addObserver(e){this.delegate.addObserver(e)}removeObserver(e){this.delegate.removeObserver(e)}static isSupported(){return i(this,void 0,void 0,(function*(){const e=document.createElement("canvas"),t=void 0!==e.getContext("2d").filter;return e.remove(),t}))}}t.default=s},9734:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlurStrengthMapper=void 0;class n{static getBlurAmount(e,t){if(e<=0)throw new Error(`invalid value for blur strength: ${e}`);return Math.round(e*t.height/this.BLUR_STRENGTH_DIVISOR)}}t.BlurStrengthMapper=n,n.BLUR_STRENGTH_DIVISOR=540,t.default={LOW:7,MEDIUM:15,HIGH:30}},1260:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(4243),a=n(8030),o=n(813),s=n(2801),c=n(179),l=n(8074),u=n(9734);class d extends s.default{setBlurStrength(){}loadAssets(){return i(this,void 0,void 0,(function*(){}))}addObserver(){}removeObserver(){}}class h extends r.default{static create(e,t){return i(this,void 0,void 0,(function*(){e=h.resolveSpec(e),t=h.resolveOptions(t);const{logger:n}=t,i=yield h.isSupported(e,t);if(n.info(`processor is ${i?"":"not"} supported`),!i)return n.warn("Using no-op processor because background blur is not supported"),new d;let r;return(yield l.default.isSupported())?(n.info("Using browser-provided background blur"),r=new l.default(e,t)):(n.info("Using built-in background blur"),r=new c.default(e,t)),yield r.loadAssets(),r}))}static resolveOptions(e={}){let t=Object.assign({},e);return t.blurStrength||(t.blurStrength=u.default.MEDIUM),t.logger||(t.logger=new a.default("BackgroundBlurProcessor",o.default.INFO)),t=super.resolveOptions(t),t}static isSupported(e,t){return e=h.resolveSpec(e),t=h.resolveOptions(t),super.isSupported(e,t)}}t.default=h},9852:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4627);class r extends i.default{}t.default=r},22:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(){this.path=null,this.input=null,this.output=null}static builder(){return new n}withDefaultModel(){return this.withSelfieSegmentationDefaults()}withSelfieSegmentationDefaults(){return this.path="https://static.sdkassets.chime.aws/bgblur/models/selfie_segmentation_landscape.tflite",this.input={height:144,width:256,range:[0,1],channels:3},this.output={height:144,width:256,range:[0,1],channels:1},this}withPath(e){return this.path=e,this}withInput(e){return this.input=e,this}withOutput(e){return this.output=e,this}validate(){if(!this.path)throw new Error("model spec path is not set");if(!this.input)throw new Error("model spec input is not set");if(!this.output)throw new Error("model spec output is not set")}build(){return this.validate(),{path:this.path,input:this.input,output:this.output}}}t.default=n},3368:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i){this.delegate=e,this.reportingPeriodMillis=t,this.filterCPUUtilization=n,this.logger=i,this._processingFilter=!0,this.lastReportedEventTimestamp=0,this.lastFilterCompleteTimestamp=0,this.filterTotalMillis=0,this.filterCount=0,this.framerate=0,this.filterDurationNotifyMillis=0,this.setSegmentationDuration()}reportEvent(e){const t=e-this.lastReportedEventTimestamp;if(t>=this.reportingPeriodMillis){const n=this.filterCount,i=this.filterTotalMillis;if(this.filterCount=0,this.filterTotalMillis=0,this.lastReportedEventTimestamp=e,0===this.framerate||0===n)return;const r=Math.round(i/n),a=Math.round(this.framerate*(t/1e3))-n,o=Math.round(100*i/t);r>=this.filterDurationNotifyMillis&&this.delegate.filterFrameDurationHigh({framesDropped:a,avgFilterDurationMillis:r,framerate:this.framerate,periodMillis:t}),o>=this.filterCPUUtilization&&this.delegate.filterCPUUtilizationHigh({cpuUtilization:o,filterMillis:i,periodMillis:t})}}setSegmentationDuration(){this.filterDurationNotifyMillis=Math.round(1e3/this.framerate*.8)}frameReceived(e){e!==this.framerate&&(this.framerate=e,this.logger.info(`frame counter setting frame rate to ${this.framerate}`),this.setSegmentationDuration());const t=Date.now();this.reportEvent(t)}filterSubmitted(){this._processingFilter=!0,this.lastFilterCompleteTimestamp=Date.now()}filterComplete(){this.filterTotalMillis+=Date.now()-this.lastFilterCompleteTimestamp,this._processingFilter=!1,this.filterCount++}get processingSegment(){return this._processingFilter}}},1851:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.BackgroundFilterMonitor=void 0;const r=n(5021),a=n(9807),o=n(3368);class s{constructor(){this.value=void 0,this.resolve=null}whenNext(){return this.promise||(this.promise=new Promise((e=>this.resolve=e))),this.promise}next(e){this.value=e,this.resolve(e),delete this.promise}}class c{constructor(e,t,n,i){this.targetCanvas=document.createElement("canvas"),this.canvasCtx=this.targetCanvas.getContext("2d"),this.canvasVideoFrameBuffer=new a.default(this.targetCanvas),this.mask$=new s,this.sourceWidth=0,this.sourceHeight=0,this.frameNumber=0,this.videoFramesPerFilterUpdate=1,this.initWorkerPromise=c.createWorkerPromise(),this.loadModelPromise=c.createWorkerPromise(),this.modelInitialized=!1,this.destroyed=!1,this.filterType=e,this.validateSpec(t),this.validateOptions(n),this.spec=t,this.logger=n.logger,this.delegate=i,this.initCPUMonitor(n)}static createWorkerPromise(){const e={resolve:null,reject:null,promise:null};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}validateSpec(e){if(!e)throw new Error("processor has null spec");if(!e.model)throw new Error("processor spec has null model");if(!e.paths)throw new Error("processor spec has null paths")}validateOptions(e){if(!e)throw new Error("processor has null options");if(!e.logger)throw new Error("processor has null options - logger");if(!e.reportingPeriodMillis)throw new Error("processor has null options - reportingPeriodMillis");if(!e.filterCPUUtilization)throw new Error("processor has null options - filterCPUUtilization")}initCPUMonitor(e){this.videoFramesPerFilterUpdate=1,this.frameCounter=new o.default(this.delegate,e.reportingPeriodMillis,e.filterCPUUtilization,this.logger),this.cpuMonitor=new l(5e3,{reduceCPUUtilization:()=>{this.updateVideoFramesPerFilterUpdate(Math.min(this.videoFramesPerFilterUpdate+1,10))},increaseCPUUtilization:()=>{this.updateVideoFramesPerFilterUpdate(Math.max(this.videoFramesPerFilterUpdate-1,1))}}),this.delegate.addObserver(this.cpuMonitor)}stringify(e){return JSON.stringify(e,null,2)}handleInitialize(e){if(this.logger.info(`received initialize message: ${this.stringify(e)}`),!e.payload)return this.logger.error("failed to initialize module"),void this.initWorkerPromise.reject(new Error("failed to initialize the module"));const t=this.spec.model;this.worker.postMessage({msg:"loadModel",payload:{modelUrl:t.path,inputHeight:t.input.height,inputWidth:t.input.width,inputChannels:4,modelRangeMin:t.input.range[0],modelRangeMax:t.input.range[1],blurPixels:0}}),this.initWorkerPromise.resolve({})}handleLoadModel(e){if(this.logger.info(`received load model message: ${this.stringify(e)}`),2!==e.payload)return this.logger.error("failed to load model! status: "+e.payload),void this.loadModelPromise.reject(new Error("failed to load model! status: "+e.payload));this.modelInitialized=!0,this.loadModelPromise.resolve({})}handlePredict(e){this.mask$.next(e.payload.output)}handleWorkerEvent(e){const t=e.data;switch(t.msg){case"initialize":this.handleInitialize(t);break;case"loadModel":this.handleLoadModel(t);break;case"predict":this.handlePredict(t);break;default:this.logger.info(`unexpected event msg: ${this.stringify(t)}`)}}loadAssets(){return i(this,void 0,void 0,(function*(){this.logger.info("start initializing the processor");try{this.worker=yield r.loadWorker(this.spec.paths.worker,"BackgroundFilterWorker",{},null),this.worker.addEventListener("message",(e=>this.handleWorkerEvent(e))),this.worker.postMessage({msg:"initialize",payload:{wasmPath:this.spec.paths.wasm,simdPath:this.spec.paths.simd}}),yield this.initWorkerPromise.promise,this.logger.info(`successfully initialized the ${this.filterType} worker`),yield this.loadModelPromise.promise,this.logger.info(`successfully loaded ${this.filterType} worker segmentation model`)}catch(e){throw new Error(`could not initialize the ${this.filterType} video frame processor due to '${e.message}'`)}this.logger.info(`successfully initialized the ${this.filterType} processor`)}))}process(e){return i(this,void 0,void 0,(function*(){if(this.destroyed)return e;this.frameCounter.frameReceived(e[0].framerate),this.cpuMonitor.frameReceived();const t=e[0].asCanvasElement();if(!t)return e;if(!this.modelInitialized)return e[0]=this.canvasVideoFrameBuffer,e;const n=t.width,i=t.height;if(0===n||0===i)return e;0===this.sourceWidth&&(this.sourceWidth=n,this.sourceHeight=i,this.targetCanvas.width=this.sourceWidth,this.targetCanvas.height=this.sourceHeight,this.logger.info(`${this.filterType} source width: ${this.sourceWidth}`),this.logger.info(`${this.filterType} source height: ${this.sourceHeight}`),this.initOnFirstExecution()),this.sourceWidth===n&&this.sourceHeight===i||(this.sourceWidth=n,this.sourceHeight=i,this.targetCanvas.width=this.sourceWidth,this.targetCanvas.height=this.sourceHeight);try{this.frameCounter.filterSubmitted();let e=this.mask$.value;const n=this.spec.model.input.width/t.width,i=this.spec.model.input.height/t.height;void 0===this.scaledCanvas&&(this.scaledCanvas=document.createElement("canvas"),this.scaledCanvas.width=this.spec.model.input.width,this.scaledCanvas.height=this.spec.model.input.height);const r=this.scaledCanvas.getContext("2d");r.save(),r.scale(n,i),r.drawImage(t,0,0),r.restore();const a=r.getImageData(0,0,this.scaledCanvas.width,this.scaledCanvas.height);if(this.frameNumber%this.videoFramesPerFilterUpdate==0){const t=this.mask$.whenNext();this.worker.postMessage({msg:"predict",payload:a},[a.data.buffer]),e=yield t}this.destroyed||this.drawImageWithMask(t,e)}catch(t){return this.logger.error(`could not process ${this.filterType} frame buffer due to ${t}`),e}finally{this.frameCounter.filterComplete(),this.frameNumber++}return e[0]=this.canvasVideoFrameBuffer,e}))}updateVideoFramesPerFilterUpdate(e){e!==this.videoFramesPerFilterUpdate&&(this.videoFramesPerFilterUpdate=e,this.logger.info(`Adjusting filter rate to compensate for CPU utilization. Filter rate is ${this.videoFramesPerFilterUpdate} video frames per filter.`))}destroy(){var e,t,n,r;return i(this,void 0,void 0,(function*(){this.destroyed=!0,this.delegate.removeObserver(this.cpuMonitor),this.canvasVideoFrameBuffer.destroy(),null===(e=this.worker)||void 0===e||e.postMessage({msg:"destroy"}),null===(t=this.worker)||void 0===t||t.postMessage({msg:"stop"}),null===(n=this.targetCanvas)||void 0===n||n.remove(),this.targetCanvas=void 0,null===(r=this.scaledCanvas)||void 0===r||r.remove(),this.scaledCanvas=void 0,this.logger.info(`${this.filterType} frame process destroyed`)}))}}t.default=c;class l{constructor(e,t){this.monitoringPeriodMillis=e,this.observer=t,this.lastCPUChangeTimestamp=0}filterCPUUtilizationHigh(){const e=Date.now();e-this.lastCPUChangeTimestamp>=this.monitoringPeriodMillis&&(this.lastCPUChangeTimestamp=e,this.observer.reduceCPUUtilization())}frameReceived(){const e=Date.now();e-this.lastCPUChangeTimestamp>=2*this.monitoringPeriodMillis&&(this.lastCPUChangeTimestamp=e,this.observer.increaseCPUUtilization())}}t.BackgroundFilterMonitor=l},4243:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5021),a=n(9424),o=n(22),s=n(543),c=n(4046),l=()=>o.default.builder().withSelfieSegmentationDefaults().build(),u="https://static.sdkassets.chime.aws",d={worker:`${u}/bgblur/workers/worker.js`,wasm:`${u}/bgblur/wasm/_cwt-wasm.wasm`,simd:`${u}/bgblur/wasm/_cwt-wasm-simd.wasm`};t.default=class{static defaultAssetSpec(){const e=c.default.sdkVersionSemVer;return{assetGroup:`sdk-${e.major}.${e.minor}`}}static createUrlWithParams(e,t){const n=new URL(e),i=Object.keys(t);for(const e of i)void 0!==t[e]&&n.searchParams.set(e,t[e]);return n.toString()}static resolveSpec(e){const{paths:t=d,model:n=l(),assetGroup:i=this.defaultAssetSpec().assetGroup,revisionID:r=this.defaultAssetSpec().revisionID}=e||{},a={assetGroup:i,revisionID:r,sdk:encodeURIComponent(c.default.sdkVersion),ua:encodeURIComponent(c.default.sdkUserAgentLowResolution)};return t.worker=this.createUrlWithParams(t.worker,a),t.wasm=this.createUrlWithParams(t.wasm,a),t.simd=this.createUrlWithParams(t.simd,a),n.path=this.createUrlWithParams(n.path,a),{paths:t,model:n,assetGroup:i,revisionID:r}}static resolveOptions(e){return e.reportingPeriodMillis||(e.reportingPeriodMillis=1e3),e.filterCPUUtilization?(e.filterCPUUtilization<0||e.filterCPUUtilization>100)&&(e.logger.warn("filterCPUUtilization must be set to a range between 0 and 100 percent. Falling back to default of 30 percent"),e.filterCPUUtilization=30):e.filterCPUUtilization=30,e}static isSupported(e,t){const{logger:n}=t;return"undefined"==typeof globalThis?(n.info("Browser does not have globalThis."),Promise.resolve(!1)):(new s.default).supportsBackgroundFilter()?a.supportsWASM(globalThis,n)?this.supportsBackgroundFilter(globalThis,e,n):(n.info("Browser does not support WASM."),Promise.resolve(!1)):(n.info("Browser is not supported."),Promise.resolve(!1))}static supportsBackgroundFilter(e=globalThis,t,n){return i(this,void 0,void 0,(function*(){if(!a.supportsWorker(e,n))return n.info("Browser does not support web workers."),!1;const i=t.paths.worker;try{const e=yield r.loadWorker(i,"BackgroundFilterWorker",{},null);try{e.terminate()}catch(e){n.info(`Failed to terminate worker. ${e.message}`)}return!0}catch(e){return n.info(`Failed to fetch and instantiate test worker ${e.message}`),!1}}))}}},4627:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.observers=new Set}addObserver(e){this.observers.add(e)}removeObserver(e){this.observers.delete(e)}filterFrameDurationHigh(e){var t;for(const n of this.observers)null===(t=n.filterFrameDurationHigh)||void 0===t||t.call(n,e)}filterCPUUtilizationHigh(e){var t;for(const n of this.observers)null===(t=n.filterCPUUtilizationHigh)||void 0===t||t.call(n,e)}}},9392:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1851),a=n(1447);class o extends r.default{constructor(e,t){super("background replacement",e,t,new a.default),this.replacementBlob=t.imageBlob,this.logger.info("BackgroundReplacement processor successfully created"),this.logger.info(`BackgroundReplacement spec: ${this.stringify(this.spec)}`),this.logger.info(`BackgroundReplacement options: ${this.stringify(t)}`)}setImageBlob(e){return i(this,void 0,void 0,(function*(){this.replacementBlob=e,this.replacementImage=yield o.loadImage(this.createReplacementObjectUrl())}))}initOnFirstExecution(){}drawImageWithMask(e,t){t||(t=new ImageData(this.spec.model.input.width,this.spec.model.input.height)),this.scaledCanvas.getContext("2d").putImageData(t,0,0);const{canvasCtx:n,targetCanvas:i}=this,{width:r,height:a}=i;n.save(),n.clearRect(0,0,r,a),n.drawImage(this.scaledCanvas,0,0,r,a),n.globalCompositeOperation="source-in",n.drawImage(e,0,0,r,a),n.globalCompositeOperation="destination-over",n.drawImage(this.replacementImage,0,0,i.width,i.height),n.restore()}static loadImageExecutor(e,t,n){const i=new Image;i.crossOrigin="Anonymous",i.addEventListener("load",(()=>{e(i)}),!1),i.addEventListener("error",(e=>{t(new Error(`Could not load replacement image ${i.src}: ${e.message}`))}),!1),i.src=n}static loadImage(e){return i(this,void 0,void 0,(function*(){return new Promise(((t,n)=>this.loadImageExecutor(t,n,e)))}))}revokeReplacementObjectUrl(){this.replacementObjectUrl&&URL.revokeObjectURL(this.replacementObjectUrl)}createReplacementObjectUrl(){return this.revokeReplacementObjectUrl(),this.replacementObjectUrl=URL.createObjectURL(this.replacementBlob),this.replacementObjectUrl}loadAssets(){const e=Object.create(null,{loadAssets:{get:()=>super.loadAssets}});return i(this,void 0,void 0,(function*(){this.replacementImage=yield o.loadImage(this.createReplacementObjectUrl()),e.loadAssets.call(this)}))}addObserver(e){this.delegate.addObserver(e)}removeObserver(e){this.delegate.removeObserver(e)}destroy(){const e=Object.create(null,{destroy:{get:()=>super.destroy}});return i(this,void 0,void 0,(function*(){e.destroy.call(this),this.revokeReplacementObjectUrl()}))}}t.default=o},9854:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(4243),a=n(8030),o=n(813),s=n(2801),c=n(9392);class l extends s.default{loadAssets(){return i(this,void 0,void 0,(function*(){}))}addObserver(){}removeObserver(){}setImageBlob(){return i(this,void 0,void 0,(function*(){}))}}class u extends r.default{static create(e,t){return i(this,void 0,void 0,(function*(){e=this.resolveSpec(e),t=this.resolveOptions(t),yield this.resolveOptionsAsync(t);const{logger:n}=t;if(!(yield u.isSupported(e,t)))return n.warn("Using no-op processor because background replacement is not supported"),new l;n.info("Using background replacement filter");const i=new c.default(e,t);return yield i.loadAssets(),i}))}static resolveOptions(e={}){const t=Object.assign({},e);return t.logger||(t.logger=new a.default("BackgroundReplacementProcessor",o.default.INFO)),super.resolveOptions(t)}static resolveOptionsAsync(e){return i(this,void 0,void 0,(function*(){if(!e.imageBlob){const t=document.createElement("canvas");t.width=100,t.height=100;const n=t.getContext("2d");n.fillStyle="blue",n.fillRect(0,0,100,100);const i=yield new Promise((e=>{t.toBlob(e)}));e.imageBlob=i}}))}static isSupported(e,t){const n=Object.create(null,{isSupported:{get:()=>super.isSupported}});return i(this,void 0,void 0,(function*(){e=this.resolveSpec(e),t=this.resolveOptions(t),yield this.resolveOptionsAsync(t);const i=t.imageBlob,r=URL.createObjectURL(i);try{yield c.default.loadImage(r)}catch(e){return t.logger.info(`Failed to fetch load replacement image ${e.message}`),!1}finally{URL.revokeObjectURL(r)}return n.isSupported.call(this,e,t)}))}}t.default=u},1447:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4627);class r extends i.default{}t.default=r},8434:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n){this.fixedWaitMs=e,this.shortBackoffMs=t,this.longBackoffMs=n,this.currentRetry=0,this.fixedWaitMs<0&&(this.fixedWaitMs=0),this.shortBackoffMs<0&&(this.shortBackoffMs=0),this.longBackoffMs<0&&(this.longBackoffMs=0),this.reset()}reset(){this.currentRetry=0}nextBackoffAmountMs(){const e=Math.random()*Math.min(this.longBackoffMs,this.shortBackoffMs*Math.pow(2,this.currentRetry))+this.fixedWaitMs;return this.currentRetry+=1,e}}},5640:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8434),r=n(7300);t.default=class{constructor(e,t,n){this.fixedWaitMs=e,this.shortBackoffMs=t,this.longBackoffMs=n}create(){return new i.default(this.fixedWaitMs,this.shortBackoffMs,this.longBackoffMs)}createWithLimit(e){return new r.default(this.fixedWaitMs,this.shortBackoffMs,this.longBackoffMs,e)}}},7300:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8434);class r extends i.default{constructor(e,t,n,i){super(e,t,n),this.limit=i,this.attempts=0}nextBackoffAmountMs(){if(this.attempts++,this.attempts>this.limit)throw new Error("retry limit exceeded");return super.nextBackoffAmountMs()}}t.default=r},543:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3631);t.default=class{constructor(){this.browser=r.detect(),this.browserSupport={chrome:78,"edge-chromium":79,electron:7,firefox:75,ios:13,safari:13,opera:66,samsung:12,crios:86,fxios:23,"ios-webview":605,"chromium-webview":92},this.browserName={chrome:"Google Chrome","edge-chromium":"Microsoft Edge",electron:"Electron",firefox:"Mozilla Firefox",ios:"Safari iOS",safari:"Safari",opera:"Opera",samsung:"Samsung Internet",crios:"Chrome iOS",fxios:"Firefox iOS","ios-webview":"WKWebView iOS","chromium-webview":"Chrome WebView"},this.chromeLike=["chrome","edge-chromium","chromium-webview","opera","samsung"],this.webkitBrowsers=["crios","fxios","safari","ios","ios-webview"]}version(){return this.browser.version}majorVersion(){return parseInt(this.version().split(".")[0])}name(){return this.browser.name}hasChromiumWebRTC(){for(const e of this.chromeLike)if(e===this.browser.name)return!0;return!1}hasWebKitWebRTC(){for(const e of this.webkitBrowsers)if(e===this.browser.name)return!0;return!1}hasFirefoxWebRTC(){return this.isFirefox()}supportsCanvasCapturedStreamPlayback(){return!this.isIOSSafari()&&!this.isIOSChrome()&&!this.isIOSFirefox()}supportsBackgroundFilter(){return("safari"!==this.name()||15!==this.majorVersion())&&!!this.supportsCanvasCapturedStreamPlayback()}supportsVideoLayersAllocationRtpHeaderExtension(){return this.hasChromiumWebRTC()}requiresResolutionAlignment(e,t){return this.isAndroid()&&this.isPixel3()?[64*Math.ceil(e/64),64*Math.ceil(t/64)]:[e,t]}requiresCheckForSdpConnectionAttributes(){return!this.isIOSSafari()&&!this.isIOSChrome()&&!this.isIOSFirefox()}requiresIceCandidateGatheringTimeoutWorkaround(){return this.hasChromiumWebRTC()}requiresBundlePolicy(){return"max-bundle"}requiresNoExactMediaStreamConstraints(){return this.isSamsungInternet()}requiresGroupIdMediaStreamConstraints(){return this.isSamsungInternet()}getDisplayMediaAudioCaptureSupport(){return this.isChrome()||this.isEdge()}doesNotSupportMediaDeviceLabels(){return"chromium-webview"===this.browser.name}isSupported(){return!(!this.browserSupport[this.browser.name]||this.majorVersion()e.includes("a=rtpmap:"))).map((e=>e.replace(/.* /,"").replace(/\/.*/,""))).filter(((e,t,n)=>n.indexOf(e)===t)).filter((e=>"rtx"!==e&&"red"!==e&&"ulpfec"!==e))}))}supportsSetSinkId(){return"setSinkId"in HTMLAudioElement.prototype}disableResolutionScaleDown(){return this.isAndroid()}disable480pResolutionScaleDown(){return/( Chrome\/98\.)/i.test(navigator.userAgent)&&this.browser.os.startsWith("Windows")}requiresDisablingH264Encoding(){return(this.isIOSSafari()||this.isIOSChrome()||this.isIOSFirefox())&&("15.1.0"===this.version()||/( OS 15_1)/i.test(navigator.userAgent))}requiresVideoPlayWorkaround(){return this.isSafari()}isIOSSafari(){return"ios"===this.browser.name||"ios-webview"===this.browser.name||"safari"===this.browser.name&&/( Mac )/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1}isSafari(){return"safari"===this.browser.name||this.isIOSSafari()}isFirefox(){return"firefox"===this.browser.name}isIOSFirefox(){return"fxios"===this.browser.name}isIOSChrome(){return"crios"===this.browser.name}isChrome(){return"chrome"===this.browser.name}isEdge(){return"edge-chromium"===this.browser.name}isSamsungInternet(){return"samsung"===this.browser.name}isAndroid(){return/(android)/i.test(navigator.userAgent)}isPixel3(){return/( pixel 3)/i.test(navigator.userAgent)}}},4571:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289),r=n(6196),a=n(9496),o=n(2306);class s{constructor(e,t,n){this.logger=e,this.videoStreamIndex=t,this.selfAttendeeId=n,this.globalMetricReport=new o.default,this.streamMetricReports={},this.rtcStatsReport={},this.currentTimestampMs=0,this.previousTimestampMs=0,this.currentSsrcs={},this.identityValue=(e,t)=>{const n=t?this.streamMetricReports[t]:this.globalMetricReport;return Number(n.currentMetrics[e])},this.decoderLossPercent=(e,t)=>{const n=this.streamMetricReports[t],i=n.currentMetrics.concealedSamples-(n.previousMetrics.concealedSamples||0),r=n.currentMetrics.totalSamplesReceived-(n.previousMetrics.totalSamplesReceived||0);return r<=0||r-i<=0?0:i/r*100},this.packetLossPercent=(e,t)=>{const n=this.streamMetricReports[t],i=n.currentMetrics[e]-(n.previousMetrics[e]||0),r=n.currentMetrics.packetsLost-(n.previousMetrics.packetsLost||0),a=i+r;return a<=0||r<=0?0:100*r/a},this.jitterBufferMs=(e,t)=>{const n=this.streamMetricReports[t],i=n.currentMetrics.jitterBufferDelay-(n.previousMetrics.jitterBufferDelay||0),r=n.currentMetrics.jitterBufferEmittedCount-(n.previousMetrics.jitterBufferEmittedCount||0);return i<=0||r<=0?0:i/r*1e3},this.countPerSecond=(e,t)=>{const n=t?this.streamMetricReports[t]:this.globalMetricReport;let i=(this.currentTimestampMs-this.previousTimestampMs)/1e3;if(i<=0)return 0;this.previousTimestampMs<=0&&(i=1);const r=n.currentMetrics[e]-(n.previousMetrics[e]||0);return r<=0?0:Math.trunc(r/i)},this.bitsPerSecond=(e,t)=>{const n=t?this.streamMetricReports[t]:this.globalMetricReport;let i=(this.currentTimestampMs-this.previousTimestampMs)/1e3;if(i<=0)return 0;this.previousTimestampMs<=0&&(i=1);const r=8*(n.currentMetrics[e]-(n.previousMetrics[e]||0));return r<=0?0:Math.trunc(r/i)},this.secondsToMilliseconds=(e,t)=>{const n=t?this.streamMetricReports[t]:this.globalMetricReport;return Number(1e3*n.currentMetrics[e])},this.globalMetricMap={retransmittedBytesSent:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_RETRANSMIT_BITRATE},totalEncodedBytesTarget:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_TARGET_ENCODER_BITRATE},totalPacketSendDelay:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_BUCKET_DELAY_MS},packetsDiscardedOnSend:{transform:this.countPerSecond,type:i.SdkMetric.Type.SOCKET_DISCARDED_PPS},availableIncomingBitrate:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_AVAILABLE_RECEIVE_BANDWIDTH},availableOutgoingBitrate:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_AVAILABLE_SEND_BANDWIDTH},currentRoundTripTime:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.STUN_RTT_MS}},this.audioUpstreamMetricMap={jitter:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.RTC_MIC_JITTER_MS},packetsSent:{transform:this.countPerSecond,type:i.SdkMetric.Type.RTC_MIC_PPS},bytesSent:{transform:this.bitsPerSecond,type:i.SdkMetric.Type.RTC_MIC_BITRATE},roundTripTime:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.RTC_MIC_RTT_MS},packetsLost:{transform:this.packetLossPercent,type:i.SdkMetric.Type.RTC_MIC_FRACTION_PACKET_LOST_PERCENT,source:"packetsSent"}},this.audioDownstreamMetricMap={concealedSamples:{transform:this.countPerSecond},totalSamplesReceived:{transform:this.countPerSecond},decoderLoss:{transform:this.decoderLossPercent,type:i.SdkMetric.Type.RTC_SPK_FRACTION_DECODER_LOSS_PERCENT},packetsReceived:{transform:this.countPerSecond,type:i.SdkMetric.Type.RTC_SPK_PPS},packetsLost:{transform:this.packetLossPercent,type:i.SdkMetric.Type.RTC_SPK_FRACTION_PACKET_LOST_PERCENT,source:"packetsReceived"},jitter:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.RTC_SPK_JITTER_MS},jitterBufferDelay:{transform:this.countPerSecond},jitterBufferEmittedCount:{transform:this.countPerSecond},jitterBufferMs:{transform:this.jitterBufferMs,type:i.SdkMetric.Type.RTC_SPK_JITTER_BUFFER_MS},bytesReceived:{transform:this.bitsPerSecond,type:i.SdkMetric.Type.RTC_SPK_BITRATE}},this.videoUpstreamMetricMap={roundTripTime:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.VIDEO_SENT_RTT_MS},nackCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_NACKS_RECEIVED},pliCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_PLIS_RECEIVED},firCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_FIRS_RECEIVED},framesPerSecond:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_INPUT_FPS},framesEncoded:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_ENCODE_FPS},packetsSent:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_SENT_PPS},packetsLost:{transform:this.packetLossPercent,type:i.SdkMetric.Type.VIDEO_SENT_FRACTION_PACKET_LOST_PERCENT,source:"packetsSent"},bytesSent:{transform:this.bitsPerSecond,type:i.SdkMetric.Type.VIDEO_SENT_BITRATE},qpSum:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_SENT_QP_SUM},frameHeight:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_ENCODE_HEIGHT},frameWidth:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_ENCODE_WIDTH},jitter:{transform:this.secondsToMilliseconds}},this.videoDownstreamMetricMap={totalDecodeTime:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_DECODE_MS},packetsReceived:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_RECEIVED_PPS},packetsLost:{transform:this.packetLossPercent,type:i.SdkMetric.Type.VIDEO_RECEIVED_FRACTION_PACKET_LOST_PERCENT,source:"packetsReceived"},framesReceived:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_RECEIVED_FPS},framesDecoded:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_DECODE_FPS},nackCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_NACKS_SENT},firCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_FIRS_SENT},pliCount:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_PLIS_SENT},bytesReceived:{transform:this.bitsPerSecond,type:i.SdkMetric.Type.VIDEO_RECEIVED_BITRATE},jitter:{transform:this.secondsToMilliseconds,type:i.SdkMetric.Type.VIDEO_RECEIVED_JITTER_MS},jitterBufferDelay:{transform:this.countPerSecond},jitterBufferEmittedCount:{transform:this.countPerSecond},jitterBufferMs:{transform:this.jitterBufferMs,type:i.SdkMetric.Type.VIDEO_JITTER_BUFFER_MS},qpSum:{transform:this.countPerSecond,type:i.SdkMetric.Type.VIDEO_RECEIVED_QP_SUM},frameHeight:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_DECODE_HEIGHT},frameWidth:{transform:this.identityValue,type:i.SdkMetric.Type.VIDEO_DECODE_WIDTH}},this.observableVideoMetricSpec={videoUpstreamBitrate:{source:"bytesSent",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamPacketsSent:{source:"packetsSent",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamPacketLossPercent:{source:"packetsLost",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamFramesEncodedPerSecond:{source:"framesEncoded",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamFrameHeight:{source:"frameHeight",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamFrameWidth:{source:"frameWidth",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamJitterMs:{source:"jitter",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoUpstreamRoundTripTimeMs:{source:"roundTripTime",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoDownstreamBitrate:{source:"bytesReceived",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamPacketLossPercent:{source:"packetsLost",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamPacketsReceived:{source:"packetsReceived",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamFramesDecodedPerSecond:{source:"framesDecoded",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamFrameHeight:{source:"frameHeight",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamFrameWidth:{source:"frameWidth",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamJitterMs:{source:"jitter",media:a.default.VIDEO,dir:r.default.DOWNSTREAM},videoDownstreamDelayMs:{source:"jitterBufferMs",media:a.default.VIDEO,dir:r.default.DOWNSTREAM}},this.observableMetricSpec={audioPacketsReceived:{source:"packetsReceived",media:a.default.AUDIO,dir:r.default.DOWNSTREAM},audioPacketsReceivedFractionLoss:{source:"packetsLost",media:a.default.AUDIO,dir:r.default.DOWNSTREAM},audioDecoderLoss:{source:"decoderLoss",media:a.default.AUDIO,dir:r.default.DOWNSTREAM},audioPacketsSent:{source:"packetsSent",media:a.default.AUDIO,dir:r.default.UPSTREAM},audioPacketLossPercent:{source:"packetsLost",media:a.default.AUDIO,dir:r.default.UPSTREAM},audioUpstreamRoundTripTimeMs:{source:"roundTripTime",media:a.default.AUDIO,dir:r.default.UPSTREAM},videoUpstreamBitrate:{source:"bytesSent",media:a.default.VIDEO,dir:r.default.UPSTREAM},videoPacketSentPerSecond:{source:"packetsSent",media:a.default.VIDEO,dir:r.default.UPSTREAM},audioSpeakerDelayMs:{source:"jitterBufferMs",media:a.default.AUDIO,dir:r.default.DOWNSTREAM},audioUpstreamJitterMs:{source:"jitter",media:a.default.AUDIO,dir:r.default.UPSTREAM},audioDownstreamJitterMs:{source:"jitter",media:a.default.AUDIO,dir:r.default.DOWNSTREAM},nackCountReceivedPerSecond:{source:"nackCount",media:a.default.VIDEO,dir:r.default.UPSTREAM},availableOutgoingBitrate:{source:"availableOutgoingBitrate"},availableIncomingBitrate:{source:"availableIncomingBitrate"},currentRoundTripTimeMs:{source:"currentRoundTripTime"}}}getMetricMap(e,t){switch(e){case a.default.AUDIO:switch(t){case r.default.UPSTREAM:return this.audioUpstreamMetricMap;case r.default.DOWNSTREAM:return this.audioDownstreamMetricMap}case a.default.VIDEO:switch(t){case r.default.UPSTREAM:return this.videoUpstreamMetricMap;case r.default.DOWNSTREAM:return this.videoDownstreamMetricMap}default:return this.globalMetricMap}}getObservableMetricValue(e){const t=this.observableMetricSpec[e],n=this.getMetricMap(t.media,t.dir)[t.source],{transform:i,source:r}=n;if(!t.hasOwnProperty("media"))return i(r||t.source);for(const e in this.streamMetricReports){const n=this.streamMetricReports[e];if(n.direction===t.dir&&n.mediaType===t.media)return i(r||t.source,Number(e))}return 0}getObservableVideoMetricValue(e,t){const n=this.observableVideoMetricSpec[e],i=this.getMetricMap(n.media,n.dir)[n.source],{transform:r,source:a}=i;return r(a||n.source,t)}getObservableMetrics(){const e={};for(const t in this.observableMetricSpec)e[t]=this.getObservableMetricValue(t);return e}getObservableVideoMetrics(){const e={};if(!this.videoStreamIndex||!this.selfAttendeeId)return this.logger.error("Need to define VideoStreamIndex and selfAttendeeId if using getObservableVideoMetrics API"),e;for(const t in this.streamMetricReports)if(this.streamMetricReports[t].mediaType===a.default.VIDEO){const n={};for(const e in this.observableVideoMetricSpec)if(this.observableVideoMetricSpec[e].dir===this.streamMetricReports[t].direction){const i=this.getObservableVideoMetricValue(e,Number(t));isNaN(i)||(n[e]=i)}const i=this.streamMetricReports[t].streamId,r=i?this.videoStreamIndex.attendeeIdForStreamId(i):this.selfAttendeeId;e[r]=e[r]?e[r]:{},e[r][t]=n}return e}getRTCStatsReport(){return this.rtcStatsReport}clone(){const e=new s(this.logger,this.videoStreamIndex,this.selfAttendeeId);return e.globalMetricReport=this.globalMetricReport,e.streamMetricReports=this.streamMetricReports,e.rtcStatsReport=this.rtcStatsReport,e.currentTimestampMs=this.currentTimestampMs,e.previousTimestampMs=this.previousTimestampMs,e}print(){const e={globalMetricReport:this.globalMetricReport,streamMetricReports:this.streamMetricReports,currentTimestampMs:this.currentTimestampMs,previousTimestampMs:this.previousTimestampMs};this.logger.debug((()=>`Client Metric Report: ${JSON.stringify(e)}`))}removeDestroyedSsrcs(){for(const e in this.streamMetricReports)this.currentSsrcs[e]||delete this.streamMetricReports[e]}}t.default=s},6196:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ClientMetricReportDirection=void 0,function(e){e[e.UPSTREAM=0]="UPSTREAM",e[e.DOWNSTREAM=1]="DOWNSTREAM"}(n=t.ClientMetricReportDirection||(t.ClientMetricReportDirection={})),t.default=n},9496:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ClientMetricReportMediaType=void 0,function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO"}(n=t.ClientMetricReportMediaType||(t.ClientMetricReportMediaType={})),t.default=n},2770:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},2306:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.previousMetrics={},this.currentMetrics={}}}},2811:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.previousMetrics={},this.currentMetrics={}}}},3940:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){this.minHealth=e.minHealth,this.maxHealth=e.maxHealth,this.currentHealth=e.initialHealth,this.currentData=t.clone()}minimumHealth(){return this.minHealth}maximumHealth(){return this.maxHealth}health(){return this.maximumHealth()}update(e){this.currentData=e}getConnectionHealthData(){return this.currentData.clone()}healthy(){return this.health()>this.minimumHealth()}healthIfChanged(){const e=this.health();return e!==this.currentHealth?(this.currentHealth=e,e):null}}},6688:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(){this.connectionStartTimestampMs=0,this.consecutiveStatsWithNoPackets=0,this.lastPacketLossInboundTimestampMs=0,this.lastGoodSignalTimestampMs=0,this.lastWeakSignalTimestampMs=0,this.lastNoSignalTimestampMs=0,this.consecutiveMissedPongs=0,this.packetsReceivedInLastMinute=[],this.fractionPacketsLostInboundInLastMinute=[],this.audioSpeakerDelayMs=0,this.connectionStartTimestampMs=Date.now(),this.lastGoodSignalTimestampMs=Date.now()}static isTimestampRecent(e,t){return Date.now(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.minHealth=0,this.maxHealth=1,this.initialHealth=1,this.connectionUnhealthyThreshold=25,this.noSignalThresholdTimeMs=1e4,this.connectionWaitTimeMs=1e4,this.zeroBarsNoSignalTimeMs=5e3,this.oneBarWeakSignalTimeMs=5e3,this.twoBarsTimeMs=5e3,this.threeBarsTimeMs=1e4,this.fourBarsTimeMs=2e4,this.fiveBarsTimeMs=6e4,this.cooldownTimeMs=6e4,this.pastSamplesToConsider=15,this.goodSignalTimeMs=15e3,this.fractionalLoss=.5,this.packetsExpected=50,this.maximumTimesToWarn=2,this.missedPongsLowerThreshold=1,this.missedPongsUpperThreshold=4,this.maximumAudioDelayMs=6e4,this.maximumAudioDelayDataPoints=10}}},9708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3940);class r extends i.default{constructor(e,t,n){super(t,n),this.logger=e,this.audioDelayPointsOverMaximum=0,r.CONNECTION_UNHEALTHY_THRESHOLD=t.connectionUnhealthyThreshold,r.CONNECTION_WAIT_TIME_MS=t.connectionWaitTimeMs,r.MISSED_PONGS_THRESHOLD=t.missedPongsUpperThreshold,r.MAXIMUM_AUDIO_DELAY_MS=t.maximumAudioDelayMs,r.MAXIMUM_AUDIO_DELAY_DATA_POINTS=t.maximumAudioDelayDataPoints}health(){if(this.currentData.isConnectionStartRecent(r.CONNECTION_WAIT_TIME_MS))return 1;const e=this.currentData.consecutiveStatsWithNoPackets>=r.CONNECTION_UNHEALTHY_THRESHOLD,t=this.currentData.consecutiveMissedPongs>=r.MISSED_PONGS_THRESHOLD;this.currentData.audioSpeakerDelayMs>r.MAXIMUM_AUDIO_DELAY_MS?this.audioDelayPointsOverMaximum+=1:this.audioDelayPointsOverMaximum=0;const n=this.audioDelayPointsOverMaximum>r.MAXIMUM_AUDIO_DELAY_DATA_POINTS;return n&&(this.audioDelayPointsOverMaximum=0),e||t||n?(this.logger.warn(`reconnection recommended due to: no packets received: ${e}, missed pongs: ${t}, bad audio delay: ${n}`),0):1}}t.default=r},1922:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3940);class r extends i.default{constructor(e,t){super(e,t),this.coolDownTimeMs=e.cooldownTimeMs,this.pastSamplesToConsider=e.pastSamplesToConsider,this.fractionalLoss=e.fractionalLoss,this.packetsExpected=e.packetsExpected,this.maximumTimesToWarn=e.maximumTimesToWarn,this.lastWarnTimestampMs=0,this.warnCount=0}calculateFractionalLoss(){if(this.currentData.packetsReceivedInLastMinute.length=this.fractionalLoss?0!==this.currentHealth&&(this.lastWarnTimestampMs=Date.now(),this.warnCount++,this.warnCount>this.maximumTimesToWarn)?1:0:1}}t.default=r},8581:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8660);t.default=class{constructor(e,t,n,i,r){this.audioVideoController=e,this.realtimeController=t,this.connectionHealthData=n,this.pingPong=i,this.statsCollector=r,this.isActive=!1,this.hasSeenValidPacketMetricsBefore=!1,this.realtimeController.realtimeSubscribeToLocalSignalStrengthChange((e=>{this.isActive&&this.receiveSignalStrengthChange(e)}))}start(){this.isActive=!0,this.pingPong.addObserver(this),this.pingPong.start(),this.audioVideoController.addObserver(this)}stop(){this.isActive=!1,this.pingPong.removeObserver(this),this.pingPong.stop(),this.audioVideoController.removeObserver(this)}receiveSignalStrengthChange(e){0===e?this.connectionHealthData.setLastNoSignalTimestampMs(Date.now()):e<=.5?this.connectionHealthData.setLastWeakSignalTimestampMs(Date.now()):this.connectionHealthData.setLastGoodSignalTimestampMs(Date.now()),this.updateConnectionHealth()}didReceivePong(e,t,n){this.connectionHealthData.setConsecutiveMissedPongs(0),this.statsCollector.logLatency("ping_pong",t),this.statsCollector.logLatency("ping_pong_clock_skew",n),this.updateConnectionHealth()}didMissPongs(){this.connectionHealthData.setConsecutiveMissedPongs(this.connectionHealthData.consecutiveMissedPongs+1),this.updateConnectionHealth()}metricsDidReceive(e){let t=0,n=0;const i=e.getObservableMetrics(),r=i.audioPacketsReceived,a=i.audioPacketsReceivedFractionLoss,o=i.audioSpeakerDelayMs;"number"!=typeof o||isNaN(o)||this.connectionHealthData.setAudioSpeakerDelayMs(o),"number"==typeof r&&"number"==typeof a&&(t=r,n=a,t<0||n<0||(this.addToMinuteWindow(this.connectionHealthData.packetsReceivedInLastMinute,t),this.addToMinuteWindow(this.connectionHealthData.fractionPacketsLostInboundInLastMinute,n),t>0?(this.hasSeenValidPacketMetricsBefore=!0,this.connectionHealthData.setConsecutiveStatsWithNoPackets(0)):this.hasSeenValidPacketMetricsBefore&&this.connectionHealthData.setConsecutiveStatsWithNoPackets(this.connectionHealthData.consecutiveStatsWithNoPackets+1),(0===t||n>0)&&this.connectionHealthData.setLastPacketLossInboundTimestampMs(Date.now()),this.updateConnectionHealth()))}addToMinuteWindow(e,t){e.unshift(t),e.length>60&&e.pop()}updateConnectionHealth(){this.audioVideoController.forEachObserver((e=>{i.Maybe.of(e.connectionHealthDidChange).map((t=>t.bind(e)(this.connectionHealthData.clone())))}))}}},8890:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Modality="#content"}(n||(n={})),t.default=n},8370:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543),a=n(4142);class o{constructor(e){this.logger=e}get mediaStream(){return this._mediaStream}set mediaStream(e){this._mediaStream=e}acquireAudioInputStream(){return i(this,void 0,void 0,(function*(){return 0===this._mediaStream.getAudioTracks().length?(this.logger.info("No audio stream available. Synthesizing an audio stream."),a.default.synthesizeAudioDevice(0)):this._mediaStream}))}acquireVideoInputStream(){return i(this,void 0,void 0,(function*(){return this._mediaStream}))}acquireDisplayInputStream(e){return i(this,void 0,void 0,(function*(){return e&&e.video&&e.video.mandatory&&e.video.mandatory.chromeMediaSource&&e.video.mandatory.chromeMediaSourceId?navigator.mediaDevices.getUserMedia(e):navigator.mediaDevices.getDisplayMedia(e)}))}acquireScreenCaptureDisplayInputStream(e,t){return i(this,void 0,void 0,(function*(){return this.acquireDisplayInputStream(this.screenCaptureDisplayMediaConstraints(e,t))}))}screenCaptureDisplayMediaConstraints(e,t){return{audio:!(e||!(new r.default).getDisplayMediaAudioCaptureSupport()),video:Object.assign(Object.assign({},!e&&{frameRate:{max:t||o.defaultFrameRate}}),e&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxFrameRate:t||o.defaultFrameRate}})}}toggleMediaStream(e){let t=!1;if(this.mediaStream)for(let n=0;n{this.stopContentShare()}));this.contentAudioVideo.start()}}))}startContentShareFromScreenCapture(e,t){return i(this,void 0,void 0,(function*(){const n=yield this.mediaStreamBroker.acquireScreenCaptureDisplayInputStream(e,t);return yield this.startContentShare(n),n}))}pauseContentShare(){this.mediaStreamBroker.toggleMediaStream(!1)&&this.forEachContentShareObserver((e=>{c.Maybe.of(e.contentShareDidPause).map((t=>t.call(e)))}))}unpauseContentShare(){this.mediaStreamBroker.toggleMediaStream(!0)&&this.forEachContentShareObserver((e=>{c.Maybe.of(e.contentShareDidUnpause).map((t=>t.call(e)))}))}setContentShareVideoCodecPreferences(e){this.contentAudioVideo.setVideoCodecSendPreferences(e)}destroy(){return i(this,void 0,void 0,(function*(){this.contentAudioVideo&&(this.destroyed=!0,this.contentAudioVideo.removeObserver(this),this.stopContentShare(),this.observerQueue.clear(),this.contentAudioVideo=void 0,this.attendeeAudioVideo=void 0,this.mediaStreamBroker=void 0)}))}stopContentShare(){this.contentAudioVideo.stop(),this.mediaStreamBroker.cleanup()}addContentShareObserver(e){this.observerQueue.add(e)}removeContentShareObserver(e){this.observerQueue.delete(e)}forEachContentShareObserver(e){for(const t of this.observerQueue)s.default.nextTick((()=>{this.observerQueue.has(t)&&e(t)}))}audioVideoDidStart(){this.mediaStreamBroker.mediaStream.getVideoTracks().length>0&&this.contentAudioVideo.videoTileController.startLocalVideoTile()}audioVideoDidStop(e){this.mediaStreamBroker.cleanup(),this.contentShareTile&&(this.attendeeAudioVideo.videoTileController.removeVideoTile(this.contentShareTile.id()),this.contentShareTile=null),this.forEachContentShareObserver((e=>{c.Maybe.of(e.contentShareDidStop).map((t=>t.call(e)))}))}setupContentShareEvents(){this.attendeeAudioVideo.realtimeController.realtimeSubscribeToAttendeeIdPresence(((e,t,n,i)=>{const r=new o.default(e).hasModality(o.default.MODALITY_CONTENT),a=new o.default(e).base()===this.attendeeAudioVideo.configuration.credentials.attendeeId;if(!r||!a||!t||this.contentShareTile)return;const s=this.mediaStreamBroker.mediaStream;if(null==s?void 0:s.getVideoTracks().length){this.contentShareTile=this.attendeeAudioVideo.videoTileController.addVideoTile();const e=s.getVideoTracks()[0];let t,n;if(e.getSettings){const i=e.getSettings();t=i.width,n=i.height}else{const i=e.getCapabilities();t=i.width,n=i.height}this.contentShareTile.bindVideoStream(this.contentAudioVideo.configuration.credentials.attendeeId,!1,s,t,n,null,this.contentAudioVideo.configuration.credentials.externalUserId)}this.forEachContentShareObserver((e=>{c.Maybe.of(e.contentShareDidStart).map((t=>t.call(e)))}))}))}}},7237:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class i{static register(){"document"in n.g&&document.addEventListener&&i.shouldRegisterCSPMonitor&&(i.added||(document.addEventListener("securitypolicyviolation",i.listener),i.added=!0))}static unregister(){"document"in n.g&&document.removeEventListener&&(document.removeEventListener("securitypolicyviolation",i.listener),i.loggers=new Set,i.added=!1)}static disable(){i.shouldRegisterCSPMonitor=!1,i.unregister()}static addLogger(e){e&&i.loggers.add(e)}static removeLogger(e){e&&i.loggers.delete(e)}}t.default=i,i.loggers=new Set,i.shouldRegisterCSPMonitor=!0,i.added=!1,i.listener=e=>{const t=`Security Policy Violation\nBlocked URI: ${e.blockedURI}\nViolated Directive: ${e.violatedDirective}\nOriginal Policy: ${e.originalPolicy}\nDocument URI: ${e.documentURI}\nSource File: ${e.sourceFile}\nLine No.: ${e.lineNumber}\n`;for(const e of i.loggers)e.error(t);0===i.loggers.size&&console.error(t)}},1018:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i,r,a){this.timestampMs=e,this.topic=t,this.data=n,this.senderAttendeeId=i,this.senderExternalUserId=r,this.throttled=!!a}text(){return(new TextDecoder).decode(this.data)}json(){return JSON.parse((new TextDecoder).decode(this.data))}}},146:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDestroyable=void 0,t.isDestroyable=function(e){return e&&"destroy"in e}},1746:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAudioTransformDevice=void 0,t.isAudioTransformDevice=function(e){return!!e&&"object"==typeof e&&"mute"in e&&"stop"in e&&"intrinsicDevice"in e}},4142:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543),a=n(6354),o=n(7797),s=n(1515),c=n(8660),l=n(3327),u=n(1746),d=n(8128),h=n(5348),f=n(1238),p=n(3110),m=n(4842),g=n(6991),C=n(6950),v=n(4500),y=n(7170);class b{constructor(e,t,n=new r.default,i){this.logger=e,this.browserBehavior=n,this.eventController=i,this.deviceInfoCache=null,this.activeDevices={audio:null,video:null},this.chosenVideoTransformDevice=null,this.audioOutputDeviceId=void 0,this.deviceChangeObservers=new Set,this.mediaStreamBrokerObservers=new Set,this.deviceLabelTrigger=()=>navigator.mediaDevices.getUserMedia({audio:!0,video:!0}),this.audioInputDestinationNode=null,this.audioInputSourceNode=null,this.videoInputQualitySettings=null,this.useWebAudio=!1,this.useMediaConstraintsFallback=!0,this.audioInputTaskQueue=new s.default,this.videoInputTaskQueue=new s.default,this.muted=!1,this.mediaStreamMuteObserver=(e,t)=>{for(const n of this.deviceChangeObservers)o.default.nextTick((()=>{this.deviceChangeObservers.has(n)&&n.audioInputMuteStateChanged&&n.audioInputMuteStateChanged(e,t)}))},this.alreadyHandlingDeviceChange=!1;const{enableWebAudio:c=!1,useMediaConstraintsFallback:l=!0}=t||{};this.useWebAudio=c,this.useMediaConstraintsFallback=l,this.videoInputQualitySettings=new v.default(b.defaultVideoWidth,b.defaultVideoHeight,b.defaultVideoFrameRate);const u=this.browserBehavior.requiresResolutionAlignment(this.videoInputQualitySettings.videoWidth,this.videoInputQualitySettings.videoHeight);this.videoInputQualitySettings.videoWidth=u[0],this.videoInputQualitySettings.videoHeight=u[1],this.logger.info(`DefaultDeviceController video dimension ${this.videoInputQualitySettings.videoWidth} x ${this.videoInputQualitySettings.videoHeight}`);try{this.mediaDeviceWrapper=(new a.default).create();const e=navigator.mediaDevices.getSupportedConstraints();this.logger.info(`Supported Constraints in this browser ${JSON.stringify(e)}`)}catch(t){e.error(t.message)}}isWatchingForDeviceChanges(){return!!this.onDeviceChangeCallback}ensureWatchingDeviceChanges(){var e;this.isWatchingForDeviceChanges()||(this.logger.info("Starting devicechange listener."),this.onDeviceChangeCallback=()=>{this.logger.info("Device change event callback is triggered"),this.handleDeviceChange()},null===(e=this.mediaDeviceWrapper)||void 0===e||e.addEventListener("devicechange",this.onDeviceChangeCallback))}stopWatchingDeviceChanges(){var e;this.isWatchingForDeviceChanges()&&(this.logger.info("Stopping devicechange listener."),null===(e=this.mediaDeviceWrapper)||void 0===e||e.removeEventListener("devicechange",this.onDeviceChangeCallback),this.onDeviceChangeCallback=void 0)}shouldObserveDeviceChanges(){return!!this.deviceChangeObservers.size||(this.activeDevices.audio&&null!==this.activeDevices.audio.constraints||this.activeDevices.video&&null!==this.activeDevices.video.constraints||!!this.audioOutputDeviceId)}watchForDeviceChangesIfNecessary(){this.shouldObserveDeviceChanges()?this.ensureWatchingDeviceChanges():this.stopWatchingDeviceChanges()}destroy(){return i(this,void 0,void 0,(function*(){this.stopWatchingDeviceChanges(),yield this.stopAudioInput(),yield this.stopVideoInput()}))}listAudioInputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.listDevicesOfKind("audioinput",e);return this.trace("listAudioInputDevices",e,t),t}))}listVideoInputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.listDevicesOfKind("videoinput",e);return this.trace("listVideoInputDevices",e,t),t}))}listAudioOutputDevices(e=!1){return i(this,void 0,void 0,(function*(){const t=yield this.listDevicesOfKind("audiooutput",e);return this.trace("listAudioOutputDevices",e,t),t}))}pushAudioMeetingStateForPermissions(e){var t;null===(t=this.eventController)||void 0===t||t.publishEvent(void 0===e?"audioInputUnselected":"audioInputSelected")}pushVideoMeetingStateForPermissions(e){var t;null===(t=this.eventController)||void 0===t||t.publishEvent(void 0===e?"videoInputUnselected":"videoInputSelected")}startAudioInput(e){return i(this,void 0,void 0,(function*(){return yield this.audioInputTaskQueue.add((()=>this.startAudioInputTask(e)))}))}startAudioInputTask(e){var t;return i(this,void 0,void 0,(function*(){if(void 0!==e)try{return u.isAudioTransformDevice(e)?(this.logger.info(`Choosing transform input device ${e}`),yield this.chooseAudioTransformInputDevice(e)):(this.logger.info(`Choosing intrinsic audio input device ${e}`),this.removeTransform(),yield this.chooseInputIntrinsicDevice("audio",e)),this.trace("startAudioInputDevice",e,"success"),this.useWebAudio?(this.attachAudioInputStreamToAudioContext(this.activeDevices.audio.stream),this.pushAudioMeetingStateForPermissions(this.getMediaStreamDestinationNode().stream),yield null===(t=this.transform)||void 0===t?void 0:t.device.mute(this.muted),this.getMediaStreamDestinationNode().stream):(this.publishAudioInputDidChangeEvent(this.activeDevices.audio.stream),this.activeDevices.audio.stream)}catch(e){throw e}else this.logger.error("Audio input device cannot be undefined")}))}stopAudioInput(){return i(this,void 0,void 0,(function*(){return this.audioInputTaskQueue.add((()=>this.stopAudioInputTask()))}))}stopAudioInputTask(){return i(this,void 0,void 0,(function*(){try{if(this.useWebAudio)return void this.releaseAudioTransformStream();this.stopTracksAndRemoveCallbacks("audio")}finally{this.watchForDeviceChangesIfNecessary(),this.publishAudioInputDidChangeEvent(void 0)}}))}chooseAudioTransformInputDevice(e){var t;return i(this,void 0,void 0,(function*(){if((null===(t=this.transform)||void 0===t?void 0:t.device)===e)return;if(!this.useWebAudio)throw new Error("Cannot apply transform device without enabling Web Audio.");const n=b.getAudioContext();if(n instanceof OfflineAudioContext);else switch(n.state){case"running":break;case"closed":throw new Error("Cannot choose a transform device with a closed audio context.");case"suspended":yield n.resume()}let i;try{i=yield e.createAudioNode(n)}catch(e){throw this.logger.error(`Unable to create transform device node: ${e}.`),e}const r=yield e.intrinsicDevice();yield this.chooseInputIntrinsicDevice("audio",r),this.logger.debug(`Got inner stream: ${r}.`),this.setTransform(e,i)}))}chooseVideoTransformInputDevice(e){var t;return i(this,void 0,void 0,(function*(){if(e===this.chosenVideoTransformDevice)return void this.logger.info("Reselecting same VideoTransformDevice");const n=this.chosenVideoTransformDevice;n&&this.logger.info("Switched from previous VideoTransformDevice");const i=!!n,r=yield e.intrinsicDevice();if(!this.isMediaStreamReusableByDeviceId(null===(t=this.activeDevices.video)||void 0===t?void 0:t.stream,r))return this.logger.info("video transform device needs new intrinsic device"),i&&n.onOutputStreamDisconnect(),this.chosenVideoTransformDevice=e,this.activeDevices.video=null,yield this.chooseInputIntrinsicDevice("video",r),this.logger.info("apply processors to transform"),void(yield this.chosenVideoTransformDevice.transformStream(this.activeDevices.video.stream));this.chosenVideoTransformDevice=e,this.logger.info("video transform device uses previous stream"),this.logger.info("apply processors to transform"),yield e.transformStream(this.activeDevices.video.stream)}))}startVideoInput(e){return i(this,void 0,void 0,(function*(){return yield this.videoInputTaskQueue.add((()=>this.startVideoInputTask(e)))}))}startVideoInputTask(e){return i(this,void 0,void 0,(function*(){if(e)try{return y.isVideoTransformDevice(e)?(this.logger.info(`Choosing video transform device ${e}`),yield this.chooseVideoTransformInputDevice(e),this.publishVideoInputDidChangeEvent(this.chosenVideoTransformDevice.outputMediaStream),this.chosenVideoTransformDevice.outputMediaStream):(this.chosenVideoInputIsTransformDevice()&&(this.chosenVideoTransformDevice.onOutputStreamDisconnect(),this.chosenVideoTransformDevice=null),yield this.chooseInputIntrinsicDevice("video",e),this.trace("startVideoInputDevice",e),this.publishVideoInputDidChangeEvent(this.activeDevices.video.stream),this.activeDevices.video.stream)}catch(e){throw e}else this.logger.error("Invalid video input device")}))}stopVideoInput(){return i(this,void 0,void 0,(function*(){return this.videoInputTaskQueue.add((()=>this.stopVideoInputTask()))}))}stopVideoInputTask(){return i(this,void 0,void 0,(function*(){try{if(this.chosenVideoInputIsTransformDevice())return void this.releaseVideoTransformStream();this.stopTracksAndRemoveCallbacks("video")}finally{this.watchForDeviceChangesIfNecessary(),this.publishVideoInputDidChangeEvent(void 0)}}))}chooseAudioOutput(e){return i(this,void 0,void 0,(function*(){this.audioOutputDeviceId=e,this.watchForDeviceChangesIfNecessary();const t=this.deviceInfoFromDeviceId("audiooutput",this.audioOutputDeviceId);this.publishAudioOutputDidChangeEvent(t),this.trace("chooseAudioOutput",e,null)}))}addDeviceChangeObserver(e){this.logger.info("adding device change observer"),this.deviceChangeObservers.add(e),this.watchForDeviceChangesIfNecessary(),this.trace("addDeviceChangeObserver")}removeDeviceChangeObserver(e){this.logger.info("removing device change observer"),this.deviceChangeObservers.delete(e),this.watchForDeviceChangesIfNecessary(),this.trace("removeDeviceChangeObserver")}createAnalyserNodeForAudioInput(){var e,t;if(!this.activeDevices.audio)return null;const n=null===(t=null===(e=this.transform)||void 0===e?void 0:e.nodes)||void 0===t?void 0:t.end;if(n){const e=n.context.createAnalyser();return e.removeOriginalInputs=()=>{try{n.disconnect(e)}catch(e){}},n.connect(e),e}return this.createAnalyserNodeForRawAudioInput()}createAnalyserNodeForRawAudioInput(){return this.activeDevices.audio?this.createAnalyserNodeForStream(this.activeDevices.audio.stream):null}createAnalyserNodeForStream(e){const t=b.getAudioContext(),n=t.createAnalyser(),i=t.createMediaStreamSource(e);return i.connect(n),this.trace("createAnalyserNodeForAudioInput"),n.removeOriginalInputs=()=>{try{i.disconnect(n)}catch(e){}},n}startVideoPreviewForVideoInput(e){if(!this.activeDevices.video)return this.logger.warn("cannot bind video preview since video input device has not been chosen"),void this.trace("startVideoPreviewForVideoInput",e.id);l.default.connectVideoStreamToVideoElement(this.chosenVideoTransformDevice?this.chosenVideoTransformDevice.outputMediaStream:this.activeDevices.video.stream,e,!0),this.trace("startVideoPreviewForVideoInput",e.id)}stopVideoPreviewForVideoInput(e){l.default.disconnectVideoStreamFromVideoElement(e,!1),this.trace("stopVideoPreviewForVideoInput",e.id)}setDeviceLabelTrigger(e){if(this.deviceInfoCache)for(const e of this.deviceInfoCache)if(!e.label){this.deviceInfoCache=null;break}this.deviceLabelTrigger=e,this.trace("setDeviceLabelTrigger")}mixIntoAudioInput(e){let t=null;return this.useWebAudio?(t=b.getAudioContext().createMediaStreamSource(e),t.connect(this.getMediaStreamOutputNode())):this.logger.warn("WebAudio is not enabled, mixIntoAudioInput will not work"),this.trace("mixIntoAudioInput",e.id),t}chooseVideoInputQuality(e,t,n){const i=this.browserBehavior.requiresResolutionAlignment(e,t);this.videoInputQualitySettings=new v.default(i[0],i[1],n)}getVideoInputQualitySettings(){return this.videoInputQualitySettings}acquireAudioInputStream(){return i(this,void 0,void 0,(function*(){return this.activeDevices.audio||(this.logger.info("No audio device chosen, creating empty audio device"),yield this.startAudioInput(null)),this.useWebAudio?this.getMediaStreamDestinationNode().stream:this.activeDevices.audio.stream}))}acquireVideoInputStream(){return i(this,void 0,void 0,(function*(){if(!this.activeDevices.video)throw new Error("No video device chosen");return this.chosenVideoInputIsTransformDevice()?this.chosenVideoTransformDevice.outputMediaStream:this.activeDevices.video.stream}))}acquireDisplayInputStream(e){return i(this,void 0,void 0,(function*(){throw new Error("unsupported")}))}releaseAudioTransformStream(){this.logger.info("Stopping audio track for Web Audio graph"),this.stopTracksAndRemoveCallbacks("audio"),this.logger.info("Removing audio transform, if there is one."),this.removeTransform(),this.audioInputSourceNode&&(this.audioInputSourceNode.disconnect(),this.audioInputSourceNode=void 0),this.audioInputDestinationNode&&(this.audioInputDestinationNode.disconnect(),this.audioInputDestinationNode=void 0)}releaseVideoTransformStream(){this.logger.info("Stopping video track for transform"),this.stopTracksAndRemoveCallbacks("video"),this.logger.info("Disconnecting video transform"),this.chosenVideoTransformDevice.onOutputStreamDisconnect(),this.chosenVideoTransformDevice=null}stopTracksAndRemoveCallbacks(e){const t=this.activeDevices[e];if(!t)return;const n=t.endedCallback,i=t.trackMuteCallback,r=t.trackUnmuteCallback;for(const a of t.stream.getTracks())a.stop(),n&&a.removeEventListener("ended",n),i&&a.removeEventListener("mute",i),r&&a.removeEventListener("unmute",r),delete t.endedCallback,delete t.trackMuteCallback,delete t.trackUnmuteCallback,delete this.activeDevices[e]}chosenVideoInputIsTransformDevice(){return!!this.chosenVideoTransformDevice}muteLocalAudioInputStream(){this.toggleLocalAudioInputStream(!1)}unmuteLocalAudioInputStream(){this.toggleLocalAudioInputStream(!0)}toggleLocalAudioInputStream(e){var t;let n=this.activeDevices.audio;if(this.useWebAudio&&(n=this.getMediaStreamDestinationNode()),n){for(const t of n.stream.getTracks())t.enabled!==e&&(t.enabled=e);this.muted!==!e&&(this.muted=!e,null===(t=this.transform)||void 0===t||t.device.mute(this.muted))}}static getIntrinsicDeviceId(e){if(!e)return;if("string"==typeof e)return e;if(e.id)return e.id;const t=e.deviceId;if(!t)return;if("string"==typeof t||Array.isArray(t))return t;const n=t;return"string"==typeof n.exact||Array.isArray(n.exact)?n.exact:void 0}static createEmptyAudioDevice(){return b.synthesizeAudioDevice(0)}static synthesizeAudioDevice(e){const t=b.getAudioContext(),n=t.createMediaStreamDestination();if(e){const i=t.createGain();i.gain.value=.1,i.connect(n);const r=t.createOscillator();r.frequency.value=e,r.connect(i),r.start()}else{const e=t.createBufferSource();try{e.buffer=t.createBuffer(1,5*t.sampleRate,t.sampleRate)}catch(n){if(!n||"NotSupportedError"!==n.name)throw n;e.buffer=t.createBuffer(1,5*b.defaultSampleRate,b.defaultSampleRate)}e.buffer.getChannelData(0)[0]=3e-4,e.loop=!0,e.connect(n),e.start()}return n.stream}listDevicesOfKind(e,t){return i(this,void 0,void 0,(function*(){return!t&&null!==this.deviceInfoCache&&this.isWatchingForDeviceChanges()||(yield this.updateDeviceInfoCacheFromBrowser()),this.listCachedDevicesOfKind(e)}))}updateDeviceInfoCacheFromBrowser(){return i(this,void 0,void 0,(function*(){if("undefined"==typeof MediaDeviceInfo)return void(this.deviceInfoCache=[]);let e=yield navigator.mediaDevices.enumerateDevices(),t=!0;for(const n of e)if(!n.label){t=!1;break}if(!t)try{this.logger.info("attempting to trigger media device labels since they are hidden");const t=yield this.deviceLabelTrigger();e=yield navigator.mediaDevices.enumerateDevices();for(const e of t.getTracks())e.stop()}catch(e){this.logger.info("unable to get media device labels")}this.logger.debug(`Update device info cache with devices: ${JSON.stringify(e)}`),this.deviceInfoCache=e}))}listCachedDevicesOfKind(e){const t=[];if(this.deviceInfoCache)for(const n of this.deviceInfoCache)n.kind===e&&t.push(n);return t}handleDeviceChange(){return i(this,void 0,void 0,(function*(){if(null===this.deviceInfoCache)return;if(this.alreadyHandlingDeviceChange)return void o.default.nextTick((()=>{this.handleDeviceChange()}));this.alreadyHandlingDeviceChange=!0;const e=this.listCachedDevicesOfKind("audioinput"),t=this.listCachedDevicesOfKind("videoinput"),n=this.listCachedDevicesOfKind("audiooutput");yield this.updateDeviceInfoCacheFromBrowser();const i=this.listCachedDevicesOfKind("audioinput"),r=this.listCachedDevicesOfKind("videoinput"),a=this.listCachedDevicesOfKind("audiooutput");this.forEachObserver((o=>{this.areDeviceListsEqual(e,i)||c.Maybe.of(o.audioInputsChanged).map((e=>e.bind(o)(i))),this.areDeviceListsEqual(t,r)||c.Maybe.of(o.videoInputsChanged).map((e=>e.bind(o)(r))),this.areDeviceListsEqual(n,a)||c.Maybe.of(o.audioOutputsChanged).map((e=>e.bind(o)(a)))})),this.alreadyHandlingDeviceChange=!1}))}handleDeviceStreamEnded(e,t){return i(this,void 0,void 0,(function*(){try{"audio"===e?(this.logger.warn("Audio input device which was active is no longer available, resetting to null device"),yield this.startAudioInput(null)):(this.logger.warn("Video input device which was active is no longer available, stopping video"),yield this.stopVideoInput())}catch(e){this.logger.error("Failed to choose null device after stream ended.")}"audio"===e?this.forEachObserver((e=>{c.Maybe.of(e.audioInputStreamEnded).map((n=>n.bind(e)(t)))})):this.forEachObserver((e=>{c.Maybe.of(e.videoInputStreamEnded).map((n=>n.bind(e)(t)))}))}))}forEachObserver(e){for(const t of this.deviceChangeObservers)o.default.nextTick((()=>{this.deviceChangeObservers.has(t)&&e(t)}))}forEachMediaStreamBrokerObserver(e){for(const t of this.mediaStreamBrokerObservers)e(t)}areDeviceListsEqual(e,t){return JSON.stringify(e.map((e=>JSON.stringify(e))).sort())===JSON.stringify(t.map((e=>JSON.stringify(e))).sort())}intrinsicDeviceAsMediaStream(e){return e&&e.id?e:null}hasSameMediaStreamId(e,t,n){var i,r,a,o;let s;return"audio"===e?(s=null==n?void 0:n.audio.streamId,!!s&&s===(null===(r=null===(i=t.constraints)||void 0===i?void 0:i.audio)||void 0===r?void 0:r.streamId)):(s=null==n?void 0:n.video.streamId,!!s&&s===(null===(o=null===(a=null==t?void 0:t.constraints)||void 0===a?void 0:a.video)||void 0===o?void 0:o.streamId))}hasSameGroupId(e,t,n){if(""===e)return!0;const i=b.getIntrinsicDeviceId(n);return this.logger.debug(`Checking deviceIds ${i} of type ${typeof i} with groupId ${e}`),"string"==typeof i&&e===this.getGroupIdFromDeviceId(t,i)}getGroupIdFromDeviceId(e,t){if(null!==this.deviceInfoCache){const n=this.listCachedDevicesOfKind(`${e}input`).find((e=>e.deviceId===t));if(n&&n.groupId)return this.logger.debug(`GroupId of deviceId ${t} found in cache is ${n.groupId}`),n.groupId}return this.logger.debug(`GroupId of deviceId ${t} found in cache is empty`),""}handleGetUserMediaError(e,t){if(!e)throw new h.default(e);switch(e.name){case"NotReadableError":case"TrackStartError":throw new p.default(e);case"NotFoundError":case"DevicesNotFoundError":throw new f.default(e);case"NotAllowedError":case"PermissionDeniedError":case"SecurityError":throw t&&t{this.activeDevices[e]&&this.activeDevices[e].stream===t.stream&&(this.handleDeviceStreamEnded(e,i),delete t.endedCallback)},r.addEventListener("ended",t.endedCallback,{once:!0})),"audio"===e){const e=t.stream.getAudioTracks()[0];if(e){const n=e.getSettings().deviceId||t.stream;t.trackMuteCallback=()=>{this.mediaStreamMuteObserver(n,!0)},t.trackUnmuteCallback=()=>{this.mediaStreamMuteObserver(n,!1)},e.addEventListener("mute",t.trackMuteCallback,{once:!1}),e.addEventListener("unmute",t.trackUnmuteCallback,{once:!1}),this.logger.debug("Notifying mute state after selection"),e.muted?t.trackMuteCallback():t.trackUnmuteCallback()}}}))}calculateMediaStreamConstraints(e,t,n,i){if(i&&1===this.listCachedDevicesOfKind(`${e}input`).length)return!0;const r={};return this.browserBehavior.requiresNoExactMediaStreamConstraints()?r.deviceId=t:r.deviceId={exact:t},n&&(r.groupId=n),i?r:"video"===e?(r.width={ideal:this.videoInputQualitySettings.videoWidth},r.height={ideal:this.videoInputQualitySettings.videoHeight},r.frameRate={ideal:this.videoInputQualitySettings.videoFrameRate},r):(this.supportSampleRateConstraint()&&(r.sampleRate={ideal:b.defaultSampleRate}),this.supportSampleSizeConstraint()&&(r.sampleSize={ideal:b.defaultSampleSize}),this.supportChannelCountConstraint()&&(r.channelCount={ideal:b.defaultChannelCount}),Object.assign({echoCancellation:!0,googEchoCancellation:!0,googEchoCancellation2:!0,googAutoGainControl:!0,googAutoGainControl2:!0,googNoiseSuppression:!0,googNoiseSuppression2:!0,googHighpassFilter:!0},r))}getMediaStreamConstraintsFromTrackConstraints(e,t){return"audio"===e?{audio:t}:{video:t}}getMediaStreamConstraints(e,t,n=!1){let i={};if(!t)return null;const r=this.intrinsicDeviceAsMediaStream(t);if(r)return i.streamId=r.id,this.getMediaStreamConstraintsFromTrackConstraints(e,i);if("string"==typeof t){let r="";return this.browserBehavior.requiresGroupIdMediaStreamConstraints()&&(null!==this.deviceInfoCache?r=this.getGroupIdFromDeviceId(e,t):this.logger.error("Device cache is not populated. Please make sure to call list devices first")),i=this.calculateMediaStreamConstraints(e,t,r,n),this.getMediaStreamConstraintsFromTrackConstraints(e,i)}return function(e){return"object"==typeof e&&"deviceId"in e&&"groupId"in e&&"kind"in e&&"label"in e}(t)?(i=this.calculateMediaStreamConstraints(e,t.deviceId,t.groupId,n),this.getMediaStreamConstraintsFromTrackConstraints(e,i)):(i=t,this.getMediaStreamConstraintsFromTrackConstraints(e,i))}deviceInfoFromDeviceId(e,t){if(null===this.deviceInfoCache)return null;for(const n of this.deviceInfoCache)if(n.kind===e&&n.deviceId===t)return n;return null}hasAppliedTransform(){return!!this.transform}isMediaStreamReusableByDeviceId(e,t){if(!e||!e.active||!t)return!1;if(t.id)return e.id===t.id;const n=this.getMediaTrackSettings(e);if(!n.deviceId)return!1;const i=b.getIntrinsicDeviceId(t);return"string"==typeof i&&n.deviceId===i}getMediaTrackSettings(e){var t;return null===(t=e.getTracks()[0])||void 0===t?void 0:t.getSettings()}reconnectAudioInputs(){if(!this.audioInputSourceNode)return;this.audioInputSourceNode.disconnect();const e=this.getMediaStreamOutputNode();this.audioInputSourceNode.connect(e)}setTransform(e,t){var n,i;null===(i=null===(n=this.transform)||void 0===n?void 0:n.nodes)||void 0===i||i.end.disconnect(),this.transform={nodes:t,device:e};const r=null==t?void 0:t.end,a=this.getMediaStreamDestinationNode();this.logger.debug(`Connecting transform node ${r} to destination ${a}.`),null==r||r.connect(a),this.reconnectAudioInputs()}removeTransform(){var e;const t=this.transform;if(t)return null===(e=this.transform.nodes)||void 0===e||e.end.disconnect(),this.transform=void 0,this.reconnectAudioInputs(),t}attachAudioInputStreamToAudioContext(e){var t;null===(t=this.audioInputSourceNode)||void 0===t||t.disconnect(),this.audioInputSourceNode=b.getAudioContext().createMediaStreamSource(e);const n=this.getMediaStreamOutputNode();this.audioInputSourceNode.connect(n)}getMediaStreamDestinationNode(){return this.audioInputDestinationNode||(this.audioInputDestinationNode=b.getAudioContext().createMediaStreamDestination()),this.audioInputDestinationNode}getMediaStreamOutputNode(){var e,t;return(null===(t=null===(e=this.transform)||void 0===e?void 0:e.nodes)||void 0===t?void 0:t.start)||this.getMediaStreamDestinationNode()}static getAudioContext(){if(!b.audioContext){const e={};navigator.mediaDevices.getSupportedConstraints().sampleRate&&(e.sampleRate=b.defaultSampleRate),b.audioContext=new(window.AudioContext||window.webkitAudioContext)(e)}return b.audioContext}static closeAudioContext(){if(b.audioContext)try{b.audioContext.close()}catch(e){}b.audioContext=null}addMediaStreamBrokerObserver(e){this.mediaStreamBrokerObservers.add(e)}removeMediaStreamBrokerObserver(e){this.mediaStreamBrokerObservers.delete(e)}publishVideoInputDidChangeEvent(e){this.forEachMediaStreamBrokerObserver((t=>{t.videoInputDidChange&&t.videoInputDidChange(e)})),this.pushVideoMeetingStateForPermissions(e)}publishAudioInputDidChangeEvent(e){this.forEachMediaStreamBrokerObserver((t=>{t.audioInputDidChange&&t.audioInputDidChange(e)})),this.pushAudioMeetingStateForPermissions(e)}publishAudioOutputDidChangeEvent(e){this.forEachMediaStreamBrokerObserver((t=>{t.audioOutputDidChange&&t.audioOutputDidChange(e)}))}supportSampleRateConstraint(){return this.useWebAudio&&!!navigator.mediaDevices.getSupportedConstraints().sampleRate}supportSampleSizeConstraint(){return this.useWebAudio&&!!navigator.mediaDevices.getSupportedConstraints().sampleSize}supportChannelCountConstraint(){return this.useWebAudio&&!!navigator.mediaDevices.getSupportedConstraints().channelCount}trace(e,t,n){let i=`API/DefaultDeviceController/${e}`;void 0!==t&&(i+=` ${JSON.stringify(t)}`),void 0!==n&&(i+=` -> ${JSON.stringify(n)}`),this.logger.info(i)}}t.default=b,b.permissionDeniedOriginDetectionThresholdMs=500,b.defaultVideoWidth=960,b.defaultVideoHeight=540,b.defaultVideoFrameRate=15,b.defaultSampleRate=48e3,b.defaultSampleSize=16,b.defaultChannelCount=1,b.audioContext=null},8128:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.groupId=""}matchesConstraints(e){return JSON.stringify(this.constraints)===JSON.stringify(e)}}},5348:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e,t){super(t||"Error fetching device."),this.cause=e,this.name="GetUserMediaError"}}t.default=n},6154:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.NoOpDeviceControllerWithEventController=void 0;const r=n(4015);class a extends r.default{constructor(e){super(),this.destroyed=!1}destroy(){return i(this,void 0,void 0,(function*(){this.destroyed=!0}))}listAudioInputDevices(){return Promise.resolve([])}listVideoInputDevices(){return Promise.resolve([])}listAudioOutputDevices(){return Promise.resolve([])}startAudioInput(e){return Promise.reject()}stopAudioInput(){return Promise.resolve()}startVideoInput(e){return Promise.reject()}stopVideoInput(){return Promise.resolve()}chooseAudioOutput(e){return Promise.reject()}addDeviceChangeObserver(e){}removeDeviceChangeObserver(e){}createAnalyserNodeForAudioInput(){return null}startVideoPreviewForVideoInput(e){}stopVideoPreviewForVideoInput(e){}setDeviceLabelTrigger(e){}mixIntoAudioInput(e){return null}chooseVideoInputQuality(e,t,n){}getVideoInputQualitySettings(){return null}}t.default=a,t.NoOpDeviceControllerWithEventController=class extends a{constructor(e){super(),this.eventController=e}}},1238:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5348);class r extends i.default{constructor(e){super(e),this.name="NotFoundError"}}t.default=r},3110:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5348);class r extends i.default{constructor(e){super(e),this.name="NotReadableError"}}t.default=r},4842:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5348);class r extends i.default{constructor(e,t){super(e),this.constraint=t,this.name="OverconstrainedError"}}t.default=r},6991:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5348);class r extends i.default{constructor(e,t){super(e,t),this.name="PermissionDeniedError"}}t.default=r},7786:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e){this.inner=e}mute(e){return n(this,void 0,void 0,(function*(){}))}stop(){var e;return n(this,void 0,void 0,(function*(){null===(e=this.node)||void 0===e||e.disconnect()}))}intrinsicDevice(){return n(this,void 0,void 0,(function*(){return this.inner}))}createAudioNode(e){var t;return n(this,void 0,void 0,(function*(){return null===(t=this.node)||void 0===t||t.disconnect(),this.node=yield this.createSingleAudioNode(e),{start:this.node,end:this.node}}))}}},6950:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5348);class r extends i.default{constructor(e){super(e),this.name="TypeError"}}t.default=r},4500:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n){this.videoWidth=e,this.videoHeight=t,this.videoFrameRate=n}}},7170:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isVideoTransformDevice=void 0,t.isVideoTransformDevice=function(e){return!!e&&"object"==typeof e&&"transformStream"in e&&"stop"in e&&"intrinsicDevice"in e}},8236:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){if(this.devicePixelRatioSource=e,this.observerQueue=new Set,this.mediaQueryListener=()=>{this.observerQueue.forEach((e=>{e.devicePixelRatioChanged(this.devicePixelRatioSource.devicePixelRatio())}))},"undefined"==typeof window)return;const n=matchMedia(`(resolution: ${this.devicePixelRatioSource.devicePixelRatio()}dppx)`);"function"==typeof n.addEventListener?(n.addEventListener("change",this.mediaQueryListener),this.mediaQueryList=n):"function"==typeof n.addListener?(n.addListener(this.mediaQueryListener),this.mediaQueryList=n):t.warn("ignoring DefaultDevicePixelRatioMonitor")}destroy(){return n(this,void 0,void 0,(function*(){this.mediaQueryList&&("function"==typeof this.mediaQueryList.addEventListener?this.mediaQueryList.removeEventListener("change",this.mediaQueryListener):this.mediaQueryList.removeListener(this.mediaQueryListener)),delete this.mediaQueryListener,this.observerQueue.clear()}))}registerObserver(e){this.observerQueue.add(e),e.devicePixelRatioChanged(this.devicePixelRatioSource.devicePixelRatio())}removeObserver(e){this.observerQueue.delete(e)}}},9190:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{devicePixelRatio(){return"undefined"!=typeof window&&window&&window.devicePixelRatio?window.devicePixelRatio:1}}},3520:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))},r=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r({type:e.type,v:e.v,payloads:[...e.payloads]}),this.sendEvents=()=>i(this,void 0,void 0,(function*(){if(this.lock)return;const e=this.getItems(this.flushSize);if(0===e.length)return;this.lock=!0;const t=this.makeRequestBody(e);let n=!1;const i=Date.now();"firefox"===this.metadata.browserName.toLowerCase()&&this.cancellableEvents.set(i,e);try{this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEvents - sending body ${t}`);const e=yield this.send(t);if(this.cancellableEvents.delete(i),e.ok)try{const n=yield e.json();this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEvents - send successful events: ${t} message: ${JSON.stringify(n)}`)}catch(e){this.logger.warn(`Event Reporting - InMemoryJSONEventBuffer - sendEvents error reading OK response ${e} for events ${t}`)}else this.logger.error(`Event Reporting - InMemoryJSONEventBuffer - sendEvents - Failed to send events ${t} with response status ${e.status}`),n=!0}catch(e){n=!0,this.logger.warn(`Event Reporting - InMemoryJSONEventBuffer - sendEvents - Error in sending events ${t} to the ingestion endpoint ${e}`)}finally{this.lock=!1}n&&(this.cancellableEvents.delete(i),this.failedIngestionEvents.push(...e))}));const c=new s.default(o).getParserResult(),{browserMajorVersion:l}=c,u=r(c,["browserMajorVersion"]),d=t.toJSON(),{type:h,v:f}=d,p=r(d,["type","v"]);this.authenticationToken=t.getAuthenticationToken(),this.metadata=Object.assign(Object.assign({},u),p),Object.keys(this.metadata).forEach((e=>this.attributesToFilter.push(e))),this.type=h,this.v=f,this.ingestionURL=n,this.logger=o,this.importantEvents=new Set(a);const{maxBufferCapacityKb:m,totalBufferItems:g,flushSize:C,flushIntervalMs:v,retryCountLimit:y}=e;this.maxBufferCapacityBytes=1024*m,this.totalBufferItems=g,this.maxBufferItemCapacityBytes=Math.round(this.maxBufferCapacityBytes/g),this.flushIntervalMs=v,this.flushSize=C,this.retryCountLimit=y,this.currentIngestionEvent=this.initializeAndGetCurrentIngestionEvent(),this.beaconEventListener=e=>this.beaconEventHandler(e),this.addEventListeners()}addEventListeners(){this.beaconEventListener&&"window"in n.g&&window.addEventListener&&"document"in n.g&&document.addEventListener&&(this.logger.debug("Event Reporting - InMemoryJSONEventBuffer - addEventListeners - adding pagehide and visibility change event listeners"),window.addEventListener("pagehide",this.beaconEventListener),document.addEventListener("visibilitychange",this.beaconEventListener))}beaconEventHandler(e){("visibilitychange"===e.type&&"hidden"===document.visibilityState||"pagehide"===e.type)&&(this.logger.debug("Event Reporting - InMemoryJSONEventBuffer - beaconEventHandler is triggered calling sendBeacon"),this.sendBeacon())}removeEventListeners(){this.beaconEventListener&&"window"in n.g&&window.removeEventListener&&"document"in n.g&&document.removeEventListener&&(window.removeEventListener("pagehide",this.beaconEventListener),document.removeEventListener("visibilitychange",this.beaconEventListener),this.logger.debug("Event Reporting - InMemoryJSONEventBuffer - removeEventListeners - removing pagehide and visibility change event listeners"))}start(){var e;this.removeEventListeners(),this.addEventListeners(),null===(e=this.intervalScheduler)||void 0===e||e.stop(),this.intervalScheduler=new o.default(this.flushIntervalMs),this.intervalScheduler.start((()=>this.sendEvents()))}stop(){var e;null===(e=this.intervalScheduler)||void 0===e||e.stop(),this.intervalScheduler=void 0,this.sendBeacon(),this.removeEventListeners()}addItem(e){return i(this,void 0,void 0,(function*(){this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - addItem - received event ${JSON.stringify(e)}`);const{name:t,ts:n,attributes:i}=e,r=i&&this.filterAttributes(i,this.attributesToFilter),a=Object.assign({name:t,ts:n},r);this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - addItem - event after filtering attributes ${JSON.stringify(a)}`);const o=this.getSize(a);if(o>l.MAX_ITEM_SIZE_BYTES_ALLOWED)throw new Error(`Event Reporting - Item to be added has size ${o} bytes. Item cannot exceed max item size allowed of ${l.MAX_ITEM_SIZE_BYTES_ALLOWED} bytes.`);if(this.importantEvents.has(t))return this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - addItem - sending important event ${JSON.stringify(a)}`),void this.sendEventImmediately({name:t,ts:n,attributes:r});if(this.isFull())throw this.logger.warn("Event Reporting - Event buffer is full"),new Error("Buffer full");if(this.currentIngestionEvent.payloads.push(a),this.ingestionEventSize+=o,this.bufferItemThresholdReached(o)){const e=this.deepCopyCurrentIngestionEvent(this.currentIngestionEvent);this.buffer.push(e),this.bufferSize+=this.ingestionEventSize,this.currentIngestionEvent=this.initializeAndGetCurrentIngestionEvent(),this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - addItem - buffer item threshold reached updated buffer ${JSON.stringify(this.buffer)}`)}}))}filterAttributes(e,t){const n=new Set(t);return Object.keys(e).filter((e=>n.has(e))).forEach((t=>delete e[t])),e}initializeAndGetCurrentIngestionEvent(){const e={type:this.type,v:this.v,payloads:[]};return this.ingestionEventSize=this.getSize(e),e}bufferItemThresholdReached(e){return e+this.ingestionEventSize>=this.maxBufferItemCapacityBytes||this.currentIngestionEvent.payloads.length===l.MAX_PAYLOAD_ITEMS}getSize(e){let t=0;if("object"==typeof e)for(const[n,i]of Object.entries(e))t+=this.getPrimitiveSize(n),t+=this.getSize(i);else t+=this.getPrimitiveSize(e);return t}getPrimitiveSize(e){let t=0;return"string"==typeof e?t+=2*e.length:"number"==typeof e&&(t+=8),t}isFull(){return this.bufferSize===this.maxBufferCapacityBytes||this.buffer.length===this.totalBufferItems}isEmpty(){return 0===this.buffer.length||0===this.bufferSize}getItems(e,t=0){return this.isEmpty()?[]:(e=Math.min(this.buffer.length,e+1),this.buffer.splice(t,e))}makeBeaconRequestBody(e){const t={metadata:this.metadata,events:e,authorization:this.authenticationToken};return JSON.stringify(t)}makeRequestBody(e){const t={metadata:this.metadata,events:e};return JSON.stringify(t)}sendEventImmediately(e){return i(this,void 0,void 0,(function*(){this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - important event received ${JSON.stringify(e)}`);const{name:t,ts:n,attributes:i}=e,r={type:this.type,v:this.v,payloads:[Object.assign({name:t,ts:n},i)]};let a=!1,o=null;const s=this.makeRequestBody([r]);try{if(o=yield this.send(s),o.ok){try{const e=yield o.json();this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - send successful event: ${s}, message: ${JSON.stringify(e)}`)}catch(e){this.logger.warn(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - Error reading OK response ${e} for event ${s}`)}return}this.logger.error(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - Failed to send an important event ${s} with response status ${o.status}`),a=!0}catch(e){this.logger.warn(`Event Reporting - There may be a failure in sending an important event ${s} to the ingestion endpoint ${e}.`),a=!0;try{if("firefox"===this.metadata.browserName.toLowerCase()){const e=this.makeBeaconRequestBody([r]);this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - beaconing data out ${e}`),a=!navigator.sendBeacon(`${this.ingestionURL}?beacon=1`,e)}}catch(e){this.logger.warn(`Event Reporting - Error sending beacon for an important event ${s}`),a=!0}}a&&(this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendEventImmediately - pushing to failed events ${s}`),this.failedIngestionEvents.push(r))}))}send(e){return i(this,void 0,void 0,(function*(){const t=new a.default(l.RETRY_FIXED_BACKOFF_WAIT_MS,l.RETRY_SHORT_BACKOFF_MS,l.RETRY_LONG_BACKOFF_MS);try{let n=0;for(;n0){const t=this.deepCopyCurrentIngestionEvent(this.currentIngestionEvent);e.push(t),this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendBeacon - clearing out current ingestion event ${JSON.stringify(t)}`),this.currentIngestionEvent=this.initializeAndGetCurrentIngestionEvent()}if(this.failedIngestionEvents.length>0){const t=this.failedIngestionEvents.map((e=>this.deepCopyCurrentIngestionEvent(e)));e.push(...t),this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendBeacon - clearing out any failed ingestion event ${JSON.stringify(t)}`),this.failedIngestionEvents=[]}if(this.cancellableEvents.size>0&&(this.cancellableEvents.forEach((t=>{e.push(...t),this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendBeacon - clearing out each cancellable event ${JSON.stringify(t)}`)})),this.cancellableEvents.clear()),0===e.length)return;const t=this.makeBeaconRequestBody(e);this.logger.debug(`Event Reporting - InMemoryJSONEventBuffer - sendBeacon - beacon data to send ${t}`);try{navigator.sendBeacon(`${this.ingestionURL}?beacon=1`,t)||this.logger.warn(`Event Reporting - Browser failed to queue beacon data ${t}`)}catch(e){this.logger.warn(`Event Reporting - Sending beacon data ${t} failed with error ${e}`)}}))}reset(){this.maxBufferCapacityBytes=0,this.totalBufferItems=0,this.buffer=[],this.bufferSize=0,this.maxBufferItemCapacityBytes=0,this.ingestionEventSize=0,this.flushIntervalMs=0,this.flushSize=0,this.failedIngestionEvents=[],this.lock=!1,this.beaconEventListener=void 0,this.cancellableEvents.clear()}destroy(){return i(this,void 0,void 0,(function*(){this.stop(),this.reset()}))}}t.default=l,l.SENDING_FAILURE_CODES=new Set([408,429,500,502,503,504]),l.RETRY_FIXED_BACKOFF_WAIT_MS=0,l.RETRY_SHORT_BACKOFF_MS=1e3,l.RETRY_LONG_BACKOFF_MS=15e3,l.MAX_PAYLOAD_ITEMS=2,l.MAX_ITEM_SIZE_BYTES_ALLOWED=3e3},7700:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e=5e3,t=2,n=64,i=100,r=15){this.flushIntervalMs=e,this.flushSize=t,this.maxBufferCapacityKb=n,this.totalBufferItems=i,this.retryCountLimit=r}}},3831:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(2238),a=n(146),o=n(5680),s=n(6366),c=n(9385),l=n(7797),u=n(4046),d=n(731);class h{constructor(e,t,n){var i,a,o,s,c,l,u;this.meetingHistoryStates=[],this.observerSet=new Set,this.destroyed=!1,this.logger=t,this.configuration=e,this.setupEventReporter(e,t,n);try{this.parserResult=navigator&&navigator.userAgent?new r.UAParser(navigator.userAgent).getResult():null}catch(e){this.logger.error(e.message)}this.browserMajorVersion=(null===(o=null===(a=null===(i=this.parserResult)||void 0===i?void 0:i.browser)||void 0===a?void 0:a.version)||void 0===o?void 0:o.split(".")[0])||h.UNAVAILABLE,this.browserName=(null===(s=this.parserResult)||void 0===s?void 0:s.browser.name)||h.UNAVAILABLE,this.browserVersion=(null===(c=this.parserResult)||void 0===c?void 0:c.browser.version)||h.UNAVAILABLE,this.deviceName=[(null===(l=this.parserResult)||void 0===l?void 0:l.device.vendor)||"",(null===(u=this.parserResult)||void 0===u?void 0:u.device.model)||""].join(" ").trim()||h.UNAVAILABLE}addObserver(e){this.observerSet.add(e)}removeObserver(e){this.observerSet.delete(e)}forEachObserver(e){for(const t of this.observerSet)l.default.nextTick((()=>{this.observerSet.has(t)&&e(t)}))}publishEvent(e,t){return i(this,void 0,void 0,(function*(){const n=Date.now();this.meetingHistoryStates.push({name:e,timestampMs:n});const i=Object.freeze(Object.assign(this.getAttributes(n),t));this.forEachObserver((t=>{t.eventDidReceive(e,i)})),this.reportEvent(e,n,t)}))}reportEvent(e,t,n){var r;return i(this,void 0,void 0,(function*(){let i;try{n&&(i=d.default(n)),yield null===(r=this.eventReporter)||void 0===r?void 0:r.reportEvent(t,e,i)}catch(e){this.logger.error(`Error reporting event ${e}`)}}))}setupEventReporter(e,t,n){if(n)this._eventReporter=n;else if(e.urls){const n=e.urls.eventIngestionURL;if(n){this.logger.info("Event ingestion URL is present in the configuration");const{meetingId:i,credentials:{attendeeId:r,joinToken:a}}=e,l=new c.default(i,r,a),u=new o.default(l,n);this._eventReporter=new s.default(u,t)}}}getAttributes(e){var t,n;return{attendeeId:this.configuration.credentials.attendeeId,browserMajorVersion:this.browserMajorVersion,browserName:this.browserName,browserVersion:this.browserVersion,deviceName:this.deviceName,externalMeetingId:"string"==typeof this.configuration.externalMeetingId?this.configuration.externalMeetingId:"",externalUserId:this.configuration.credentials.externalUserId,meetingHistory:this.meetingHistoryStates,meetingId:this.configuration.meetingId,osName:(null===(t=this.parserResult)||void 0===t?void 0:t.os.name)||h.UNAVAILABLE,osVersion:(null===(n=this.parserResult)||void 0===n?void 0:n.os.version)||h.UNAVAILABLE,sdkVersion:u.default.sdkVersion,sdkName:u.default.sdkName,timestampMs:e}}get eventReporter(){return this._eventReporter}destroy(){return i(this,void 0,void 0,(function*(){a.isDestroyable(this.eventReporter)&&(yield this.eventReporter.destroy()),this.logger=void 0,this.configuration=void 0,this._eventReporter=void 0,this.destroyed=!0}))}}t.default=h,h.UNAVAILABLE="Unavailable"},731:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=e=>{const t={};for(const[n,i]of Object.entries(e))if(null!=i&&""!==i){if("number"!=typeof i&&"string"!=typeof i)throw new TypeError("Unhandled type received while flattening attributes.");t[n]=i}return t}},5680:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7700);t.default=class{constructor(e,t,n=new i.default){this.eventsClientConfiguration=e,this.ingestionURL=t,this.eventBufferConfiguration=n}}},6366:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(146),a=n(3520);t.default=class{constructor(e,t){this.reportingEvents=!1,this.importantEvents=["meetingEnded","meetingFailed","meetingStartFailed","audioInputFailed","videoInputFailed","meetingStartSucceeded"],this.destroyed=!1;const{eventsClientConfiguration:n,ingestionURL:i,eventBufferConfiguration:r}=e,{eventsToIgnore:o}=n;this.eventBuffer=new a.default(r,n,i,this.importantEvents,t),this.logger=t,this.eventsToIgnore=o,this.start()}start(){if(!this.reportingEvents)try{this.eventBuffer.start(),this.logger.info("Event reporting started"),this.reportingEvents=!0}catch(e){this.logger.error(`Event Reporting - Error starting the event buffer ${e}`)}}stop(){if(this.reportingEvents)try{this.eventBuffer.stop(),this.logger.info("Event reporting stopped"),this.reportingEvents=!1}catch(e){this.logger.error(`Event Reporting - Error stopping the event buffer ${e}`)}}reportEvent(e,t,n){return i(this,void 0,void 0,(function*(){if(this.logger.debug(`Event Reporting - DefaultMeetingEventReporter - event received in reportEvent ${e}, ${t}, ${JSON.stringify(n)}`),this.eventsToIgnore.includes(t))this.logger.debug(`Event Reporting - DefaultMeetingEventReporter - ${t} event will be ignored as it is in events to ignore`);else try{this.logger.debug("Event Reporting - DefaultMeetingEventReporter - adding item to event buffer"),yield this.eventBuffer.addItem({ts:e,name:t,attributes:n})}catch(e){this.logger.error(`Event Reporting - Error adding event to buffer ${e}`)}}))}destroy(){return i(this,void 0,void 0,(function*(){this.destroyed=!0,this.stop(),r.isDestroyable(this.eventBuffer)&&this.eventBuffer.destroy(),this.eventBuffer=void 0}))}}},732:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){}reportEvent(e,t,n){}start(){}stop(){}}},9385:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i=[]){this.type="Meet",this.v=1,this.meetingId=e,this.attendeeId=t,this.eventsToIgnore=i,this.authenticationToken=n}getAuthenticationToken(){return this.authenticationToken}toJSON(){const e={};return e.type=this.type,e.v=this.v,e.meetingId=this.meetingId,e.attendeeId=this.attendeeId,e}}},3204:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultEventController=t.DefaultDevicePixelRatioMonitor=t.DefaultDeviceController=t.DefaultContentShareController=t.DefaultBrowserBehavior=t.DefaultAudioVideoFacade=t.DefaultAudioVideoController=t.DefaultAudioMixController=t.DefaultActiveSpeakerPolicy=t.DefaultActiveSpeakerDetector=t.DataMessage=t.CreateSDPTask=t.CreatePeerConnectionTask=t.ContentShareMediaStreamBroker=t.ContentShareConstants=t.ConsoleLogger=t.ConnectionHealthPolicyConfiguration=t.ConnectionHealthData=t.ClientVideoStreamReceivingReport=t.ClientMetricReportMediaType=t.ClientMetricReportDirection=t.ClientMetricReport=t.CleanStoppedSessionTask=t.CleanRestartedSessionTask=t.CheckVideoInputFeedback=t.CheckVideoConnectivityFeedback=t.CheckNetworkUDPConnectivityFeedback=t.CheckNetworkTCPConnectivityFeedback=t.CheckContentShareConnectivityFeedback=t.CheckCameraResolutionFeedback=t.CheckAudioOutputFeedback=t.CheckAudioInputFeedback=t.CheckAudioConnectivityFeedback=t.CanvasVideoFrameBuffer=t.CSPMonitor=t.BitrateParameters=t.BaseTask=t.BaseConnectionHealthPolicy=t.BackgroundReplacementVideoFrameProcessor=t.BackgroundFilterVideoFrameProcessor=t.BackgroundBlurVideoFrameProcessor=t.BackgroundBlurStrength=t.AudioVideoControllerState=t.AudioProfile=t.AudioLogEvent=t.Attendee=t.AttachMediaInputTask=t.AsyncScheduler=t.ApplicationMetadata=t.AllHighestVideoBandwidthPolicy=void 0,t.MeetingSessionCredentials=t.MeetingSessionConfiguration=t.MeetingReadinessCheckerConfiguration=t.MeetingEventsClientConfiguration=t.MediaDeviceProxyHandler=t.Maybe=t.LogLevel=t.Log=t.ListenForVolumeIndicatorsTask=t.LeaveAndReceiveLeaveAckTask=t.JoinAndReceiveIndexTask=t.IntervalScheduler=t.InMemoryJSONEventBuffer=t.GlobalMetricReport=t.GetUserMediaError=t.FullJitterLimitedBackoff=t.FullJitterBackoffFactory=t.FullJitterBackoff=t.FinishGatheringICECandidatesTask=t.EventIngestionConfiguration=t.EventBufferConfiguration=t.DeviceSelection=t.DevicePixelRatioWindowSource=t.DefaultWebSocketAdapter=t.DefaultVolumeIndicatorAdapter=t.DefaultVideoTransformDevice=t.DefaultVideoTileFactory=t.DefaultVideoTileController=t.DefaultVideoTile=t.DefaultVideoStreamIndex=t.DefaultVideoStreamIdSet=t.DefaultVideoFrameProcessorPipeline=t.DefaultVideoCaptureAndEncodeParameter=t.DefaultUserAgentParser=t.DefaultTranscriptionController=t.DefaultTransceiverController=t.DefaultSimulcastUplinkPolicyForContentShare=t.DefaultSimulcastUplinkPolicy=t.DefaultSignalingClient=t.DefaultSigV4=t.DefaultSessionStateController=t.DefaultReconnectController=t.DefaultRealtimeController=t.DefaultPingPong=t.DefaultModality=t.DefaultMessagingSession=t.DefaultMeetingSession=t.DefaultMeetingReadinessChecker=t.DefaultMeetingEventReporter=t.DefaultMediaDeviceFactory=void 0,t.SendAndReceiveDataMessagesTask=t.SDPMediaSection=t.SDPCandidateType=t.SDP=t.RunnableTask=t.ReconnectionHealthPolicy=t.ReceiveVideoStreamIndexTask=t.ReceiveVideoInputTask=t.ReceiveTURNCredentialsTask=t.ReceiveAudioInputTask=t.RealtimeVolumeIndicator=t.RealtimeState=t.RealtimeAttendeePositionInFrame=t.PromoteToPrimaryMeetingTask=t.PromiseQueue=t.PrefetchOn=t.PermissionDeniedError=t.ParallelGroupTask=t.POSTLogger=t.OverconstrainedError=t.OpenSignalingConnectionTask=t.OnceTask=t.NotReadableError=t.NotFoundError=t.None=t.NoVideoUplinkBandwidthPolicy=t.NoVideoDownlinkBandwidthPolicy=t.NoOpVideoFrameProcessor=t.NoOpVideoElementFactory=t.NoOpTask=t.NoOpMediaStreamBroker=t.NoOpLogger=t.NoOpEventReporter=t.NoOpDeviceController=t.NoOpDebugLogger=t.NoOpAudioVideoController=t.NScaleVideoUplinkBandwidthPolicy=t.MutableVideoPreferences=t.MultiLogger=t.MonitorTask=t.ModelSpecBuilder=t.MessagingSessionConfiguration=t.Message=t.MeetingSessionVideoAvailability=t.MeetingSessionURLs=t.MeetingSessionTURNCredentials=t.MeetingSessionStatusCode=t.MeetingSessionStatus=t.MeetingSessionLifecycleEventCondition=t.MeetingSessionLifecycleEvent=void 0,t.VideoStreamDescription=t.VideoSource=t.VideoQualitySettings=t.VideoPriorityBasedPolicyConfig=t.VideoPriorityBasedPolicy=t.VideoPreferences=t.VideoPreference=t.VideoOnlyTransceiverController=t.VideoLogEvent=t.VideoCodecCapability=t.VideoAdaptiveProbePolicy=t.Versioning=t.UnusableAudioWarningConnectionHealthPolicy=t.TypeError=t.TranscriptionStatusType=t.TranscriptionStatus=t.TranscriptResult=t.TranscriptLanguageWithScore=t.TranscriptItemType=t.TranscriptItem=t.TranscriptEntity=t.TranscriptAlternative=t.Transcript=t.TimeoutTask=t.TimeoutScheduler=t.TaskStatus=t.TargetDisplaySize=t.SubscribeAndReceiveSubscribeAckTask=t.StreamMetricReport=t.Some=t.SingleNodeAudioTransformDevice=t.SimulcastVideoStreamIndex=t.SimulcastTransceiverController=t.SimulcastLayers=t.SimulcastContentShareTransceiverController=t.SignalingClientVideoSubscriptionConfiguration=t.SignalingClientSubscribe=t.SignalingClientJoin=t.SignalingClientEventType=t.SignalingClientEvent=t.SignalingClientConnectionRequest=t.SignalingAndMetricsConnectionMonitor=t.SetRemoteDescriptionTask=t.SetLocalDescriptionTask=t.SessionStateControllerTransitionResult=t.SessionStateControllerState=t.SessionStateControllerDeferPriority=t.SessionStateControllerAction=t.ServerSideNetworkAdaption=t.SerialGroupTask=void 0,t.isVideoTransformDevice=t.isDestroyable=t.isAudioTransformDevice=t.ZLIBTextCompressor=t.WebSocketReadyState=t.WaitForAttendeePresenceTask=t.VoiceFocusTransformDevice=t.VoiceFocusDeviceTransformer=t.VideoTileState=void 0;const i=n(5185);t.AllHighestVideoBandwidthPolicy=i.default;const r=n(7535);t.ApplicationMetadata=r.default;const a=n(7797);t.AsyncScheduler=a.default;const o=n(8358);t.AttachMediaInputTask=o.default;const s=n(7602);t.Attendee=s.default;const c=n(9880);t.AudioLogEvent=c.default;const l=n(3765);t.AudioProfile=l.default;const u=n(1876);t.AudioVideoControllerState=u.default;const d=n(9734);t.BackgroundBlurStrength=d.default;const h=n(1260);t.BackgroundBlurVideoFrameProcessor=h.default;const f=n(4243);t.BackgroundFilterVideoFrameProcessor=f.default;const p=n(9854);t.BackgroundReplacementVideoFrameProcessor=p.default;const m=n(3940);t.BaseConnectionHealthPolicy=m.default;const g=n(1789);t.BaseTask=g.default;const C=n(9394);t.BitrateParameters=C.default;const v=n(7237);t.CSPMonitor=v.default;const y=n(9807);t.CanvasVideoFrameBuffer=y.default;const b=n(2084);t.CheckAudioConnectivityFeedback=b.default;const M=n(8892);t.CheckAudioInputFeedback=M.default;const x=n(9333);t.CheckAudioOutputFeedback=x.default;const _=n(1087);t.CheckCameraResolutionFeedback=_.default;const S=n(2606);t.CheckContentShareConnectivityFeedback=S.default;const w=n(7415);t.CheckNetworkTCPConnectivityFeedback=w.default;const L=n(4299);t.CheckNetworkUDPConnectivityFeedback=L.default;const E=n(6818);t.CheckVideoConnectivityFeedback=E.default;const T=n(1737);t.CheckVideoInputFeedback=T.default;const z=n(3216);t.CleanRestartedSessionTask=z.default;const A=n(7408);t.CleanStoppedSessionTask=A.default;const V=n(4571);t.ClientMetricReport=V.default;const H=n(6196);t.ClientMetricReportDirection=H.default;const R=n(9496);t.ClientMetricReportMediaType=R.default;const P=n(2770);t.ClientVideoStreamReceivingReport=P.default;const I=n(6688);t.ConnectionHealthData=I.default;const k=n(3731);t.ConnectionHealthPolicyConfiguration=k.default;const N=n(8030);t.ConsoleLogger=N.default;const D=n(8890);t.ContentShareConstants=D.default;const O=n(8370);t.ContentShareMediaStreamBroker=O.default;const B=n(5482);t.CreatePeerConnectionTask=B.default;const F=n(1129);t.CreateSDPTask=F.default;const U=n(1018);t.DataMessage=U.default;const W=n(8320);t.DefaultActiveSpeakerDetector=W.default;const G=n(2363);t.DefaultActiveSpeakerPolicy=G.default;const j=n(6802);t.DefaultAudioMixController=j.default;const q=n(9059);t.DefaultAudioVideoController=q.default;const X=n(8538);t.DefaultAudioVideoFacade=X.default;const Y=n(543);t.DefaultBrowserBehavior=Y.default;const J=n(8023);t.DefaultContentShareController=J.default;const $=n(4142);t.DefaultDeviceController=$.default;const K=n(8236);t.DefaultDevicePixelRatioMonitor=K.default;const Z=n(3831);t.DefaultEventController=Z.default;const Q=n(6354);t.DefaultMediaDeviceFactory=Q.default;const ee=n(6366);t.DefaultMeetingEventReporter=ee.default;const te=n(3980);t.DefaultMeetingReadinessChecker=te.default;const ne=n(4202);t.DefaultMeetingSession=ne.default;const ie=n(8947);t.DefaultMessagingSession=ie.default;const re=n(214);t.DefaultModality=re.default;const ae=n(7500);t.DefaultPingPong=ae.default;const oe=n(983);t.DefaultRealtimeController=oe.default;const se=n(9141);t.DefaultReconnectController=se.default;const ce=n(9678);t.DefaultSessionStateController=ce.default;const le=n(334);t.DefaultSigV4=le.default;const ue=n(1208);t.DefaultSignalingClient=ue.default;const de=n(4450);t.DefaultSimulcastUplinkPolicy=de.default;const he=n(3879);t.DefaultSimulcastUplinkPolicyForContentShare=he.default;const fe=n(365);t.DefaultTransceiverController=fe.default;const pe=n(5308);t.DefaultTranscriptionController=pe.default;const me=n(8627);t.DefaultUserAgentParser=me.default;const ge=n(1133);t.DefaultVideoCaptureAndEncodeParameter=ge.default;const Ce=n(8919);t.DefaultVideoFrameProcessorPipeline=Ce.default;const ve=n(1508);t.DefaultVideoStreamIdSet=ve.default;const ye=n(1318);t.DefaultVideoStreamIndex=ye.default;const be=n(3327);t.DefaultVideoTile=be.default;const Me=n(2958);t.DefaultVideoTileController=Me.default;const xe=n(4922);t.DefaultVideoTileFactory=xe.default;const _e=n(7673);t.DefaultVideoTransformDevice=_e.default;const Se=n(9751);t.DefaultVolumeIndicatorAdapter=Se.default;const we=n(7631);t.DefaultWebSocketAdapter=we.default;const Le=n(9190);t.DevicePixelRatioWindowSource=Le.default;const Ee=n(8128);t.DeviceSelection=Ee.default;const Te=n(7700);t.EventBufferConfiguration=Te.default;const ze=n(5680);t.EventIngestionConfiguration=ze.default;const Ae=n(6240);t.FinishGatheringICECandidatesTask=Ae.default;const Ve=n(8434);t.FullJitterBackoff=Ve.default;const He=n(5640);t.FullJitterBackoffFactory=He.default;const Re=n(7300);t.FullJitterLimitedBackoff=Re.default;const Pe=n(5348);t.GetUserMediaError=Pe.default;const Ie=n(2306);t.GlobalMetricReport=Ie.default;const ke=n(3520);t.InMemoryJSONEventBuffer=ke.default;const Ne=n(3922);t.IntervalScheduler=Ne.default;const De=n(1960);t.JoinAndReceiveIndexTask=De.default;const Oe=n(6180);t.LeaveAndReceiveLeaveAckTask=Oe.default;const Be=n(2748);t.ListenForVolumeIndicatorsTask=Be.default;const Fe=n(293);t.Log=Fe.default;const Ue=n(813);t.LogLevel=Ue.default;const We=n(4236);t.MediaDeviceProxyHandler=We.default;const Ge=n(9385);t.MeetingEventsClientConfiguration=Ge.default;const je=n(3990);t.MeetingReadinessCheckerConfiguration=je.default;const qe=n(589);t.MeetingSessionConfiguration=qe.default;const Xe=n(8015);t.MeetingSessionCredentials=Xe.default;const Ye=n(7604);t.MeetingSessionLifecycleEvent=Ye.default;const Je=n(1296);t.MeetingSessionLifecycleEventCondition=Je.default;const $e=n(3789);t.MeetingSessionStatus=$e.default;const Ke=n(5687);t.MeetingSessionStatusCode=Ke.default;const Ze=n(7215);t.MeetingSessionTURNCredentials=Ze.default;const Qe=n(6057);t.MeetingSessionURLs=Qe.default;const et=n(5723);t.MeetingSessionVideoAvailability=et.default;const tt=n(9358);t.Message=tt.default;const nt=n(4323);t.MessagingSessionConfiguration=nt.default;const it=n(22);t.ModelSpecBuilder=it.default;const rt=n(1981);t.MonitorTask=rt.default;const at=n(9938);t.MultiLogger=at.default;const ot=n(4442);t.NScaleVideoUplinkBandwidthPolicy=ot.default;const st=n(9836);t.NoOpAudioVideoController=st.default;const ct=n(209);t.NoOpDebugLogger=ct.default;const lt=n(6154);t.NoOpDeviceController=lt.default;const ut=n(732);t.NoOpEventReporter=ut.default;const dt=n(7434);t.NoOpLogger=dt.default;const ht=n(4015);t.NoOpMediaStreamBroker=ht.default;const ft=n(8831);t.NoOpTask=ft.default;const pt=n(3663);t.NoOpVideoElementFactory=pt.default;const mt=n(2801);t.NoOpVideoFrameProcessor=mt.default;const gt=n(5319);t.NoVideoDownlinkBandwidthPolicy=gt.default;const Ct=n(657);t.NoVideoUplinkBandwidthPolicy=Ct.default;const vt=n(1238);t.NotFoundError=vt.default;const yt=n(3110);t.NotReadableError=yt.default;const bt=n(1124);t.OnceTask=bt.default;const Mt=n(4543);t.OpenSignalingConnectionTask=Mt.default;const xt=n(4842);t.OverconstrainedError=xt.default;const _t=n(5013);t.POSTLogger=_t.default;const St=n(8556);t.ParallelGroupTask=St.default;const wt=n(6991);t.PermissionDeniedError=wt.default;const Lt=n(106);t.PrefetchOn=Lt.default;const Et=n(1515);t.PromiseQueue=Et.default;const Tt=n(9945);t.PromoteToPrimaryMeetingTask=Tt.default;const zt=n(5910);t.RealtimeAttendeePositionInFrame=zt.default;const At=n(9825);t.RealtimeState=At.default;const Vt=n(9576);t.RealtimeVolumeIndicator=Vt.default;const Ht=n(1209);t.ReceiveAudioInputTask=Ht.default;const Rt=n(5547);t.ReceiveTURNCredentialsTask=Rt.default;const Pt=n(120);t.ReceiveVideoInputTask=Pt.default;const It=n(9560);t.ReceiveVideoStreamIndexTask=It.default;const kt=n(9708);t.ReconnectionHealthPolicy=kt.default;const Nt=n(4191);t.RunnableTask=Nt.default;const Dt=n(326);t.SDP=Dt.default;const Ot=n(4076);t.SDPCandidateType=Ot.default;const Bt=n(1944);t.SDPMediaSection=Bt.default;const Ft=n(9485);t.SendAndReceiveDataMessagesTask=Ft.default;const Ut=n(7079);t.SerialGroupTask=Ut.default;const Wt=n(7103);t.ServerSideNetworkAdaption=Wt.default;const Gt=n(3860);t.SessionStateControllerAction=Gt.default;const jt=n(6850);t.SessionStateControllerDeferPriority=jt.default;const qt=n(9553);t.SessionStateControllerState=qt.default;const Xt=n(3013);t.SessionStateControllerTransitionResult=Xt.default;const Yt=n(4833);t.SetLocalDescriptionTask=Yt.default;const Jt=n(5275);t.SetRemoteDescriptionTask=Jt.default;const $t=n(8581);t.SignalingAndMetricsConnectionMonitor=$t.default;const Kt=n(3920);t.SignalingClientConnectionRequest=Kt.default;const Zt=n(2902);t.SignalingClientEvent=Zt.default;const Qt=n(9416);t.SignalingClientEventType=Qt.default;const en=n(2168);t.SignalingClientJoin=en.default;const tn=n(6729);t.SignalingClientSubscribe=tn.default;const nn=n(9101);t.SignalingClientVideoSubscriptionConfiguration=nn.default;const rn=n(7377);t.SimulcastContentShareTransceiverController=rn.default;const an=n(7606);t.SimulcastLayers=an.default;const on=n(5785);t.SimulcastTransceiverController=on.default;const sn=n(4242);t.SimulcastVideoStreamIndex=sn.default;const cn=n(7786);t.SingleNodeAudioTransformDevice=cn.default;const ln=n(2811);t.StreamMetricReport=ln.default;const un=n(5924);t.SubscribeAndReceiveSubscribeAckTask=un.default;const dn=n(2721);t.TargetDisplaySize=dn.default;const hn=n(4456);t.TaskStatus=hn.default;const fn=n(4929);t.TimeoutScheduler=fn.default;const pn=n(250);t.TimeoutTask=pn.default;const mn=n(4739);t.Transcript=mn.default;const gn=n(2471);t.TranscriptAlternative=gn.default;const Cn=n(7210);t.TranscriptEntity=Cn.default;const vn=n(1741);t.TranscriptItem=vn.default;const yn=n(6864);t.TranscriptItemType=yn.default;const bn=n(9063);t.TranscriptLanguageWithScore=bn.default;const Mn=n(5323);t.TranscriptResult=Mn.default;const xn=n(1288);t.TranscriptionStatus=xn.default;const _n=n(1326);t.TranscriptionStatusType=_n.default;const Sn=n(6950);t.TypeError=Sn.default;const wn=n(1922);t.UnusableAudioWarningConnectionHealthPolicy=wn.default;const Ln=n(4046);t.Versioning=Ln.default;const En=n(2880);t.VideoAdaptiveProbePolicy=En.default;const Tn=n(2330);t.VideoCodecCapability=Tn.default;const zn=n(155);t.VideoLogEvent=zn.default;const An=n(9354);t.VideoOnlyTransceiverController=An.default;const Vn=n(1754);t.VideoPreference=Vn.default;const Hn=n(1819);t.VideoPreferences=Hn.default;const Rn=n(4992);t.VideoPriorityBasedPolicy=Rn.default;const Pn=n(1034);t.VideoPriorityBasedPolicyConfig=Pn.default;const In=n(4500);t.VideoQualitySettings=In.default;const kn=n(60);t.VideoSource=kn.default;const Nn=n(6876);t.VideoStreamDescription=Nn.default;const Dn=n(7804);t.VideoTileState=Dn.default;const On=n(2497);t.VoiceFocusDeviceTransformer=On.default;const Bn=n(8878);t.VoiceFocusTransformDevice=Bn.default;const Fn=n(6171);t.WaitForAttendeePresenceTask=Fn.default;const Un=n(7387);t.WebSocketReadyState=Un.default;const Wn=n(3320);t.ZLIBTextCompressor=Wn.default;const Gn=n(1819);Object.defineProperty(t,"MutableVideoPreferences",{enumerable:!0,get:function(){return Gn.MutableVideoPreferences}});const jn=n(8660);Object.defineProperty(t,"Some",{enumerable:!0,get:function(){return jn.Some}}),Object.defineProperty(t,"None",{enumerable:!0,get:function(){return jn.None}}),Object.defineProperty(t,"Maybe",{enumerable:!0,get:function(){return jn.Maybe}});const qn=n(1746);Object.defineProperty(t,"isAudioTransformDevice",{enumerable:!0,get:function(){return qn.isAudioTransformDevice}});const Xn=n(146);Object.defineProperty(t,"isDestroyable",{enumerable:!0,get:function(){return Xn.isDestroyable}});const Yn=n(7170);Object.defineProperty(t,"isVideoTransformDevice",{enumerable:!0,get:function(){return Yn.isVideoTransformDevice}})},8030:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(813);t.default=class{constructor(e,t=i.default.WARN){this.name=e,this.level=t}info(e){this.log(i.default.INFO,e)}warn(e){this.log(i.default.WARN,e)}error(e){this.log(i.default.ERROR,e)}debug(e){i.default.DEBUG{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i){this.sequenceNumber=e,this.message=t,this.timestampMs=n,this.logLevel=i}}},813:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevel=void 0,function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.OFF=4]="OFF"}(n=t.LogLevel||(t.LogLevel={})),t.default=n},9938:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(813);t.default=class{constructor(...e){this._loggers=e}info(e){for(const t of this._loggers)t.info(e)}warn(e){for(const t of this._loggers)t.warn(e)}error(e){for(const t of this._loggers)t.error(e)}debug(e){let t,n;n="string"==typeof e?e:e?()=>(t||(t=e()),t):""+e;for(const e of this._loggers)e.debug(n)}setLogLevel(e){for(const t of this._loggers)t.setLogLevel(e)}getLogLevel(){for(const e of this._loggers)return e.getLogLevel();return i.default.OFF}}},209:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(813),r=n(7434);class a extends r.default{constructor(){super(i.default.DEBUG)}}t.default=a},7434:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(813);t.default=class{constructor(e=i.default.OFF){this.level=e}info(e){}warn(e){}error(e){}debug(e){i.default.DEBUG{this.stop()},this.addEventListener()}addEventListener(){this.eventListener&&"window"in n.g&&window.addEventListener&&window.addEventListener("unload",this.eventListener)}removeEventListener(){this.eventListener&&"window"in n.g&&window.removeEventListener&&window.removeEventListener("unload",this.eventListener)}debug(e){o.default.DEBUGi(this,void 0,void 0,(function*(){if(!0===this.lock||0===this.getLogCaptureSize())return;this.lock=!0;const e=this.logCapture.slice(0,this.batchSize),t=this.makeRequestBody(e);try{200===(yield fetch(this.url,Object.assign({method:"POST",body:t},this.headers?{headers:this.headers}:{}))).status&&(this.logCapture=this.logCapture.slice(e.length))}catch(e){console.warn("[POSTLogger] "+e.message)}finally{this.lock=!1}}))))}stop(){var e;null===(e=this.intervalScheduler)||void 0===e||e.stop(),this.intervalScheduler=void 0,this.removeEventListener();const t=this.makeRequestBody(this.logCapture);navigator.sendBeacon(this.url,t)}destroy(){return i(this,void 0,void 0,(function*(){this.stop(),this.metadata=void 0,this.headers=void 0,this.logCapture=[],this.sequenceNumber=0,this.lock=!1,this.batchSize=0,this.intervalMs=0,this.url=void 0}))}makeRequestBody(e){return JSON.stringify(Object.assign(Object.assign({},this.metadata),{logs:e}))}log(e,t){if(e{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4236);t.default=class{constructor(){this.isMediaDevicesSupported="undefined"!=typeof navigator&&!!navigator.mediaDevices}create(){if(this.isMediaDevicesSupported)return new Proxy(navigator.mediaDevices,new i.default);throw new Error("navigator.mediaDevices is not supported")}}},4236:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(7797),a=n(3922);class o{constructor(){this.scheduler=null,this.devices=null,this.deviceChangeListeners=new Set,this.get=(e,t,n)=>{if(!Reflect.has(e,t))return;if(!("ondevicechange"in navigator.mediaDevices)){if("addEventListener"===t)return this.patchAddEventListener(e,t,n);if("removeEventListener"===t)return this.patchRemoveEventListener(e,t,n)}const i=Reflect.get(e,t,n);return"function"==typeof i?i.bind(e):i},this.patchAddEventListener=(e,t,n)=>{const i=Reflect.get(e,t,n);return(t,n,r)=>{if("devicechange"!==t)return Reflect.apply(i,e,[t,n,r]);this.deviceChangeListeners.add(n),this.scheduler||(this.scheduler=new a.default(o.INTERVAL_MS),this.scheduler.start(this.pollDeviceLists))}},this.patchRemoveEventListener=(e,t,n)=>{const i=Reflect.get(e,t,n);return(t,n,r)=>{if("devicechange"!==t)return Reflect.apply(i,e,[t,n,r]);this.deviceChangeListeners.delete(n),0===this.deviceChangeListeners.size&&this.scheduler&&(this.scheduler.stop(),this.scheduler=null)}},this.pollDeviceLists=()=>i(this,void 0,void 0,(function*(){const e=yield this.sortedDeviceList();this.devices&&(e.length!==this.devices.length||e.some(((e,t)=>e.deviceId!==this.devices[t].deviceId)))&&this.handleDeviceChangeEvent(),this.devices=e}))}sortedDeviceList(){return i(this,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).sort(((e,t)=>e.deviceIdt.deviceId?-1:0))}))}handleDeviceChangeEvent(){for(const e of this.deviceChangeListeners)r.default.nextTick((()=>{if(this.deviceChangeListeners.has(e)){const t=new Event("devicechange");"function"==typeof e?e(t):e.handleEvent(t)}}))}}t.default=o,o.INTERVAL_MS=1e3},4015:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{acquireAudioInputStream(){return Promise.reject()}acquireVideoInputStream(){return Promise.reject()}acquireDisplayInputStream(e){return Promise.reject()}muteLocalAudioInputStream(){}unmuteLocalAudioInputStream(){}addMediaStreamBrokerObserver(e){}removeMediaStreamBrokerObserver(e){}}},2084:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckAudioConnectivityFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.AudioInputRequestFailed=1]="AudioInputRequestFailed",e[e.AudioInputPermissionDenied=2]="AudioInputPermissionDenied",e[e.ConnectionFailed=3]="ConnectionFailed",e[e.AudioNotReceived=4]="AudioNotReceived"}(n=t.CheckAudioConnectivityFeedback||(t.CheckAudioConnectivityFeedback={})),t.default=n},8892:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckAudioInputFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.Failed=1]="Failed",e[e.PermissionDenied=2]="PermissionDenied"}(n=t.CheckAudioInputFeedback||(t.CheckAudioInputFeedback={})),t.default=n},9333:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckAudioOutputFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.Failed=1]="Failed"}(n=t.CheckAudioOutputFeedback||(t.CheckAudioOutputFeedback={})),t.default=n},1087:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckCameraResolutionFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.Failed=1]="Failed",e[e.ResolutionNotSupported=2]="ResolutionNotSupported",e[e.PermissionDenied=3]="PermissionDenied"}(n=t.CheckCameraResolutionFeedback||(t.CheckCameraResolutionFeedback={})),t.default=n},2606:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckContentShareConnectivityFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.Failed=1]="Failed",e[e.PermissionDenied=2]="PermissionDenied",e[e.TimedOut=3]="TimedOut",e[e.ConnectionFailed=4]="ConnectionFailed"}(n=t.CheckContentShareConnectivityFeedback||(t.CheckContentShareConnectivityFeedback={})),t.default=n},7415:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckNetworkTCPConnectivityFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.MeetingSessionURLsNotInitialized=1]="MeetingSessionURLsNotInitialized",e[e.ConnectionFailed=2]="ConnectionFailed",e[e.ICENegotiationFailed=3]="ICENegotiationFailed"}(n=t.CheckNetworkTCPConnectivityFeedback||(t.CheckNetworkTCPConnectivityFeedback={})),t.default=n},4299:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckNetworkUDPConnectivityFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.MeetingSessionURLsNotInitialized=1]="MeetingSessionURLsNotInitialized",e[e.ConnectionFailed=2]="ConnectionFailed",e[e.ICENegotiationFailed=3]="ICENegotiationFailed"}(n=t.CheckNetworkUDPConnectivityFeedback||(t.CheckNetworkUDPConnectivityFeedback={})),t.default=n},6818:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckVideoConnectivityFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.VideoInputRequestFailed=1]="VideoInputRequestFailed",e[e.VideoInputPermissionDenied=2]="VideoInputPermissionDenied",e[e.ConnectionFailed=3]="ConnectionFailed",e[e.VideoNotSent=4]="VideoNotSent"}(n=t.CheckVideoConnectivityFeedback||(t.CheckVideoConnectivityFeedback={})),t.default=n},1737:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.CheckVideoInputFeedback=void 0,function(e){e[e.Succeeded=0]="Succeeded",e[e.Failed=1]="Failed",e[e.PermissionDenied=2]="PermissionDenied"}(n=t.CheckVideoInputFeedback||(t.CheckVideoInputFeedback={})),t.default=n},3980:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(6802),a=n(543),o=n(4142),s=n(6991),c=n(1789),l=n(250),u=n(2084),d=n(8892),h=n(9333),f=n(1087),p=n(2606),m=n(7415),g=n(4299),C=n(6818),v=n(1737),y=n(3990);class b{constructor(e,t,n=new y.default){this.logger=e,this.meetingSession=t,this.configuration=n,this.browserBehavior=new a.default}static delay(e){return i(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}checkAudioInput(e){return i(this,void 0,void 0,(function*(){try{return yield this.meetingSession.audioVideo.startAudioInput(e),yield this.meetingSession.audioVideo.stopAudioInput(),d.default.Succeeded}catch(e){return this.logger.error(`MeetingReadinessChecker: Audio input check failed with error ${e}`),e instanceof s.default?d.default.PermissionDenied:d.default.Failed}}))}checkAudioOutput(e,t,n=null){return i(this,void 0,void 0,(function*(){try{const i=e?o.default.getIntrinsicDeviceId(e):"";return yield this.playTone(i,440,n),(yield t())?h.default.Succeeded:h.default.Failed}catch(e){return this.logger.error(`MeetingReadinessChecker: Audio output check failed with error: ${e}`),h.default.Failed}finally{this.stopTone()}}))}playTone(e,t,n){return i(this,void 0,void 0,(function*(){this.oscillatorNode&&this.stopTone(),this.audioContext=o.default.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=0,this.oscillatorNode=this.audioContext.createOscillator(),this.oscillatorNode.frequency.value=t,this.oscillatorNode.connect(this.gainNode),this.destinationStream=this.audioContext.createMediaStreamDestination(),this.gainNode.connect(this.destinationStream);const i=this.audioContext.currentTime+.1;this.gainNode.gain.linearRampToValueAtTime(0,i),this.gainNode.gain.linearRampToValueAtTime(.1,i+.1),this.oscillatorNode.start();const a=new r.default(this.logger);try{this.browserBehavior.supportsSetSinkId()&&(yield a.bindAudioDevice({deviceId:e}))}catch(e){this.logger.error(`Failed to bind audio device: ${e}`)}try{yield a.bindAudioElement(n||new Audio)}catch(e){this.logger.error(`Failed to bind audio element: ${e}`)}yield a.bindAudioStream(this.destinationStream.stream)}))}stopTone(){if(!(this.audioContext&&this.gainNode&&this.oscillatorNode&&this.destinationStream))return;const e=this.audioContext.currentTime;this.gainNode.gain.linearRampToValueAtTime(.1,e+.1+1),this.gainNode.gain.linearRampToValueAtTime(0,e+.2+1),this.oscillatorNode.stop(),this.oscillatorNode.disconnect(this.gainNode),this.gainNode.disconnect(this.destinationStream),this.oscillatorNode=null,this.gainNode=null,this.destinationStream=null}checkVideoInput(e){return i(this,void 0,void 0,(function*(){try{return yield this.meetingSession.audioVideo.startVideoInput(e),yield this.meetingSession.audioVideo.stopVideoInput(),v.default.Succeeded}catch(e){return this.logger.error(`MeetingReadinessChecker: Video check failed with error ${e}`),e instanceof s.default?v.default.PermissionDenied:v.default.Failed}}))}checkCameraResolution(e,t,n){return i(this,void 0,void 0,(function*(){let i;try{const r=o.default.getIntrinsicDeviceId(e),a={video:this.calculateVideoConstraint(r,t,n)};i=yield navigator.mediaDevices.getUserMedia(a)}catch(e){return this.logger.error(`MeetingReadinessChecker: Camera resolution check with width: ${t} height ${n} failed with error ${e}`),e&&"OverconstrainedError"===e.name?f.default.ResolutionNotSupported:e&&"NotAllowedError"===e.name?f.default.PermissionDenied:f.default.Failed}finally{i&&i.getTracks().forEach((function(e){e.stop()}))}return f.default.Succeeded}))}calculateVideoConstraint(e,t,n){const i=this.browserBehavior.requiresResolutionAlignment(t,n),r={};return this.browserBehavior.requiresNoExactMediaStreamConstraints()?(r.deviceId=e,r.width=t,r.height=n):(r.deviceId={exact:e},r.width={exact:i[0]},r.height={exact:i[1]}),r}checkContentShareConnectivity(e){return i(this,void 0,void 0,(function*(){let t=!1,n=!1;const r={contentShareDidStart:()=>{t=!0}},a={audioVideoDidStart:()=>{n=!0}};try{return this.meetingSession.audioVideo.addObserver(a),this.meetingSession.audioVideo.start(),this.meetingSession.audioVideo.addContentShareObserver(r),yield this.meetingSession.audioVideo.startContentShareFromScreenCapture(e),yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return n&&t})))),n?(yield this.stopMeeting(),t?p.default.Succeeded:p.default.TimedOut):p.default.ConnectionFailed}catch(e){return this.logger.error(`MeetingReadinessChecker: Content share check failed with error ${e}`),"NotAllowedError"===e.name?p.default.PermissionDenied:p.default.Failed}finally{this.meetingSession.audioVideo.removeObserver(a),this.meetingSession.audioVideo.stopContentShare(),this.meetingSession.audioVideo.removeContentShareObserver(r)}}))}checkAudioConnectivity(e){return i(this,void 0,void 0,(function*(){let t=!1;const n=this.meetingSession.audioVideo,r=(e,n,i,r)=>{e===this.meetingSession.configuration.credentials.attendeeId&&n&&(t=!0)};try{yield n.startAudioInput(e)}catch(e){return this.logger.error(`MeetingReadinessChecker: Failed to get audio input device with error ${e}`),e instanceof s.default?u.default.AudioInputPermissionDenied:u.default.AudioInputRequestFailed}return n.realtimeSubscribeToAttendeeIdPresence(r),(yield this.startMeeting())?(yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return t})))),n.realtimeUnsubscribeToAttendeeIdPresence(r),yield this.stopMeeting(),yield this.meetingSession.audioVideo.stopAudioInput(),t?u.default.Succeeded:u.default.AudioNotReceived):(n.realtimeUnsubscribeToAttendeeIdPresence(r),yield this.meetingSession.audioVideo.stopAudioInput(),u.default.ConnectionFailed)}))}checkVideoConnectivity(e){return i(this,void 0,void 0,(function*(){const t=this.meetingSession.audioVideo;let n=0;const r={metricsDidReceive(e){e.getRTCStatsReport().forEach((e=>{"outbound-rtp"===e.type&&"video"===e.mediaType&&(n=e.packetsSent)}))}};try{yield t.startVideoInput(e)}catch(e){return this.logger.error(`MeetingReadinessChecker: Failed to get video input device with error ${e}`),e instanceof s.default?C.default.VideoInputPermissionDenied:C.default.VideoInputRequestFailed}return t.addObserver(r),(yield this.startMeeting())?(t.startLocalVideoTile(),yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return n>0})))),yield t.stopVideoInput(),yield this.stopMeeting(),t.removeObserver(r),n<=0?C.default.VideoNotSent:C.default.Succeeded):C.default.ConnectionFailed}))}checkNetworkUDPConnectivity(){return i(this,void 0,void 0,(function*(){let e=!1;const t={metricsDidReceive(t){t.getRTCStatsReport().forEach((t=>{"candidate-pair"===t.type&&"succeeded"===t.state&&(e=!0)}))}};try{this.originalURLRewriter=this.meetingSession.configuration.urls.urlRewriter}catch(e){return this.logger.error(`MeetingSessionConfiguration.urls doesn't exist. Error: ${e}`),g.default.MeetingSessionURLsNotInitialized}this.meetingSession.configuration.urls.urlRewriter=e=>{const t=this.originalURLRewriter(e);return t.includes("transport=tcp")?"":t};const n=this.meetingSession.audioVideo;return n.addObserver(t),(yield this.startMeeting())?(yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return e})))),this.meetingSession.configuration.urls.urlRewriter=this.originalURLRewriter,yield this.stopMeeting(),n.removeObserver(t),e?g.default.Succeeded:g.default.ICENegotiationFailed):(this.meetingSession.configuration.urls.urlRewriter=this.originalURLRewriter,g.default.ConnectionFailed)}))}checkNetworkTCPConnectivity(){return i(this,void 0,void 0,(function*(){let e=!1;const t={metricsDidReceive(t){t.getRTCStatsReport().forEach((t=>{"candidate-pair"===t.type&&"succeeded"===t.state&&(e=!0)}))}};try{this.originalURLRewriter=this.meetingSession.configuration.urls.urlRewriter}catch(e){return this.logger.error(`MeetingSessionConfiguration.urls doesn't exist. Error: ${e}`),m.default.MeetingSessionURLsNotInitialized}this.meetingSession.configuration.urls.urlRewriter=e=>{const t=this.originalURLRewriter(e);return t.includes("transport=udp")?"":t};const n=this.meetingSession.audioVideo;return n.addObserver(t),(yield this.startMeeting())?(yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return e})))),this.meetingSession.configuration.urls.urlRewriter=this.originalURLRewriter,yield this.stopMeeting(),n.removeObserver(t),e?m.default.Succeeded:m.default.ICENegotiationFailed):(this.meetingSession.configuration.urls.urlRewriter=this.originalURLRewriter,m.default.ConnectionFailed)}))}startMeeting(){return i(this,void 0,void 0,(function*(){let e=!1;const t={audioVideoDidStart:()=>{e=!0}};return this.meetingSession.audioVideo.addObserver(t),this.meetingSession.audioVideo.start(),yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return e})))),this.meetingSession.audioVideo.removeObserver(t),e}))}stopMeeting(){return i(this,void 0,void 0,(function*(){let e=!1;const t={audioVideoDidStop:t=>{e=!0}};return this.meetingSession.audioVideo.addObserver(t),this.meetingSession.audioVideo.stop(),yield this.executeTimeoutTask((()=>i(this,void 0,void 0,(function*(){return e})))),this.meetingSession.audioVideo.removeObserver(t),e}))}executeTimeoutTask(e){return i(this,void 0,void 0,(function*(){let t=!1;class n extends c.default{constructor(e,t){super(e),this.waitDurationMs=t,this.isCancelled=!1}cancel(){this.isCancelled=!0}run(){return i(this,void 0,void 0,(function*(){for(;!this.isCancelled;){if(yield e()){t=!0;break}yield b.delay(this.waitDurationMs)}}))}}const r=new l.default(this.logger,new n(this.logger,this.configuration.waitDurationMs),this.configuration.timeoutMs);return yield r.run(),t}))}}t.default=b},3990:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.timeoutMs=1e4,this.waitDurationMs=3e3}}},4202:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9059),a=n(8538),o=n(8434),s=n(543),c=n(8370),l=n(8023),u=n(7237),d=n(146),h=n(3831),f=n(9141),p=n(7631);t.default=class{constructor(e,t,n,i){this._eventController=i,this._configuration=e,this._logger=t,this.checkBrowserSupportAndFeatureConfiguration(),u.default.addLogger(this._logger),u.default.register(),this._eventController||(this._eventController=new h.default(e,t)),n.eventController||(n.eventController=this.eventController),this.audioVideoController=new r.default(this._configuration,this._logger,new p.default(this._logger),n,new f.default(this._configuration.reconnectTimeoutMs,new o.default(this._configuration.reconnectFixedWaitMs,this._configuration.reconnectShortBackOffMs,this._configuration.reconnectLongBackOffMs)),this.eventController),this._deviceController=n;const s=new c.default(this._logger);this.contentShareController=new l.default(s,new r.default(l.default.createContentShareMeetingSessionConfigure(this._configuration),this._logger,new p.default(this._logger),s,new f.default(this._configuration.reconnectTimeoutMs,new o.default(this._configuration.reconnectFixedWaitMs,this._configuration.reconnectShortBackOffMs,this._configuration.reconnectLongBackOffMs))),this.audioVideoController),this.audioVideoFacade=new a.default(this.audioVideoController,this.audioVideoController.videoTileController,this.audioVideoController.realtimeController,this.audioVideoController.audioMixController,this._deviceController,this.contentShareController)}get configuration(){return this._configuration}get logger(){return this._logger}get audioVideo(){return this.audioVideoFacade}get contentShare(){return this.contentShareController}get deviceController(){return this._deviceController}get eventController(){return this._eventController}destroy(){return i(this,void 0,void 0,(function*(){d.isDestroyable(this.contentShareController)&&(yield this.contentShareController.destroy()),d.isDestroyable(this.audioVideoController)&&(yield this.audioVideoController.destroy()),d.isDestroyable(this.eventController)&&(yield this.eventController.destroy()),u.default.removeLogger(this._logger),this._logger=void 0,this._configuration=void 0,this._deviceController=void 0,this.audioVideoFacade=void 0,this.audioVideoController=void 0,this.contentShareController=void 0,this._eventController=void 0}))}checkBrowserSupportAndFeatureConfiguration(){const e=new s.default,t=`${e.name()} ${e.majorVersion()} (${e.version()})`;if(this.logger.info(`browser is ${t}`),e.isSupported()||this.logger.warn(`this browser is not currently supported. Stability may suffer. Supported browsers are: ${e.supportString()}.`),this._configuration.videoUplinkBandwidthPolicy)if(this.isSimulcastUplinkPolicy(this._configuration.videoUplinkBandwidthPolicy)){if(!e.hasChromiumWebRTC())throw new Error("Simulcast is only supported on Chromium-based browsers");this._configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers=!0}else this._configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers=!1;this._configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers&&(e.hasChromiumWebRTC()?this.logger.info(`Simulcast is enabled for ${e.name()}`):(this._configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers=!1,this.logger.info("Simulcast is only supported on Chromium-based browsers")))}isSimulcastUplinkPolicy(e){return!(!e||!e.addObserver)}}},589:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3731),r=n(8690),a=n(8015),o=n(6057);t.default=class{constructor(e,t){this.meetingId=null,this.externalMeetingId=null,this.credentials=null,this.urls=null,this.connectionTimeoutMs=15e3,this.attendeePresenceTimeoutMs=0,this.connectionHealthPolicyConfiguration=new i.default,this.reconnectTimeoutMs=12e4,this.reconnectFixedWaitMs=0,this.reconnectShortBackOffMs=1e3,this.reconnectLongBackOffMs=5e3,this.enableSimulcastForUnifiedPlanChromiumBasedBrowsers=!1,this.videoDownlinkBandwidthPolicy=null,this.videoUplinkBandwidthPolicy=null,this.keepLastFrameWhenPaused=!1,e&&((e=r.toLowerCasePropertyNames(e)).meeting&&(e=e.meeting),this.meetingId=e.meetingid,this.externalMeetingId=e.externalmeetingid,this.urls=new o.default,this.urls.audioHostURL=e.mediaplacement.audiohosturl,this.urls.signalingURL=e.mediaplacement.signalingurl,this.urls.turnControlURL=e.mediaplacement.turncontrolurl,e.mediaplacement.eventingestionurl&&(this.urls.eventIngestionURL=e.mediaplacement.eventingestionurl)),t&&((t=r.toLowerCasePropertyNames(t)).attendee&&(t=t.attendee),this.credentials=new a.default,this.credentials.attendeeId=t.attendeeid,this.credentials.externalUserId=t.externaluserid,this.credentials.joinToken=t.jointoken)}}},8015:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.attendeeId=null,this.externalUserId=null,this.joinToken=null}toJSON(){return{attendeeId:this.attendeeId,joinToken:null===this.joinToken?null:""}}}},7604:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingSessionLifecycleEvent=void 0,function(e){e[e.Connecting=0]="Connecting",e[e.Started=1]="Started",e[e.Stopped=2]="Stopped"}(n=t.MeetingSessionLifecycleEvent||(t.MeetingSessionLifecycleEvent={})),t.default=n},1296:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingSessionLifecycleEventCondition=void 0,function(e){e[e.ConnectingNew=0]="ConnectingNew",e[e.ReconnectingExisting=1]="ReconnectingExisting",e[e.StartedNew=2]="StartedNew",e[e.StartedExisting=3]="StartedExisting",e[e.StartedAfterReconnect=4]="StartedAfterReconnect",e[e.StoppedCleanly=5]="StoppedCleanly",e[e.StoppedWithFailure=6]="StoppedWithFailure"}(n=t.MeetingSessionLifecycleEventCondition||(t.MeetingSessionLifecycleEventCondition={})),t.default=n},3789:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289),r=n(5687);class a{constructor(e){this._statusCode=e}statusCode(){return this._statusCode}isFailure(){switch(this._statusCode){case r.default.AudioAuthenticationRejected:case r.default.AudioCallAtCapacity:case r.default.AudioInternalServerError:case r.default.AudioServiceUnavailable:case r.default.AudioDisconnected:case r.default.VideoCallAtSourceCapacity:case r.default.SignalingBadRequest:case r.default.SignalingInternalServerError:case r.default.SignalingRequestFailed:case r.default.ICEGatheringTimeoutWorkaround:case r.default.ConnectionHealthReconnect:case r.default.RealtimeApiFailed:case r.default.TaskFailed:case r.default.NoAttendeePresent:return!0;default:return!1}}isTerminal(){switch(this._statusCode){case r.default.Left:case r.default.AudioJoinedFromAnotherDevice:case r.default.AudioAuthenticationRejected:case r.default.AudioCallAtCapacity:case r.default.MeetingEnded:case r.default.AudioDisconnected:case r.default.TURNCredentialsForbidden:case r.default.SignalingBadRequest:case r.default.SignalingRequestFailed:case r.default.VideoCallAtSourceCapacity:case r.default.RealtimeApiFailed:case r.default.AudioAttendeeRemoved:return!0;default:return!1}}isAudioConnectionFailure(){switch(this._statusCode){case r.default.AudioAuthenticationRejected:case r.default.AudioInternalServerError:case r.default.AudioServiceUnavailable:case r.default.ICEGatheringTimeoutWorkaround:case r.default.SignalingBadRequest:case r.default.SignalingInternalServerError:case r.default.SignalingRequestFailed:case r.default.RealtimeApiFailed:case r.default.NoAttendeePresent:return!0;default:return!1}}toString(){switch(this._statusCode){case r.default.OK:return"Everything is OK so far.";case r.default.Left:return"The attendee left the meeting.";case r.default.AudioJoinedFromAnotherDevice:return"The attendee joined from another device.";case r.default.AudioAuthenticationRejected:return"The meeting rejected the attendee.";case r.default.AudioCallAtCapacity:return"The attendee couldn't join because the meeting was at capacity.";case r.default.MeetingEnded:return"The meeting ended.";case r.default.AudioInternalServerError:case r.default.AudioServiceUnavailable:case r.default.AudioDisconnected:return"The audio connection failed.";case r.default.VideoCallSwitchToViewOnly:return"The attendee couldn't start the local video because the maximum video capacity was reached.";case r.default.VideoCallAtSourceCapacity:return"The connection failed due to an internal server error.";case r.default.SignalingBadRequest:case r.default.SignalingInternalServerError:case r.default.SignalingRequestFailed:return"The signaling connection failed.";case r.default.ICEGatheringTimeoutWorkaround:return"Gathering ICE candidates timed out. In Chrome, this might indicate that the browser is in a bad state after reconnecting to VPN.";case r.default.ConnectionHealthReconnect:return"The meeting was reconnected.";case r.default.RealtimeApiFailed:return"The real-time API failed. This status code might indicate that the callback you passed to the real-time API threw an exception.";case r.default.TaskFailed:return"The connection failed. See the error message for more details.";case r.default.IncompatibleSDP:return"The connection failed due to incompatible SDP.";case r.default.TURNCredentialsForbidden:return"The meeting ended, or the attendee was removed.";case r.default.NoAttendeePresent:return"The attendee was not present.";case r.default.AudioAttendeeRemoved:return"The meeting ended because attendee removed.";case r.default.AudioVideoWasRemovedFromPrimaryMeeting:return"The Primary meeting credentials provided are no longer valid. chime::DeleteAttendee may have been called on them.";case r.default.AudioDisconnectAudio:return"The audio connection failed.";default:{const e=this._statusCode;throw new Error(`Unhandled case: ${e}`)}}}static fromSignalFrame(e){return e.error&&e.error.status?this.fromSignalingStatus(e.error.status):e.type===i.SdkSignalFrame.Type.AUDIO_STATUS?e.audioStatus?this.fromAudioStatus(e.audioStatus.audioStatus):new a(r.default.SignalingRequestFailed):e.type===i.SdkSignalFrame.Type.PRIMARY_MEETING_LEAVE?new a(r.default.AudioVideoWasRemovedFromPrimaryMeeting):new a(r.default.OK)}static fromAudioStatus(e){switch(e){case 200:return new a(r.default.OK);case 301:return new a(r.default.AudioJoinedFromAnotherDevice);case 302:return new a(r.default.AudioDisconnectAudio);case 403:return new a(r.default.AudioAuthenticationRejected);case 409:return new a(r.default.AudioCallAtCapacity);case 410:return new a(r.default.MeetingEnded);case 411:return new a(r.default.AudioAttendeeRemoved);case 500:return new a(r.default.AudioInternalServerError);case 503:return new a(r.default.AudioServiceUnavailable);default:return 2===Math.floor(e/100)?new a(r.default.OK):new a(r.default.AudioDisconnected)}}static fromSignalingStatus(e){switch(e){case 206:return new a(r.default.VideoCallSwitchToViewOnly);case 509:return new a(r.default.VideoCallAtSourceCapacity);case 403:return new a(r.default.AudioAuthenticationRejected);case 409:return new a(r.default.AudioCallAtCapacity);default:switch(Math.floor(e/100)){case 2:return new a(r.default.OK);case 4:return new a(r.default.SignalingBadRequest);case 5:return new a(r.default.SignalingInternalServerError);default:return new a(r.default.SignalingRequestFailed)}}}}t.default=a},5687:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.MeetingSessionStatusCode=void 0,function(e){e[e.OK=0]="OK",e[e.Left=1]="Left",e[e.AudioJoinedFromAnotherDevice=2]="AudioJoinedFromAnotherDevice",e[e.AudioAuthenticationRejected=3]="AudioAuthenticationRejected",e[e.AudioCallAtCapacity=4]="AudioCallAtCapacity",e[e.MeetingEnded=5]="MeetingEnded",e[e.AudioInternalServerError=6]="AudioInternalServerError",e[e.AudioServiceUnavailable=7]="AudioServiceUnavailable",e[e.AudioDisconnected=8]="AudioDisconnected",e[e.VideoCallSwitchToViewOnly=9]="VideoCallSwitchToViewOnly",e[e.VideoCallAtSourceCapacity=10]="VideoCallAtSourceCapacity",e[e.SignalingBadRequest=11]="SignalingBadRequest",e[e.SignalingInternalServerError=12]="SignalingInternalServerError",e[e.SignalingRequestFailed=13]="SignalingRequestFailed",e[e.ICEGatheringTimeoutWorkaround=14]="ICEGatheringTimeoutWorkaround",e[e.ConnectionHealthReconnect=15]="ConnectionHealthReconnect",e[e.RealtimeApiFailed=16]="RealtimeApiFailed",e[e.TaskFailed=17]="TaskFailed",e[e.IncompatibleSDP=18]="IncompatibleSDP",e[e.TURNCredentialsForbidden=19]="TURNCredentialsForbidden",e[e.NoAttendeePresent=20]="NoAttendeePresent",e[e.AudioAttendeeRemoved=21]="AudioAttendeeRemoved",e[e.AudioVideoWasRemovedFromPrimaryMeeting=22]="AudioVideoWasRemovedFromPrimaryMeeting",e[e.AudioDisconnectAudio=23]="AudioDisconnectAudio"}(n=t.MeetingSessionStatusCode||(t.MeetingSessionStatusCode={})),t.default=n},7215:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.username=null,this.password=null,this.ttl=null,this.uris=null}}},6057:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this._audioHostURL=null,this._signalingURL=null,this._turnControlURL=null,this._eventIngestionURL=null,this.urlRewriter=e=>e}get audioHostURL(){return this.urlRewriter(this._audioHostURL)}set audioHostURL(e){this._audioHostURL=e}get signalingURL(){return this.urlRewriter(this._signalingURL)}set signalingURL(e){this._signalingURL=e}get turnControlURL(){return this.urlRewriter(this._turnControlURL)}set turnControlURL(e){this._turnControlURL=e}get eventIngestionURL(){return this.urlRewriter(this._eventIngestionURL)}set eventIngestionURL(e){this._eventIngestionURL=e}}},5723:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(){this.remoteVideoAvailable=!1,this.canStartLocalVideo=!1}equal(e){return this.remoteVideoAvailable===e.remoteVideoAvailable&&this.canStartLocalVideo===e.canStartLocalVideo}clone(){const e=new n;return e.remoteVideoAvailable=this.remoteVideoAvailable,e.canStartLocalVideo=this.canStartLocalVideo,e}}t.default=n},9358:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n){this.type=e,this.headers=t,this.payload=n}}},8947:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(8434),a=n(7237),o=n(9358),s=n(9141),c=n(7797),l=n(334),u=n(7631),d=n(7387),h=n(106);t.default=class{constructor(e,t,n,i,o){this.configuration=e,this.logger=t,this.webSocket=n,this.reconnectController=i,this.sigV4=o,this.observerQueue=new Set,this.webSocket||(this.webSocket=new u.default(this.logger)),this.reconnectController||(this.reconnectController=new s.default(e.reconnectTimeoutMs,new r.default(e.reconnectFixedWaitMs,e.reconnectShortBackoffMs,e.reconnectLongBackoffMs))),this.sigV4||(this.sigV4=new l.default(this.configuration.chimeClient)),a.default.addLogger(this.logger),a.default.register()}addObserver(e){this.logger.info("adding messaging observer"),this.observerQueue.add(e)}removeObserver(e){this.logger.info("removing messaging observer"),this.observerQueue.delete(e)}start(){return i(this,void 0,void 0,(function*(){this.isClosed()?yield this.startConnecting(!1):this.logger.info("messaging session already started")}))}stop(){this.isClosed()?this.logger.info("no existing messaging session needs closing"):(this.isClosing=!0,this.webSocket.close(),a.default.removeLogger(this.logger))}forEachObserver(e){for(const t of this.observerQueue)c.default.nextTick((()=>{this.observerQueue.has(t)&&e(t)}))}setUpEventListeners(){this.webSocket.addEventListener("open",(()=>{this.openEventHandler()})),this.webSocket.addEventListener("message",(e=>{this.receiveMessageHandler(e.data)})),this.webSocket.addEventListener("close",(e=>{this.closeEventHandler(e)})),this.webSocket.addEventListener("error",(()=>{this.logger.error("WebSocket error")}))}startConnecting(e){return i(this,void 0,void 0,(function*(){const t=yield this.prepareWebSocketUrl();this.logger.info(`opening connection to ${t}`),e||this.reconnectController.reset(),this.reconnectController.hasStartedConnectionAttempt()?this.reconnectController.startedConnectionAttempt(!1):this.reconnectController.startedConnectionAttempt(!0),this.webSocket.create(t,[],!0),this.forEachObserver((t=>{t.messagingSessionDidStartConnecting&&t.messagingSessionDidStartConnecting(e)})),this.setUpEventListeners()}))}prepareWebSocketUrl(){return i(this,void 0,void 0,(function*(){const e=new Map;return e.set("userArn",[this.configuration.userArn]),e.set("sessionId",[this.configuration.messagingSessionId]),this.configuration.prefetchOn===h.default.Connect&&e.set("prefetch-on",[h.default.Connect]),yield this.sigV4.signURL("GET","wss","chime",this.configuration.endpointUrl,"/connect","",e)}))}isClosed(){return this.webSocket.readyState()===d.default.None||this.webSocket.readyState()===d.default.Closed}openEventHandler(){this.reconnectController.reset(),this.isSessionEstablished=!1}receiveMessageHandler(e){try{const t=JSON.parse(e),n=t.Headers["x-amz-chime-event-type"],i=new o.default(n,t.Headers,t.Payload||null);if(this.isSessionEstablished||"SESSION_ESTABLISHED"!==n){if(!this.isSessionEstablished)return}else this.forEachObserver((e=>{e.messagingSessionDidStart&&e.messagingSessionDidStart()})),this.isSessionEstablished=!0;this.forEachObserver((e=>{e.messagingSessionDidReceiveMessage&&e.messagingSessionDidReceiveMessage(i)}))}catch(e){this.logger.error(`Messaging parsing failed: ${e}`)}}closeEventHandler(e){this.logger.info(`WebSocket close: ${e.code} ${e.reason}`),this.webSocket.destroy(),!this.isClosing&&this.canReconnect(e.code)&&this.reconnectController.retryWithBackoff((()=>i(this,void 0,void 0,(function*(){this.startConnecting(!0)}))),null)||(this.isClosing=!1,this.isSessionEstablished&&this.forEachObserver((t=>{t.messagingSessionDidStop&&t.messagingSessionDidStop(e)})))}canReconnect(e){return 1001===e||1006===e||e>=1011&&e<=1014||e>4e3&&4002!==e&&4003!==e&&4401!==e}}},4323:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i){this.userArn=e,this.messagingSessionId=t,this.endpointUrl=n,this.chimeClient=i,this.reconnectTimeoutMs=1e4,this.reconnectFixedWaitMs=0,this.reconnectShortBackoffMs=1e3,this.reconnectLongBackoffMs=5e3,this.prefetchOn=void 0,this.messagingSessionId||(this.messagingSessionId=this.generateSessionId())}generateSessionId(){const e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0].toString()}}},106:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Connect="connect"}(n||(n={})),t.default=n},214:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8890);class r{constructor(e){this._id=e}id(){return this._id}base(){return this._id?this._id.split(r.MODALITY_SEPARATOR)[0]:""}modality(){if(!this._id)return"";const e=this._id.split(r.MODALITY_SEPARATOR);return 2===e.length?e[1]:""}hasModality(e){return""!==e&&this.modality()===e}withModality(e){const t=new r(this.base()+r.MODALITY_SEPARATOR+e);return""===e||""===this.base()||new r(t._id).modality()!==e?new r(this.base()):t}}t.default=r,r.MODALITY_SEPARATOR=i.default.Modality[0],r.MODALITY_CONTENT=i.default.Modality.substr(1)},7500:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7797),r=n(3922),a=n(9416),o=n(289),s=n(8660);t.default=class{constructor(e,t,n){this.signalingClient=e,this.intervalMs=t,this.logger=n,this.observerQueue=new Set,this.consecutivePongsUnaccountedFor=0,this.intervalScheduler=new r.default(this.intervalMs),this.pingId=0}addObserver(e){this.logger.info("adding a ping-pong observer"),this.observerQueue.add(e)}removeObserver(e){this.logger.info("removing a ping-pong observer"),this.observerQueue.delete(e)}forEachObserver(e){for(const t of this.observerQueue)i.default.nextTick((()=>{this.observerQueue.has(t)&&e(t)}))}start(){this.stop(),this.signalingClient.registerObserver(this),this.signalingClient.ready()&&this.startPingInterval()}stop(){this.stopPingInterval(),this.signalingClient.removeObserver(this)}startPingInterval(){this.intervalScheduler.start((()=>{this.ping()})),this.ping()}stopPingInterval(){this.intervalScheduler.stop(),this.pingId=0,this.consecutivePongsUnaccountedFor=0}ping(){this.consecutivePongsUnaccountedFor>0&&(this.logger.warn(`missed pong ${this.consecutivePongsUnaccountedFor} time(s)`),this.forEachObserver((e=>{s.Maybe.of(e.didMissPongs).map((t=>t.bind(e)(this.consecutivePongsUnaccountedFor)))}))),this.consecutivePongsUnaccountedFor+=1,this.pingId=this.pingId+1&4294967295;const e=o.SdkPingPongFrame.create();e.pingId=this.pingId,e.type=o.SdkPingPongType.PING,this.pingTimestampLocalMs=this.signalingClient.pingPong(e),this.logger.debug((()=>`sent ping ${this.pingId}`))}pong(e){const t=o.SdkPingPongFrame.create();t.pingId=e,t.type=o.SdkPingPongType.PONG,this.signalingClient.pingPong(t)}handleSignalingClientEvent(e){switch(e.type){case a.default.WebSocketOpen:this.startPingInterval();break;case a.default.WebSocketFailed:case a.default.WebSocketError:this.logger.warn(`stopped pinging (${a.default[e.type]})`),this.stopPingInterval();break;case a.default.WebSocketClosing:case a.default.WebSocketClosed:this.logger.info(`stopped pinging (${a.default[e.type]})`),this.stopPingInterval();break;case a.default.ReceivedSignalFrame:if(e.message.type!==o.SdkSignalFrame.Type.PING_PONG)break;if(e.message.pingPong.type===o.SdkPingPongType.PONG){const t=e.message.pingPong.pingId;if(t!==this.pingId){this.logger.warn(`unexpected ping id ${t} (expected ${this.pingId})`);break}let n;if(this.consecutivePongsUnaccountedFor=0,"number"!=typeof e.message.timestampMs)break;n=e.message.timestampMs,this.logger.debug((()=>`received pong ${t} with timestamp ${n}`));const i=e.timestampMs-this.pingTimestampLocalMs,r=Math.round(n-i/2),a=this.pingTimestampLocalMs-r;this.logger.info(`local clock skew estimate=${a}ms from ping-pong time=${i}ms`),this.forEachObserver((e=>{s.Maybe.of(e.didReceivePong).map((n=>n.bind(e)(t,a,i)))}))}else this.pong(e.message.pingPong.pingId)}}}},983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(5308),r=n(9825),a=n(9576);t.default=class{constructor(e,t){this.mediaStreamBroker=e,this.state=new r.default,this._transcriptionController=t||new i.default(this)}realtimeSetLocalAttendeeId(e,t){this.state.localAttendeeId=e,this.state.localExternalUserId=t}realtimeSetAttendeeIdPresence(e,t,n,i,r){try{t&&(this.state.attendeeIdToExternalUserId[e]=n);for(const a of this.state.attendeeIdChangesCallbacks)a(e,t,n,i,r)}catch(e){this.onError(e)}}realtimeSubscribeToAttendeeIdPresence(e){try{this.state.attendeeIdChangesCallbacks.push(e)}catch(e){this.onError(e)}}realtimeUnsubscribeToAttendeeIdPresence(e){try{const t=this.state.attendeeIdChangesCallbacks.indexOf(e);-1!==t&&this.state.attendeeIdChangesCallbacks.splice(t,1)}catch(e){this.onError(e)}}realtimeSetCanUnmuteLocalAudio(e){try{if(this.state.canUnmute===e)return;this.state.canUnmute=e;for(const t of this.state.setCanUnmuteLocalAudioCallbacks)t(e)}catch(e){this.onError(e)}}realtimeSubscribeToSetCanUnmuteLocalAudio(e){try{this.state.setCanUnmuteLocalAudioCallbacks.push(e)}catch(e){this.onError(e)}}realtimeUnsubscribeToSetCanUnmuteLocalAudio(e){try{const t=this.state.setCanUnmuteLocalAudioCallbacks.indexOf(e);-1!==t&&this.state.setCanUnmuteLocalAudioCallbacks.splice(t,1)}catch(e){this.onError(e)}}realtimeCanUnmuteLocalAudio(){return this.state.canUnmute}realtimeMuteLocalAudio(){if(!this.state.muted)try{this.setAudioInputEnabled(!1),this.state.muted=!0,this.realtimeUpdateVolumeIndicator(this.state.localAttendeeId,null,null,null,this.state.localExternalUserId);for(const e of this.state.muteAndUnmuteLocalAudioCallbacks)e(!0)}catch(e){this.onError(e)}}realtimeUnmuteLocalAudio(){if(!this.state.muted)return!0;if(!this.state.canUnmute)return!1;try{this.setAudioInputEnabled(!0),this.state.muted=!1,this.realtimeUpdateVolumeIndicator(this.state.localAttendeeId,null,null,null,this.state.localExternalUserId);for(const e of this.state.muteAndUnmuteLocalAudioCallbacks)e(!1);return!0}catch(e){return this.onError(e),!1}}realtimeSubscribeToMuteAndUnmuteLocalAudio(e){try{this.state.muteAndUnmuteLocalAudioCallbacks.push(e)}catch(e){this.onError(e)}}realtimeUnsubscribeToMuteAndUnmuteLocalAudio(e){try{const t=this.state.muteAndUnmuteLocalAudioCallbacks.indexOf(e);-1!==t&&this.state.muteAndUnmuteLocalAudioCallbacks.splice(t,1)}catch(e){this.onError(e)}}realtimeIsLocalAudioMuted(){return this.state.muted}realtimeSubscribeToVolumeIndicator(e,t){try{this.state.volumeIndicatorCallbacks.hasOwnProperty(e)||(this.state.volumeIndicatorCallbacks[e]=[]),this.state.volumeIndicatorCallbacks[e].push(t),this.sendVolumeIndicatorChange(e,!0,!0,!0,this.state.attendeeIdToExternalUserId[e])}catch(e){this.onError(e)}}realtimeUnsubscribeFromVolumeIndicator(e,t){if(this.state.volumeIndicatorCallbacks[e])if(t){const n=this.state.volumeIndicatorCallbacks[e].indexOf(t);n>=0&&this.state.volumeIndicatorCallbacks[e].splice(n,1)}else delete this.state.volumeIndicatorCallbacks[e]}realtimeUpdateVolumeIndicator(e,t,n,i,r){try{n=this.applyLocalMuteOverride(e,n);const a=this.getVolumeIndicatorState(e);let o=!1,s=!1,c=!1;null!==n&&a.muted!==n&&(a.muted=n,s=!0,a.muted&&0!==a.volume&&(a.volume=0,o=!0)),a.muted||null===t||(a.volume!==t&&(a.volume=t,o=!0),null===a.muted&&(a.muted=!1,s=!0)),null!==i&&a.signalStrength!==i&&(a.signalStrength=i,c=!0),this.sendVolumeIndicatorChange(e,o,s,c,r)}catch(e){this.onError(e)}}realtimeSubscribeToLocalSignalStrengthChange(e){try{if(this.state.localSignalStrengthChangeCallbacks.push(e),null===this.state.localAttendeeId)return;this.sendLocalSignalStrengthChange(this.state.localAttendeeId,!0)}catch(e){this.onError(e)}}realtimeUnsubscribeToLocalSignalStrengthChange(e){try{const t=this.state.localSignalStrengthChangeCallbacks.indexOf(e);-1!==t&&this.state.localSignalStrengthChangeCallbacks.splice(t,1)}catch(e){this.onError(e)}}realtimeSubscribeToSendDataMessage(e){try{this.state.sendDataMessageCallbacks.push(e)}catch(e){this.onError(e)}}realtimeUnsubscribeFromSendDataMessage(e){try{const t=this.state.sendDataMessageCallbacks.indexOf(e);-1!==t&&this.state.sendDataMessageCallbacks.splice(t,1)}catch(e){this.onError(e)}}realtimeSendDataMessage(e,t,n){try{for(const i of this.state.sendDataMessageCallbacks)i(e,t,n)}catch(e){this.onError(e)}}realtimeSubscribeToReceiveDataMessage(e,t){try{this.state.receiveDataMessageCallbacks.has(e)?this.state.receiveDataMessageCallbacks.get(e).push(t):this.state.receiveDataMessageCallbacks.set(e,[t])}catch(e){this.onError(e)}}realtimeUnsubscribeFromReceiveDataMessage(e){try{this.state.receiveDataMessageCallbacks.delete(e)}catch(e){this.onError(e)}}realtimeReceiveDataMessage(e){try{if(this.state.receiveDataMessageCallbacks.has(e.topic))for(const t of this.state.receiveDataMessageCallbacks.get(e.topic))t(e)}catch(e){this.onError(e)}}realtimeSubscribeToFatalError(e){try{this.state.fatalErrorCallbacks.push(e)}catch(e){this.onError(e)}}realtimeUnsubscribeToFatalError(e){try{const t=this.state.fatalErrorCallbacks.indexOf(e);-1!==t&&this.state.fatalErrorCallbacks.splice(t,1)}catch(e){this.onError(e)}}get transcriptionController(){return this._transcriptionController}setAudioInputEnabled(e){e?this.mediaStreamBroker.unmuteLocalAudioInputStream():this.mediaStreamBroker.muteLocalAudioInputStream()}applyLocalMuteOverride(e,t){const n=this.state.localAttendeeId,i=this.state.muted;return e!==n?t:"activeDevices"in this.mediaStreamBroker&&this.mediaStreamBroker.activeDevices.audio?i:t}sendVolumeIndicatorChange(e,t,n,i,r){if(this.sendLocalSignalStrengthChange(e,i),!this.state.volumeIndicatorCallbacks.hasOwnProperty(e))return;const o=this.getVolumeIndicatorState(e),s=new a.default;if(t&&(s.volume=o.volume),n&&(s.muted=o.muted),i&&(s.signalStrength=o.signalStrength),!this.stateIsEmpty(s))for(const t of this.state.volumeIndicatorCallbacks[e])t(e,s.volume,s.muted,s.signalStrength,r)}sendLocalSignalStrengthChange(e,t){if(!t)return;if(e!==this.state.localAttendeeId)return;const n=this.getVolumeIndicatorState(e).signalStrength;if(null!==n)for(const e of this.state.localSignalStrengthChangeCallbacks)e(n)}getVolumeIndicatorState(e){return this.state.volumeIndicatorState.hasOwnProperty(e)||(this.state.volumeIndicatorState[e]=new a.default),this.state.volumeIndicatorState[e]}stateIsEmpty(e){return null===e.volume&&null===e.muted&&null===e.signalStrength}onError(e){try{for(const t of this.state.fatalErrorCallbacks)t(e)}catch(t){try{console.error(e),console.error(t)}catch(e){}}}}},5910:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.attendeeIndex=null,this.attendeesInFrame=null}}},9825:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.localAttendeeId=null,this.localExternalUserId=null,this.attendeeIdChangesCallbacks=[],this.canUnmute=!0,this.setCanUnmuteLocalAudioCallbacks=[],this.muted=!1,this.muteAndUnmuteLocalAudioCallbacks=[],this.volumeIndicatorState={},this.attendeeIdToExternalUserId={},this.volumeIndicatorCallbacks={},this.localSignalStrengthChangeCallbacks=[],this.fatalErrorCallbacks=[],this.sendDataMessageCallbacks=[],this.receiveDataMessageCallbacks=new Map}}},9576:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.volume=null,this.muted=null,this.signalStrength=null}}},9141:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4929);class r{constructor(e,t){this.reconnectTimeoutMs=e,this.backoffPolicy=t,this.shouldReconnect=!0,this.onlyRestartPeerConnection=!1,this.firstConnectionAttempted=!1,this.firstConnectionAttemptTimestampMs=0,this.lastActiveTimestampMs=1/0,this._isFirstConnection=!0,this.backoffTimer=null,this.backoffCancel=null,this.reset()}timeSpentReconnectingMs(){return this.firstConnectionAttempted?Date.now()-this.firstConnectionAttemptTimestampMs:0}hasPastReconnectDeadline(){return Date.now()-this.lastActiveTimestampMs>=this.reconnectTimeoutMs||this.timeSpentReconnectingMs()>=this.reconnectTimeoutMs}reset(){this.cancel(),this.shouldReconnect=!0,this.onlyRestartPeerConnection=!1,this.firstConnectionAttempted=!1,this.firstConnectionAttemptTimestampMs=0,this.lastActiveTimestampMs=1/0,this.backoffPolicy.reset()}startedConnectionAttempt(e){this._isFirstConnection=e,this.firstConnectionAttempted||(this.firstConnectionAttempted=!0,this.firstConnectionAttemptTimestampMs=Date.now())}hasStartedConnectionAttempt(){return this.firstConnectionAttempted}isFirstConnection(){return this._isFirstConnection}disableReconnect(){this.shouldReconnect=!1}enableRestartPeerConnection(){this.onlyRestartPeerConnection=!0}cancel(){this.disableReconnect(),this.backoffTimer&&(this.backoffTimer.stop(),this.backoffCancel&&(this.backoffCancel(),this.backoffCancel=null))}retryWithBackoff(e,t){const n=this.shouldReconnect&&!this.hasPastReconnectDeadline();return n&&(this.backoffCancel=t,this.backoffTimer=new i.default(this.backoffPolicy.nextBackoffAmountMs()),this.backoffTimer.start((()=>{this.backoffCancel=null,e()}))),n}shouldOnlyRestartPeerConnection(){return this.onlyRestartPeerConnection}clone(){return new r(this.reconnectTimeoutMs,this.backoffPolicy)}setLastActiveTimestampMs(e){this.lastActiveTimestampMs=e}}t.default=r},7797:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4929);class r extends i.default{constructor(){super(0)}static nextTick(e){setTimeout(e,0)}}t.default=r},3922:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e){this.intervalMs=e}start(e){this.stop(),this.timer=setInterval(e,this.intervalMs)}stop(){void 0!==this.timer&&(clearInterval(this.timer),this.timer=void 0)}running(){return void 0!==this.timer}}},4929:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e){this.timeoutMs=e,this.timer=null}start(e){this.stop(),this.timer=setTimeout((()=>{clearTimeout(this.timer),e()}),this.timeoutMs)}stop(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}}},326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4076),r=n(1944),a=n(2330);class o{constructor(e){this.sdp=e}clone(){return new o(this.sdp)}static isRTPCandidate(e){const t=/candidate[:](\S+) (\d+)/g.exec(e);return null!==t&&"1"===t[2]}static linesToSDP(e){return new o(e.join(o.CRLF))}static candidateTypeFromString(e){switch(e){case i.default.Host:return i.default.Host;case i.default.ServerReflexive:return i.default.ServerReflexive;case i.default.PeerReflexive:return i.default.PeerReflexive;case i.default.Relay:return i.default.Relay}return null}static candidateType(e){const t=/a[=]candidate[:].* typ ([a-z]+) /g.exec(e);return null===t?null:o.candidateTypeFromString(t[1])}static mediaType(e){const t=/m=(audio|video)/g.exec(e);if(null!==t)return t[1]}static mid(e){if(e.includes("a=mid:"))return e.replace(/^(a=mid:)/,"")}static direction(e){const t=/a=(sendrecv|sendonly|recvonly|inactive)/g.exec(e);if(null!==t)return t[1]}static splitLines(e){return e.trim().split("\n").map((e=>e.trim()))}static splitSections(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+o.CRLF))}static findActiveCameraSection(e){let t=0,n=!1;for(const i of e){if(/^m=video/.test(i)&&(i.indexOf("sendrecv")>-1||-1===i.indexOf("sendonly")&&-1===i.indexOf("recvonly")&&-1===i.indexOf("inactive"))){n=!0;break}t++}return!1===n&&(t=-1),t}static extractSSRCsFromFIDGroupLine(e){return/^a=ssrc-group:FID\s(.+)/.exec(e)[1]}static matchPrefix(e,t){return o.splitLines(e).filter((e=>0===e.indexOf(t)))}lines(){return this.sdp.split(o.CRLF)}hasVideo(){return null!==/^m=video/gm.exec(this.sdp)}hasCandidates(){return null!==/a[=]candidate[:]/g.exec(this.sdp)}hasCandidatesForAllMLines(){return!(this.sdp.indexOf("c=IN IP4 0.0.0.0")>-1)}withoutCandidateType(e){return o.linesToSDP(this.lines().filter((t=>o.candidateType(t)!==e)))}withoutServerReflexiveCandidates(){return this.withoutCandidateType(i.default.ServerReflexive)}withAudioMaxAverageBitrate(e){if(!e)return this.clone();e=Math.trunc(Math.min(Math.max(e,o.rfc7587LowestBitrate),o.rfc7587HighestBitrate));const t=this.lines(),n=o.findOpusFmtpAttributes(t),i=o.updateOpusFmtpAttributes(t,n,[`maxaveragebitrate=${e}`]);return o.linesToSDP(i)}withStereoAudio(){const e=this.lines(),t=o.findOpusFmtpAttributes(e),n=o.updateOpusFmtpAttributes(e,t,["stereo=1","sprop-stereo=1"]);return o.linesToSDP(n)}static findOpusFmtpAttributes(e){const t=/^a=rtpmap:\s*(\d+)\s+opus\/48000/;let n=!1;const i=[];for(const r of e)if(r.startsWith("m=audio")&&(i.push(null),n=!0),r.startsWith("m=video")&&(n=!1),n){const e=t.exec(r);null!==e&&(i[i.length-1]=`a=fmtp:${e[1]} `)}return i}static updateOpusFmtpAttributes(e,t,n){const i=[];let r=0,a=null;for(const o of e)if(o.startsWith("m=audio")&&(a=t[r],r++),o.startsWith("m=video")&&(a=null),a&&o.startsWith(a)){const e=o.slice(a.length).split(";"),t=[];for(const i of e)n.findIndex((e=>e.startsWith(i.split("=")[0])))<0&&t.push(i);for(const e of n)t.push(e);i.push(a+t.join(";"))}else i.push(o);return i}withUnifiedPlanFormat(){let e=this.sdp;return e.includes("mozilla")?this.clone():(e=e.replace("o=-","o=mozilla-chrome"),new o(e))}getUniqueRtpHeaderExtensionId(e){const t=[];for(const n of e)if(/^a=extmap:/.test(n.trim())){const e=+n.split("a=extmap:")[1].split(" ")[0];t.includes(e)||t.push(e)}t.sort(((e,t)=>e-t));let n=0;for(const e of t){if(e-n>1)return n+1;n=e}return 14===n?-1:n+1}withVideoLayersAllocationRtpHeaderExtension(e){const t="http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00",n=e?e.getRtpHeaderExtensionId(t):-1,i=-1===n?this.getUniqueRtpHeaderExtensionId(o.splitLines(this.sdp)):n,r=o.splitSections(this.sdp),a=[];for(let e of r){if(/^m=video/.test(e)&&-1===o.getRtpHeaderExtensionIdInSection(e,t)){const n=o.splitLines(e),r=[];if(-1===i||this.hasRtpHeaderExtensionId(i)){a.push(e);continue}for(const e of n)if(r.push(e),/^a=sendrecv/.test(e.trim())){const e="a=extmap:"+i+" "+t;r.push(e)}e=r.join(o.CRLF)+o.CRLF}else if(-1!==n&&/^m=video/.test(e)&&o.getRtpHeaderExtensionIdInSection(e,t)!==n){const i=o.splitLines(e),r=[];for(const e of i)if(/^a=extmap:/.test(e.trim())&&e.split("a=extmap:")[1].split(" ")[1]===t){if(!this.hasRtpHeaderExtensionId(n)){const e="a=extmap:"+n+" "+t;r.push(e)}}else r.push(e);e=r.join(o.CRLF)+o.CRLF}a.push(e)}const s=a.join("");return new o(s)}ssrcForVideoSendingSection(){const e=this.sdp,t=o.splitSections(e);if(t.length<2)return"";const n=o.findActiveCameraSection(t);if(-1===n)return"";const i=o.matchPrefix(t[n],"a=ssrc-group:FID ");if(i.length<1)return"";const r=o.extractSSRCsFromFIDGroupLine(i[0]),[a]=r.split(" ").map((e=>parseInt(e,10)));return a.toString()}videoSendSectionHasDifferentSSRC(e){const t=this.ssrcForVideoSendingSection(),n=e.ssrcForVideoSendingSection();return""!==t&&""!==n&&parseInt(t,10)!==parseInt(n,10)}removeH264SupportFromSendSection(){const e=this.sdp,t=o.splitSections(e),n=o.findActiveCameraSection(t);if(-1===n)return new o(this.sdp);const i=t[n],r=o.splitLines(i),a=[],s=new Map;r.forEach((e=>{if(/^a=rtpmap:/.test(e)){const t=/^a=rtpmap:([0-9]+)\s/.exec(e);t&&e.toLowerCase().includes("h264")&&a.push(parseInt(t[1],10))}if(/^a=fmtp:/.test(e)){const t=/^a=fmtp:([0-9]+) apt=([0-9]+)/.exec(e);if(t&&3===t.length){const e=parseInt(t[1],10),n=parseInt(t[2],10);s.has(n)?s.get(n).push(e):s.set(n,[e])}}}));const c=new Set;for(const e of a){c.add(e);const t=s.get(e);if(t)for(const e of t)c.add(e)}if(a.length>0){const e=r[0].split(" ");r[0]=e.filter((e=>!c.has(parseInt(e)))).join(" ")}const l=r.filter((e=>{if(!e.includes("rtpmap")&&!e.includes("rtcp-fb")&&!e.includes("fmtp"))return!0;for(const t of c)if(e.includes(t.toString()))return!1;return!0}));t[n]=l.join(o.CRLF)+o.CRLF;const u=t.join("");return new o(u)}mediaSections(){const e=o.splitSections(this.sdp);if(e.length<2)return[];const t=[];for(let n=1;n{if(/^a=rtpmap:/.test(e))for(const r of t){if(!e.includes(`${r.codecName}/${r.codecCapability.clockRate}`))continue;const t=/^a=rtpmap:([0-9]+)\s/.exec(e);let a=!1;if(void 0!==r.codecCapability.sdpFmtpLine){for(const e of i)if(e.startsWith(`a=fmtp:${t[1]} ${r.codecCapability.sdpFmtpLine}`)){a=!0;break}}else a=!0;if(a){n.set(r.codecName,t[1]);break}}}));const r=new Set(n.values()),a=i[0].split(" ").filter((e=>!r.has(e))),s=Array.from(n.values()).sort(((e,i)=>t.findIndex((t=>n.get(t.codecName)===e))-t.findIndex((e=>n.get(e.codecName)===i))));return a.splice(3,0,...s.values()),i[0]=a.join(" "),i.join(o.CRLF)+o.CRLF}highestPriorityVideoSendCodec(){const e=this.sdp,t=o.splitSections(e),n=o.findActiveCameraSection(t);if(-1===n)return;const i=o.splitLines(t[n]),r=i[0].split(" ");if(r.length<4)return;const s=r[3];let c,l,u;for(const e of i){const t=/^a=rtpmap:([0-9]+)\s/.exec(e);if(null===t||t.length<2||t[1]!==s)continue;const n=e.split(" ")[1].split("/");if(!(void 0===n||n.length<2)){c=n[0],l=n[1];for(const e of i)if(e.startsWith(`a=fmtp:${s}`)){const t=e.split(" ");if(void 0===t||t.length<2)return;u=t[1]}break}}return void 0!==c?new a.default(c,{clockRate:parseInt(l),mimeType:`video/${c}`,sdpFmtpLine:u}):void 0}}t.default=o,o.CRLF="\r\n",o.rfc7587LowestBitrate=6e3,o.rfc7587HighestBitrate=51e4},4076:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SDPCandidateType=void 0,function(e){e.Host="host",e.ServerReflexive="srflx",e.PeerReflexive="prflx",e.Relay="relay"}(n=t.SDPCandidateType||(t.SDPCandidateType={})),t.default=n},1944:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},2330:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289);class r{constructor(e,t){this.codecName=e,this.codecCapability=t}equals(e){return void 0!==e&&this.codecName===e.codecName&&this.codecCapability.mimeType===e.codecCapability.mimeType&&this.codecCapability.clockRate===e.codecCapability.clockRate&&this.codecCapability.sdpFmtpLine===e.codecCapability.sdpFmtpLine}static vp8(){return new r("VP8",{clockRate:9e4,mimeType:"video/VP8"})}static h264ConstrainedBaselineProfile(){return new r("H264",{clockRate:9e4,mimeType:"video/H264",sdpFmtpLine:"level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f"})}static h264(){return this.h264ConstrainedBaselineProfile()}static fromSignaled(e){switch(e){case i.SdkVideoCodecCapability.VP8:return this.vp8();case i.SdkVideoCodecCapability.H264_CONSTRAINED_BASELINE_PROFILE:return this.h264ConstrainedBaselineProfile();default:return}}}t.default=r},3320:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9591);class r{constructor(e){this.logger=e}compress(e,t){if(t.length>0){const e=Math.min(t.length,r.MAX_DICTIONARY_SIZE);t=t.slice(0,e)}const n={memLevel:r.Z_MEM_LEVEL,dictionary:t};return i.deflateRaw(e,n)}decompress(e,t){if(t.length>0){const e=Math.min(t.length,r.MAX_DICTIONARY_SIZE);t=t.slice(0,e)}const n={to:"string",dictionary:t,chunkSize:4096};let a="";try{a=i.inflateRaw(e,n)}catch(e){this.logger.error(`failed to decompress the string with error: [${e}]`)}return a}}t.default=r,r.Z_MEM_LEVEL=9,r.MAX_DICTIONARY_SIZE=31744},9678:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3860),r=n(6850),a=n(9553),o=n(3013);t.default=class{constructor(e){this.logger=e,this.currentState=a.SessionStateControllerState.NotConnected,this.deferredAction=null,this.deferredWork=null}perform(e,t){const n=this.currentState;if(n===a.SessionStateControllerState.NotConnected&&e===i.SessionStateControllerAction.Connect)this.transition(a.SessionStateControllerState.Connecting,e);else if(n===a.SessionStateControllerState.Connecting&&e===i.SessionStateControllerAction.Fail)this.transition(a.SessionStateControllerState.Disconnecting,e);else if(n===a.SessionStateControllerState.Connecting&&e===i.SessionStateControllerAction.FinishConnecting)this.transition(a.SessionStateControllerState.Connected,e);else if(n===a.SessionStateControllerState.Connected&&e===i.SessionStateControllerAction.Disconnect)this.transition(a.SessionStateControllerState.Disconnecting,e);else if(n===a.SessionStateControllerState.Connected&&e===i.SessionStateControllerAction.Reconnect)this.transition(a.SessionStateControllerState.Connecting,e);else if(n===a.SessionStateControllerState.Connected&&e===i.SessionStateControllerAction.Fail)this.transition(a.SessionStateControllerState.Disconnecting,e);else if(n===a.SessionStateControllerState.Connected&&e===i.SessionStateControllerAction.Update)this.transition(a.SessionStateControllerState.Updating,e);else if(n===a.SessionStateControllerState.Updating&&e===i.SessionStateControllerAction.Fail)this.transition(a.SessionStateControllerState.Disconnecting,e);else if(n===a.SessionStateControllerState.Updating&&e===i.SessionStateControllerAction.FinishUpdating)this.transition(a.SessionStateControllerState.Connected,e);else{if(n!==a.SessionStateControllerState.Disconnecting||e!==i.SessionStateControllerAction.FinishDisconnecting)return this.canDefer(e)?(this.logger.info(`deferring transition from ${a.SessionStateControllerState[this.currentState]} with ${i.SessionStateControllerAction[e]}`),this.deferAction(e,t),o.SessionStateControllerTransitionResult.DeferredTransition):(this.logger.warn(`no transition found from ${a.SessionStateControllerState[this.currentState]} with ${i.SessionStateControllerAction[e]}`),o.SessionStateControllerTransitionResult.NoTransitionAvailable);this.transition(a.SessionStateControllerState.NotConnected,e)}try{t()}catch(t){return this.logger.error(`error during state ${a.SessionStateControllerState[this.currentState]} with action ${i.SessionStateControllerAction[e]}: ${t}`),this.logger.info(`rolling back transition to ${a.SessionStateControllerState[n]}`),this.currentState=n,o.SessionStateControllerTransitionResult.TransitionFailed}return this.performDeferredAction(),o.SessionStateControllerTransitionResult.Transitioned}state(){return this.currentState}transition(e,t){this.logger.info(`transitioning from ${a.SessionStateControllerState[this.currentState]} to ${a.SessionStateControllerState[e]} with ${i.SessionStateControllerAction[t]}`),this.currentState=e}deferPriority(e){switch(e){case i.SessionStateControllerAction.Disconnect:return r.SessionStateControllerDeferPriority.VeryHigh;case i.SessionStateControllerAction.Fail:return r.SessionStateControllerDeferPriority.High;case i.SessionStateControllerAction.Reconnect:return r.SessionStateControllerDeferPriority.Medium;case i.SessionStateControllerAction.Update:return r.SessionStateControllerDeferPriority.Low;default:return r.SessionStateControllerDeferPriority.DoNotDefer}}deferAction(e,t){null!==this.deferredAction&&this.deferPriority(this.deferredAction)>this.deferPriority(e)||(this.deferredAction=e,this.deferredWork=t)}canDefer(e){return this.deferPriority(e)!==r.SessionStateControllerDeferPriority.DoNotDefer&&(this.currentState===a.SessionStateControllerState.Connecting||this.currentState===a.SessionStateControllerState.Updating)}performDeferredAction(){if(!this.deferredAction)return;const e=this.deferredAction,t=this.deferredWork;this.deferredAction=null,this.deferredWork=null,this.logger.info(`performing deferred action ${i.SessionStateControllerAction[e]}`),this.perform(e,t)!==o.SessionStateControllerTransitionResult.Transitioned&&this.logger.info(`unable to perform deferred action ${i.SessionStateControllerAction[e]} in state ${a.SessionStateControllerState[this.currentState]}`)}}},3860:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SessionStateControllerAction=void 0,function(e){e[e.Connect=0]="Connect",e[e.FinishConnecting=1]="FinishConnecting",e[e.Update=2]="Update",e[e.FinishUpdating=3]="FinishUpdating",e[e.Reconnect=4]="Reconnect",e[e.Disconnect=5]="Disconnect",e[e.Fail=6]="Fail",e[e.FinishDisconnecting=7]="FinishDisconnecting"}(n=t.SessionStateControllerAction||(t.SessionStateControllerAction={})),t.default=n},6850:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SessionStateControllerDeferPriority=void 0,function(e){e[e.DoNotDefer=0]="DoNotDefer",e[e.Low=1]="Low",e[e.Medium=2]="Medium",e[e.High=3]="High",e[e.VeryHigh=4]="VeryHigh"}(n=t.SessionStateControllerDeferPriority||(t.SessionStateControllerDeferPriority={})),t.default=n},9553:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SessionStateControllerState=void 0,function(e){e[e.NotConnected=0]="NotConnected",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Updating=3]="Updating",e[e.Disconnecting=4]="Disconnecting"}(n=t.SessionStateControllerState||(t.SessionStateControllerState={})),t.default=n},3013:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SessionStateControllerTransitionResult=void 0,function(e){e[e.Transitioned=0]="Transitioned",e[e.NoTransitionAvailable=1]="NoTransitionAvailable",e[e.DeferredTransition=2]="DeferredTransition",e[e.TransitionFailed=3]="TransitionFailed"}(n=t.SessionStateControllerTransitionResult||(t.SessionStateControllerTransitionResult={})),t.default=n},1208:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(543),r=n(4929),a=n(289),o=n(4046),s=n(7387),c=n(7103),l=n(2902),u=n(9416);class d{constructor(e,t){this.webSocket=e,this.logger=t,this.unloadHandler=null,this.closeEventHandler=e=>{this.deactivatePageUnloadHandler(),this.resetConnection(),this.sendEvent(new l.default(this,u.default.WebSocketClosed,null,e.code,e.reason)),this.serviceConnectionRequestQueue()},this.observerQueue=new Set,this.connectionRequestQueue=[],this.resetConnection(),this.logger.debug((()=>"signaling client init")),this.audioSessionId=this.generateNewAudioSessionId()}registerObserver(e){this.logger.debug((()=>"registering signaling client observer")),this.observerQueue.add(e)}removeObserver(e){this.logger.debug((()=>"removing signaling client observer")),this.observerQueue.delete(e)}openConnection(e){this.logger.info("adding connection request to queue: "+e.url()),this.connectionRequestQueue.push(e),this.closeConnection()}pingPong(e){this.logger.debug((()=>"sending ping"));const t=a.SdkSignalFrame.create();return t.type=a.SdkSignalFrame.Type.PING_PONG,t.pingPong=e,this.sendMessage(t),t.timestampMs}join(e){this.logger.info("sending join");const t=a.SdkJoinFrame.create();t.protocolVersion=2,t.flags=a.SdkJoinFlags.HAS_STREAM_UPDATE;const n=new i.default,r={platformName:n.name(),platformVersion:n.version(),clientSource:o.default.sdkName,chimeSdkVersion:o.default.sdkVersion};if(e.applicationMetadata){const{appName:t,appVersion:n}=e.applicationMetadata;r.appName=t,r.appVersion=n}t.clientDetails=a.SdkClientDetails.create(r),t.audioSessionId=this.audioSessionId,t.wantsCompressedSdp=d.CLIENT_SUPPORTS_COMPRESSION,t.serverSideNetworkAdaption=c.convertServerSideNetworkAdaptionEnumToSignaled(e.serverSideNetworkAdaption),e.serverSideNetworkAdaption===c.default.BandwidthProbing&&(t.wantsServerSideNetworkProbingOnReceiveSideEstimator=!0),t.supportedServerSideNetworkAdaptions=e.supportedServerSideNetworkAdaptions.map(c.convertServerSideNetworkAdaptionEnumToSignaled);const s=a.SdkSignalFrame.create();s.type=a.SdkSignalFrame.Type.JOIN,s.join=t,this.sendMessage(s)}subscribe(e){const t=a.SdkSubscribeFrame.create();if(t.sendStreams=[],t.sdpOffer=e.sdpOffer,e.connectionTypeHasVideo&&(t.receiveStreamIds=e.receiveStreamIds),e.audioHost&&(t.audioCheckin=e.audioCheckin,t.audioHost=e.audioHost,t.audioMuted=e.audioMuted,!e.audioCheckin)){const n=a.SdkStreamDescriptor.create();n.mediaType=a.SdkStreamMediaType.AUDIO,n.trackLabel="AmazonChimeExpressAudio",n.attendeeId=e.attendeeId,n.streamId=1,n.groupId=1,n.framerate=15,n.maxBitrateKbps=600,n.avgBitrateBps=4e5,t.sendStreams.push(n)}if(t.compressedSdpOffer=e.compressedSdpOffer,t.duplex=a.SdkStreamServiceType.RX,e.localVideoEnabled){t.duplex=a.SdkStreamServiceType.DUPLEX;for(let n=0;n0&&(t.videoSubscriptionConfiguration=e.videoSubscriptionConfiguration.map(this.convertVideoSubscriptionConfiguration));const n=a.SdkSignalFrame.create();n.type=a.SdkSignalFrame.Type.SUBSCRIBE,n.sub=t,this.sendMessage(n)}remoteVideoUpdate(e,t){const n=a.SdkRemoteVideoUpdateFrame.create();n.addedOrUpdatedVideoSubscriptions=e.map(this.convertVideoSubscriptionConfiguration),n.removedVideoSubscriptionMids=t;const i=a.SdkSignalFrame.create();i.type=a.SdkSignalFrame.Type.REMOTE_VIDEO_UPDATE,i.remoteVideoUpdate=n,this.sendMessage(i)}convertVideoSubscriptionConfiguration(e){const t=new a.SdkVideoSubscriptionConfiguration;return t.mid=e.mid,t.attendeeId=e.attendeeId,t.streamId=e.streamId,t.groupId=e.groupId,t.priority=e.priority,t.targetBitrateKbps=e.targetBitrateKbps,t}leave(){const e=a.SdkSignalFrame.create();e.type=a.SdkSignalFrame.Type.LEAVE,e.leave=a.SdkLeaveFrame.create(),this.sendMessage(e),this.logger.debug((()=>"sent leave"))}sendClientMetrics(e){const t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.CLIENT_METRIC,t.clientMetric=e,this.sendMessage(t)}sendDataMessage(e){const t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.DATA_MESSAGE,t.dataMessage=e,this.sendMessage(t)}closeConnection(){var e,t;if(this.webSocket.readyState()!==s.default.None&&this.webSocket.readyState()!==s.default.Closed){this.isClosing=!0,this.sendEvent(new l.default(this,u.default.WebSocketClosing,null));const n=new r.default(d.CLOSE_EVENT_TIMEOUT_MS),i=e=>{var t,r;null===(r=(t=this.webSocket).removeEventListener)||void 0===r||r.call(t,"close",i),n.stop(),this.closeEventHandler(e)};null===(t=(e=this.webSocket).removeEventListener)||void 0===t||t.call(e,"close",this.closeEventHandler),this.webSocket.addEventListener("close",i),n.start((()=>{i(new CloseEvent("close",{wasClean:!1,code:1006,reason:"",bubbles:!1}))})),this.webSocket.close(),this.deactivatePageUnloadHandler()}else this.logger.info("no existing signaling client connection needs closing"),this.serviceConnectionRequestQueue()}ready(){return this.webSocket.readyState()===s.default.Open&&!this.isClosing&&this.wasOpened}mute(e){const t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.AUDIO_CONTROL;const n=a.SdkAudioControlFrame.create();n.muted=e,t.audioControl=n,this.sendMessage(t)}pause(e){const t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.PAUSE,t.pause=a.SdkPauseResumeFrame.create(),t.pause.streamIds=e,this.sendMessage(t)}resume(e){const t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.RESUME,t.pause=a.SdkPauseResumeFrame.create(),t.pause.streamIds=e,this.sendMessage(t)}resetConnection(){this.webSocket.destroy(),this.wasOpened=!1}sendMessage(e){e.timestampMs=Date.now(),this.logger.debug((()=>`sending: ${JSON.stringify(e)}`));const t=this.prependWithFrameTypeRTC(a.SdkSignalFrame.encode(e).finish());if(this.ready()){if(!this.webSocket.send(t))return void this.sendEvent(new l.default(this,u.default.WebSocketSendMessageFailure,null));this.sendEvent(new l.default(this,u.default.WebSocketSentMessage,null))}else this.sendEvent(new l.default(this,u.default.WebSocketSkippedMessage,null))}receiveMessage(e){let t;try{t=a.SdkSignalFrame.decode(e)}catch(t){return this.logger.info(`failed to decode: ${e}`),void this.sendEvent(new l.default(this,u.default.ProtocolDecodeFailure,null))}this.logger.debug((()=>`received: ${JSON.stringify(t)}`)),this.webSocket.readyState()===s.default.Open?this.sendEvent(new l.default(this,u.default.ReceivedSignalFrame,t)):this.logger.info(`skipping notification of message since WebSocket is not open: ${JSON.stringify(t)}`)}stripFrameTypeRTC(e){const t=e[0];return t!==d.FRAME_TYPE_RTC&&2!==t&&this.logger.warn(`expected FrameTypeRTC for message but got ${t}`),e.slice(1)}prependWithFrameTypeRTC(e){const t=new Uint8Array(e.length+1);return t[0]=d.FRAME_TYPE_RTC,t.set(e,1),t}serviceConnectionRequestQueue(){if(0===this.connectionRequestQueue.length)return void this.logger.info("no connection requests to service");const e=this.connectionRequestQueue.shift();this.logger.info(`opening connection to ${e.url()}`),this.isClosing=!1,this.webSocket.create(e.url(),e.protocols()),this.setUpEventListeners(),this.sendEvent(new l.default(this,u.default.WebSocketConnecting,null))}sendEvent(e){switch(e.type){case u.default.WebSocketMessage:case u.default.ReceivedSignalFrame:case u.default.WebSocketSentMessage:this.logger.debug((()=>`notifying event: ${u.default[e.type]}`));break;case u.default.WebSocketSkippedMessage:this.logger.debug((()=>`notifying event: ${u.default[e.type]}, websocket state=${s.default[this.webSocket.readyState()]}`));break;default:this.logger.info(`notifying event: ${u.default[e.type]}`)}for(const t of this.observerQueue)t.handleSignalingClientEvent(e)}setUpEventListeners(){this.webSocket.addEventListener("open",(()=>{this.activatePageUnloadHandler(),this.wasOpened=!0,this.sendEvent(new l.default(this,u.default.WebSocketOpen,null))})),this.webSocket.addEventListener("message",(e=>{this.sendEvent(new l.default(this,u.default.WebSocketMessage,null)),this.receiveMessage(this.stripFrameTypeRTC(new Uint8Array(e.data)))})),this.webSocket.addEventListener("close",this.closeEventHandler),this.webSocket.addEventListener("error",(()=>{!this.isClosing||this.wasOpened?this.wasOpened?(this.logger.error("received error while connected"),this.sendEvent(new l.default(this,u.default.WebSocketError,null))):(this.logger.error("failed to connect"),this.sendEvent(new l.default(this,u.default.WebSocketFailed,null))):this.logger.info("ignoring error closing signaling while connecting")}))}activatePageUnloadHandler(){this.unloadHandler=()=>{this.leave()};const e=n.g;e.window&&e.window.addEventListener&&window.addEventListener("unload",this.unloadHandler)}deactivatePageUnloadHandler(){const e=n.g;e.window&&e.window.removeEventListener&&window.removeEventListener("unload",this.unloadHandler),this.unloadHandler=null}generateNewAudioSessionId(){const e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}promoteToPrimaryMeeting(e){const t=a.SdkMeetingSessionCredentials.create();t.attendeeId=e.attendeeId,t.externalUserId=e.externalUserId,t.joinToken=e.joinToken;const n=a.SdkPrimaryMeetingJoinFrame.create();n.credentials=t;const i=a.SdkSignalFrame.create();i.type=a.SdkSignalFrame.Type.PRIMARY_MEETING_JOIN,i.primaryMeetingJoin=n,this.sendMessage(i)}demoteFromPrimaryMeeting(){const e=a.SdkPrimaryMeetingLeaveFrame.create(),t=a.SdkSignalFrame.create();t.type=a.SdkSignalFrame.Type.PRIMARY_MEETING_LEAVE,t.primaryMeetingLeave=e,this.sendMessage(t)}}t.default=d,d.FRAME_TYPE_RTC=5,d.CLOSE_EVENT_TIMEOUT_MS=2e3,d.CLIENT_SUPPORTS_COMPRESSION=!0},7103:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertServerSideNetworkAdaptionEnumToSignaled=t.convertServerSideNetworkAdaptionEnumFromSignaled=t.ServerSideNetworkAdaption=void 0;const i=n(289);var r;!function(e){e[e.Default=0]="Default",e[e.None=1]="None",e[e.BandwidthProbing=2]="BandwidthProbing"}(r=t.ServerSideNetworkAdaption||(t.ServerSideNetworkAdaption={})),t.default=r,t.convertServerSideNetworkAdaptionEnumFromSignaled=function(e){switch(e){case i.SdkServerSideNetworkAdaption.DEFAULT:return r.Default;case i.SdkServerSideNetworkAdaption.NONE:return r.None;case i.SdkServerSideNetworkAdaption.BANDWIDTH_PROBING:return r.BandwidthProbing}},t.convertServerSideNetworkAdaptionEnumToSignaled=function(e){switch(e){case r.Default:return i.SdkServerSideNetworkAdaption.DEFAULT;case r.None:return i.SdkServerSideNetworkAdaption.NONE;case r.BandwidthProbing:return i.SdkServerSideNetworkAdaption.BANDWIDTH_PROBING}}},3920:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){this.signalingURL=e,this.joinToken=t}url(){return this.signalingURL+"?X-Chime-Control-Protocol-Version=3&X-Amzn-Chime-Send-Close-On-Error=1"}protocols(){return["_aws_wt_session",this.joinToken]}}},2902:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(9416);t.default=class{constructor(e,t,n,i,r){this.client=e,this.type=t,this.message=n,this.closeCode=i,this.closeReason=r,this.timestampMs=Date.now()}isConnectionTerminated(){switch(this.type){case i.default.WebSocketFailed:case i.default.WebSocketError:case i.default.WebSocketClosing:case i.default.WebSocketClosed:return!0;default:return!1}}}},9416:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SignalingClientEventType=void 0,function(e){e[e.WebSocketConnecting=0]="WebSocketConnecting",e[e.WebSocketOpen=1]="WebSocketOpen",e[e.WebSocketError=2]="WebSocketError",e[e.WebSocketClosing=3]="WebSocketClosing",e[e.WebSocketClosed=4]="WebSocketClosed",e[e.WebSocketFailed=5]="WebSocketFailed",e[e.WebSocketMessage=6]="WebSocketMessage",e[e.WebSocketSendMessageFailure=7]="WebSocketSendMessageFailure",e[e.WebSocketSentMessage=8]="WebSocketSentMessage",e[e.ProtocolDecodeFailure=9]="ProtocolDecodeFailure",e[e.ReceivedSignalFrame=10]="ReceivedSignalFrame",e[e.WebSocketSkippedMessage=11]="WebSocketSkippedMessage"}(n=t.SignalingClientEventType||(t.SignalingClientEventType={})),t.default=n},2168:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7103);t.default=class{constructor(e){this.applicationMetadata=e,this.serverSideNetworkAdaption=i.default.Default,this.supportedServerSideNetworkAdaptions=[]}}},6729:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t,n,i,r,a,o,s,c,l){this.attendeeId=e,this.sdpOffer=t,this.audioHost=n,this.audioMuted=i,this.audioCheckin=r,this.receiveStreamIds=a,this.localVideoEnabled=o,this.videoStreamDescriptions=s,this.connectionTypeHasVideo=c,this.compressedSdpOffer=l,this.videoSubscriptionConfiguration=[]}}},9101:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},289:(e,t,n)=>{"use strict";var i,r,a=n(2100),o=a.Reader,s=a.Writer,c=a.util,l=a.roots.default||(a.roots.default={});l.SdkSignalFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.timestampMs=e.uint64();break;case 2:i.type=e.int32();break;case 3:i.error=l.SdkErrorFrame.decode(e,e.uint32());break;case 4:i.join=l.SdkJoinFrame.decode(e,e.uint32());break;case 5:i.joinack=l.SdkJoinAckFrame.decode(e,e.uint32());break;case 6:i.sub=l.SdkSubscribeFrame.decode(e,e.uint32());break;case 7:i.suback=l.SdkSubscribeAckFrame.decode(e,e.uint32());break;case 8:i.index=l.SdkIndexFrame.decode(e,e.uint32());break;case 10:i.pause=l.SdkPauseResumeFrame.decode(e,e.uint32());break;case 11:i.leave=l.SdkLeaveFrame.decode(e,e.uint32());break;case 12:i.leaveAck=l.SdkLeaveAckFrame.decode(e,e.uint32());break;case 14:i.bitrates=l.SdkBitrateFrame.decode(e,e.uint32());break;case 17:i.audioControl=l.SdkAudioControlFrame.decode(e,e.uint32());break;case 18:i.audioMetadata=l.SdkAudioMetadataFrame.decode(e,e.uint32());break;case 19:i.audioStreamIdInfo=l.SdkAudioStreamIdInfoFrame.decode(e,e.uint32());break;case 20:i.pingPong=l.SdkPingPongFrame.decode(e,e.uint32());break;case 21:i.audioStatus=l.SdkAudioStatusFrame.decode(e,e.uint32());break;case 22:i.clientMetric=l.SdkClientMetricFrame.decode(e,e.uint32());break;case 23:i.dataMessage=l.SdkDataMessageFrame.decode(e,e.uint32());break;case 25:i.remoteVideoUpdate=l.SdkRemoteVideoUpdateFrame.decode(e,e.uint32());break;case 26:i.primaryMeetingJoin=l.SdkPrimaryMeetingJoinFrame.decode(e,e.uint32());break;case 27:i.primaryMeetingJoinAck=l.SdkPrimaryMeetingJoinAckFrame.decode(e,e.uint32());break;case 28:i.primaryMeetingLeave=l.SdkPrimaryMeetingLeaveFrame.decode(e,e.uint32());break;default:e.skipType(7&r)}}if(!i.hasOwnProperty("timestampMs"))throw c.ProtocolError("missing required 'timestampMs'",{instance:i});if(!i.hasOwnProperty("type"))throw c.ProtocolError("missing required 'type'",{instance:i});return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(!(c.isInteger(e.timestampMs)||e.timestampMs&&c.isInteger(e.timestampMs.low)&&c.isInteger(e.timestampMs.high)))return"timestampMs: integer|Long expected";switch(e.type){default:return"type: enum value expected";case 1:case 2:case 3:case 4:case 5:case 7:case 8:case 9:case 10:case 13:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 24:case 25:case 26:case 27:}var t;return null!=e.error&&e.hasOwnProperty("error")&&(t=l.SdkErrorFrame.verify(e.error))?"error."+t:null!=e.join&&e.hasOwnProperty("join")&&(t=l.SdkJoinFrame.verify(e.join))?"join."+t:null!=e.joinack&&e.hasOwnProperty("joinack")&&(t=l.SdkJoinAckFrame.verify(e.joinack))?"joinack."+t:null!=e.sub&&e.hasOwnProperty("sub")&&(t=l.SdkSubscribeFrame.verify(e.sub))?"sub."+t:null!=e.suback&&e.hasOwnProperty("suback")&&(t=l.SdkSubscribeAckFrame.verify(e.suback))?"suback."+t:null!=e.index&&e.hasOwnProperty("index")&&(t=l.SdkIndexFrame.verify(e.index))?"index."+t:null!=e.pause&&e.hasOwnProperty("pause")&&(t=l.SdkPauseResumeFrame.verify(e.pause))?"pause."+t:null!=e.leave&&e.hasOwnProperty("leave")&&(t=l.SdkLeaveFrame.verify(e.leave))?"leave."+t:null!=e.leaveAck&&e.hasOwnProperty("leaveAck")&&(t=l.SdkLeaveAckFrame.verify(e.leaveAck))?"leaveAck."+t:null!=e.bitrates&&e.hasOwnProperty("bitrates")&&(t=l.SdkBitrateFrame.verify(e.bitrates))?"bitrates."+t:null!=e.audioControl&&e.hasOwnProperty("audioControl")&&(t=l.SdkAudioControlFrame.verify(e.audioControl))?"audioControl."+t:null!=e.audioMetadata&&e.hasOwnProperty("audioMetadata")&&(t=l.SdkAudioMetadataFrame.verify(e.audioMetadata))?"audioMetadata."+t:null!=e.audioStreamIdInfo&&e.hasOwnProperty("audioStreamIdInfo")&&(t=l.SdkAudioStreamIdInfoFrame.verify(e.audioStreamIdInfo))?"audioStreamIdInfo."+t:null!=e.pingPong&&e.hasOwnProperty("pingPong")&&(t=l.SdkPingPongFrame.verify(e.pingPong))?"pingPong."+t:null!=e.audioStatus&&e.hasOwnProperty("audioStatus")&&(t=l.SdkAudioStatusFrame.verify(e.audioStatus))?"audioStatus."+t:null!=e.clientMetric&&e.hasOwnProperty("clientMetric")&&(t=l.SdkClientMetricFrame.verify(e.clientMetric))?"clientMetric."+t:null!=e.dataMessage&&e.hasOwnProperty("dataMessage")&&(t=l.SdkDataMessageFrame.verify(e.dataMessage))?"dataMessage."+t:null!=e.remoteVideoUpdate&&e.hasOwnProperty("remoteVideoUpdate")&&(t=l.SdkRemoteVideoUpdateFrame.verify(e.remoteVideoUpdate))?"remoteVideoUpdate."+t:null!=e.primaryMeetingJoin&&e.hasOwnProperty("primaryMeetingJoin")&&(t=l.SdkPrimaryMeetingJoinFrame.verify(e.primaryMeetingJoin))?"primaryMeetingJoin."+t:null!=e.primaryMeetingJoinAck&&e.hasOwnProperty("primaryMeetingJoinAck")&&(t=l.SdkPrimaryMeetingJoinAckFrame.verify(e.primaryMeetingJoinAck))?"primaryMeetingJoinAck."+t:null!=e.primaryMeetingLeave&&e.hasOwnProperty("primaryMeetingLeave")&&(t=l.SdkPrimaryMeetingLeaveFrame.verify(e.primaryMeetingLeave))?"primaryMeetingLeave."+t:null},e.fromObject=function(e){if(e instanceof l.SdkSignalFrame)return e;var t=new l.SdkSignalFrame;switch(null!=e.timestampMs&&(c.Long?(t.timestampMs=c.Long.fromValue(e.timestampMs)).unsigned=!0:"string"==typeof e.timestampMs?t.timestampMs=parseInt(e.timestampMs,10):"number"==typeof e.timestampMs?t.timestampMs=e.timestampMs:"object"==typeof e.timestampMs&&(t.timestampMs=new c.LongBits(e.timestampMs.low>>>0,e.timestampMs.high>>>0).toNumber(!0))),e.type){case"JOIN":case 1:t.type=1;break;case"JOIN_ACK":case 2:t.type=2;break;case"SUBSCRIBE":case 3:t.type=3;break;case"SUBSCRIBE_ACK":case 4:t.type=4;break;case"INDEX":case 5:t.type=5;break;case"PAUSE":case 7:t.type=7;break;case"RESUME":case 8:t.type=8;break;case"LEAVE":case 9:t.type=9;break;case"LEAVE_ACK":case 10:t.type=10;break;case"BITRATES":case 13:t.type=13;break;case"AUDIO_CONTROL":case 16:t.type=16;break;case"AUDIO_METADATA":case 17:t.type=17;break;case"AUDIO_STREAM_ID_INFO":case 18:t.type=18;break;case"PING_PONG":case 19:t.type=19;break;case"AUDIO_STATUS":case 20:t.type=20;break;case"CLIENT_METRIC":case 21:t.type=21;break;case"DATA_MESSAGE":case 22:t.type=22;break;case"REMOTE_VIDEO_UPDATE":case 24:t.type=24;break;case"PRIMARY_MEETING_JOIN":case 25:t.type=25;break;case"PRIMARY_MEETING_JOIN_ACK":case 26:t.type=26;break;case"PRIMARY_MEETING_LEAVE":case 27:t.type=27}if(null!=e.error){if("object"!=typeof e.error)throw TypeError(".SdkSignalFrame.error: object expected");t.error=l.SdkErrorFrame.fromObject(e.error)}if(null!=e.join){if("object"!=typeof e.join)throw TypeError(".SdkSignalFrame.join: object expected");t.join=l.SdkJoinFrame.fromObject(e.join)}if(null!=e.joinack){if("object"!=typeof e.joinack)throw TypeError(".SdkSignalFrame.joinack: object expected");t.joinack=l.SdkJoinAckFrame.fromObject(e.joinack)}if(null!=e.sub){if("object"!=typeof e.sub)throw TypeError(".SdkSignalFrame.sub: object expected");t.sub=l.SdkSubscribeFrame.fromObject(e.sub)}if(null!=e.suback){if("object"!=typeof e.suback)throw TypeError(".SdkSignalFrame.suback: object expected");t.suback=l.SdkSubscribeAckFrame.fromObject(e.suback)}if(null!=e.index){if("object"!=typeof e.index)throw TypeError(".SdkSignalFrame.index: object expected");t.index=l.SdkIndexFrame.fromObject(e.index)}if(null!=e.pause){if("object"!=typeof e.pause)throw TypeError(".SdkSignalFrame.pause: object expected");t.pause=l.SdkPauseResumeFrame.fromObject(e.pause)}if(null!=e.leave){if("object"!=typeof e.leave)throw TypeError(".SdkSignalFrame.leave: object expected");t.leave=l.SdkLeaveFrame.fromObject(e.leave)}if(null!=e.leaveAck){if("object"!=typeof e.leaveAck)throw TypeError(".SdkSignalFrame.leaveAck: object expected");t.leaveAck=l.SdkLeaveAckFrame.fromObject(e.leaveAck)}if(null!=e.bitrates){if("object"!=typeof e.bitrates)throw TypeError(".SdkSignalFrame.bitrates: object expected");t.bitrates=l.SdkBitrateFrame.fromObject(e.bitrates)}if(null!=e.audioControl){if("object"!=typeof e.audioControl)throw TypeError(".SdkSignalFrame.audioControl: object expected");t.audioControl=l.SdkAudioControlFrame.fromObject(e.audioControl)}if(null!=e.audioMetadata){if("object"!=typeof e.audioMetadata)throw TypeError(".SdkSignalFrame.audioMetadata: object expected");t.audioMetadata=l.SdkAudioMetadataFrame.fromObject(e.audioMetadata)}if(null!=e.audioStreamIdInfo){if("object"!=typeof e.audioStreamIdInfo)throw TypeError(".SdkSignalFrame.audioStreamIdInfo: object expected");t.audioStreamIdInfo=l.SdkAudioStreamIdInfoFrame.fromObject(e.audioStreamIdInfo)}if(null!=e.pingPong){if("object"!=typeof e.pingPong)throw TypeError(".SdkSignalFrame.pingPong: object expected");t.pingPong=l.SdkPingPongFrame.fromObject(e.pingPong)}if(null!=e.audioStatus){if("object"!=typeof e.audioStatus)throw TypeError(".SdkSignalFrame.audioStatus: object expected");t.audioStatus=l.SdkAudioStatusFrame.fromObject(e.audioStatus)}if(null!=e.clientMetric){if("object"!=typeof e.clientMetric)throw TypeError(".SdkSignalFrame.clientMetric: object expected");t.clientMetric=l.SdkClientMetricFrame.fromObject(e.clientMetric)}if(null!=e.dataMessage){if("object"!=typeof e.dataMessage)throw TypeError(".SdkSignalFrame.dataMessage: object expected");t.dataMessage=l.SdkDataMessageFrame.fromObject(e.dataMessage)}if(null!=e.remoteVideoUpdate){if("object"!=typeof e.remoteVideoUpdate)throw TypeError(".SdkSignalFrame.remoteVideoUpdate: object expected");t.remoteVideoUpdate=l.SdkRemoteVideoUpdateFrame.fromObject(e.remoteVideoUpdate)}if(null!=e.primaryMeetingJoin){if("object"!=typeof e.primaryMeetingJoin)throw TypeError(".SdkSignalFrame.primaryMeetingJoin: object expected");t.primaryMeetingJoin=l.SdkPrimaryMeetingJoinFrame.fromObject(e.primaryMeetingJoin)}if(null!=e.primaryMeetingJoinAck){if("object"!=typeof e.primaryMeetingJoinAck)throw TypeError(".SdkSignalFrame.primaryMeetingJoinAck: object expected");t.primaryMeetingJoinAck=l.SdkPrimaryMeetingJoinAckFrame.fromObject(e.primaryMeetingJoinAck)}if(null!=e.primaryMeetingLeave){if("object"!=typeof e.primaryMeetingLeave)throw TypeError(".SdkSignalFrame.primaryMeetingLeave: object expected");t.primaryMeetingLeave=l.SdkPrimaryMeetingLeaveFrame.fromObject(e.primaryMeetingLeave)}return t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(c.Long){var i=new c.Long(0,0,!0);n.timestampMs=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.timestampMs=t.longs===String?"0":0;n.type=t.enums===String?"JOIN":1,n.error=null,n.join=null,n.joinack=null,n.sub=null,n.suback=null,n.index=null,n.pause=null,n.leave=null,n.leaveAck=null,n.bitrates=null,n.audioControl=null,n.audioMetadata=null,n.audioStreamIdInfo=null,n.pingPong=null,n.audioStatus=null,n.clientMetric=null,n.dataMessage=null,n.remoteVideoUpdate=null,n.primaryMeetingJoin=null,n.primaryMeetingJoinAck=null,n.primaryMeetingLeave=null}return null!=e.timestampMs&&e.hasOwnProperty("timestampMs")&&("number"==typeof e.timestampMs?n.timestampMs=t.longs===String?String(e.timestampMs):e.timestampMs:n.timestampMs=t.longs===String?c.Long.prototype.toString.call(e.timestampMs):t.longs===Number?new c.LongBits(e.timestampMs.low>>>0,e.timestampMs.high>>>0).toNumber(!0):e.timestampMs),null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?l.SdkSignalFrame.Type[e.type]:e.type),null!=e.error&&e.hasOwnProperty("error")&&(n.error=l.SdkErrorFrame.toObject(e.error,t)),null!=e.join&&e.hasOwnProperty("join")&&(n.join=l.SdkJoinFrame.toObject(e.join,t)),null!=e.joinack&&e.hasOwnProperty("joinack")&&(n.joinack=l.SdkJoinAckFrame.toObject(e.joinack,t)),null!=e.sub&&e.hasOwnProperty("sub")&&(n.sub=l.SdkSubscribeFrame.toObject(e.sub,t)),null!=e.suback&&e.hasOwnProperty("suback")&&(n.suback=l.SdkSubscribeAckFrame.toObject(e.suback,t)),null!=e.index&&e.hasOwnProperty("index")&&(n.index=l.SdkIndexFrame.toObject(e.index,t)),null!=e.pause&&e.hasOwnProperty("pause")&&(n.pause=l.SdkPauseResumeFrame.toObject(e.pause,t)),null!=e.leave&&e.hasOwnProperty("leave")&&(n.leave=l.SdkLeaveFrame.toObject(e.leave,t)),null!=e.leaveAck&&e.hasOwnProperty("leaveAck")&&(n.leaveAck=l.SdkLeaveAckFrame.toObject(e.leaveAck,t)),null!=e.bitrates&&e.hasOwnProperty("bitrates")&&(n.bitrates=l.SdkBitrateFrame.toObject(e.bitrates,t)),null!=e.audioControl&&e.hasOwnProperty("audioControl")&&(n.audioControl=l.SdkAudioControlFrame.toObject(e.audioControl,t)),null!=e.audioMetadata&&e.hasOwnProperty("audioMetadata")&&(n.audioMetadata=l.SdkAudioMetadataFrame.toObject(e.audioMetadata,t)),null!=e.audioStreamIdInfo&&e.hasOwnProperty("audioStreamIdInfo")&&(n.audioStreamIdInfo=l.SdkAudioStreamIdInfoFrame.toObject(e.audioStreamIdInfo,t)),null!=e.pingPong&&e.hasOwnProperty("pingPong")&&(n.pingPong=l.SdkPingPongFrame.toObject(e.pingPong,t)),null!=e.audioStatus&&e.hasOwnProperty("audioStatus")&&(n.audioStatus=l.SdkAudioStatusFrame.toObject(e.audioStatus,t)),null!=e.clientMetric&&e.hasOwnProperty("clientMetric")&&(n.clientMetric=l.SdkClientMetricFrame.toObject(e.clientMetric,t)),null!=e.dataMessage&&e.hasOwnProperty("dataMessage")&&(n.dataMessage=l.SdkDataMessageFrame.toObject(e.dataMessage,t)),null!=e.remoteVideoUpdate&&e.hasOwnProperty("remoteVideoUpdate")&&(n.remoteVideoUpdate=l.SdkRemoteVideoUpdateFrame.toObject(e.remoteVideoUpdate,t)),null!=e.primaryMeetingJoin&&e.hasOwnProperty("primaryMeetingJoin")&&(n.primaryMeetingJoin=l.SdkPrimaryMeetingJoinFrame.toObject(e.primaryMeetingJoin,t)),null!=e.primaryMeetingJoinAck&&e.hasOwnProperty("primaryMeetingJoinAck")&&(n.primaryMeetingJoinAck=l.SdkPrimaryMeetingJoinAckFrame.toObject(e.primaryMeetingJoinAck,t)),null!=e.primaryMeetingLeave&&e.hasOwnProperty("primaryMeetingLeave")&&(n.primaryMeetingLeave=l.SdkPrimaryMeetingLeaveFrame.toObject(e.primaryMeetingLeave,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e.Type=(t={},(n=Object.create(t))[t[1]="JOIN"]=1,n[t[2]="JOIN_ACK"]=2,n[t[3]="SUBSCRIBE"]=3,n[t[4]="SUBSCRIBE_ACK"]=4,n[t[5]="INDEX"]=5,n[t[7]="PAUSE"]=7,n[t[8]="RESUME"]=8,n[t[9]="LEAVE"]=9,n[t[10]="LEAVE_ACK"]=10,n[t[13]="BITRATES"]=13,n[t[16]="AUDIO_CONTROL"]=16,n[t[17]="AUDIO_METADATA"]=17,n[t[18]="AUDIO_STREAM_ID_INFO"]=18,n[t[19]="PING_PONG"]=19,n[t[20]="AUDIO_STATUS"]=20,n[t[21]="CLIENT_METRIC"]=21,n[t[22]="DATA_MESSAGE"]=22,n[t[24]="REMOTE_VIDEO_UPDATE"]=24,n[t[25]="PRIMARY_MEETING_JOIN"]=25,n[t[26]="PRIMARY_MEETING_JOIN_ACK"]=26,n[t[27]="PRIMARY_MEETING_LEAVE"]=27,n),e}(),l.SdkErrorFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.status=e.uint32();break;case 2:i.description=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!c.isInteger(e.status)?"status: integer expected":null!=e.description&&e.hasOwnProperty("description")&&!c.isString(e.description)?"description: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkErrorFrame)return e;var t=new l.SdkErrorFrame;return null!=e.status&&(t.status=e.status>>>0),null!=e.description&&(t.description=String(e.description)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.status=0,n.description=""),null!=e.status&&e.hasOwnProperty("status")&&(n.status=e.status),null!=e.description&&e.hasOwnProperty("description")&&(n.description=e.description),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkJoinFlags=(i={},(r=Object.create(i))[i[2]="HAS_STREAM_UPDATE"]=2,r[i[16]="COMPLETE_VIDEO_SOURCES_LIST"]=16,r[i[32]="EXCLUDE_SELF_CONTENT_IN_INDEX"]=32,r),l.SdkClientDetails=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.appName=e.string();break;case 2:i.appVersion=e.string();break;case 3:i.deviceModel=e.string();break;case 4:i.deviceMake=e.string();break;case 5:i.platformName=e.string();break;case 6:i.platformVersion=e.string();break;case 7:i.clientSource=e.string();break;case 8:i.chimeSdkVersion=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appName&&e.hasOwnProperty("appName")&&!c.isString(e.appName)?"appName: string expected":null!=e.appVersion&&e.hasOwnProperty("appVersion")&&!c.isString(e.appVersion)?"appVersion: string expected":null!=e.deviceModel&&e.hasOwnProperty("deviceModel")&&!c.isString(e.deviceModel)?"deviceModel: string expected":null!=e.deviceMake&&e.hasOwnProperty("deviceMake")&&!c.isString(e.deviceMake)?"deviceMake: string expected":null!=e.platformName&&e.hasOwnProperty("platformName")&&!c.isString(e.platformName)?"platformName: string expected":null!=e.platformVersion&&e.hasOwnProperty("platformVersion")&&!c.isString(e.platformVersion)?"platformVersion: string expected":null!=e.clientSource&&e.hasOwnProperty("clientSource")&&!c.isString(e.clientSource)?"clientSource: string expected":null!=e.chimeSdkVersion&&e.hasOwnProperty("chimeSdkVersion")&&!c.isString(e.chimeSdkVersion)?"chimeSdkVersion: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkClientDetails)return e;var t=new l.SdkClientDetails;return null!=e.appName&&(t.appName=String(e.appName)),null!=e.appVersion&&(t.appVersion=String(e.appVersion)),null!=e.deviceModel&&(t.deviceModel=String(e.deviceModel)),null!=e.deviceMake&&(t.deviceMake=String(e.deviceMake)),null!=e.platformName&&(t.platformName=String(e.platformName)),null!=e.platformVersion&&(t.platformVersion=String(e.platformVersion)),null!=e.clientSource&&(t.clientSource=String(e.clientSource)),null!=e.chimeSdkVersion&&(t.chimeSdkVersion=String(e.chimeSdkVersion)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.appName="",n.appVersion="",n.deviceModel="",n.deviceMake="",n.platformName="",n.platformVersion="",n.clientSource="",n.chimeSdkVersion=""),null!=e.appName&&e.hasOwnProperty("appName")&&(n.appName=e.appName),null!=e.appVersion&&e.hasOwnProperty("appVersion")&&(n.appVersion=e.appVersion),null!=e.deviceModel&&e.hasOwnProperty("deviceModel")&&(n.deviceModel=e.deviceModel),null!=e.deviceMake&&e.hasOwnProperty("deviceMake")&&(n.deviceMake=e.deviceMake),null!=e.platformName&&e.hasOwnProperty("platformName")&&(n.platformName=e.platformName),null!=e.platformVersion&&e.hasOwnProperty("platformVersion")&&(n.platformVersion=e.platformVersion),null!=e.clientSource&&e.hasOwnProperty("clientSource")&&(n.clientSource=e.clientSource),null!=e.chimeSdkVersion&&e.hasOwnProperty("chimeSdkVersion")&&(n.chimeSdkVersion=e.chimeSdkVersion),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkServerSideNetworkAdaption=function(){var e={},t=Object.create(e);return t[e[1]="DEFAULT"]=1,t[e[2]="NONE"]=2,t[e[3]="BANDWIDTH_PROBING"]=3,t}(),l.SdkJoinFrame=function(){function e(e){if(this.supportedServerSideNetworkAdaptions=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.protocolVersion=e.uint32();break;case 2:i.maxNumOfVideos=e.uint32();break;case 3:i.flags=e.uint32();break;case 4:i.clientDetails=l.SdkClientDetails.decode(e,e.uint32());break;case 6:i.audioSessionId=e.uint64();break;case 7:i.wantsCompressedSdp=e.bool();break;case 8:i.wantsServerSideNetworkProbingOnReceiveSideEstimator=e.bool();break;case 10:i.serverSideNetworkAdaption=e.int32();break;case 11:if(i.supportedServerSideNetworkAdaptions&&i.supportedServerSideNetworkAdaptions.length||(i.supportedServerSideNetworkAdaptions=[]),2==(7&r))for(var a=e.uint32()+e.pos;e.pos>>0),null!=e.maxNumOfVideos&&(t.maxNumOfVideos=e.maxNumOfVideos>>>0),null!=e.flags&&(t.flags=e.flags>>>0),null!=e.clientDetails){if("object"!=typeof e.clientDetails)throw TypeError(".SdkJoinFrame.clientDetails: object expected");t.clientDetails=l.SdkClientDetails.fromObject(e.clientDetails)}switch(null!=e.audioSessionId&&(c.Long?(t.audioSessionId=c.Long.fromValue(e.audioSessionId)).unsigned=!0:"string"==typeof e.audioSessionId?t.audioSessionId=parseInt(e.audioSessionId,10):"number"==typeof e.audioSessionId?t.audioSessionId=e.audioSessionId:"object"==typeof e.audioSessionId&&(t.audioSessionId=new c.LongBits(e.audioSessionId.low>>>0,e.audioSessionId.high>>>0).toNumber(!0))),null!=e.wantsCompressedSdp&&(t.wantsCompressedSdp=Boolean(e.wantsCompressedSdp)),null!=e.wantsServerSideNetworkProbingOnReceiveSideEstimator&&(t.wantsServerSideNetworkProbingOnReceiveSideEstimator=Boolean(e.wantsServerSideNetworkProbingOnReceiveSideEstimator)),e.serverSideNetworkAdaption){case"DEFAULT":case 1:t.serverSideNetworkAdaption=1;break;case"NONE":case 2:t.serverSideNetworkAdaption=2;break;case"BANDWIDTH_PROBING":case 3:t.serverSideNetworkAdaption=3}if(e.supportedServerSideNetworkAdaptions){if(!Array.isArray(e.supportedServerSideNetworkAdaptions))throw TypeError(".SdkJoinFrame.supportedServerSideNetworkAdaptions: array expected");t.supportedServerSideNetworkAdaptions=[];for(var n=0;n>>0,e.audioSessionId.high>>>0).toNumber(!0):e.audioSessionId),null!=e.wantsCompressedSdp&&e.hasOwnProperty("wantsCompressedSdp")&&(n.wantsCompressedSdp=e.wantsCompressedSdp),null!=e.wantsServerSideNetworkProbingOnReceiveSideEstimator&&e.hasOwnProperty("wantsServerSideNetworkProbingOnReceiveSideEstimator")&&(n.wantsServerSideNetworkProbingOnReceiveSideEstimator=e.wantsServerSideNetworkProbingOnReceiveSideEstimator),null!=e.serverSideNetworkAdaption&&e.hasOwnProperty("serverSideNetworkAdaption")&&(n.serverSideNetworkAdaption=t.enums===String?l.SdkServerSideNetworkAdaption[e.serverSideNetworkAdaption]:e.serverSideNetworkAdaption),e.supportedServerSideNetworkAdaptions&&e.supportedServerSideNetworkAdaptions.length){n.supportedServerSideNetworkAdaptions=[];for(var r=0;r>>3){case 1:i.turnCredentials=l.SdkTurnCredentials.decode(e,e.uint32());break;case 2:i.videoSubscriptionLimit=e.uint32();break;case 3:i.wantsCompressedSdp=e.bool();break;case 4:i.defaultServerSideNetworkAdaption=e.int32();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.turnCredentials&&e.hasOwnProperty("turnCredentials")){var t=l.SdkTurnCredentials.verify(e.turnCredentials);if(t)return"turnCredentials."+t}if(null!=e.videoSubscriptionLimit&&e.hasOwnProperty("videoSubscriptionLimit")&&!c.isInteger(e.videoSubscriptionLimit))return"videoSubscriptionLimit: integer expected";if(null!=e.wantsCompressedSdp&&e.hasOwnProperty("wantsCompressedSdp")&&"boolean"!=typeof e.wantsCompressedSdp)return"wantsCompressedSdp: boolean expected";if(null!=e.defaultServerSideNetworkAdaption&&e.hasOwnProperty("defaultServerSideNetworkAdaption"))switch(e.defaultServerSideNetworkAdaption){default:return"defaultServerSideNetworkAdaption: enum value expected";case 1:case 2:case 3:}return null},e.fromObject=function(e){if(e instanceof l.SdkJoinAckFrame)return e;var t=new l.SdkJoinAckFrame;if(null!=e.turnCredentials){if("object"!=typeof e.turnCredentials)throw TypeError(".SdkJoinAckFrame.turnCredentials: object expected");t.turnCredentials=l.SdkTurnCredentials.fromObject(e.turnCredentials)}switch(null!=e.videoSubscriptionLimit&&(t.videoSubscriptionLimit=e.videoSubscriptionLimit>>>0),null!=e.wantsCompressedSdp&&(t.wantsCompressedSdp=Boolean(e.wantsCompressedSdp)),e.defaultServerSideNetworkAdaption){case"DEFAULT":case 1:t.defaultServerSideNetworkAdaption=1;break;case"NONE":case 2:t.defaultServerSideNetworkAdaption=2;break;case"BANDWIDTH_PROBING":case 3:t.defaultServerSideNetworkAdaption=3}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.turnCredentials=null,n.videoSubscriptionLimit=0,n.wantsCompressedSdp=!1,n.defaultServerSideNetworkAdaption=t.enums===String?"DEFAULT":1),null!=e.turnCredentials&&e.hasOwnProperty("turnCredentials")&&(n.turnCredentials=l.SdkTurnCredentials.toObject(e.turnCredentials,t)),null!=e.videoSubscriptionLimit&&e.hasOwnProperty("videoSubscriptionLimit")&&(n.videoSubscriptionLimit=e.videoSubscriptionLimit),null!=e.wantsCompressedSdp&&e.hasOwnProperty("wantsCompressedSdp")&&(n.wantsCompressedSdp=e.wantsCompressedSdp),null!=e.defaultServerSideNetworkAdaption&&e.hasOwnProperty("defaultServerSideNetworkAdaption")&&(n.defaultServerSideNetworkAdaption=t.enums===String?l.SdkServerSideNetworkAdaption[e.defaultServerSideNetworkAdaption]:e.defaultServerSideNetworkAdaption),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkLeaveFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.duplex=e.int32();break;case 2:i.sendStreams&&i.sendStreams.length||(i.sendStreams=[]),i.sendStreams.push(l.SdkStreamDescriptor.decode(e,e.uint32()));break;case 3:if(i.receiveStreamIds&&i.receiveStreamIds.length||(i.receiveStreamIds=[]),2==(7&r))for(var a=e.uint32()+e.pos;e.pos>>0}if(null!=e.sdpOffer&&(t.sdpOffer=String(e.sdpOffer)),null!=e.audioHost&&(t.audioHost=String(e.audioHost)),null!=e.audioCheckin&&(t.audioCheckin=Boolean(e.audioCheckin)),null!=e.audioMuted&&(t.audioMuted=Boolean(e.audioMuted)),null!=e.compressedSdpOffer&&("string"==typeof e.compressedSdpOffer?c.base64.decode(e.compressedSdpOffer,t.compressedSdpOffer=c.newBuffer(c.base64.length(e.compressedSdpOffer)),0):e.compressedSdpOffer.length&&(t.compressedSdpOffer=e.compressedSdpOffer)),e.videoSubscriptionConfiguration){if(!Array.isArray(e.videoSubscriptionConfiguration))throw TypeError(".SdkSubscribeFrame.videoSubscriptionConfiguration: array expected");for(t.videoSubscriptionConfiguration=[],n=0;n>>3){case 1:i.duplex=e.int32();break;case 2:i.allocations&&i.allocations.length||(i.allocations=[]),i.allocations.push(l.SdkStreamAllocation.decode(e,e.uint32()));break;case 3:i.sdpAnswer=e.string();break;case 4:i.tracks&&i.tracks.length||(i.tracks=[]),i.tracks.push(l.SdkTrackMapping.decode(e,e.uint32()));break;case 5:i.compressedSdpAnswer=e.bytes();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.duplex&&e.hasOwnProperty("duplex"))switch(e.duplex){default:return"duplex: enum value expected";case 1:case 2:case 3:}if(null!=e.allocations&&e.hasOwnProperty("allocations")){if(!Array.isArray(e.allocations))return"allocations: array expected";for(var t=0;t>>3){case 1:i.atCapacity=e.bool();break;case 2:i.sources&&i.sources.length||(i.sources=[]),i.sources.push(l.SdkStreamDescriptor.decode(e,e.uint32()));break;case 3:if(i.pausedAtSourceIds&&i.pausedAtSourceIds.length||(i.pausedAtSourceIds=[]),2==(7&r))for(var a=e.uint32()+e.pos;e.pos>>0}if(null!=e.numParticipants&&(t.numParticipants=e.numParticipants>>>0),e.supportedReceiveCodecIntersection){if(!Array.isArray(e.supportedReceiveCodecIntersection))throw TypeError(".SdkIndexFrame.supportedReceiveCodecIntersection: array expected");for(t.supportedReceiveCodecIntersection=[],n=0;n>>3){case 1:if(i.streamIds&&i.streamIds.length||(i.streamIds=[]),2==(7&r))for(var a=e.uint32()+e.pos;e.pos>>0}if(e.groupIds){if(!Array.isArray(e.groupIds))throw TypeError(".SdkPauseResumeFrame.groupIds: array expected");for(t.groupIds=[],n=0;n>>0}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.streamIds=[],n.groupIds=[]),e.streamIds&&e.streamIds.length){n.streamIds=[];for(var i=0;i>>3==1?(i.bitrates&&i.bitrates.length||(i.bitrates=[]),i.bitrates.push(l.SdkBitrate.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.bitrates&&e.hasOwnProperty("bitrates")){if(!Array.isArray(e.bitrates))return"bitrates: array expected";for(var t=0;t>>3){case 1:i.streamId=e.uint32();break;case 2:i.framerate=e.uint32();break;case 3:i.maxBitrateKbps=e.uint32();break;case 4:i.trackLabel=e.string();break;case 6:i.groupId=e.uint32();break;case 7:i.avgBitrateBps=e.uint32();break;case 8:i.attendeeId=e.string();break;case 9:i.mediaType=e.int32();break;case 10:i.externalUserId=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.streamId&&e.hasOwnProperty("streamId")&&!c.isInteger(e.streamId))return"streamId: integer expected";if(null!=e.framerate&&e.hasOwnProperty("framerate")&&!c.isInteger(e.framerate))return"framerate: integer expected";if(null!=e.maxBitrateKbps&&e.hasOwnProperty("maxBitrateKbps")&&!c.isInteger(e.maxBitrateKbps))return"maxBitrateKbps: integer expected";if(null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&!c.isString(e.trackLabel))return"trackLabel: string expected";if(null!=e.groupId&&e.hasOwnProperty("groupId")&&!c.isInteger(e.groupId))return"groupId: integer expected";if(null!=e.avgBitrateBps&&e.hasOwnProperty("avgBitrateBps")&&!c.isInteger(e.avgBitrateBps))return"avgBitrateBps: integer expected";if(null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&!c.isString(e.attendeeId))return"attendeeId: string expected";if(null!=e.mediaType&&e.hasOwnProperty("mediaType"))switch(e.mediaType){default:return"mediaType: enum value expected";case 1:case 2:}return null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&!c.isString(e.externalUserId)?"externalUserId: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkStreamDescriptor)return e;var t=new l.SdkStreamDescriptor;switch(null!=e.streamId&&(t.streamId=e.streamId>>>0),null!=e.framerate&&(t.framerate=e.framerate>>>0),null!=e.maxBitrateKbps&&(t.maxBitrateKbps=e.maxBitrateKbps>>>0),null!=e.trackLabel&&(t.trackLabel=String(e.trackLabel)),null!=e.groupId&&(t.groupId=e.groupId>>>0),null!=e.avgBitrateBps&&(t.avgBitrateBps=e.avgBitrateBps>>>0),null!=e.attendeeId&&(t.attendeeId=String(e.attendeeId)),e.mediaType){case"AUDIO":case 1:t.mediaType=1;break;case"VIDEO":case 2:t.mediaType=2}return null!=e.externalUserId&&(t.externalUserId=String(e.externalUserId)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.streamId=0,n.framerate=0,n.maxBitrateKbps=0,n.trackLabel="",n.groupId=0,n.avgBitrateBps=0,n.attendeeId="",n.mediaType=t.enums===String?"AUDIO":1,n.externalUserId=""),null!=e.streamId&&e.hasOwnProperty("streamId")&&(n.streamId=e.streamId),null!=e.framerate&&e.hasOwnProperty("framerate")&&(n.framerate=e.framerate),null!=e.maxBitrateKbps&&e.hasOwnProperty("maxBitrateKbps")&&(n.maxBitrateKbps=e.maxBitrateKbps),null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&(n.trackLabel=e.trackLabel),null!=e.groupId&&e.hasOwnProperty("groupId")&&(n.groupId=e.groupId),null!=e.avgBitrateBps&&e.hasOwnProperty("avgBitrateBps")&&(n.avgBitrateBps=e.avgBitrateBps),null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&(n.attendeeId=e.attendeeId),null!=e.mediaType&&e.hasOwnProperty("mediaType")&&(n.mediaType=t.enums===String?l.SdkStreamMediaType[e.mediaType]:e.mediaType),null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&(n.externalUserId=e.externalUserId),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkStreamAllocation=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.trackLabel=e.string();break;case 2:i.streamId=e.uint32();break;case 3:i.groupId=e.uint32();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&!c.isString(e.trackLabel)?"trackLabel: string expected":null!=e.streamId&&e.hasOwnProperty("streamId")&&!c.isInteger(e.streamId)?"streamId: integer expected":null!=e.groupId&&e.hasOwnProperty("groupId")&&!c.isInteger(e.groupId)?"groupId: integer expected":null},e.fromObject=function(e){if(e instanceof l.SdkStreamAllocation)return e;var t=new l.SdkStreamAllocation;return null!=e.trackLabel&&(t.trackLabel=String(e.trackLabel)),null!=e.streamId&&(t.streamId=e.streamId>>>0),null!=e.groupId&&(t.groupId=e.groupId>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.trackLabel="",n.streamId=0,n.groupId=0),null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&(n.trackLabel=e.trackLabel),null!=e.streamId&&e.hasOwnProperty("streamId")&&(n.streamId=e.streamId),null!=e.groupId&&e.hasOwnProperty("groupId")&&(n.groupId=e.groupId),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkTrackMapping=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.streamId=e.uint32();break;case 2:i.ssrc=e.uint32();break;case 3:i.trackLabel=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.streamId&&e.hasOwnProperty("streamId")&&!c.isInteger(e.streamId)?"streamId: integer expected":null!=e.ssrc&&e.hasOwnProperty("ssrc")&&!c.isInteger(e.ssrc)?"ssrc: integer expected":null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&!c.isString(e.trackLabel)?"trackLabel: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkTrackMapping)return e;var t=new l.SdkTrackMapping;return null!=e.streamId&&(t.streamId=e.streamId>>>0),null!=e.ssrc&&(t.ssrc=e.ssrc>>>0),null!=e.trackLabel&&(t.trackLabel=String(e.trackLabel)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.streamId=0,n.ssrc=0,n.trackLabel=""),null!=e.streamId&&e.hasOwnProperty("streamId")&&(n.streamId=e.streamId),null!=e.ssrc&&e.hasOwnProperty("ssrc")&&(n.ssrc=e.ssrc),null!=e.trackLabel&&e.hasOwnProperty("trackLabel")&&(n.trackLabel=e.trackLabel),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkBitrate=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.sourceStreamId=e.uint32();break;case 2:i.avgBitrateBps=e.uint32();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.sourceStreamId&&e.hasOwnProperty("sourceStreamId")&&!c.isInteger(e.sourceStreamId)?"sourceStreamId: integer expected":null!=e.avgBitrateBps&&e.hasOwnProperty("avgBitrateBps")&&!c.isInteger(e.avgBitrateBps)?"avgBitrateBps: integer expected":null},e.fromObject=function(e){if(e instanceof l.SdkBitrate)return e;var t=new l.SdkBitrate;return null!=e.sourceStreamId&&(t.sourceStreamId=e.sourceStreamId>>>0),null!=e.avgBitrateBps&&(t.avgBitrateBps=e.avgBitrateBps>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.sourceStreamId=0,n.avgBitrateBps=0),null!=e.sourceStreamId&&e.hasOwnProperty("sourceStreamId")&&(n.sourceStreamId=e.sourceStreamId),null!=e.avgBitrateBps&&e.hasOwnProperty("avgBitrateBps")&&(n.avgBitrateBps=e.avgBitrateBps),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkAudioControlFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3==1?i.muted=e.bool():e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.muted&&e.hasOwnProperty("muted")&&"boolean"!=typeof e.muted?"muted: boolean expected":null},e.fromObject=function(e){if(e instanceof l.SdkAudioControlFrame)return e;var t=new l.SdkAudioControlFrame;return null!=e.muted&&(t.muted=Boolean(e.muted)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.muted=!1),null!=e.muted&&e.hasOwnProperty("muted")&&(n.muted=e.muted),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkAudioMetadataFrame=function(){function e(e){if(this.attendeeStates=[],e)for(var t=Object.keys(e),n=0;n>>3==1?(i.attendeeStates&&i.attendeeStates.length||(i.attendeeStates=[]),i.attendeeStates.push(l.SdkAudioAttendeeState.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.attendeeStates&&e.hasOwnProperty("attendeeStates")){if(!Array.isArray(e.attendeeStates))return"attendeeStates: array expected";for(var t=0;t>>3){case 1:i.audioStreamId=e.uint32();break;case 2:i.volume=e.uint32();break;case 3:i.muted=e.bool();break;case 4:i.signalStrength=e.uint32();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.audioStreamId&&e.hasOwnProperty("audioStreamId")&&!c.isInteger(e.audioStreamId)?"audioStreamId: integer expected":null!=e.volume&&e.hasOwnProperty("volume")&&!c.isInteger(e.volume)?"volume: integer expected":null!=e.muted&&e.hasOwnProperty("muted")&&"boolean"!=typeof e.muted?"muted: boolean expected":null!=e.signalStrength&&e.hasOwnProperty("signalStrength")&&!c.isInteger(e.signalStrength)?"signalStrength: integer expected":null},e.fromObject=function(e){if(e instanceof l.SdkAudioAttendeeState)return e;var t=new l.SdkAudioAttendeeState;return null!=e.audioStreamId&&(t.audioStreamId=e.audioStreamId>>>0),null!=e.volume&&(t.volume=e.volume>>>0),null!=e.muted&&(t.muted=Boolean(e.muted)),null!=e.signalStrength&&(t.signalStrength=e.signalStrength>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.audioStreamId=0,n.volume=0,n.muted=!1,n.signalStrength=0),null!=e.audioStreamId&&e.hasOwnProperty("audioStreamId")&&(n.audioStreamId=e.audioStreamId),null!=e.volume&&e.hasOwnProperty("volume")&&(n.volume=e.volume),null!=e.muted&&e.hasOwnProperty("muted")&&(n.muted=e.muted),null!=e.signalStrength&&e.hasOwnProperty("signalStrength")&&(n.signalStrength=e.signalStrength),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkAudioStreamIdInfoFrame=function(){function e(e){if(this.streams=[],e)for(var t=Object.keys(e),n=0;n>>3==1?(i.streams&&i.streams.length||(i.streams=[]),i.streams.push(l.SdkAudioStreamIdInfo.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.streams&&e.hasOwnProperty("streams")){if(!Array.isArray(e.streams))return"streams: array expected";for(var t=0;t>>3){case 1:i.audioStreamId=e.uint32();break;case 2:i.attendeeId=e.string();break;case 3:i.muted=e.bool();break;case 4:i.externalUserId=e.string();break;case 5:i.dropped=e.bool();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.audioStreamId&&e.hasOwnProperty("audioStreamId")&&!c.isInteger(e.audioStreamId)?"audioStreamId: integer expected":null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&!c.isString(e.attendeeId)?"attendeeId: string expected":null!=e.muted&&e.hasOwnProperty("muted")&&"boolean"!=typeof e.muted?"muted: boolean expected":null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&!c.isString(e.externalUserId)?"externalUserId: string expected":null!=e.dropped&&e.hasOwnProperty("dropped")&&"boolean"!=typeof e.dropped?"dropped: boolean expected":null},e.fromObject=function(e){if(e instanceof l.SdkAudioStreamIdInfo)return e;var t=new l.SdkAudioStreamIdInfo;return null!=e.audioStreamId&&(t.audioStreamId=e.audioStreamId>>>0),null!=e.attendeeId&&(t.attendeeId=String(e.attendeeId)),null!=e.muted&&(t.muted=Boolean(e.muted)),null!=e.externalUserId&&(t.externalUserId=String(e.externalUserId)),null!=e.dropped&&(t.dropped=Boolean(e.dropped)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.audioStreamId=0,n.attendeeId="",n.muted=!1,n.externalUserId="",n.dropped=!1),null!=e.audioStreamId&&e.hasOwnProperty("audioStreamId")&&(n.audioStreamId=e.audioStreamId),null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&(n.attendeeId=e.attendeeId),null!=e.muted&&e.hasOwnProperty("muted")&&(n.muted=e.muted),null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&(n.externalUserId=e.externalUserId),null!=e.dropped&&e.hasOwnProperty("dropped")&&(n.dropped=e.dropped),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkPingPongType=function(){var e={},t=Object.create(e);return t[e[1]="PING"]=1,t[e[2]="PONG"]=2,t}(),l.SdkPingPongFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.type=e.int32();break;case 2:i.pingId=e.uint32();break;default:e.skipType(7&r)}}if(!i.hasOwnProperty("type"))throw c.ProtocolError("missing required 'type'",{instance:i});if(!i.hasOwnProperty("pingId"))throw c.ProtocolError("missing required 'pingId'",{instance:i});return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";switch(e.type){default:return"type: enum value expected";case 1:case 2:}return c.isInteger(e.pingId)?null:"pingId: integer expected"},e.fromObject=function(e){if(e instanceof l.SdkPingPongFrame)return e;var t=new l.SdkPingPongFrame;switch(e.type){case"PING":case 1:t.type=1;break;case"PONG":case 2:t.type=2}return null!=e.pingId&&(t.pingId=e.pingId>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.type=t.enums===String?"PING":1,n.pingId=0),null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?l.SdkPingPongType[e.type]:e.type),null!=e.pingId&&e.hasOwnProperty("pingId")&&(n.pingId=e.pingId),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkAudioStatusFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3==1?i.audioStatus=e.uint32():e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.audioStatus&&e.hasOwnProperty("audioStatus")&&!c.isInteger(e.audioStatus)?"audioStatus: integer expected":null},e.fromObject=function(e){if(e instanceof l.SdkAudioStatusFrame)return e;var t=new l.SdkAudioStatusFrame;return null!=e.audioStatus&&(t.audioStatus=e.audioStatus>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.audioStatus=0),null!=e.audioStatus&&e.hasOwnProperty("audioStatus")&&(n.audioStatus=e.audioStatus),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkMetric=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.type=e.int32();break;case 2:i.value=e.double();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.type&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 64:case 66:case 69:case 72:case 86:case 87:}return null!=e.value&&e.hasOwnProperty("value")&&"number"!=typeof e.value?"value: number expected":null},e.fromObject=function(e){if(e instanceof l.SdkMetric)return e;var t=new l.SdkMetric;switch(e.type){case"VIDEO_ACTUAL_ENCODER_BITRATE":case 1:t.type=1;break;case"VIDEO_AVAILABLE_SEND_BANDWIDTH":case 2:t.type=2;break;case"VIDEO_RETRANSMIT_BITRATE":case 3:t.type=3;break;case"VIDEO_AVAILABLE_RECEIVE_BANDWIDTH":case 4:t.type=4;break;case"VIDEO_TARGET_ENCODER_BITRATE":case 5:t.type=5;break;case"VIDEO_BUCKET_DELAY_MS":case 6:t.type=6;break;case"STUN_RTT_MS":case 7:t.type=7;break;case"SOCKET_DISCARDED_PPS":case 8:t.type=8;break;case"RTC_MIC_JITTER_MS":case 9:t.type=9;break;case"RTC_MIC_PPS":case 10:t.type=10;break;case"RTC_MIC_FRACTION_PACKET_LOST_PERCENT":case 11:t.type=11;break;case"RTC_MIC_BITRATE":case 12:t.type=12;break;case"RTC_MIC_RTT_MS":case 13:t.type=13;break;case"RTC_SPK_PPS":case 14:t.type=14;break;case"RTC_SPK_FRACTION_PACKET_LOST_PERCENT":case 15:t.type=15;break;case"RTC_SPK_JITTER_MS":case 16:t.type=16;break;case"RTC_SPK_FRACTION_DECODER_LOSS_PERCENT":case 17:t.type=17;break;case"RTC_SPK_BITRATE":case 18:t.type=18;break;case"RTC_SPK_CURRENT_DELAY_MS":case 19:t.type=19;break;case"RTC_SPK_JITTER_BUFFER_MS":case 20:t.type=20;break;case"VIDEO_SENT_RTT_MS":case 21:t.type=21;break;case"VIDEO_ENCODE_USAGE_PERCENT":case 22:t.type=22;break;case"VIDEO_NACKS_RECEIVED":case 23:t.type=23;break;case"VIDEO_PLIS_RECEIVED":case 24:t.type=24;break;case"VIDEO_AVERAGE_ENCODE_MS":case 25:t.type=25;break;case"VIDEO_INPUT_FPS":case 26:t.type=26;break;case"VIDEO_ENCODE_FPS":case 27:t.type=27;break;case"VIDEO_SENT_FPS":case 28:t.type=28;break;case"VIDEO_FIRS_RECEIVED":case 29:t.type=29;break;case"VIDEO_SENT_PPS":case 30:t.type=30;break;case"VIDEO_SENT_FRACTION_PACKET_LOST_PERCENT":case 31:t.type=31;break;case"VIDEO_SENT_BITRATE":case 32:t.type=32;break;case"VIDEO_DROPPED_FPS":case 33:t.type=33;break;case"VIDEO_TARGET_DELAY_MS":case 34:t.type=34;break;case"VIDEO_DECODE_MS":case 35:t.type=35;break;case"VIDEO_OUTPUT_FPS":case 36:t.type=36;break;case"VIDEO_RECEIVED_PPS":case 37:t.type=37;break;case"VIDEO_RECEIVED_FRACTION_PACKET_LOST_PERCENT":case 38:t.type=38;break;case"VIDEO_RENDER_DELAY_MS":case 39:t.type=39;break;case"VIDEO_RECEIVED_FPS":case 40:t.type=40;break;case"VIDEO_DECODE_FPS":case 41:t.type=41;break;case"VIDEO_NACKS_SENT":case 42:t.type=42;break;case"VIDEO_FIRS_SENT":case 43:t.type=43;break;case"VIDEO_RECEIVED_BITRATE":case 44:t.type=44;break;case"VIDEO_CURRENT_DELAY_MS":case 45:t.type=45;break;case"VIDEO_JITTER_BUFFER_MS":case 46:t.type=46;break;case"VIDEO_DISCARDED_PPS":case 47:t.type=47;break;case"VIDEO_PLIS_SENT":case 48:t.type=48;break;case"VIDEO_RECEIVED_JITTER_MS":case 49:t.type=49;break;case"VIDEO_ENCODE_HEIGHT":case 64:t.type=64;break;case"VIDEO_SENT_QP_SUM":case 66:t.type=66;break;case"VIDEO_DECODE_HEIGHT":case 69:t.type=69;break;case"VIDEO_RECEIVED_QP_SUM":case 72:t.type=72;break;case"VIDEO_ENCODE_WIDTH":case 86:t.type=86;break;case"VIDEO_DECODE_WIDTH":case 87:t.type=87}return null!=e.value&&(t.value=Number(e.value)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.type=t.enums===String?"VIDEO_ACTUAL_ENCODER_BITRATE":1,n.value=0),null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?l.SdkMetric.Type[e.type]:e.type),null!=e.value&&e.hasOwnProperty("value")&&(n.value=t.json&&!isFinite(e.value)?String(e.value):e.value),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e.Type=function(){var e={},t=Object.create(e);return t[e[1]="VIDEO_ACTUAL_ENCODER_BITRATE"]=1,t[e[2]="VIDEO_AVAILABLE_SEND_BANDWIDTH"]=2,t[e[3]="VIDEO_RETRANSMIT_BITRATE"]=3,t[e[4]="VIDEO_AVAILABLE_RECEIVE_BANDWIDTH"]=4,t[e[5]="VIDEO_TARGET_ENCODER_BITRATE"]=5,t[e[6]="VIDEO_BUCKET_DELAY_MS"]=6,t[e[7]="STUN_RTT_MS"]=7,t[e[8]="SOCKET_DISCARDED_PPS"]=8,t[e[9]="RTC_MIC_JITTER_MS"]=9,t[e[10]="RTC_MIC_PPS"]=10,t[e[11]="RTC_MIC_FRACTION_PACKET_LOST_PERCENT"]=11,t[e[12]="RTC_MIC_BITRATE"]=12,t[e[13]="RTC_MIC_RTT_MS"]=13,t[e[14]="RTC_SPK_PPS"]=14,t[e[15]="RTC_SPK_FRACTION_PACKET_LOST_PERCENT"]=15,t[e[16]="RTC_SPK_JITTER_MS"]=16,t[e[17]="RTC_SPK_FRACTION_DECODER_LOSS_PERCENT"]=17,t[e[18]="RTC_SPK_BITRATE"]=18,t[e[19]="RTC_SPK_CURRENT_DELAY_MS"]=19,t[e[20]="RTC_SPK_JITTER_BUFFER_MS"]=20,t[e[21]="VIDEO_SENT_RTT_MS"]=21,t[e[22]="VIDEO_ENCODE_USAGE_PERCENT"]=22,t[e[23]="VIDEO_NACKS_RECEIVED"]=23,t[e[24]="VIDEO_PLIS_RECEIVED"]=24,t[e[25]="VIDEO_AVERAGE_ENCODE_MS"]=25,t[e[26]="VIDEO_INPUT_FPS"]=26,t[e[27]="VIDEO_ENCODE_FPS"]=27,t[e[28]="VIDEO_SENT_FPS"]=28,t[e[29]="VIDEO_FIRS_RECEIVED"]=29,t[e[30]="VIDEO_SENT_PPS"]=30,t[e[31]="VIDEO_SENT_FRACTION_PACKET_LOST_PERCENT"]=31,t[e[32]="VIDEO_SENT_BITRATE"]=32,t[e[33]="VIDEO_DROPPED_FPS"]=33,t[e[34]="VIDEO_TARGET_DELAY_MS"]=34,t[e[35]="VIDEO_DECODE_MS"]=35,t[e[36]="VIDEO_OUTPUT_FPS"]=36,t[e[37]="VIDEO_RECEIVED_PPS"]=37,t[e[38]="VIDEO_RECEIVED_FRACTION_PACKET_LOST_PERCENT"]=38,t[e[39]="VIDEO_RENDER_DELAY_MS"]=39,t[e[40]="VIDEO_RECEIVED_FPS"]=40,t[e[41]="VIDEO_DECODE_FPS"]=41,t[e[42]="VIDEO_NACKS_SENT"]=42,t[e[43]="VIDEO_FIRS_SENT"]=43,t[e[44]="VIDEO_RECEIVED_BITRATE"]=44,t[e[45]="VIDEO_CURRENT_DELAY_MS"]=45,t[e[46]="VIDEO_JITTER_BUFFER_MS"]=46,t[e[47]="VIDEO_DISCARDED_PPS"]=47,t[e[48]="VIDEO_PLIS_SENT"]=48,t[e[49]="VIDEO_RECEIVED_JITTER_MS"]=49,t[e[64]="VIDEO_ENCODE_HEIGHT"]=64,t[e[66]="VIDEO_SENT_QP_SUM"]=66,t[e[69]="VIDEO_DECODE_HEIGHT"]=69,t[e[72]="VIDEO_RECEIVED_QP_SUM"]=72,t[e[86]="VIDEO_ENCODE_WIDTH"]=86,t[e[87]="VIDEO_DECODE_WIDTH"]=87,t}(),e}(),l.SdkStreamMetricFrame=function(){function e(e){if(this.metrics=[],e)for(var t=Object.keys(e),n=0;n>>3){case 3:i.streamId=e.uint32();break;case 4:i.groupId=e.uint32();break;case 5:i.metrics&&i.metrics.length||(i.metrics=[]),i.metrics.push(l.SdkMetric.decode(e,e.uint32()));break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.streamId&&e.hasOwnProperty("streamId")&&!c.isInteger(e.streamId))return"streamId: integer expected";if(null!=e.groupId&&e.hasOwnProperty("groupId")&&!c.isInteger(e.groupId))return"groupId: integer expected";if(null!=e.metrics&&e.hasOwnProperty("metrics")){if(!Array.isArray(e.metrics))return"metrics: array expected";for(var t=0;t>>0),null!=e.groupId&&(t.groupId=e.groupId>>>0),e.metrics){if(!Array.isArray(e.metrics))throw TypeError(".SdkStreamMetricFrame.metrics: array expected");t.metrics=[];for(var n=0;n>>3){case 1:i.globalMetrics&&i.globalMetrics.length||(i.globalMetrics=[]),i.globalMetrics.push(l.SdkMetric.decode(e,e.uint32()));break;case 2:i.streamMetricFrames&&i.streamMetricFrames.length||(i.streamMetricFrames=[]),i.streamMetricFrames.push(l.SdkStreamMetricFrame.decode(e,e.uint32()));break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.globalMetrics&&e.hasOwnProperty("globalMetrics")){if(!Array.isArray(e.globalMetrics))return"globalMetrics: array expected";for(var t=0;t>>3==1?(i.messages&&i.messages.length||(i.messages=[]),i.messages.push(l.SdkDataMessagePayload.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.messages&&e.hasOwnProperty("messages")){if(!Array.isArray(e.messages))return"messages: array expected";for(var t=0;t>>3){case 1:i.topic=e.string();break;case 2:i.data=e.bytes();break;case 3:i.lifetimeMs=e.uint32();break;case 4:i.senderAttendeeId=e.string();break;case 5:i.ingestTimeNs=e.int64();break;case 6:i.senderExternalUserId=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.topic&&e.hasOwnProperty("topic")&&!c.isString(e.topic)?"topic: string expected":null!=e.data&&e.hasOwnProperty("data")&&!(e.data&&"number"==typeof e.data.length||c.isString(e.data))?"data: buffer expected":null!=e.lifetimeMs&&e.hasOwnProperty("lifetimeMs")&&!c.isInteger(e.lifetimeMs)?"lifetimeMs: integer expected":null!=e.senderAttendeeId&&e.hasOwnProperty("senderAttendeeId")&&!c.isString(e.senderAttendeeId)?"senderAttendeeId: string expected":null!=e.ingestTimeNs&&e.hasOwnProperty("ingestTimeNs")&&!(c.isInteger(e.ingestTimeNs)||e.ingestTimeNs&&c.isInteger(e.ingestTimeNs.low)&&c.isInteger(e.ingestTimeNs.high))?"ingestTimeNs: integer|Long expected":null!=e.senderExternalUserId&&e.hasOwnProperty("senderExternalUserId")&&!c.isString(e.senderExternalUserId)?"senderExternalUserId: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkDataMessagePayload)return e;var t=new l.SdkDataMessagePayload;return null!=e.topic&&(t.topic=String(e.topic)),null!=e.data&&("string"==typeof e.data?c.base64.decode(e.data,t.data=c.newBuffer(c.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),null!=e.lifetimeMs&&(t.lifetimeMs=e.lifetimeMs>>>0),null!=e.senderAttendeeId&&(t.senderAttendeeId=String(e.senderAttendeeId)),null!=e.ingestTimeNs&&(c.Long?(t.ingestTimeNs=c.Long.fromValue(e.ingestTimeNs)).unsigned=!1:"string"==typeof e.ingestTimeNs?t.ingestTimeNs=parseInt(e.ingestTimeNs,10):"number"==typeof e.ingestTimeNs?t.ingestTimeNs=e.ingestTimeNs:"object"==typeof e.ingestTimeNs&&(t.ingestTimeNs=new c.LongBits(e.ingestTimeNs.low>>>0,e.ingestTimeNs.high>>>0).toNumber())),null!=e.senderExternalUserId&&(t.senderExternalUserId=String(e.senderExternalUserId)),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(n.topic="",t.bytes===String?n.data="":(n.data=[],t.bytes!==Array&&(n.data=c.newBuffer(n.data))),n.lifetimeMs=0,n.senderAttendeeId="",c.Long){var i=new c.Long(0,0,!1);n.ingestTimeNs=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.ingestTimeNs=t.longs===String?"0":0;n.senderExternalUserId=""}return null!=e.topic&&e.hasOwnProperty("topic")&&(n.topic=e.topic),null!=e.data&&e.hasOwnProperty("data")&&(n.data=t.bytes===String?c.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),null!=e.lifetimeMs&&e.hasOwnProperty("lifetimeMs")&&(n.lifetimeMs=e.lifetimeMs),null!=e.senderAttendeeId&&e.hasOwnProperty("senderAttendeeId")&&(n.senderAttendeeId=e.senderAttendeeId),null!=e.ingestTimeNs&&e.hasOwnProperty("ingestTimeNs")&&("number"==typeof e.ingestTimeNs?n.ingestTimeNs=t.longs===String?String(e.ingestTimeNs):e.ingestTimeNs:n.ingestTimeNs=t.longs===String?c.Long.prototype.toString.call(e.ingestTimeNs):t.longs===Number?new c.LongBits(e.ingestTimeNs.low>>>0,e.ingestTimeNs.high>>>0).toNumber():e.ingestTimeNs),null!=e.senderExternalUserId&&e.hasOwnProperty("senderExternalUserId")&&(n.senderExternalUserId=e.senderExternalUserId),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkTurnCredentials=function(){function e(e){if(this.uris=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.username=e.string();break;case 2:i.password=e.string();break;case 3:i.ttl=e.uint32();break;case 4:i.uris&&i.uris.length||(i.uris=[]),i.uris.push(e.string());break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.username&&e.hasOwnProperty("username")&&!c.isString(e.username))return"username: string expected";if(null!=e.password&&e.hasOwnProperty("password")&&!c.isString(e.password))return"password: string expected";if(null!=e.ttl&&e.hasOwnProperty("ttl")&&!c.isInteger(e.ttl))return"ttl: integer expected";if(null!=e.uris&&e.hasOwnProperty("uris")){if(!Array.isArray(e.uris))return"uris: array expected";for(var t=0;t>>0),e.uris){if(!Array.isArray(e.uris))throw TypeError(".SdkTurnCredentials.uris: array expected");t.uris=[];for(var n=0;n>>3){case 1:i.content=e.string();break;case 2:i.endTime=e.int64();break;case 3:i.speakerAttendeeId=e.string();break;case 4:i.speakerExternalUserId=e.string();break;case 5:i.startTime=e.int64();break;case 6:i.type=e.int32();break;case 7:i.vocabularyFilterMatch=e.bool();break;case 8:i.confidence=e.double();break;case 9:i.stable=e.bool();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.content&&e.hasOwnProperty("content")&&!c.isString(e.content))return"content: string expected";if(null!=e.endTime&&e.hasOwnProperty("endTime")&&!(c.isInteger(e.endTime)||e.endTime&&c.isInteger(e.endTime.low)&&c.isInteger(e.endTime.high)))return"endTime: integer|Long expected";if(null!=e.speakerAttendeeId&&e.hasOwnProperty("speakerAttendeeId")&&!c.isString(e.speakerAttendeeId))return"speakerAttendeeId: string expected";if(null!=e.speakerExternalUserId&&e.hasOwnProperty("speakerExternalUserId")&&!c.isString(e.speakerExternalUserId))return"speakerExternalUserId: string expected";if(null!=e.startTime&&e.hasOwnProperty("startTime")&&!(c.isInteger(e.startTime)||e.startTime&&c.isInteger(e.startTime.low)&&c.isInteger(e.startTime.high)))return"startTime: integer|Long expected";if(null!=e.type&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 1:case 2:}return null!=e.vocabularyFilterMatch&&e.hasOwnProperty("vocabularyFilterMatch")&&"boolean"!=typeof e.vocabularyFilterMatch?"vocabularyFilterMatch: boolean expected":null!=e.confidence&&e.hasOwnProperty("confidence")&&"number"!=typeof e.confidence?"confidence: number expected":null!=e.stable&&e.hasOwnProperty("stable")&&"boolean"!=typeof e.stable?"stable: boolean expected":null},e.fromObject=function(e){if(e instanceof l.SdkTranscriptItem)return e;var t=new l.SdkTranscriptItem;switch(null!=e.content&&(t.content=String(e.content)),null!=e.endTime&&(c.Long?(t.endTime=c.Long.fromValue(e.endTime)).unsigned=!1:"string"==typeof e.endTime?t.endTime=parseInt(e.endTime,10):"number"==typeof e.endTime?t.endTime=e.endTime:"object"==typeof e.endTime&&(t.endTime=new c.LongBits(e.endTime.low>>>0,e.endTime.high>>>0).toNumber())),null!=e.speakerAttendeeId&&(t.speakerAttendeeId=String(e.speakerAttendeeId)),null!=e.speakerExternalUserId&&(t.speakerExternalUserId=String(e.speakerExternalUserId)),null!=e.startTime&&(c.Long?(t.startTime=c.Long.fromValue(e.startTime)).unsigned=!1:"string"==typeof e.startTime?t.startTime=parseInt(e.startTime,10):"number"==typeof e.startTime?t.startTime=e.startTime:"object"==typeof e.startTime&&(t.startTime=new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber())),e.type){case"PRONUNCIATION":case 1:t.type=1;break;case"PUNCTUATION":case 2:t.type=2}return null!=e.vocabularyFilterMatch&&(t.vocabularyFilterMatch=Boolean(e.vocabularyFilterMatch)),null!=e.confidence&&(t.confidence=Number(e.confidence)),null!=e.stable&&(t.stable=Boolean(e.stable)),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(n.content="",c.Long){var i=new c.Long(0,0,!1);n.endTime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.endTime=t.longs===String?"0":0;n.speakerAttendeeId="",n.speakerExternalUserId="",c.Long?(i=new c.Long(0,0,!1),n.startTime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i):n.startTime=t.longs===String?"0":0,n.type=t.enums===String?"PRONUNCIATION":1,n.vocabularyFilterMatch=!1,n.confidence=0,n.stable=!1}return null!=e.content&&e.hasOwnProperty("content")&&(n.content=e.content),null!=e.endTime&&e.hasOwnProperty("endTime")&&("number"==typeof e.endTime?n.endTime=t.longs===String?String(e.endTime):e.endTime:n.endTime=t.longs===String?c.Long.prototype.toString.call(e.endTime):t.longs===Number?new c.LongBits(e.endTime.low>>>0,e.endTime.high>>>0).toNumber():e.endTime),null!=e.speakerAttendeeId&&e.hasOwnProperty("speakerAttendeeId")&&(n.speakerAttendeeId=e.speakerAttendeeId),null!=e.speakerExternalUserId&&e.hasOwnProperty("speakerExternalUserId")&&(n.speakerExternalUserId=e.speakerExternalUserId),null!=e.startTime&&e.hasOwnProperty("startTime")&&("number"==typeof e.startTime?n.startTime=t.longs===String?String(e.startTime):e.startTime:n.startTime=t.longs===String?c.Long.prototype.toString.call(e.startTime):t.longs===Number?new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber():e.startTime),null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?l.SdkTranscriptItem.Type[e.type]:e.type),null!=e.vocabularyFilterMatch&&e.hasOwnProperty("vocabularyFilterMatch")&&(n.vocabularyFilterMatch=e.vocabularyFilterMatch),null!=e.confidence&&e.hasOwnProperty("confidence")&&(n.confidence=t.json&&!isFinite(e.confidence)?String(e.confidence):e.confidence),null!=e.stable&&e.hasOwnProperty("stable")&&(n.stable=e.stable),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e.Type=function(){var e={},t=Object.create(e);return t[e[1]="PRONUNCIATION"]=1,t[e[2]="PUNCTUATION"]=2,t}(),e}(),l.SdkTranscriptEntity=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.category=e.string();break;case 2:i.confidence=e.double();break;case 3:i.content=e.string();break;case 4:i.endTime=e.int64();break;case 5:i.startTime=e.int64();break;case 6:i.type=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.category&&e.hasOwnProperty("category")&&!c.isString(e.category)?"category: string expected":null!=e.confidence&&e.hasOwnProperty("confidence")&&"number"!=typeof e.confidence?"confidence: number expected":null!=e.content&&e.hasOwnProperty("content")&&!c.isString(e.content)?"content: string expected":null!=e.endTime&&e.hasOwnProperty("endTime")&&!(c.isInteger(e.endTime)||e.endTime&&c.isInteger(e.endTime.low)&&c.isInteger(e.endTime.high))?"endTime: integer|Long expected":null!=e.startTime&&e.hasOwnProperty("startTime")&&!(c.isInteger(e.startTime)||e.startTime&&c.isInteger(e.startTime.low)&&c.isInteger(e.startTime.high))?"startTime: integer|Long expected":null!=e.type&&e.hasOwnProperty("type")&&!c.isString(e.type)?"type: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkTranscriptEntity)return e;var t=new l.SdkTranscriptEntity;return null!=e.category&&(t.category=String(e.category)),null!=e.confidence&&(t.confidence=Number(e.confidence)),null!=e.content&&(t.content=String(e.content)),null!=e.endTime&&(c.Long?(t.endTime=c.Long.fromValue(e.endTime)).unsigned=!1:"string"==typeof e.endTime?t.endTime=parseInt(e.endTime,10):"number"==typeof e.endTime?t.endTime=e.endTime:"object"==typeof e.endTime&&(t.endTime=new c.LongBits(e.endTime.low>>>0,e.endTime.high>>>0).toNumber())),null!=e.startTime&&(c.Long?(t.startTime=c.Long.fromValue(e.startTime)).unsigned=!1:"string"==typeof e.startTime?t.startTime=parseInt(e.startTime,10):"number"==typeof e.startTime?t.startTime=e.startTime:"object"==typeof e.startTime&&(t.startTime=new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber())),null!=e.type&&(t.type=String(e.type)),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(n.category="",n.confidence=0,n.content="",c.Long){var i=new c.Long(0,0,!1);n.endTime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.endTime=t.longs===String?"0":0;c.Long?(i=new c.Long(0,0,!1),n.startTime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i):n.startTime=t.longs===String?"0":0,n.type=""}return null!=e.category&&e.hasOwnProperty("category")&&(n.category=e.category),null!=e.confidence&&e.hasOwnProperty("confidence")&&(n.confidence=t.json&&!isFinite(e.confidence)?String(e.confidence):e.confidence),null!=e.content&&e.hasOwnProperty("content")&&(n.content=e.content),null!=e.endTime&&e.hasOwnProperty("endTime")&&("number"==typeof e.endTime?n.endTime=t.longs===String?String(e.endTime):e.endTime:n.endTime=t.longs===String?c.Long.prototype.toString.call(e.endTime):t.longs===Number?new c.LongBits(e.endTime.low>>>0,e.endTime.high>>>0).toNumber():e.endTime),null!=e.startTime&&e.hasOwnProperty("startTime")&&("number"==typeof e.startTime?n.startTime=t.longs===String?String(e.startTime):e.startTime:n.startTime=t.longs===String?c.Long.prototype.toString.call(e.startTime):t.longs===Number?new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber():e.startTime),null!=e.type&&e.hasOwnProperty("type")&&(n.type=e.type),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkTranscriptAlternative=function(){function e(e){if(this.items=[],this.entities=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.items&&i.items.length||(i.items=[]),i.items.push(l.SdkTranscriptItem.decode(e,e.uint32()));break;case 2:i.transcript=e.string();break;case 3:i.entities&&i.entities.length||(i.entities=[]),i.entities.push(l.SdkTranscriptEntity.decode(e,e.uint32()));break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.items&&e.hasOwnProperty("items")){if(!Array.isArray(e.items))return"items: array expected";for(var t=0;t>>3){case 1:i.languageCode=e.string();break;case 2:i.score=e.double();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.languageCode&&e.hasOwnProperty("languageCode")&&!c.isString(e.languageCode)?"languageCode: string expected":null!=e.score&&e.hasOwnProperty("score")&&"number"!=typeof e.score?"score: number expected":null},e.fromObject=function(e){if(e instanceof l.SdkTranscriptLanguageWithScore)return e;var t=new l.SdkTranscriptLanguageWithScore;return null!=e.languageCode&&(t.languageCode=String(e.languageCode)),null!=e.score&&(t.score=Number(e.score)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.languageCode="",n.score=0),null!=e.languageCode&&e.hasOwnProperty("languageCode")&&(n.languageCode=e.languageCode),null!=e.score&&e.hasOwnProperty("score")&&(n.score=t.json&&!isFinite(e.score)?String(e.score):e.score),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkTranscriptResult=function(){function e(e){if(this.alternatives=[],this.languageIdentification=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.alternatives&&i.alternatives.length||(i.alternatives=[]),i.alternatives.push(l.SdkTranscriptAlternative.decode(e,e.uint32()));break;case 2:i.channelId=e.string();break;case 3:i.endTime=e.int64();break;case 4:i.isPartial=e.bool();break;case 5:i.resultId=e.string();break;case 6:i.startTime=e.int64();break;case 7:i.languageCode=e.string();break;case 8:i.languageIdentification&&i.languageIdentification.length||(i.languageIdentification=[]),i.languageIdentification.push(l.SdkTranscriptLanguageWithScore.decode(e,e.uint32()));break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.alternatives&&e.hasOwnProperty("alternatives")){if(!Array.isArray(e.alternatives))return"alternatives: array expected";for(var t=0;t>>0,e.endTime.high>>>0).toNumber())),null!=e.isPartial&&(t.isPartial=Boolean(e.isPartial)),null!=e.resultId&&(t.resultId=String(e.resultId)),null!=e.startTime&&(c.Long?(t.startTime=c.Long.fromValue(e.startTime)).unsigned=!1:"string"==typeof e.startTime?t.startTime=parseInt(e.startTime,10):"number"==typeof e.startTime?t.startTime=e.startTime:"object"==typeof e.startTime&&(t.startTime=new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber())),null!=e.languageCode&&(t.languageCode=String(e.languageCode)),e.languageIdentification){if(!Array.isArray(e.languageIdentification))throw TypeError(".SdkTranscriptResult.languageIdentification: array expected");for(t.languageIdentification=[],n=0;n>>0,e.endTime.high>>>0).toNumber():e.endTime),null!=e.isPartial&&e.hasOwnProperty("isPartial")&&(n.isPartial=e.isPartial),null!=e.resultId&&e.hasOwnProperty("resultId")&&(n.resultId=e.resultId),null!=e.startTime&&e.hasOwnProperty("startTime")&&("number"==typeof e.startTime?n.startTime=t.longs===String?String(e.startTime):e.startTime:n.startTime=t.longs===String?c.Long.prototype.toString.call(e.startTime):t.longs===Number?new c.LongBits(e.startTime.low>>>0,e.startTime.high>>>0).toNumber():e.startTime),null!=e.languageCode&&e.hasOwnProperty("languageCode")&&(n.languageCode=e.languageCode),e.languageIdentification&&e.languageIdentification.length)for(n.languageIdentification=[],r=0;r>>3==1?(i.results&&i.results.length||(i.results=[]),i.results.push(l.SdkTranscriptResult.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.results&&e.hasOwnProperty("results")){if(!Array.isArray(e.results))return"results: array expected";for(var t=0;t>>3){case 1:i.type=e.int32();break;case 2:i.eventTime=e.int64();break;case 3:i.transcriptionRegion=e.string();break;case 4:i.transcriptionConfiguration=e.string();break;case 5:i.message=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.type&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 1:case 2:case 3:case 4:case 5:}return null!=e.eventTime&&e.hasOwnProperty("eventTime")&&!(c.isInteger(e.eventTime)||e.eventTime&&c.isInteger(e.eventTime.low)&&c.isInteger(e.eventTime.high))?"eventTime: integer|Long expected":null!=e.transcriptionRegion&&e.hasOwnProperty("transcriptionRegion")&&!c.isString(e.transcriptionRegion)?"transcriptionRegion: string expected":null!=e.transcriptionConfiguration&&e.hasOwnProperty("transcriptionConfiguration")&&!c.isString(e.transcriptionConfiguration)?"transcriptionConfiguration: string expected":null!=e.message&&e.hasOwnProperty("message")&&!c.isString(e.message)?"message: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkTranscriptionStatus)return e;var t=new l.SdkTranscriptionStatus;switch(e.type){case"STARTED":case 1:t.type=1;break;case"INTERRUPTED":case 2:t.type=2;break;case"RESUMED":case 3:t.type=3;break;case"STOPPED":case 4:t.type=4;break;case"FAILED":case 5:t.type=5}return null!=e.eventTime&&(c.Long?(t.eventTime=c.Long.fromValue(e.eventTime)).unsigned=!1:"string"==typeof e.eventTime?t.eventTime=parseInt(e.eventTime,10):"number"==typeof e.eventTime?t.eventTime=e.eventTime:"object"==typeof e.eventTime&&(t.eventTime=new c.LongBits(e.eventTime.low>>>0,e.eventTime.high>>>0).toNumber())),null!=e.transcriptionRegion&&(t.transcriptionRegion=String(e.transcriptionRegion)),null!=e.transcriptionConfiguration&&(t.transcriptionConfiguration=String(e.transcriptionConfiguration)),null!=e.message&&(t.message=String(e.message)),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(n.type=t.enums===String?"STARTED":1,c.Long){var i=new c.Long(0,0,!1);n.eventTime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.eventTime=t.longs===String?"0":0;n.transcriptionRegion="",n.transcriptionConfiguration="",n.message=""}return null!=e.type&&e.hasOwnProperty("type")&&(n.type=t.enums===String?l.SdkTranscriptionStatus.Type[e.type]:e.type),null!=e.eventTime&&e.hasOwnProperty("eventTime")&&("number"==typeof e.eventTime?n.eventTime=t.longs===String?String(e.eventTime):e.eventTime:n.eventTime=t.longs===String?c.Long.prototype.toString.call(e.eventTime):t.longs===Number?new c.LongBits(e.eventTime.low>>>0,e.eventTime.high>>>0).toNumber():e.eventTime),null!=e.transcriptionRegion&&e.hasOwnProperty("transcriptionRegion")&&(n.transcriptionRegion=e.transcriptionRegion),null!=e.transcriptionConfiguration&&e.hasOwnProperty("transcriptionConfiguration")&&(n.transcriptionConfiguration=e.transcriptionConfiguration),null!=e.message&&e.hasOwnProperty("message")&&(n.message=e.message),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e.Type=function(){var e={},t=Object.create(e);return t[e[1]="STARTED"]=1,t[e[2]="INTERRUPTED"]=2,t[e[3]="RESUMED"]=3,t[e[4]="STOPPED"]=4,t[e[5]="FAILED"]=5,t}(),e}(),l.SdkTranscriptEvent=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.status=l.SdkTranscriptionStatus.decode(e,e.uint32());break;case 2:i.transcript=l.SdkTranscript.decode(e,e.uint32());break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.status&&e.hasOwnProperty("status")&&(t.Event=1,n=l.SdkTranscriptionStatus.verify(e.status)))return"status."+n;if(null!=e.transcript&&e.hasOwnProperty("transcript")){if(1===t.Event)return"Event: multiple values";var n;if(t.Event=1,n=l.SdkTranscript.verify(e.transcript))return"transcript."+n}return null},e.fromObject=function(e){if(e instanceof l.SdkTranscriptEvent)return e;var t=new l.SdkTranscriptEvent;if(null!=e.status){if("object"!=typeof e.status)throw TypeError(".SdkTranscriptEvent.status: object expected");t.status=l.SdkTranscriptionStatus.fromObject(e.status)}if(null!=e.transcript){if("object"!=typeof e.transcript)throw TypeError(".SdkTranscriptEvent.transcript: object expected");t.transcript=l.SdkTranscript.fromObject(e.transcript)}return t},e.toObject=function(e,t){t||(t={});var n={};return null!=e.status&&e.hasOwnProperty("status")&&(n.status=l.SdkTranscriptionStatus.toObject(e.status,t),t.oneofs&&(n.Event="status")),null!=e.transcript&&e.hasOwnProperty("transcript")&&(n.transcript=l.SdkTranscript.toObject(e.transcript,t),t.oneofs&&(n.Event="transcript")),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkTranscriptFrame=function(){function e(e){if(this.events=[],e)for(var t=Object.keys(e),n=0;n>>3==1?(i.events&&i.events.length||(i.events=[]),i.events.push(l.SdkTranscriptEvent.decode(e,e.uint32()))):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.events&&e.hasOwnProperty("events")){if(!Array.isArray(e.events))return"events: array expected";for(var t=0;t>>3){case 1:i.addedOrUpdatedVideoSubscriptions&&i.addedOrUpdatedVideoSubscriptions.length||(i.addedOrUpdatedVideoSubscriptions=[]),i.addedOrUpdatedVideoSubscriptions.push(l.SdkVideoSubscriptionConfiguration.decode(e,e.uint32()));break;case 2:i.removedVideoSubscriptionMids&&i.removedVideoSubscriptionMids.length||(i.removedVideoSubscriptionMids=[]),i.removedVideoSubscriptionMids.push(e.string());break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.addedOrUpdatedVideoSubscriptions&&e.hasOwnProperty("addedOrUpdatedVideoSubscriptions")){if(!Array.isArray(e.addedOrUpdatedVideoSubscriptions))return"addedOrUpdatedVideoSubscriptions: array expected";for(var t=0;t>>3){case 1:i.mid=e.string();break;case 2:i.attendeeId=e.string();break;case 3:i.streamId=e.uint32();break;case 4:i.priority=e.uint32();break;case 5:i.targetBitrateKbps=e.uint32();break;case 6:i.groupId=e.uint32();break;default:e.skipType(7&r)}}if(!i.hasOwnProperty("mid"))throw c.ProtocolError("missing required 'mid'",{instance:i});return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":c.isString(e.mid)?null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&!c.isString(e.attendeeId)?"attendeeId: string expected":null!=e.streamId&&e.hasOwnProperty("streamId")&&!c.isInteger(e.streamId)?"streamId: integer expected":null!=e.priority&&e.hasOwnProperty("priority")&&!c.isInteger(e.priority)?"priority: integer expected":null!=e.targetBitrateKbps&&e.hasOwnProperty("targetBitrateKbps")&&!c.isInteger(e.targetBitrateKbps)?"targetBitrateKbps: integer expected":null!=e.groupId&&e.hasOwnProperty("groupId")&&!c.isInteger(e.groupId)?"groupId: integer expected":null:"mid: string expected"},e.fromObject=function(e){if(e instanceof l.SdkVideoSubscriptionConfiguration)return e;var t=new l.SdkVideoSubscriptionConfiguration;return null!=e.mid&&(t.mid=String(e.mid)),null!=e.attendeeId&&(t.attendeeId=String(e.attendeeId)),null!=e.streamId&&(t.streamId=e.streamId>>>0),null!=e.priority&&(t.priority=e.priority>>>0),null!=e.targetBitrateKbps&&(t.targetBitrateKbps=e.targetBitrateKbps>>>0),null!=e.groupId&&(t.groupId=e.groupId>>>0),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.mid="",n.attendeeId="",n.streamId=0,n.priority=0,n.targetBitrateKbps=0,n.groupId=0),null!=e.mid&&e.hasOwnProperty("mid")&&(n.mid=e.mid),null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&(n.attendeeId=e.attendeeId),null!=e.streamId&&e.hasOwnProperty("streamId")&&(n.streamId=e.streamId),null!=e.priority&&e.hasOwnProperty("priority")&&(n.priority=e.priority),null!=e.targetBitrateKbps&&e.hasOwnProperty("targetBitrateKbps")&&(n.targetBitrateKbps=e.targetBitrateKbps),null!=e.groupId&&e.hasOwnProperty("groupId")&&(n.groupId=e.groupId),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkPrimaryMeetingJoinFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3==1?i.credentials=l.SdkMeetingSessionCredentials.decode(e,e.uint32()):e.skipType(7&r)}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.credentials&&e.hasOwnProperty("credentials")){var t=l.SdkMeetingSessionCredentials.verify(e.credentials);if(t)return"credentials."+t}return null},e.fromObject=function(e){if(e instanceof l.SdkPrimaryMeetingJoinFrame)return e;var t=new l.SdkPrimaryMeetingJoinFrame;if(null!=e.credentials){if("object"!=typeof e.credentials)throw TypeError(".SdkPrimaryMeetingJoinFrame.credentials: object expected");t.credentials=l.SdkMeetingSessionCredentials.fromObject(e.credentials)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.credentials=null),null!=e.credentials&&e.hasOwnProperty("credentials")&&(n.credentials=l.SdkMeetingSessionCredentials.toObject(e.credentials,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkPrimaryMeetingJoinAckFrame=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:i.attendeeId=e.string();break;case 2:i.externalUserId=e.string();break;case 3:i.joinToken=e.string();break;default:e.skipType(7&r)}}return i},e.decodeDelimited=function(e){return e instanceof o||(e=new o(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&!c.isString(e.attendeeId)?"attendeeId: string expected":null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&!c.isString(e.externalUserId)?"externalUserId: string expected":null!=e.joinToken&&e.hasOwnProperty("joinToken")&&!c.isString(e.joinToken)?"joinToken: string expected":null},e.fromObject=function(e){if(e instanceof l.SdkMeetingSessionCredentials)return e;var t=new l.SdkMeetingSessionCredentials;return null!=e.attendeeId&&(t.attendeeId=String(e.attendeeId)),null!=e.externalUserId&&(t.externalUserId=String(e.externalUserId)),null!=e.joinToken&&(t.joinToken=String(e.joinToken)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.attendeeId="",n.externalUserId="",n.joinToken=""),null!=e.attendeeId&&e.hasOwnProperty("attendeeId")&&(n.attendeeId=e.attendeeId),null!=e.externalUserId&&e.hasOwnProperty("externalUserId")&&(n.externalUserId=e.externalUserId),null!=e.joinToken&&e.hasOwnProperty("joinToken")&&(n.joinToken=e.joinToken),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),l.SdkVideoCodecCapability=function(){var e={},t=Object.create(e);return t[e[1]="VP8"]=1,t[e[3]="H264_CONSTRAINED_BASELINE_PROFILE"]=3,t}(),e.exports=l,c.Long=void 0,a.configure()},334:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1938),a=n(3538),o=n(4046);t.default=class{constructor(e){this.chimeClient=e}makeTwoDigits(e){return e>9?e.toString():"0"+e.toString()}hmac(e,t){const n=new r.Sha256(t);return n.update(e),n.digest()}getDateTimeString(){const e=new Date;return e.getUTCFullYear()+this.makeTwoDigits(e.getUTCMonth()+1)+this.makeTwoDigits(e.getUTCDate())+"T"+this.makeTwoDigits(e.getUTCHours())+this.makeTwoDigits(e.getUTCMinutes())+this.makeTwoDigits(e.getUTCSeconds())+"Z"}getDateString(e){return e.substring(0,e.indexOf("T"))}getSignatureKey(e,t,n,r){return i(this,void 0,void 0,(function*(){const i=yield this.hmac(t,"AWS4"+e),a=yield this.hmac(n,i),o=yield this.hmac(r,a);return yield this.hmac("aws4_request",o)}))}signURL(e,t,n,r,s,c,l){return i(this,void 0,void 0,(function*(){const i=this.getDateTimeString(),u=this.getDateString(i);let d="";d=this.chimeClient.config.region instanceof Function?yield this.chimeClient.config.region():this.chimeClient.config.region;const h="host:"+r.toLowerCase()+"\n",f=u+"/"+d+"/"+n+"/aws4_request";let p;p=this.chimeClient.config.credentials instanceof Function?yield this.chimeClient.config.credentials():this.chimeClient.config.credentials;let m=new Map;m.set("X-Amz-Algorithm",["AWS4-HMAC-SHA256"]),m.set("X-Amz-Credential",[encodeURIComponent(p.accessKeyId+"/"+f)]),m.set("X-Amz-Date",[i]),m.set("X-Amz-Expires",["10"]),m.set("X-Amz-SignedHeaders",["host"]),p.sessionToken&&m.set("X-Amz-Security-Token",[encodeURIComponent(p.sessionToken)]),m.set(o.default.X_AMZN_VERSION,[encodeURIComponent(o.default.sdkVersion)]),m.set(o.default.X_AMZN_USER_AGENT,[encodeURIComponent(o.default.sdkUserAgentLowResolution)]),null==l||l.forEach(((e,t)=>{const n=encodeURIComponent(t);e.sort().forEach((e=>{m.has(n)||m.set(n,[]),m.get(n).push(encodeURIComponent(e))}))}));let g="";m=new Map([...m.entries()].sort()),m.forEach(((e,t)=>{e.forEach((e=>{g.length&&(g+="&"),g+=t+"="+e}))}));const C=e+"\n"+s+"\n"+g+"\n"+h+"\nhost\n"+a.toHex(yield this.hmac(c)),v=a.toHex(yield this.hmac(C)),y="AWS4-HMAC-SHA256\n"+i+"\n"+u+"/"+d+"/"+n+"/aws4_request\n"+v,b=yield this.getSignatureKey(p.secretAccessKey,u,d,n),M=a.toHex(yield this.hmac(y,b));return t+"://"+r+s+"?"+g+"&X-Amz-Signature="+M}))}}},7606:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SimulcastLayers=void 0,function(e){e[e.Low=0]="Low",e[e.LowAndMedium=1]="LowAndMedium",e[e.LowAndHigh=2]="LowAndHigh",e[e.Medium=3]="Medium",e[e.MediumAndHigh=4]="MediumAndHigh",e[e.High=5]="High"}(n=t.SimulcastLayers||(t.SimulcastLayers={})),t.default=n},9880:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.AudioLogEvent=void 0,function(e){e[e.DeviceChanged=0]="DeviceChanged",e[e.MutedLocal=1]="MutedLocal",e[e.UnmutedLocal=2]="UnmutedLocal",e[e.Connected=3]="Connected",e[e.ConnectFailed=4]="ConnectFailed",e[e.RedmicStartLoss=5]="RedmicStartLoss",e[e.RedmicEndLoss=6]="RedmicEndLoss"}(n=t.AudioLogEvent||(t.AudioLogEvent={})),t.default=n},8597:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(4571),a=n(6196),o=n(9496),s=n(2811),c=n(7604),l=n(1296),u=n(3922),d=n(289),h=n(8660),f=n(9880),p=n(155);class m{constructor(e,t,n=m.INTERVAL_MS){this.audioVideoController=e,this.logger=t,this.interval=n,this.intervalScheduler=null,this.metricsAddTime=(e,t,n)=>{},this.metricsLogEvent=(e,t)=>{}}toAttribute(e){return this.toSuffix(e).substring(1)}toSuffix(e){return e.toLowerCase()===e?`_${e}`:e.toUpperCase()===e?`_${e.toLowerCase()}`:e.replace(/([A-Z][a-z]+)/g,(function(e){return`_${e}`})).replace(/([A-Z][A-Z]+)/g,(function(e){return`_${e}`})).toLowerCase()}logLatency(e,t,n){const i=this.toSuffix(e);this.logEventTime("meeting"+i,t,n)}logStateTimeout(e,t){const n=this.toSuffix(e);this.logEvent("meeting_session_state_timeout",Object.assign(Object.assign({},t),{state:`state${n}`}))}logAudioEvent(e,t){const n="audio"+this.toSuffix(f.default[e]);this.logEvent(n,t)}logVideoEvent(e,t){const n="video"+this.toSuffix(p.default[e]);this.logEvent(n,t)}logEventTime(e,t,n={}){const i=Object.assign(Object.assign({},n),{call_id:this.audioVideoController.configuration.meetingId,client_type:m.CLIENT_TYPE,metric_type:"latency"});this.logger.debug((()=>`[StatsCollector] ${e}: ${JSON.stringify(i)}`)),this.metricsAddTime(e,t,i)}logMeetingSessionStatus(e){const t=`${e.statusCode()}`;this.logEvent(t);const n={status:t,status_code:`${e.statusCode()}`};this.logEvent("meeting_session_status",n),e.isTerminal()&&this.logEvent("meeting_session_stopped",n),e.isAudioConnectionFailure()&&this.logEvent("meeting_session_audio_failed",n),e.isFailure()&&this.logEvent("meeting_session_failed",n)}logLifecycleEvent(e,t){const n={lifecycle_event:`lifecycle${this.toSuffix(c.default[e])}`,lifecycle_event_code:`${e}`,lifecycle_event_condition:`condition${this.toSuffix(l.default[t])}`,lifecycle_event_condition_code:`${t}`};this.logEvent("meeting_session_lifecycle",n)}logEvent(e,t={}){const n=Object.assign(Object.assign({},t),{call_id:this.audioVideoController.configuration.meetingId,client_type:m.CLIENT_TYPE});this.logger.debug((()=>`[StatsCollector] ${e}: ${JSON.stringify(n)}`)),this.metricsLogEvent(e,n)}start(e,t){return!this.intervalScheduler&&(this.logger.info("Starting StatsCollector"),this.signalingClient=e,this.videoStreamIndex=t,this.clientMetricReport=new r.default(this.logger,this.videoStreamIndex,this.audioVideoController.configuration.credentials.attendeeId),this.intervalScheduler=new u.default(this.interval),this.intervalScheduler.start((()=>i(this,void 0,void 0,(function*(){yield this.getStatsWrapper()})))),!0)}stop(){this.logger.info("Stopping StatsCollector"),this.intervalScheduler&&this.intervalScheduler.stop(),this.intervalScheduler=null}updateMetricValues(e,t){const n=t?this.clientMetricReport.streamMetricReports[Number(e.ssrc)]:this.clientMetricReport.globalMetricReport;let i;i=t?this.clientMetricReport.getMetricMap(n.mediaType,n.direction):this.clientMetricReport.getMetricMap();for(const t in e)t in i&&(n.previousMetrics[t]=n.currentMetrics[t],n.currentMetrics[t]=e[t])}processRawMetricReports(e){this.clientMetricReport.currentSsrcs={};const t=Date.now();for(const t of e){const e=this.isStreamRawMetricReport(t.type);if(e){const e=this.clientMetricReport.streamMetricReports[Number(t.ssrc)];if(e)e.streamId=this.videoStreamIndex.streamIdForSSRC(Number(t.ssrc));else{const e=new s.default;e.mediaType=this.getMediaType(t),e.direction=this.getDirectionType(t),this.videoStreamIndex.allStreams().empty()||(e.streamId=this.videoStreamIndex.streamIdForSSRC(Number(t.ssrc))),this.clientMetricReport.streamMetricReports[Number(t.ssrc)]=e}this.clientMetricReport.currentSsrcs[Number(t.ssrc)]=1}this.updateMetricValues(t,e)}this.clientMetricReport.removeDestroyedSsrcs(),this.clientMetricReport.previousTimestampMs=this.clientMetricReport.currentTimestampMs,this.clientMetricReport.currentTimestampMs=t,this.clientMetricReport.print()}addMetricFrame(e,t,n,i){const r=n.type,a=n.transform,o=n.source,s=t.streamMetricFrames.length,c=t.streamMetricFrames[s-1];if(r){const n=d.SdkMetric.create();n.type=r,n.value=a(o||e,i),i?c.metrics.push(n):t.globalMetrics.push(n)}}addGlobalMetricsToProtobuf(e){const t=this.clientMetricReport.getMetricMap();for(const n in this.clientMetricReport.globalMetricReport.currentMetrics)this.addMetricFrame(n,e,t[n])}addStreamMetricsToProtobuf(e){for(const t in this.clientMetricReport.streamMetricReports){const n=this.clientMetricReport.streamMetricReports[t],i=d.SdkStreamMetricFrame.create();i.streamId=n.streamId,i.metrics=[],e.streamMetricFrames.push(i);const r=this.clientMetricReport.getMetricMap(n.mediaType,n.direction);for(const i in n.currentMetrics)this.addMetricFrame(i,e,r[i],Number(t))}}makeClientMetricProtobuf(){const e=d.SdkClientMetricFrame.create();return e.globalMetrics=[],e.streamMetricFrames=[],this.addGlobalMetricsToProtobuf(e),this.addStreamMetricsToProtobuf(e),e}sendClientMetricProtobuf(e){this.signalingClient.sendClientMetrics(e)}isStreamRawMetricReport(e){return["inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp"].includes(e)}getMediaType(e){return"audio"===e.kind?o.default.AUDIO:o.default.VIDEO}getDirectionType(e){const{type:t}=e;return"inbound-rtp"===t||"remote-outbound-rtp"===t?a.default.DOWNSTREAM:a.default.UPSTREAM}isValidStandardRawMetric(e){return"inbound-rtp"===e.type||"outbound-rtp"===e.type||"remote-inbound-rtp"===e.type||"remote-outbound-rtp"===e.type||"candidate-pair"===e.type&&"succeeded"===e.state}isValidSsrc(e){let t=!0;return this.isStreamRawMetricReport(e.type)&&this.getDirectionType(e)===a.default.DOWNSTREAM&&this.getMediaType(e)===o.default.VIDEO&&(t=this.videoStreamIndex.streamIdForSSRC(Number(e.ssrc))>0),t}isValidRawMetricReport(e){return this.isValidStandardRawMetric(e)&&this.isValidSsrc(e)}filterRawMetricReports(e){const t=[];for(const n of e)this.isValidRawMetricReport(n)&&t.push(n);return t}handleRawMetricReports(e){const t=this.filterRawMetricReports(e);this.logger.debug((()=>`Filtered raw metrics : ${JSON.stringify(t)}`)),this.processRawMetricReports(t);const n=this.makeClientMetricProtobuf();this.sendClientMetricProtobuf(n),this.audioVideoController.forEachObserver((e=>{h.Maybe.of(e.metricsDidReceive).map((t=>t.bind(e)(this.clientMetricReport.clone())))}))}getStatsWrapper(){return i(this,void 0,void 0,(function*(){if(!this.audioVideoController.rtcPeerConnection)return;const e=[];try{const t=yield this.audioVideoController.rtcPeerConnection.getStats();this.clientMetricReport.rtcStatsReport=t,t.forEach((t=>{e.push(t)})),this.handleRawMetricReports(e)}catch(e){this.logger.error(e.message)}}))}}t.default=m,m.INTERVAL_MS=1e3,m.CLIENT_TYPE="amazon-chime-sdk-js"},155:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.VideoLogEvent=void 0,function(e){e[e.InputAttached=0]="InputAttached",e[e.SendingFailed=1]="SendingFailed",e[e.SendingSuccess=2]="SendingSuccess"}(n=t.VideoLogEvent||(t.VideoLogEvent={})),t.default=n},8358:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(155),a=n(1789);class o extends a.default{constructor(e){super(e.logger),this.context=e,this.taskName="AttachMediaInputTask"}run(){return i(this,void 0,void 0,(function*(){const e=this.context.transceiverController;e.setPeer(this.context.peer),e.setupLocalTransceivers();const t=this.context.activeAudioInput;if(t){const n=t.getAudioTracks();this.context.logger.info("attaching audio track to peer connection"),yield e.setAudioInput(n.length?n[0]:null)}else yield e.setAudioInput(null),this.context.logger.info("no audio track");const n=this.context.activeVideoInput;if(n){const t=n.getVideoTracks(),i=t.length?t[0]:null;if(this.context.logger.info("attaching video track to peer connection"),yield e.setVideoInput(i),this.context.enableSimulcast&&this.context.videoUplinkBandwidthPolicy){const t=this.context.videoUplinkBandwidthPolicy.chooseEncodingParameters();e.setEncodingParameters(t)}i&&(this.context.statsCollector.logVideoEvent(r.default.InputAttached,this.context.videoDeviceInformation),this.context.videoInputAttachedTimestampMs=Date.now())}else yield e.setVideoInput(null),this.context.logger.info("no video track");this.context.videoSubscriptions=e.updateVideoTransceivers(this.context.videoStreamIndex,this.context.videosToReceive)}))}}t.default=o},1789:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1124),a=n(4456);t.default=class{constructor(e){this.logger=e,this.taskName="BaseTask",this.parentTask=null,this.status=a.default.IDLE,this.run=this.baseRun.bind(this,this.run),this.cancel=this.baseCancel.bind(this,this.cancel)}once(...e){return new r.default(this.logger,this,e)}cancel(){}name(){return this.parentTask?`${this.parentTask.name()}/${this.taskName}`:this.taskName}setParent(e){this.parentTask=e}getStatus(){return this.status}logAndThrow(e){throw this.logger.info(e),new Error(e)}baseRun(e){return i(this,void 0,void 0,(function*(){try{const t=Date.now();switch(this.logger.info(`running task ${this.name()}`),this.status){case a.default.RUNNING:this.logAndThrow(`${this.name()} is already running`);case a.default.CANCELED:this.logAndThrow(`${this.name()} was canceled before running`);case a.default.FINISHED:this.logAndThrow(`${this.name()} was already finished`)}this.status=a.default.RUNNING,yield e.call(this),this.logger.info(`${this.name()} took ${Math.round(Date.now()-t)} ms`)}catch(e){throw e}finally{this.status!==a.default.CANCELED&&(this.status=a.default.FINISHED)}}))}baseCancel(e){this.status!==a.default.CANCELED&&this.status!==a.default.FINISHED?(this.logger.info(`canceling task ${this.name()}`),this.status=a.default.CANCELED,e.call(this)):this.logger.info(`Not canceling ${this.name()}: state is ${this.status}`)}}},3216:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1789);class a extends r.default{constructor(e){super(e.logger),this.context=e,this.taskName="CleanRestartedSessionTask"}run(){return i(this,void 0,void 0,(function*(){this.context.peer&&this.context.peer.close(),this.context.transceiverController.reset(),this.context.peer=null,this.context.videoDownlinkBandwidthPolicy.reset(),this.context.videoUplinkBandwidthPolicy.reset&&this.context.videoUplinkBandwidthPolicy.reset(),this.context.iceCandidateHandler=null,this.context.iceCandidates=[],this.context.previousSdpOffer=null}))}}t.default=a},7408:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9416),a=n(1789);class o extends a.default{constructor(e){super(e.logger),this.context=e,this.taskName="CleanStoppedSessionTask",this.taskCanceler=null}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){try{this.context.signalingClient.ready()&&(this.context.signalingClient.closeConnection(),yield this.receiveWebSocketClosedEvent())}catch(e){throw e}finally{for(const e of this.context.removableObservers)e.removeObserver();this.context.statsCollector.stop(),this.context.statsCollector=null,this.context.connectionMonitor.stop(),this.context.connectionMonitor=null,this.context.peer&&this.context.peer.close(),this.context.peer=null,this.context.sdpAnswer=null,this.context.sdpOfferInit=null,this.context.indexFrame=null,this.context.videoDownlinkBandwidthPolicy.reset(),this.context.videoUplinkBandwidthPolicy.reset&&this.context.videoUplinkBandwidthPolicy.reset(),this.context.iceCandidateHandler=null,this.context.iceCandidates=[],this.context.turnCredentials=null,this.context.videoSubscriptions=null,this.context.transceiverController.reset(),this.context.videoUplinkBandwidthPolicy.setTransceiverController&&this.context.videoUplinkBandwidthPolicy.setTransceiverController(void 0),this.context.videoDownlinkBandwidthPolicy.bindToTileController&&this.context.videoDownlinkBandwidthPolicy.bindToTileController(void 0);const e=this.context.videoTileController.getLocalVideoTile();e&&e.bindVideoStream("",!0,null,null,null,null),this.context.videoTileController.removeAllVideoTiles()}}))}receiveWebSocketClosedEvent(){return new Promise(((e,t)=>{const n=new class{constructor(e){this.signalingClient=e}cancel(){this.signalingClient.removeObserver(this),t(new Error("CleanStoppedSessionTask got canceled while waiting for the WebSocket closed event"))}handleSignalingClientEvent(t){t.type===r.default.WebSocketClosed&&(this.signalingClient.removeObserver(this),e())}}(this.context.signalingClient);this.taskCanceler=n,this.context.signalingClient.registerObserver(n)}))}}t.default=o},5482:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1789);class a extends r.default{constructor(e){super(e.logger),this.context=e,this.taskName="CreatePeerConnectionTask",this.removeTrackAddedEventListener=null,this.removeTrackRemovedEventListeners={},this.trackEvents=["ended","mute","unmute","isolationchange","overconstrained"],this.removeVideoTrackEventListeners={},this.trackAddedHandler=e=>{const t=e.track;if(this.context.logger.info(`received track event: kind=${t.kind} id=${t.id} label=${t.label}`),e.transceiver&&"inactive"===e.transceiver.currentDirection)return;if(0===e.streams.length)return void this.context.logger.warn("Track event but no stream");const n=e.streams[0];"audio"===t.kind?this.context.audioMixController.bindAudioStream(n):"video"!==t.kind||this.trackIsVideoInput(t)||this.addRemoteVideoTrack(t,n)}}removeObserver(){this.removeTrackAddedEventListener&&this.removeTrackAddedEventListener();for(const e in this.removeTrackRemovedEventListeners)this.removeTrackRemovedEventListeners[e]()}addPeerConnectionEventLogger(){const e=this.context.peer;e.addEventListener("connectionstatechange",(()=>{this.context.logger.info(`peer connection state changed: ${e.connectionState}`)})),e.addEventListener("negotiationneeded",(()=>{this.context.logger.info("peer connection negotiation is needed")})),e.addEventListener("icegatheringstatechange",(()=>{this.context.logger.info(`peer connection ice gathering state changed: ${e.iceGatheringState}`)})),e.addEventListener("icecandidate",(e=>{this.context.logger.info(`peer connection ice candidate: ${e.candidate?e.candidate.candidate:"(null)"}`)})),e.addEventListener("iceconnectionstatechange",(()=>{this.context.logger.info(`peer connection ice connection state changed: ${e.iceConnectionState}`)}))}run(){return i(this,void 0,void 0,(function*(){this.context.removableObservers.push(this);const e=this.context.turnCredentials&&this.context.turnCredentials.uris.length>0?{iceServers:[{urls:this.context.turnCredentials.uris,username:this.context.turnCredentials.username,credential:this.context.turnCredentials.password,credentialType:"password"}],iceTransportPolicy:"relay"}:{};e.bundlePolicy=this.context.browserBehavior.requiresBundlePolicy(),e.sdpSemantics="unified-plan",this.context.peer?this.context.logger.info("reusing peer connection"):(this.context.logger.info("creating new peer connection"),this.context.peer=new RTCPeerConnection(e),this.addPeerConnectionEventLogger()),this.removeTrackAddedEventListener=()=>{this.context.peer&&this.context.peer.removeEventListener("track",this.trackAddedHandler),this.removeTrackAddedEventListener=null},this.context.peer.addEventListener("track",this.trackAddedHandler)}))}trackIsVideoInput(e){return!!this.context.transceiverController.useTransceivers()&&(this.logger.debug((()=>"getting video track type")),this.context.transceiverController.trackIsVideoInput(e))}addRemoteVideoTrack(e,t){var n;const i=t.id,r=this.context.videoStreamIndex.attendeeIdForTrack(i);let a,o;if(this.context.videoTileController.getVideoTileForAttendeeId?(o=this.context.videoTileController.getVideoTileForAttendeeId(r),a=!!(null===(n=null==o?void 0:o.state())||void 0===n?void 0:n.boundVideoStream)):a=this.context.videoTileController.haveVideoTileForAttendeeId(r),a)return void this.context.logger.info(`Not adding remote track. Already have tile for attendeeId: ${r}`);o||(o=this.context.videoTileController.addVideoTile(),this.logger.info(`Created video tile ${o.id()}`));let s,c,l=this.context.videoStreamIndex.streamIdForTrack(i);void 0===l&&(this.logger.warn(`stream not found for tile=${o.id()} track=${i}`),l=null);for(let n=0;n{this.context.logger.info(`received the ${i} event for tile=${o.id()} id=${e.id} streamId=${l}`),"ended"===i&&this.removeRemoteVideoTrack(e,o.state())};t.addEventListener(i,n),this.removeVideoTrackEventListeners[e.id]||(this.removeVideoTrackEventListeners[e.id]=[]),this.removeVideoTrackEventListeners[e.id].push((()=>{t.removeEventListener(i,n)}))}}if(e.getSettings){const t=e.getSettings();s=t.width,c=t.height}else{const t=e.getCapabilities();s=t.width,c=t.height}const u=this.context.videoStreamIndex.externalUserIdForTrack(i);o.bindVideoStream(r,!1,t,s,c,l,u),this.logger.info(`video track added, use tile=${o.id()} track=${i} streamId=${l}`);const d="removetrack",h=t,f=()=>this.removeRemoteVideoTrack(e,o.state());this.removeTrackRemovedEventListeners[e.id]=()=>{h.removeEventListener(d,f),delete this.removeTrackRemovedEventListeners[e.id]},h.addEventListener(d,f)}removeRemoteVideoTrack(e,t){if(this.removeTrackRemovedEventListeners.hasOwnProperty(e.id)){this.removeTrackRemovedEventListeners[e.id]();for(const t of this.removeVideoTrackEventListeners[e.id])t();delete this.removeVideoTrackEventListeners[e.id]}this.logger.info(`video track ended, removing tile=${t.tileId} id=${e.id} stream=${t.streamId}`),t.streamId?this.context.videosPaused.remove(t.streamId):this.logger.warn(`no stream found for tile=${t.tileId}`),this.context.videoTileController.removeVideoTile(t.tileId)}}t.default=a,a.REMOVE_HANDLER_INTERVAL_MS=1e4},1129:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5687),a=n(326),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="CreateSDPTask"}cancel(){if(this.cancelPromise){const e=new Error(`canceling ${this.name()}`);this.cancelPromise(e),delete this.cancelPromise}}sessionUsesAudio(){var e,t;return!!(null===(t=null===(e=this.context.meetingSessionConfiguration)||void 0===e?void 0:e.urls)||void 0===t?void 0:t.audioHostURL)}sessionUsesVideo(){let e;e=this.context.transceiverController.useTransceivers()?this.context.transceiverController.hasVideoInput():this.context.videoTileController.hasStartedLocalVideoTile();const t=!!this.context.videosToReceive&&!this.context.videosToReceive.empty(),n=e||t;return this.context.logger.info(`uses video: ${n} (enabled: true, sending: ${e}, receiving: ${t})`),n}run(){return i(this,void 0,void 0,(function*(){const e={offerToReceiveAudio:this.sessionUsesAudio(),offerToReceiveVideo:this.sessionUsesVideo()};this.logger.info(`peer connection offerOptions: ${JSON.stringify(e)}`),yield new Promise(((t,n)=>i(this,void 0,void 0,(function*(){this.cancelPromise=e=>{n(e)};try{if(this.context.sdpOfferInit=yield this.context.peer.createOffer(e),this.context.logger.info("peer connection created offer"),this.context.previousSdpOffer&&new a.default(this.context.sdpOfferInit.sdp).videoSendSectionHasDifferentSSRC(this.context.previousSdpOffer)){const e=new Error(`canceling ${this.name()} due to the meeting status code: ${r.default.IncompatibleSDP}`);return this.context.previousSdpOffer=null,void n(e)}t()}catch(e){n(e)}finally{delete this.cancelPromise}}))))}))}}t.default=s},6240:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5687),a=n(326),o=n(1789);class s extends o.default{constructor(e,t=s.CHROME_VPN_TIMEOUT_MS){super(e.logger),this.context=e,this.chromeVpnTimeoutMs=t,this.taskName="FinishGatheringICECandidatesTask"}removeEventListener(){this.context.peer&&(this.context.peer.removeEventListener("icecandidate",this.context.iceCandidateHandler),this.context.turnCredentials||this.context.peer.removeEventListener("icegatheringstatechange",this.context.iceGatheringStateEventHandler))}cancel(){let e;this.context.browserBehavior.requiresIceCandidateGatheringTimeoutWorkaround()&&this.chromeVpnTimeoutMsthis.chromeVpnTimeoutMs&&(e=new Error(`canceling ${this.name()} due to the meeting status code: ${r.default.ICEGatheringTimeoutWorkaround}`)),this.cancelPromise&&(e=e||new Error(`canceling ${this.name()}`),this.cancelPromise(e),delete this.cancelPromise)}run(){return i(this,void 0,void 0,(function*(){if(this.context.peer||this.logAndThrow("session does not have peer connection; bypass ice gathering"),this.context.browserBehavior.requiresCheckForSdpConnectionAttributes()){if(new a.default(this.context.peer.localDescription.sdp).hasCandidatesForAllMLines())return void this.context.logger.info(`ice gathering already complete; bypass gathering, current local description ${this.context.peer.localDescription.sdp}`)}else this.context.logger.info(`iOS device does not require checking for connection attributes in SDP, current local description ${this.context.peer.localDescription.sdp}`);if(!this.context.browserBehavior.hasFirefoxWebRTC()&&"complete"!==this.context.peer.iceGatheringState||!new a.default(this.context.peer.localDescription.sdp).hasCandidates())try{yield new Promise(((e,t)=>{this.cancelPromise=e=>{this.removeEventListener(),t(e)},this.context.turnCredentials||(this.context.iceGatheringStateEventHandler=()=>{if("complete"===this.context.peer.iceGatheringState)return this.removeEventListener(),e(),void delete this.cancelPromise},this.context.peer.addEventListener("icegatheringstatechange",this.context.iceGatheringStateEventHandler)),this.context.iceCandidateHandler=n=>{if(this.context.logger.info(`ice candidate: ${n.candidate?n.candidate.candidate:"(null)"} state: ${this.context.peer.iceGatheringState}`),n.candidate&&(a.default.isRTPCandidate(n.candidate.candidate)&&this.context.iceCandidates.push(n.candidate),this.context.turnCredentials&&this.context.iceCandidates.length>=1))return this.context.logger.info("gathered at least one relay candidate"),this.removeEventListener(),e(),void delete this.cancelPromise;"complete"===this.context.peer.iceGatheringState&&(this.context.logger.info("done gathering ice candidates"),this.removeEventListener(),new a.default(this.context.peer.localDescription.sdp).hasCandidates()&&0!==this.context.iceCandidates.length?(e(),delete this.cancelPromise):(t(new Error("no ice candidates were gathered")),delete this.cancelPromise))},this.context.peer.addEventListener("icecandidate",this.context.iceCandidateHandler),this.startTimestampMs=Date.now()}))}catch(e){throw e}finally{this.startTimestampMs&&(this.context.iceGatheringDurationMs=Math.round(Date.now()-this.startTimestampMs))}else this.context.logger.info("ice gathering state is complete and candidates are in SDP; bypass gathering")}))}}t.default=s,s.CHROME_VPN_TIMEOUT_MS=5e3},1960:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3789),a=n(5687),o=n(7215),s=n(7103),c=n(9416),l=n(2168),u=n(289),d=n(1789);class h extends d.default{constructor(e){super(e.logger),this.context=e,this.taskName="JoinAndReceiveIndexTask",this.taskCanceler=null}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){const e=yield new Promise(((e,t)=>{const n=this.context;n.turnCredentials=null;const i=new class{constructor(e){this.signalingClient=e}cancel(){this.signalingClient.removeObserver(this),t(new Error("JoinAndReceiveIndexTask got canceled while waiting for SdkIndexFrame"))}handleSignalingClientEvent(t){if(t.type===c.default.WebSocketClosed){let e=`The signaling connection was closed with code ${t.closeCode} and reason: ${t.closeReason}`;n.logger.warn(e);let i=a.default.SignalingBadRequest;return 4410===t.closeCode?(e="The meeting already ended.",n.logger.warn(e),i=a.default.MeetingEnded):t.closeCode>=4500&&t.closeCode<4600&&(i=a.default.SignalingInternalServerError),void n.audioVideoController.handleMeetingSessionStatus(new r.default(i),new Error(e))}if(t.type!==c.default.ReceivedSignalFrame)return;if(t.message.type===u.SdkSignalFrame.Type.JOIN_ACK){const e=t.message.joinack;if(e&&e.videoSubscriptionLimit&&(n.videoSubscriptionLimit=e.videoSubscriptionLimit),n.serverSupportsCompression=null==e?void 0:e.wantsCompressedSdp,void 0!==(null==e?void 0:e.defaultServerSideNetworkAdaption)&&e.defaultServerSideNetworkAdaption!==s.default.Default&&void 0!==n.videoDownlinkBandwidthPolicy.setServerSideNetworkAdaption){const t=e.defaultServerSideNetworkAdaption;n.logger.info(`Overriding server side network adaption value to ${t}`),n.videoDownlinkBandwidthPolicy.setServerSideNetworkAdaption(s.convertServerSideNetworkAdaptionEnumFromSignaled(t))}return void(e&&e.turnCredentials?(n.turnCredentials=new o.default,n.turnCredentials.username=e.turnCredentials.username,n.turnCredentials.password=e.turnCredentials.password,n.turnCredentials.ttl=e.turnCredentials.ttl,n.turnCredentials.uris=e.turnCredentials.uris.map((e=>n.meetingSessionConfiguration.urls.urlRewriter(e))).filter((e=>!!e))):n.logger.error("missing TURN credentials in JoinAckFrame"))}if(t.message.type!==u.SdkSignalFrame.Type.INDEX)return;this.signalingClient.removeObserver(this);const i=t.message.index;e(i)}}(this.context.signalingClient);this.context.signalingClient.registerObserver(i),this.taskCanceler=i,this.context.previousSdpAnswerAsString="",this.context.previousSdpOffer=null,this.context.serverSupportsCompression=!1;const d=new l.default(this.context.meetingSessionConfiguration.applicationMetadata);void 0!==this.context.videoDownlinkBandwidthPolicy.getServerSideNetworkAdaption&&void 0!==this.context.videoDownlinkBandwidthPolicy.supportedServerSideNetworkAdaptions&&(d.serverSideNetworkAdaption=this.context.videoDownlinkBandwidthPolicy.getServerSideNetworkAdaption(),d.supportedServerSideNetworkAdaptions=this.context.videoDownlinkBandwidthPolicy.supportedServerSideNetworkAdaptions()),this.context.signalingClient.join(d)}));this.context.logger.info(`received first index ${JSON.stringify(e)}`),this.context.indexFrame=e}))}}t.default=h},6180:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9416),a=n(289),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="LeaveAndReceiveLeaveAckTask",this.taskCanceler=null}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){this.context.signalingClient.ready()&&(this.context.signalingClient.leave(),this.context.logger.info("sent leave"),yield this.receiveLeaveAck())}))}receiveLeaveAck(){return new Promise(((e,t)=>{const n=new class{constructor(e,t){this.signalingClient=e,this.logger=t}cancel(){this.signalingClient.removeObserver(this),t(new Error("LeaveAndReceiveLeaveAckTask got canceled while waiting for IndexFrame"))}handleSignalingClientEvent(t){if(t.isConnectionTerminated())return this.signalingClient.removeObserver(this),this.logger.info("LeaveAndReceiveLeaveAckTask connection terminated"),void e();t.type===r.default.ReceivedSignalFrame&&t.message.type===a.SdkSignalFrame.Type.LEAVE_ACK&&(this.signalingClient.removeObserver(this),this.logger.info("got leave ack"),e())}}(this.context.signalingClient,this.context.logger);this.taskCanceler=n,this.context.signalingClient.registerObserver(n)}))}}t.default=s},2748:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9416),a=n(289),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="ListenForVolumeIndicatorsTask",this.realtimeMuteAndUnmuteHandler=e=>{this.context.signalingClient.mute(e)}}run(){return i(this,void 0,void 0,(function*(){this.context.removableObservers.push(this),this.context.signalingClient.registerObserver(this),this.context.realtimeController.realtimeSubscribeToMuteAndUnmuteLocalAudio(this.realtimeMuteAndUnmuteHandler)}))}removeObserver(){this.context.realtimeController.realtimeUnsubscribeToMuteAndUnmuteLocalAudio(this.realtimeMuteAndUnmuteHandler),this.context.signalingClient.removeObserver(this)}handleSignalingClientEvent(e){if(e.type===r.default.ReceivedSignalFrame)if(e.message.type===a.SdkSignalFrame.Type.AUDIO_STREAM_ID_INFO){const t=e.message.audioStreamIdInfo;this.context.volumeIndicatorAdapter.sendRealtimeUpdatesForAudioStreamIdInfo(t)}else if(e.message.type===a.SdkSignalFrame.Type.AUDIO_METADATA){const t=e.message.audioMetadata;this.context.volumeIndicatorAdapter.sendRealtimeUpdatesForAudioMetadata(t)}}}t.default=s},1981:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(6196),a=n(9496),o=n(2770),s=n(9708),c=n(1922),l=n(3789),u=n(5687),d=n(9416),h=n(289),f=n(9880),p=n(8660),m=n(1789);class g extends m.default{constructor(e,t,n){super(e.logger),this.context=e,this.initialConnectionHealthData=n,this.taskName="MonitorTask",this.prevSignalStrength=1,this.currentVideoDownlinkBandwidthEstimationKbps=1e4,this.currentAvailableStreamAvgBitrates=null,this.hasSignalingError=!1,this.presenceHandlerCalled=!1,this.isResubscribeCheckPaused=!1,this.pendingMetricsReport=void 0,this.checkAndSendWeakSignalEvent=e=>{const t=e<1,n=this.prevSignalStrength<1,i=t?n?null:f.default.RedmicStartLoss:n?f.default.RedmicEndLoss:null;i&&this.context.statsCollector.logAudioEvent(i),this.prevSignalStrength=e},this.realtimeFatalErrorCallback=e=>{this.logger.error(`realtime error: ${e}: ${e.stack}`),this.context.audioVideoController.handleMeetingSessionStatus(new l.default(u.default.RealtimeApiFailed),e)},this.realtimeAttendeeIdPresenceHandler=(e,t)=>{var n;const i=this.context.meetingSessionConfiguration.credentials.attendeeId;this.logger.info(`attendeePresenceReceived: ${i}`),i===e&&t&&!this.presenceHandlerCalled&&(this.presenceHandlerCalled=!0,this.context.attendeePresenceDurationMs=Date.now()-this.context.startAudioVideoTimestamp,null===(n=this.context.eventController)||void 0===n||n.publishEvent("attendeePresenceReceived",{attendeePresenceDurationMs:this.context.attendeePresenceDurationMs}))},this.generateAudioVideoEventAttributes=()=>{const{signalingOpenDurationMs:e,poorConnectionCount:t,startTimeMs:n,iceGatheringDurationMs:i,attendeePresenceDurationMs:r,meetingStartDurationMs:a}=this.context;return{maxVideoTileCount:this.context.maxVideoTileCount,meetingDurationMs:null===n?0:Math.round(Date.now()-n),signalingOpenDurationMs:e,iceGatheringDurationMs:i,attendeePresenceDurationMs:r,poorConnectionCount:t,meetingStartDurationMs:a}},this.reconnectionHealthPolicy=new s.default(e.logger,Object.assign({},t),this.initialConnectionHealthData.clone()),this.unusableAudioWarningHealthPolicy=new c.default(Object.assign({},t),this.initialConnectionHealthData.clone())}removeObserver(){this.context.audioVideoController.removeObserver(this),this.context.realtimeController.realtimeUnsubscribeToFatalError(this.realtimeFatalErrorCallback),this.context.realtimeController.realtimeUnsubscribeToLocalSignalStrengthChange(this.checkAndSendWeakSignalEvent),this.context.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(this.realtimeAttendeeIdPresenceHandler),this.context.signalingClient.removeObserver(this)}run(){return i(this,void 0,void 0,(function*(){this.context.removableObservers.push(this),this.context.audioVideoController.addObserver(this),this.context.realtimeController.realtimeSubscribeToFatalError(this.realtimeFatalErrorCallback),this.context.realtimeController.realtimeSubscribeToLocalSignalStrengthChange(this.checkAndSendWeakSignalEvent),this.context.realtimeController.realtimeSubscribeToAttendeeIdPresence(this.realtimeAttendeeIdPresenceHandler),this.context.connectionMonitor.start(),this.context.statsCollector.start(this.context.signalingClient,this.context.videoStreamIndex),this.context.signalingClient.registerObserver(this)}))}pauseResubscribeCheck(){this.isResubscribeCheckPaused=!0}resumeResubscribeCheck(){this.isResubscribeCheckPaused&&(this.isResubscribeCheckPaused=!1,this.pendingMetricsReport&&(this.context.logger.info("Resuming resubscribe check with pending metrics report"),this.checkResubscribe(this.pendingMetricsReport)&&this.context.audioVideoController.update({needsRenegotiation:!1})))}videoTileDidUpdate(e){this.context.maxVideoTileCount=Math.max(this.context.maxVideoTileCount,this.context.videoTileController.getAllVideoTiles().length)}checkResubscribe(e){if(this.isResubscribeCheckPaused)return this.context.logger.info("Resubscribe check is paused, setting incoming client metric report as pending"),void(this.pendingMetricsReport=e);this.pendingMetricsReport=void 0;const t=e.getObservableMetrics();if(!t)return!1;const n=t.availableOutgoingBitrate,i=t.nackCountReceivedPerSecond;let r=!1;this.context.videoDownlinkBandwidthPolicy.updateMetrics(e);const a=this.context.videoDownlinkBandwidthPolicy.wantsResubscribe();if(r=r||a,a){const e=this.context.videoDownlinkBandwidthPolicy.chooseSubscriptions();this.context.videosToReceive=e.truncate(this.context.videoSubscriptionLimit),e.size()>this.context.videosToReceive.size()&&this.logger.warn(`Video receive limit exceeded. Limiting the videos to ${this.context.videosToReceive.size()}. Please consider using AllHighestVideoBandwidthPolicy or VideoPriorityBasedPolicy along with chooseRemoteVideoSources api to select the video sources to be displayed.`),this.logger.info(`trigger resubscribe for down=${a}; videosToReceive=[${this.context.videosToReceive.array()}]`)}if(this.context.videoTileController.hasStartedLocalVideoTile()){this.context.videoUplinkBandwidthPolicy.updateConnectionMetric({uplinkKbps:n/1e3,nackCountPerSecond:i});const e=this.context.videoUplinkBandwidthPolicy.wantsResubscribe();r=r||e,e&&(this.logger.info(`trigger resubscribe for up=${e}; videosToReceive=[${this.context.videosToReceive.array()}]`),this.context.videoUplinkBandwidthPolicy.chooseEncodingParameters(),this.context.videoUplinkBandwidthPolicy.chooseMediaTrackConstraints())}return r}metricsDidReceive(e){const t=e;if(!t)return;if(this.checkResubscribe(e)&&this.context.audioVideoController.update({needsRenegotiation:!1}),!this.currentAvailableStreamAvgBitrates)return;const n=t.streamMetricReports;if(!n)return;const i=e.getObservableMetrics();this.currentVideoDownlinkBandwidthEstimationKbps=i.availableIncomingBitrate;const s=new Map,c=new Map;for(const e in n)n[e].mediaType===a.default.VIDEO&&n[e].direction===r.default.DOWNSTREAM&&s.set(n[e].streamId,n[e]);let l=!1;for(const e of this.currentAvailableStreamAvgBitrates.bitrates)if(s.has(e.sourceStreamId)){const t=s.get(e.sourceStreamId),n=this.context.videoStreamIndex.attendeeIdForStreamId(e.sourceStreamId);if(!n)continue;const i=new o.default,r=t.previousMetrics.bytesReceived,a=t.currentMetrics.bytesReceived;if(!r||!a)continue;const u=8*(a-r)/1e3;i.expectedAverageBitrateKbps=e.avgBitrateBps/1e3,i.receivedAverageBitrateKbps=u,i.attendeeId=n,u{p.Maybe.of(e.connectionDidSuggestStopVideo).map((t=>t.bind(e)()))})):this.context.audioVideoController.forEachObserver((e=>{p.Maybe.of(e.connectionDidBecomePoor).map((t=>t.bind(e)()))}))}else this.context.audioVideoController.forEachObserver((e=>{p.Maybe.of(e.connectionDidBecomeGood).map((t=>t.bind(e)()))}))}handleBitrateFrame(e){let t=0;this.currentAvailableStreamAvgBitrates=e,this.logger.debug((()=>`simulcast: bitrates from server ${JSON.stringify(e)}`));for(const n of e.bitrates)this.context.videosToReceive.contain(n.sourceStreamId)&&(t+=n.avgBitrateBps);t/=1e3,this.currentVideoDownlinkBandwidthEstimationKbps*g.DEFAULT_DOWNLINK_CALLRATE_OVERSHOOT_FACTOR=4500&&e.closeCode<4600)||e.type===d.default.WebSocketError||e.type===d.default.WebSocketFailed){if(!this.hasSignalingError){const e=this.generateAudioVideoEventAttributes();null===(t=this.context.eventController)||void 0===t||t.publishEvent("signalingDropped",e),this.hasSignalingError=!0}}else e.type===d.default.WebSocketOpen&&(this.hasSignalingError=!1);if(e.type===d.default.ReceivedSignalFrame){if(e.message.bitrates){const t=e.message.bitrates;this.context.videoStreamIndex.integrateBitratesFrame(t),this.context.videoDownlinkBandwidthPolicy.updateIndex(this.context.videoStreamIndex),this.handleBitrateFrame(e.message.bitrates)}const t=l.default.fromSignalFrame(e.message);e.message.type!==h.SdkSignalFrame.Type.PRIMARY_MEETING_JOIN_ACK&&t.statusCode()!==u.default.OK&&this.context.audioVideoController.handleMeetingSessionStatus(t,null)}}}t.default=g,g.DEFAULT_DOWNLINK_CALLRATE_OVERSHOOT_FACTOR=2,g.DEFAULT_DOWNLINK_CALLRATE_UNDERSHOOT_FACTOR=.2},8831:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{cancel(){}name(){return"NoOpTask"}run(){return Promise.resolve()}setParent(e){}}},1124:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(813),r=n(7797);t.default=class{constructor(e,t,n){this.logger=e,this.task=t,this.dependencies=n,this.canceled=!1}name(){return`${this.task.name()} (once)`}cancel(){if(!this.canceled){if(this.dependencies)for(const e of this.dependencies)e.cancel();this.logger.info(`Canceling ${this.name()}`),r.default.nextTick((()=>this.task.cancel())),this.canceled=!0,this.cancelPromise&&r.default.nextTick((()=>this.cancelPromise(new Error(`canceling ${this.name()}`))))}}logDependencies(){if(this.logger.getLogLevel()>i.default.INFO)return;if(!this.dependencies)return;const e=this.dependencies.filter((e=>e)).map((e=>e.name())).join(", ");this.logger.info(`${this.task.name()} waiting for dependencies: ${e}`)}run(){if(this.promise)return this.promise;const e=this.dependencies?Promise.all(this.dependencies.map((e=>null==e?void 0:e.run()))):Promise.resolve();return this.logDependencies(),this.ongoing=e.then((()=>this.task.run())),this.promise=new Promise(((e,t)=>{this.cancelPromise=t,this.ongoing.then(e).catch(t)}))}setParent(e){this.task.setParent(e)}}},4543:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3920),a=n(9416),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="OpenSignalingConnectionTask",this.taskCanceler=null}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){const e=this.context.meetingSessionConfiguration;this.context.signalingClient.openConnection(new r.default(e.urls.signalingURL,e.credentials.joinToken));const t=Date.now();try{yield new Promise(((e,t)=>{const n=new class{constructor(e){this.signalingClient=e}cancel(){this.signalingClient.removeObserver(this),t(new Error("OpenSignalingConnectionTask got canceled while waiting to open signaling connection"))}handleSignalingClientEvent(n){switch(n.type){case a.default.WebSocketOpen:this.signalingClient.removeObserver(this),e();break;case a.default.WebSocketFailed:this.signalingClient.removeObserver(this),t(new Error("WebSocket connection failed"))}}}(this.context.signalingClient);this.context.signalingClient.registerObserver(n),this.taskCanceler=n}))}catch(e){throw e}finally{this.context.signalingOpenDurationMs=Math.round(Date.now()-t),this.logger.info(`Opening signaling connection took ${this.context.signalingOpenDurationMs} ms`)}}))}}t.default=s},8556:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1789);class a extends r.default{constructor(e,t,n){super(e),this.taskName=t,this.tasksToRunParallel=n;for(const e of n)e.setParent(this)}cancel(){for(const e of this.tasksToRunParallel)this.logger.info(`canceling parallel group task ${this.name()} subtask ${e.name()}`),e.cancel()}run(){return i(this,void 0,void 0,(function*(){const e=[];for(const t of this.tasksToRunParallel)this.logger.info(`parallel group task ${this.name()} running subtask ${t.name()}`),e.push(t.run());const t=[];for(let n=0;n0){const e=t.join(", ");this.logAndThrow(`parallel group task ${this.name()} failed for tasks: ${e}`)}this.logger.info(`parallel group task ${this.name()} completed`)}))}}t.default=a},9945:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3204),a=n(9416),o=n(289),s=n(1789);class c extends s.default{constructor(e,t,n){super(e.logger),this.context=e,this.credentials=t,this.completionCallback=n,this.taskName="PromoteToPrimaryMeetingTask",this.taskCanceler=null}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){this.context.signalingClient.ready()?(this.context.signalingClient.promoteToPrimaryMeeting(this.credentials),this.context.logger.info("Sent request to join primary meeting"),yield this.receivePrimaryMeetingJoinAck()):this.completionCallback(new r.MeetingSessionStatus(r.MeetingSessionStatusCode.SignalingRequestFailed))}))}receivePrimaryMeetingJoinAck(){return new Promise(((e,t)=>{const n=new class{constructor(e,t,n){this.signalingClient=e,this.completionCallback=t,this.logger=n}cancel(){this.signalingClient.removeObserver(this),this.completionCallback(new r.MeetingSessionStatus(r.MeetingSessionStatusCode.SignalingRequestFailed)),e()}handleSignalingClientEvent(t){t.isConnectionTerminated()&&(this.signalingClient.removeObserver(this),this.logger.info("PromoteToPrimaryMeetingTask connection terminated"),this.completionCallback(new r.MeetingSessionStatus(r.MeetingSessionStatusCode.SignalingRequestFailed)),e()),t.type===a.default.ReceivedSignalFrame&&t.message.type===o.SdkSignalFrame.Type.PRIMARY_MEETING_JOIN_ACK&&(this.signalingClient.removeObserver(this),this.logger.info("Got a primary meeting join ACK"),this.completionCallback(r.MeetingSessionStatus.fromSignalFrame(t.message)),e())}}(this.context.signalingClient,this.completionCallback,this.context.logger);this.taskCanceler=n,this.context.signalingClient.registerObserver(n)}))}}t.default=c},1209:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1789);class a extends r.default{constructor(e){super(e.logger),this.context=e,this.taskName="ReceiveAudioInputTask"}run(){var e,t;return i(this,void 0,void 0,(function*(){if(!(null===(t=null===(e=this.context.meetingSessionConfiguration)||void 0===e?void 0:e.urls)||void 0===t?void 0:t.audioHostURL))return void this.context.logger.info("No audio connection: not acquiring audio input");if(this.context.activeAudioInput)return void this.context.logger.info("an active audio input exists");let n;try{n=yield this.context.mediaStreamBroker.acquireAudioInputStream()}catch(e){this.context.logger.warn("could not acquire audio input from current device")}n?this.context.activeAudioInput=n:this.context.logger.warn("an audio input is not available")}))}}t.default=a},5547:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5687),a=n(7215),o=n(214),s=n(4046),c=n(1789);class l extends c.default{constructor(e){super(e.logger),this.context=e,this.taskName="ReceiveTURNCredentialsTask",this.url=e.meetingSessionConfiguration.urls.turnControlURL,this.meetingId=e.meetingSessionConfiguration.meetingId,this.joinToken=e.meetingSessionConfiguration.credentials.joinToken}cancel(){if(this.cancelPromise){const e=new Error(`canceling ${this.name()}`);this.cancelPromise(e),delete this.cancelPromise}}run(){return i(this,void 0,void 0,(function*(){if(this.context.turnCredentials)return void this.context.logger.info("TURN credentials available, skipping credentials fetch");if(this.context.logger.error("missing TURN credentials - falling back to fetch"),!this.url)return void this.context.logger.info("TURN control url not supplied, skipping credentials fetch");const e={method:"POST",mode:"cors",cache:"no-cache",credentials:"omit",headers:{"Content-Type":"application/json","X-Chime-Auth-Token":"_aws_wt_session="+new o.default(this.joinToken).base()},redirect:"follow",referrer:"no-referrer",body:JSON.stringify({meetingId:this.meetingId})};this.context.logger.info(`requesting TURN credentials from ${this.url}`);const t=yield new Promise(((t,n)=>i(this,void 0,void 0,(function*(){this.cancelPromise=e=>{n(e)};try{const i=yield fetch(s.default.urlWithVersion(this.url),e);if(this.context.logger.info("received TURN credentials"),i.status&&403===i.status)return void n(new Error(`canceling ${this.name()} due to the meeting status code: ${r.default.TURNCredentialsForbidden}`));if(i.status&&404===i.status)return void n(new Error(`canceling ${this.name()} due to the meeting status code: ${r.default.MeetingEnded}`));t(yield i.json())}catch(e){n(e)}finally{delete this.cancelPromise}}))));this.context.turnCredentials=new a.default,this.context.turnCredentials.password=t.password,this.context.turnCredentials.ttl=t.ttl,this.context.turnCredentials.uris=t.uris.map((e=>this.context.meetingSessionConfiguration.urls.urlRewriter(e))).filter((e=>!!e)),this.context.turnCredentials.username=t.username}))}}t.default=l},120:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(214),a=n(289),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="ReceiveVideoInputTask"}run(){return i(this,void 0,void 0,(function*(){const e=this.context.videoDuplexMode===a.SdkStreamServiceType.RX||this.context.videoDuplexMode===a.SdkStreamServiceType.DUPLEX;if(this.context.videoTileController.hasStartedLocalVideoTile()?this.context.videoDuplexMode=e?a.SdkStreamServiceType.DUPLEX:a.SdkStreamServiceType.TX:this.context.videoDuplexMode=e?a.SdkStreamServiceType.RX:0,this.context.videoCaptureAndEncodeParameter=this.context.videoUplinkBandwidthPolicy.chooseCaptureAndEncodeParameters(),!this.context.videoTileController.hasStartedLocalVideoTile())return this.context.logger.info("has not started local video tile"),void(this.context.activeVideoInput&&(this.context.activeVideoInput=void 0,this.context.videoStreamIndex.integrateUplinkPolicyDecision([])));const t=this.context.videoTileController.getLocalVideoTile();let n;try{n=yield this.context.mediaStreamBroker.acquireVideoInputStream()}catch(e){this.context.logger.warn("could not acquire video input from current device"),this.context.videoTileController.stopLocalVideoTile()}if(this.context.enableSimulcast){const e=this.context.videoUplinkBandwidthPolicy.chooseEncodingParameters();this.context.videoStreamIndex.integrateUplinkPolicyDecision(Array.from(e.values()))}if(this.context.activeVideoInput=n,n){const e=n.getVideoTracks();if(!e||0===e.length)return;const i=this.context.meetingSessionConfiguration.credentials.attendeeId,a=new r.default(i).hasModality(r.default.MODALITY_CONTENT),o=e[0].getSettings();if(this.context.enableSimulcast&&!a){const t=this.context.videoUplinkBandwidthPolicy.chooseMediaTrackConstraints();this.context.logger.info(`simulcast: choose constraint ${JSON.stringify(t)}`);try{yield e[0].applyConstraints(t)}catch(e){this.context.logger.info("simulcast: pass video without more constraint")}}const s=this.context.audioVideoController.configuration.credentials.externalUserId;t.bindVideoStream(i,!0,n,o.width,o.height,null,s);for(let t=0;t{const n=new a.default(e.attendeeId);return!(n.base()===t&&n.hasModality(a.default.MODALITY_CONTENT))}));const{videoStreamIndex:n,videoDownlinkBandwidthPolicy:i,videoUplinkBandwidthPolicy:r}=this.context,o=n.allVideoSendingSourcesExcludingSelf(t);n.integrateIndexFrame(e),i.updateIndex(n),r.updateIndex(n),this.resubscribe(i,r),this.updateVideoAvailability(e),this.handleIndexVideosPausedAtSource(),e.supportedReceiveCodecIntersection.length>0&&this.handleSupportedVideoReceiveCodecIntersection(e);const s=n.allVideoSendingSourcesExcludingSelf(t);this.areVideoSourcesEqual(o,s)||this.context.audioVideoController.forEachObserver((e=>{l.Maybe.of(e.remoteVideoSourcesDidChange).map((t=>t.bind(e)(s)))}))}areVideoSourcesEqual(e,t){if(e.length!==t.length)return!1;const n=(e,t)=>e.attendee.attendeeId.localeCompare(t.attendee.attendeeId),i=[...e].sort(n),r=[...t].sort(n);for(let e=0;ethis.context.videosToReceive.size()&&this.logger.warn(`Video receive limit exceeded. Limiting the videos to ${this.context.videosToReceive.size()}. Please consider using AllHighestVideoBandwidthPolicy or VideoPriorityBasedPolicy along with chooseRemoteVideoSources api to select the video sources to be displayed.`),this.context.videoCaptureAndEncodeParameter=t.chooseCaptureAndEncodeParameters(),this.logger.info(`trigger resubscribe for up=${i} down=${n}; videosToReceive=[${this.context.videosToReceive.array()}] captureParams=${JSON.stringify(this.context.videoCaptureAndEncodeParameter)}`),this.context.audioVideoController.update({needsRenegotiation:!1})}updateVideoAvailability(e){if(!this.context.videosToReceive)return void this.logger.error("videosToReceive must be set in the meeting context.");const t=new r.default;t.remoteVideoAvailable=!this.context.videosToReceive.empty(),t.canStartLocalVideo=!e.atCapacity,this.context.lastKnownVideoAvailability&&this.context.lastKnownVideoAvailability.equal(t)||(this.context.lastKnownVideoAvailability=t.clone(),this.context.audioVideoController.forEachObserver((e=>{l.Maybe.of(e.videoAvailabilityDidChange).map((n=>n.bind(e)(t.clone())))})))}handleSupportedVideoReceiveCodecIntersection(e){if(void 0===this.context.videoSendCodecPreferences)return;const t=[];let n=!1;for(const i of this.context.videoSendCodecPreferences){for(const n of e.supportedReceiveCodecIntersection)if(i.equals(o.default.fromSignaled(n))){t.push(i);break}i.equals(this.context.currentVideoSendCodec)&&(n=!0)}t.length>0?this.context.meetingSupportedVideoSendCodecPreferences=t:(this.logger.warn("Interesection of meeting receive codec support and send codec preferences has no overlap, falling back to just values provided in `setVideoCodecSendPreferences`"),this.context.meetingSupportedVideoSendCodecPreferences=void 0),n&&this.context.audioVideoController.update({needsRenegotiation:!0})}handleIndexVideosPausedAtSource(){const e=this.context.videoStreamIndex.streamsPausedAtSource();for(const t of this.context.videoTileController.getAllVideoTiles()){const n=t.state();e.contain(n.streamId)?t.markPoorConnection()&&this.logger.info(`marks the tile ${n.tileId} as having a poor connection`):t.unmarkPoorConnection()&&this.logger.info(`unmarks the tile ${n.tileId} as having a poor connection`)}}}t.default=d},4191:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1789);class r extends i.default{constructor(e,t,n="RunnableTask"){super(e),this.fn=t,this.taskName=n}run(){return this.fn().then((()=>{}))}}t.default=r},9485:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1018),a=n(9416),o=n(289),s=n(1789);class c extends s.default{constructor(e){super(e.logger),this.context=e,this.taskName="SendAndReceiveDataMessagesTask",this.sendDataMessageHandler=(e,t,n)=>{if(this.context.signalingClient.ready()){let i;i=t instanceof Uint8Array?t:"string"==typeof t?(new TextEncoder).encode(t):(new TextEncoder).encode(JSON.stringify(t)),this.validateDataMessage(e,i,n);const r=o.SdkDataMessagePayload.create();r.topic=e,r.lifetimeMs=n,r.data=i;const a=o.SdkDataMessageFrame.create();a.messages=[r],this.context.signalingClient.sendDataMessage(a)}else this.context.logger.error("Signaling client is not ready")}}run(){return i(this,void 0,void 0,(function*(){this.context.removableObservers.push(this),this.context.signalingClient.registerObserver(this),this.context.realtimeController.realtimeSubscribeToSendDataMessage(this.sendDataMessageHandler)}))}removeObserver(){this.context.realtimeController.realtimeUnsubscribeFromSendDataMessage(this.sendDataMessageHandler),this.context.signalingClient.removeObserver(this)}handleSignalingClientEvent(e){if(e.type===a.default.ReceivedSignalFrame&&e.message.type===o.SdkSignalFrame.Type.DATA_MESSAGE)for(const t of e.message.dataMessage.messages){const e=new r.default(t.ingestTimeNs/1e6,t.topic,t.data,t.senderAttendeeId,t.senderExternalUserId,0===t.ingestTimeNs);this.context.realtimeController.realtimeReceiveDataMessage(e)}}validateDataMessage(e,t,n){if(!c.TOPIC_REGEX.test(e))throw new Error("Invalid topic");if(t.length>c.DATA_SIZE)throw new Error("Data size has to be less than 2048 bytes");if(n&&n<0)throw new Error("The life time of the message has to be non negative")}}t.default=c,c.TOPIC_REGEX=new RegExp(/^[a-zA-Z0-9_-]{1,36}$/),c.DATA_SIZE=2048},7079:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1789),a=n(4456);class o extends r.default{constructor(e,t,n){super(e),this.taskName=t,this.tasksToRunSerially=n,this.currentTask=null;for(const e of n)e.setParent(this)}cancel(){this.currentTask&&(this.logger.info(`canceling serial group task ${this.name()} subtask ${this.currentTask.name()}`),this.currentTask.cancel())}run(){return i(this,void 0,void 0,(function*(){for(const e of this.tasksToRunSerially){this.getStatus()===a.default.CANCELED&&this.logAndThrow(`serial group task ${this.name()} was canceled`);try{this.logger.info(`serial group task ${this.name()} running subtask ${e.name()}`),this.currentTask=e,yield e.run(),this.logger.info(`serial group task ${this.name()} completed subtask ${e.name()}`)}catch(e){this.logAndThrow(`serial group task ${this.name()} was canceled due to subtask ${this.currentTask.name()} error: ${e.message}`)}finally{this.currentTask=null}}this.logger.info(`serial group task ${this.name()} completed`)}))}}t.default=o},4833:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543),a=n(326),o=n(1789);class s extends o.default{constructor(e){super(e.logger),this.context=e,this.taskName="SetLocalDescriptionTask"}cancel(){if(this.cancelPromise){const e=new Error(`canceling ${this.name()}`);this.cancelPromise(e),delete this.cancelPromise}}run(){return i(this,void 0,void 0,(function*(){const e=this.context.peer;let t=this.context.sdpOfferInit.sdp;this.context.browserBehavior.supportsVideoLayersAllocationRtpHeaderExtension()&&(t=new a.default(t).withVideoLayersAllocationRtpHeaderExtension(this.context.previousSdpOffer).sdp),(new r.default).requiresDisablingH264Encoding()&&(t=new a.default(t).removeH264SupportFromSendSection().sdp),void 0!==this.context.videoSendCodecPreferences&&this.context.videoSendCodecPreferences.length>0&&(t=new a.default(t).withVideoSendCodecPreferences(void 0!==this.context.meetingSupportedVideoSendCodecPreferences?this.context.meetingSupportedVideoSendCodecPreferences:this.context.videoSendCodecPreferences).sdp),this.context.audioProfile&&(t=new a.default(t).withAudioMaxAverageBitrate(this.context.audioProfile.audioBitrateBps).sdp,this.context.audioProfile.isStereo()&&(t=new a.default(t).withStereoAudio().sdp)),this.logger.debug((()=>`local description is >>>${t}<<<`));const n={type:"offer",sdp:t,toJSON:null};yield new Promise(((t,r)=>i(this,void 0,void 0,(function*(){this.cancelPromise=e=>{r(e)};try{yield e.setLocalDescription(n),t()}catch(e){r(e)}finally{delete this.cancelPromise}})))),this.context.logger.info("set local description")}))}}t.default=s},5275:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(326),a=n(1789);class o extends a.default{constructor(e){super(e.logger),this.context=e,this.taskName="SetRemoteDescriptionTask"}cancel(){this.cancelICEPromise&&this.cancelICEPromise()}run(){return i(this,void 0,void 0,(function*(){this.context.peer||this.logAndThrow("session does not have peer connection; bypass set remote description");let e=this.context.sdpAnswer;e=new r.default(e).withoutServerReflexiveCandidates().sdp,this.context.audioProfile&&(e=new r.default(e).withAudioMaxAverageBitrate(this.context.audioProfile.audioBitrateBps).sdp,this.context.audioProfile.isStereo()&&(e=new r.default(e).withStereoAudio().sdp)),void 0!==this.context.videoSendCodecPreferences&&this.context.videoSendCodecPreferences.length>0&&(e=new r.default(e).withVideoSendCodecPreferences(void 0!==this.context.meetingSupportedVideoSendCodecPreferences?this.context.meetingSupportedVideoSendCodecPreferences:this.context.videoSendCodecPreferences).sdp,this.context.currentVideoSendCodec=new r.default(e).highestPriorityVideoSendCodec()),this.logger.info(`processed remote description is >>>${e}<<<`);const t={type:"answer",sdp:e,toJSON:null};try{yield this.createICEConnectionCompletedPromise(t)}catch(e){throw e}}))}createICEConnectionCompletedPromise(e){return new Promise(((t,n)=>i(this,void 0,void 0,(function*(){const i=()=>{"connected"!==this.context.peer.iceConnectionState&&"completed"!==this.context.peer.iceConnectionState||(this.context.peer.removeEventListener("iceconnectionstatechange",i),t())};this.cancelICEPromise=()=>{this.context.peer&&this.context.peer.removeEventListener("iceconnectionstatechange",i),n(new Error(`${this.name()} got canceled while waiting for the ICE connection state`))},this.context.peer.addEventListener("iceconnectionstatechange",i);try{yield this.context.peer.setRemoteDescription(e),this.logger.info("set remote description, waiting for ICE connection"),i()}catch(e){n(e)}}))))}}t.default=o},5924:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3789),a=n(5687),o=n(326),s=n(3320),c=n(7103),l=n(9416),u=n(6729),d=n(9101),h=n(289),f=n(1789);class p extends f.default{constructor(e){super(e.logger),this.context=e,this.taskName="SubscribeAndReceiveSubscribeAckTask",this.taskCanceler=null,this.textCompressor=new s.default(e.logger)}cancel(){this.taskCanceler&&(this.taskCanceler.cancel(),this.taskCanceler=null)}run(){return i(this,void 0,void 0,(function*(){let e="";if(this.context.peer&&this.context.peer.localDescription&&(e=new o.default(this.context.peer.localDescription.sdp).withUnifiedPlanFormat().sdp),!this.context.enableSimulcast){let e=0,t=0;this.context.videoCaptureAndEncodeParameter&&(e=this.context.videoCaptureAndEncodeParameter.captureFrameRate(),t=this.context.videoCaptureAndEncodeParameter.encodeBitrates()[0]);const n={rid:"hi",maxBitrate:1e3*t,maxFramerate:e,active:!0};this.context.videoStreamIndex.integrateUplinkPolicyDecision([n])}this.context.videoStreamIndex.subscribeFrameSent();const t=this.fixUpSubscriptionOrder(e,this.context.videoSubscriptions),n=this.context.videoDuplexMode===h.SdkStreamServiceType.TX||this.context.videoDuplexMode===h.SdkStreamServiceType.DUPLEX;let i;const r=e;if(this.context.serverSupportsCompression){const t=this.context.previousSdpOffer?this.context.previousSdpOffer.sdp:"";i=this.textCompressor.compress(r,t),this.context.logger.info(`Compressed the SDP message from ${r.length} to ${i.length} bytes.`),e=""}this.context.previousSdpOffer=new o.default(r);const a=new u.default(this.context.meetingSessionConfiguration.credentials.attendeeId,e,this.context.meetingSessionConfiguration.urls.audioHostURL,this.context.realtimeController.realtimeIsLocalAudioMuted(),!1,t,n,this.context.videoStreamIndex.localStreamDescriptions(),!0,i);void 0!==this.context.videoDownlinkBandwidthPolicy.getServerSideNetworkAdaption&&this.context.videoDownlinkBandwidthPolicy.getServerSideNetworkAdaption()!==c.default.None&&void 0!==this.context.videoDownlinkBandwidthPolicy.getVideoPreferences&&(a.videoSubscriptionConfiguration=this.convertVideoPreferencesToVideoSubscriptionConfiguration(t,this.context.videoDownlinkBandwidthPolicy.getVideoPreferences())),this.context.logger.info(`sending subscribe: ${JSON.stringify(a)}`),this.context.signalingClient.subscribe(a);const s=yield this.receiveSubscribeAck();this.context.logger.info(`got subscribe ack: ${JSON.stringify(s)}`);let l="";s.compressedSdpAnswer&&s.compressedSdpAnswer.length?(l=this.textCompressor.decompress(s.compressedSdpAnswer,this.context.previousSdpAnswerAsString),0===l.length&&(this.context.sdpAnswer="",this.context.previousSdpAnswerAsString="",this.logAndThrow("Error occurred while trying to decompress the SDP answer.")),this.context.logger.info(`Decompressed the SDP message from ${s.compressedSdpAnswer.length} to ${l.length} bytes.`),this.context.sdpAnswer=l):this.context.sdpAnswer=s.sdpAnswer,this.context.previousSdpAnswerAsString=this.context.sdpAnswer,this.context.videoStreamIndex.integrateSubscribeAckFrame(s)}))}fixUpSubscriptionOrder(e,t){if(void 0===this.context.transceiverController.getMidForStreamId)return t;const n=new Map;for(const e of t){const t=this.context.transceiverController.getMidForStreamId(e);void 0!==t?n.set(t,e):0!==e&&this.logger.warn(`Could not find MID for stream ID: ${e}`)}const i=new o.default(e).mediaSections(),r=[];for(const e of i)if("video"===e.mediaType)if("recvonly"===e.direction){const t=n.get(e.mid);if(void 0===t){this.logger.warn(`Could not find stream ID for MID: ${e.mid}`);continue}r.push(t)}else r.push(0);return this.logger.info(`Fixed up ${JSON.stringify(t)} to ${JSON.stringify(r)} (may be same))}`),r}convertVideoPreferencesToVideoSubscriptionConfiguration(e,t){if(void 0===this.context.transceiverController.getMidForStreamId||void 0===t)return[];const n=new Array,i=new Map,r=new Map;for(const t of e){const e=this.context.transceiverController.getMidForStreamId(t);if(void 0===e){0!==t&&this.context.logger.warn(`Could not find MID for stream ID: ${t}`);continue}const n=this.context.videoStreamIndex.attendeeIdForStreamId(t);i.set(n,e),r.set(n,this.context.videoStreamIndex.groupIdForStreamId(t))}for(const e of t){const t=new d.default,a=i.get(e.attendeeId);void 0!==a?(t.mid=a,t.attendeeId=e.attendeeId,t.groupId=r.get(e.attendeeId),t.priority=Number.MAX_SAFE_INTEGER-e.priority,t.targetBitrateKbps=e.targetSizeToBitrateKbps(e.targetSize),n.push(t)):this.context.logger.warn(`Could not find MID for attendee ID: ${e.attendeeId}`)}return n}receiveSubscribeAck(){return new Promise(((e,t)=>{const n=this.context,i=new class{constructor(e){this.signalingClient=e}cancel(){this.signalingClient.removeObserver(this),t(new Error("SubscribeAndReceiveSubscribeAckTask got canceled while waiting for SdkSubscribeAckFrame"))}handleSignalingClientEvent(t){if(t.isConnectionTerminated()){const e=`SubscribeAndReceiveSubscribeAckTask connection was terminated with code ${t.closeCode} and reason: ${t.closeReason}`;n.logger.warn(e);let i=a.default.TaskFailed;return t.closeCode>=4500&&t.closeCode<4600&&(i=a.default.SignalingInternalServerError),void n.audioVideoController.handleMeetingSessionStatus(new r.default(i),new Error(e))}if(t.type!==l.default.ReceivedSignalFrame||t.message.type!==h.SdkSignalFrame.Type.SUBSCRIBE_ACK)return;this.signalingClient.removeObserver(this);const i=t.message.suback;e(i)}}(this.context.signalingClient);this.context.signalingClient.registerObserver(i),this.taskCanceler=i}))}}t.default=p},4456:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.IDLE="IDLE",e.RUNNING="RUNNING",e.CANCELED="CANCELED",e.FINISHED="FINISHED"}(n||(n={})),t.default=n},250:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(4929),a=n(1789);class o extends a.default{constructor(e,t,n){super(e),this.taskToRunBeforeTimeout=t,this.timeoutMs=n,this.taskName=`Timeout${this.timeoutMs}ms`,t.setParent(this)}cancel(){this.logger.info(`canceling timeout task ${this.name()} subtask ${this.taskToRunBeforeTimeout}`),this.taskToRunBeforeTimeout.cancel()}run(){return i(this,void 0,void 0,(function*(){const e=new r.default(this.timeoutMs);e.start((()=>{this.logger.info(`timeout reached for task ${this.name()}`),this.taskToRunBeforeTimeout.cancel()}));try{yield this.taskToRunBeforeTimeout.run()}finally{e.stop()}this.logger.info(`timeout task ${this.name()} completed`)}))}}t.default=o},6171:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5687),a=n(1789);class o extends a.default{constructor(e){super(e.logger),this.context=e,this.taskName="WaitForAttendeePresenceTask"}cancel(){if(this.cancelPromise){const e=new Error(`canceling ${this.name()} due to the meeting status code: ${r.default.NoAttendeePresent}`);this.cancelPromise(e),delete this.cancelPromise}}run(){return i(this,void 0,void 0,(function*(){const e=this.context.meetingSessionConfiguration.credentials.attendeeId;return new Promise(((t,n)=>{const i=(n,r,a,o,s)=>{e===n&&r&&(this.context.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(i),t(),delete this.cancelPromise)};this.cancelPromise=e=>{this.context.realtimeController.realtimeUnsubscribeToAttendeeIdPresence(i),n(e)},this.context.realtimeController.realtimeSubscribeToAttendeeIdPresence(i)}))}))}}t.default=o},365:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){this.logger=e,this.browserBehavior=t,this._localCameraTransceiver=null,this._localAudioTransceiver=null,this.videoSubscriptions=[],this.defaultMediaStream=null,this.peer=null,this.streamIdToTransceiver=new Map}setEncodingParameters(e){return n(this,void 0,void 0,(function*(){if(!this._localCameraTransceiver||"sendrecv"!==this._localCameraTransceiver.direction)return;const t=this._localCameraTransceiver.sender;if(!e||0===e.size)return;const n=Array.from(e.values()),i=t.getParameters();if(i.encodings&&0!==i.encodings.length)for(const e of i.encodings)for(const t of n){if((e.rid||t.rid)&&e.rid!==t.rid)continue;let n;for(n in t)"rid"!==n&&"codecPayloadType"!==n&&t.hasOwnProperty(n)&&(e[n]=t[n])}else i.encodings=n;yield t.setParameters(i)}))}localAudioTransceiver(){return this._localAudioTransceiver}localVideoTransceiver(){return this._localCameraTransceiver}setVideoSendingBitrateKbps(e){return n(this,void 0,void 0,(function*(){if(!this._localCameraTransceiver||"sendrecv"!==this._localCameraTransceiver.direction)return;const t=this._localCameraTransceiver.sender;if(!t||e<=0)return;const n=t.getParameters();n.encodings||(n.encodings=[{}]);for(const t of n.encodings)t.maxBitrate=1e3*e;yield t.setParameters(n)}))}setPeer(e){this.peer=e}reset(){this._localCameraTransceiver=null,this._localAudioTransceiver=null,this.videoSubscriptions=[],this.defaultMediaStream=null,this.peer=null}useTransceivers(){return!!this.peer&&void 0!==this.peer.getTransceivers}hasVideoInput(){return!(!this._localCameraTransceiver||"sendrecv"!==this._localCameraTransceiver.direction)}trackIsVideoInput(e){return!!this._localCameraTransceiver&&(e===this._localCameraTransceiver.sender.track||e===this._localCameraTransceiver.receiver.track)}setupLocalTransceivers(){this.useTransceivers()&&(this.defaultMediaStream||"undefined"==typeof MediaStream||(this.defaultMediaStream=new MediaStream),this._localAudioTransceiver||(this._localAudioTransceiver=this.peer.addTransceiver("audio",{direction:"inactive",streams:[this.defaultMediaStream]})),this._localCameraTransceiver||(this._localCameraTransceiver=this.peer.addTransceiver("video",{direction:"inactive",streams:[this.defaultMediaStream]})))}replaceAudioTrack(e){return n(this,void 0,void 0,(function*(){return this._localAudioTransceiver&&"sendrecv"===this._localAudioTransceiver.direction?(yield this._localAudioTransceiver.sender.replaceTrack(e),!0):(this.logger.info("audio transceiver direction is not set up or not activated"),!1)}))}setAudioInput(e){return n(this,void 0,void 0,(function*(){yield this.setTransceiverInput(this._localAudioTransceiver,e)}))}setVideoInput(e){return n(this,void 0,void 0,(function*(){yield this.setTransceiverInput(this._localCameraTransceiver,e)}))}updateVideoTransceivers(e,t){if(!this.useTransceivers())return t.array();const n=this.peer.getTransceivers();return this.videoSubscriptions=[0],t=t.clone(),this.updateTransceivers(n,e,t),this.logger.debug((()=>this.debugDumpTransceivers())),this.videoSubscriptions}updateTransceivers(e,t,n){const i=n.array();0===e.length||e[0].stop?0!==e.length&&this.updateTransceiverWithStop(e,t,i):(this.logger.info("Updating transceivers without `stop` function"),this.updateTransceiverWithoutStop(e,t,i));for(const e of i){const t=this.peer.addTransceiver("video",{direction:"recvonly",streams:[new MediaStream]});this.streamIdToTransceiver.set(e,t),this.videoSubscriptions.push(e),this.logger.info(`adding transceiver mid: ${t.mid} subscription: ${e} direction: recvonly`)}}updateTransceiverWithStop(e,t,n){let i=1;this.videoSubscriptions=[0];for(const r of e){if(r===this._localCameraTransceiver||!this.transceiverIsVideo(r)||!r.mid)continue;let e=!1;const a=t.streamIdForTrack("v_"+r.mid);if("inactive"!==r.direction&&void 0!==a)for(const[o,s]of n.entries())if(t.StreamIdsInSameGroup(a,s)){r.direction="recvonly",this.videoSubscriptions[i]=s,e=!0,this.streamIdToTransceiver.delete(a),this.streamIdToTransceiver.set(s,r),n.splice(o,1);break}if(!e){this.videoSubscriptions[i]=0,this.logger.info(`Stopping MID: ${r.mid}, direction: ${r.direction}, current direction: ${r.currentDirection}`),r.stop();for(const[e,t]of this.streamIdToTransceiver.entries())r.mid===t.mid&&this.streamIdToTransceiver.delete(e)}i+=1}}updateTransceiverWithoutStop(e,t,n){let i=1;for(const r of e)if(r!==this._localCameraTransceiver&&this.transceiverIsVideo(r)){if(this.videoSubscriptions[i]=0,"inactive"!==r.direction){const e=t.streamIdForTrack("v_"+r.mid);if(void 0!==e)for(const[a,o]of n.entries())if(t.StreamIdsInSameGroup(e,o)){r.direction="recvonly",this.videoSubscriptions[i]=o,this.streamIdToTransceiver.delete(e),this.streamIdToTransceiver.set(o,r),n.splice(a,1);break}}i+=1}i=1;for(const t of e)if(t!==this._localCameraTransceiver&&this.transceiverIsVideo(t)){if("inactive"===t.direction&&n.length>0){t.direction="recvonly";const e=n.shift();this.videoSubscriptions[i]=e,this.streamIdToTransceiver.set(e,t)}else if(0===this.videoSubscriptions[i]){t.direction="inactive";for(const[e,n]of this.streamIdToTransceiver.entries())t===n&&this.streamIdToTransceiver.delete(e)}i+=1}}getMidForStreamId(e){var t;return null===(t=this.streamIdToTransceiver.get(e))||void 0===t?void 0:t.mid}setStreamIdForMid(e,t){for(const[n,i]of this.streamIdToTransceiver.entries())if(i.mid===e)return this.streamIdToTransceiver.delete(n),void this.streamIdToTransceiver.set(t,i)}transceiverIsVideo(e){return e.receiver&&e.receiver.track&&"video"===e.receiver.track.kind||e.sender&&e.sender.track&&"video"===e.sender.track.kind}debugDumpTransceivers(){let e="",t=0;for(const n of this.peer.getTransceivers())this.transceiverIsVideo(n)&&(e+=`transceiver index=${t} mid=${n.mid} subscription=${this.videoSubscriptions[t]} direction=${n.direction}\n`,t+=1);return e}setTransceiverInput(e,t){return n(this,void 0,void 0,(function*(){e&&(e.direction=t?"sendrecv":"inactive",yield e.sender.replaceTrack(t))}))}}},7377:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(5785);class a extends r.default{constructor(e,t){super(e,t);let n=2;this.videoQualityControlParameterMap=new Map;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(365);class r extends i.default{constructor(e,t){super(e,t)}setupLocalTransceivers(){this.useTransceivers()&&(this.defaultMediaStream||"undefined"==typeof MediaStream||(this.defaultMediaStream=new MediaStream),this._localCameraTransceiver||(this._localCameraTransceiver=this.peer.addTransceiver("video",{direction:"inactive",streams:[this.defaultMediaStream]})))}}t.default=r},5308:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TRANSCRIPTION_DATA_MESSAGE_TOPIC=void 0;const i=n(1877);t.TRANSCRIPTION_DATA_MESSAGE_TOPIC="aws:chime:transcription",t.default=class{constructor(e){this.realtimeController=e,this.transcriptEventCallbacks=new Set}subscribeToTranscriptEvent(e){0===this.transcriptEventCallbacks.size&&this.realtimeController.realtimeSubscribeToReceiveDataMessage(t.TRANSCRIPTION_DATA_MESSAGE_TOPIC,(e=>{for(const t of i.TranscriptEventConverter.from(e))for(const e of this.transcriptEventCallbacks)e(t)})),this.transcriptEventCallbacks.add(e)}unsubscribeFromTranscriptEvent(e){this.transcriptEventCallbacks.delete(e),0===this.transcriptEventCallbacks.size&&this.realtimeController.realtimeUnsubscribeFromReceiveDataMessage(t.TRANSCRIPTION_DATA_MESSAGE_TOPIC)}}},4739:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},2471:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},7210:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},1877:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TranscriptEventConverter=void 0;const i=n(289),r=n(4739),a=n(1288),o=n(1326),s=n(6864),c={[i.SdkTranscriptionStatus.Type.STARTED]:o.default.STARTED,[i.SdkTranscriptionStatus.Type.INTERRUPTED]:o.default.INTERRUPTED,[i.SdkTranscriptionStatus.Type.RESUMED]:o.default.RESUMED,[i.SdkTranscriptionStatus.Type.STOPPED]:o.default.STOPPED,[i.SdkTranscriptionStatus.Type.FAILED]:o.default.FAILED};t.TranscriptEventConverter=class{static from(e){let t;try{t=i.SdkTranscriptFrame.decode(e.data)}catch(e){throw new Error("Cannot decode transcript data message: "+e)}const n=[];for(const e of t.events)if(e.status){const t=c[e.status.type];if(!t)continue;const i=new a.default;i.type=t,i.eventTimeMs=e.status.eventTime,i.transcriptionRegion=e.status.transcriptionRegion,i.transcriptionConfiguration=e.status.transcriptionConfiguration,e.status.message&&(i.message=e.status.message),n.push(i)}else if(e.transcript){const t=new r.default;t.results=[];for(const n of e.transcript.results){const e={channelId:n.channelId,isPartial:n.isPartial,resultId:n.resultId,startTimeMs:n.startTime,endTimeMs:n.endTime,alternatives:[]};if(n.languageCode&&(e.languageCode=n.languageCode),n.languageIdentification&&n.languageIdentification.length>0){e.languageIdentification=[];for(const t of n.languageIdentification){const n={languageCode:t.languageCode,score:t.score};e.languageIdentification.push(n)}}for(const t of n.alternatives){const n={items:[],transcript:t.transcript};for(const e of t.items){const t={content:e.content,attendee:{attendeeId:e.speakerAttendeeId,externalUserId:e.speakerExternalUserId},startTimeMs:e.startTime,endTimeMs:e.endTime,type:null};switch(e.vocabularyFilterMatch&&(t.vocabularyFilterMatch=e.vocabularyFilterMatch),e.hasOwnProperty("stable")&&(t.stable=e.stable),e.hasOwnProperty("confidence")&&(t.confidence=e.confidence),e.type){case i.SdkTranscriptItem.Type.PRONUNCIATION:t.type=s.default.PRONUNCIATION;break;case i.SdkTranscriptItem.Type.PUNCTUATION:t.type=s.default.PUNCTUATION}n.items.push(t)}for(const e of t.entities){n.entities||(n.entities=[]);const t={category:e.category,confidence:e.confidence,content:e.content,startTimeMs:e.startTime,endTimeMs:e.endTime};e.type&&(t.type=e.type),n.entities.push(t)}e.alternatives.push(n)}t.results.push(e)}n.push(t)}return n}}},1741:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},6864:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.PRONUNCIATION="pronunciation",e.PUNCTUATION="punctuation"}(n||(n={})),t.default=n},9063:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},5323:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},1288:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},1326:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.STARTED="started",e.INTERRUPTED="interrupted",e.RESUMED="resumed",e.STOPPED="stopped",e.FAILED="failed"}(n||(n={})),t.default=n},8627:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2238),r=n(4046);class a{constructor(e){var t,n,r,o,s,c,l;try{this.parserResult=navigator&&navigator.userAgent?new i.UAParser(navigator.userAgent).getResult():void 0}catch(t){e.error(t.message)}this.browserMajorVersion=(null===(r=null===(n=null===(t=this.parserResult)||void 0===t?void 0:t.browser)||void 0===n?void 0:n.version)||void 0===r?void 0:r.split(".")[0])||a.UNAVAILABLE,this.browserName=(null===(o=this.parserResult)||void 0===o?void 0:o.browser.name)||a.UNAVAILABLE,this.browserVersion=(null===(s=this.parserResult)||void 0===s?void 0:s.browser.version)||a.UNAVAILABLE,this.deviceName=[(null===(c=this.parserResult)||void 0===c?void 0:c.device.vendor)||"",(null===(l=this.parserResult)||void 0===l?void 0:l.device.model)||""].join(" ").trim()||a.UNAVAILABLE}getParserResult(){var e,t;return{browserMajorVersion:this.browserMajorVersion,browserName:this.browserName,browserVersion:this.browserVersion,deviceName:this.deviceName,osName:(null===(e=this.parserResult)||void 0===e?void 0:e.os.name)||a.UNAVAILABLE,osVersion:(null===(t=this.parserResult)||void 0===t?void 0:t.os.version)||a.UNAVAILABLE,sdkVersion:r.default.sdkVersion,sdkName:r.default.sdkName}}}t.default=a,a.UNAVAILABLE="Unavailable"},1515:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.queue=Promise.resolve()}add(e){return new Promise(((t,n)=>{this.queue=this.queue.then(e).then(t).catch(n)}))}}},8660:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.None=t.Some=t.Maybe=void 0;class n{static of(e){return null==e?r.of():i.of(e)}}t.Maybe=n;class i{constructor(e){this.value=e,this.isSome=!0,this.isNone=!1}map(e){return n.of(e(this.value))}flatMap(e){return e(this.value)}get(){return this.value}getOrElse(e){return this.value}defaulting(e){return n.of(this.getOrElse(e))}static of(e){if(null==e)throw new Error("value is ${value}");return new i(e)}}t.Some=i;class r{constructor(){this.isSome=!1,this.isNone=!0}get(){throw new Error("value is null")}getOrElse(e){return e}map(e){return new r}flatMap(e){return new r}defaulting(e){return n.of(this.getOrElse(e))}static of(){return new r}}t.None=r},8690:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toLowerCasePropertyNames=t.isIFramed=t.wait=void 0,t.wait=function(e){return new Promise((t=>setTimeout(t,e)))},t.isIFramed=function(){var e;try{return"IFRAME"===(null===(e=window.frameElement)||void 0===e?void 0:e.nodeName)||parent!==top}catch(e){return!0}},t.toLowerCasePropertyNames=function e(t){return null===t?null:"object"!=typeof t?t:Array.isArray(t)?t.map(e):Object.keys(t).reduce(((n,i)=>{const r=t[i],a="object"==typeof r?e(r):r;return n[i.toLowerCase()]=a,n}),{})}},4046:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(543),r=n(2336);class a{static get sdkName(){return"amazon-chime-sdk-js"}static get sdkVersion(){return r.default.semverString}static get sdkVersionSemVer(){var e,t,n,i;const a=r.default.semverString.match(/^(?[0-9]+)\.(?[0-9]+)((?:\.(?[0-9]+))(?:-(?[a-zA-Z]+(\.[0-9])*))?)?/);return{major:null===(e=null==a?void 0:a.groups)||void 0===e?void 0:e.major,minor:null===(t=null==a?void 0:a.groups)||void 0===t?void 0:t.minor,patch:null===(n=null==a?void 0:a.groups)||void 0===n?void 0:n.patch,preRelease:null===(i=null==a?void 0:a.groups)||void 0===i?void 0:i.preRelease}}static get buildSHA(){return r.default.hash.substr(1)}static get sdkUserAgentLowResolution(){const e=new i.default;return`${e.name()}-${e.majorVersion()}`}static urlWithVersion(e){const t=new URL(e);return t.searchParams.append(a.X_AMZN_VERSION,a.sdkVersion),t.searchParams.append(a.X_AMZN_USER_AGENT,a.sdkUserAgentLowResolution),t.toString()}}t.default=a,a.X_AMZN_VERSION="X-Amzn-Version",a.X_AMZN_USER_AGENT="X-Amzn-User-Agent"},2336:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={hash:"8ebe622",raw:"v3.6.0",semverString:"3.6.0"}},1133:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e,t,n,i,r,a=1){this.cameraWidth=e,this.cameraHeight=t,this.cameraFrameRate=n,this.maxEncodeBitrateKbps=i,this.isSimulcast=r,this.scaleResolutionDownBy=a}equal(e){let t=e.captureWidth()===this.cameraWidth&&e.captureHeight()===this.cameraHeight&&e.captureFrameRate()===this.cameraFrameRate&&e.encodeBitrates().length===this.encodeBitrates().length&&e.encodeScaleResolutionDownBy().length===this.encodeScaleResolutionDownBy().length&&e.encodeWidths().length===this.encodeWidths().length&&e.encodeHeights().length===this.encodeHeights().length;if(t)for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1508);t.default=class{constructor(e){this.selfAttendeeId=e,this.reset()}reset(){this.optimalReceiveSet=new i.default,this.subscribedReceiveSet=new i.default,this.videoSources=void 0}updateIndex(e){this.videoIndex=e,this.optimalReceiveSet=this.calculateOptimalReceiveSet(e)}updateMetrics(e){}wantsResubscribe(){return!this.subscribedReceiveSet.equal(this.optimalReceiveSet)}chooseSubscriptions(){return this.subscribedReceiveSet=this.optimalReceiveSet.clone(),this.subscribedReceiveSet.clone()}chooseRemoteVideoSources(e){this.videoSources=e,this.optimalReceiveSet=this.calculateOptimalReceiveSet(this.videoIndex).clone()}calculateOptimalReceiveSet(e){const t=new i.default;if(!this.videoIndex||this.videoIndex.allStreams().empty())return t;const n=e.highestQualityStreamFromEachGroupExcludingSelf(this.selfAttendeeId);if(void 0===this.videoSources)return n;const r=this.videoIndex.remoteStreamDescriptions(),a=new Map;for(const e of r)n.contain(e.streamId)&&a.set(e.attendeeId,e.streamId);for(const e of this.videoSources){const n=e.attendee.attendeeId;a.has(n)&&t.add(a.get(n))}return t}}},5319:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1508);t.default=class{reset(){}updateIndex(e){}updateMetrics(e){}wantsResubscribe(){return!1}chooseSubscriptions(){return new i.default}}},2721:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TargetDisplaySize=void 0,function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(n=t.TargetDisplaySize||(t.TargetDisplaySize={})),t.default=n},2880:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8890),r=n(1754),a=n(1819),o=n(4992);class s extends o.default{constructor(e){super(e),this.logger=e,super.shouldPauseTiles=!1,this.videoPreferences=void 0}reset(){super.reset(),super.shouldPauseTiles=!1,this.videoPreferences=void 0}updateIndex(e){super.updateIndex(e);const t=a.VideoPreferences.prepare();let n=!1;const o=e.remoteStreamDescriptions();for(const e of o)t.some((t=>t.attendeeId===e.attendeeId))||(e.attendeeId.endsWith(i.default.Modality)?(t.add(new r.default(e.attendeeId,1)),n=!0):t.add(new r.default(e.attendeeId,2)));n?(this.videoPreferences=t.build(),this.videoPreferencesUpdated=!0):this.videoPreferences=void 0}chooseRemoteVideoSources(e){this.logger.error("chooseRemoteVideoSources should not be called by VideoAdaptiveProbePolicy")}}t.default=s},1754:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(2721);class r{constructor(e,t,n){this.attendeeId=e,this.priority=t,this.targetSize=void 0!==n?n:i.default.High}partialCompare(e){return this.priority-e.priority}equals(e){return this.attendeeId===e.attendeeId&&this.targetSize===e.targetSize&&this.priority===e.priority}clone(){return new r(this.attendeeId,this.priority,this.targetSize)}targetSizeToBitrateKbps(e){switch(e){case i.default.High:return r.HIGH_BITRATE_KBPS;case i.default.Medium:return r.MID_BITRATE_KBPS;case i.default.Low:return r.LOW_BITRATE_KBPS}}}t.default=r,r.LOW_BITRATE_KBPS=300,r.MID_BITRATE_KBPS=600,r.HIGH_BITRATE_KBPS=1200},1819:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VideoPreferences=t.MutableVideoPreferences=void 0;class n{constructor(e=[]){this.items=e}static default(){return new n([])}[Symbol.iterator](){let e=0;const t=this.items;return{next:()=>e!t.equals(e)))}clear(){this.items=[]}isEmpty(){return 0===this.items.length}equals(e){if(e===this)return!0;if(e.items.length!==this.items.length)return!1;for(const t of this.items)if(!e.items.some((e=>e.equals(t))))return!1;return!0}has(e){return this.items.some((t=>t.equals(e)))}some(e){return this.items.some(e)}clone(){return new n([...this.items])}sort(){this.items.sort(((e,t)=>e.partialCompare(t)))}modify(){return new i(this)}}class i{constructor(e=new n){this.items=e,this.copied=!1}cow(){this.copied||(this.items=this.items.clone(),this.copied=!0)}add(e){this.items.has(e)||(this.cow(),this.items.add(e))}replaceFirst(e,t){this.items.has(e)&&!this.items.some(t)||(this.cow(),this.items.replaceFirst(e,t))}remove(e){this.items.has(e)&&(this.cow(),this.items.remove(e))}some(e){return this.items.some(e)}clear(){this.items.isEmpty()||(this.cow(),this.items.clear())}build(){return this.copied&&this.items.sort(),this.copied=!1,this.items}}class r{constructor(e){this.builder=e}add(e){this.builder.add(e)}replaceFirst(e,t){this.builder.replaceFirst(e,t)}remove(e){this.builder.remove(e)}some(e){return this.builder.some(e)}clear(){this.builder.clear()}build(){return new a(this.builder.build())}}t.MutableVideoPreferences=r;class a{constructor(e){this.items=e}static prepare(){return new r(new i)}static default(){return new a(n.default())}[Symbol.iterator](){return this.items[Symbol.iterator]()}highestPriority(){var e;return null===(e=this.items.first())||void 0===e?void 0:e.priority}sorted(){return this.items[Symbol.iterator]()}equals(e){return e===this||this.items.equals(e.items)}modify(){return new r(this.items.modify())}some(e){return this.items.some(e)}isEmpty(){return this.items.isEmpty()}clone(){const e=a.prepare();for(const t of this.items)e.add(t.clone());return e.build()}}t.VideoPreferences=a,t.default=a},4992:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(6196),r=n(9496),a=n(8890),o=n(813),s=n(7103),c=n(1508),l=n(2721),u=n(1754),d=n(1819),h=n(1034);class f{constructor(){this.bandwidthEstimateKbps=0,this.usedBandwidthKbps=0,this.packetsLost=0,this.nackCount=0,this.rttMs=0}}class p{constructor(e,t=h.default.Default){this.logger=e,this.videoPriorityBasedPolicyConfig=t,this.shouldPauseTiles=!0,this.observerQueue=new Set,this.pausedBwAttendeeIds=new Set,this.reset()}reset(){this.optimalReceiveSet=new c.default,this.optimalReceiveStreams=[],this.optimalNonPausedReceiveStreams=[],this.subscribedReceiveSet=new c.default,this.subscribedReceiveStreams=[],this.videoPreferences=void 0,this.defaultVideoPreferences=void 0,this.shouldPauseTiles=!0,this.pausedStreamIds=new c.default,this.pausedBwAttendeeIds=new Set,this.videoPreferencesUpdated=!1,this.logCount=0,this.startupPeriod=!0,this.usingPrevTargetRate=!1,this.rateProbeState="Not Probing",this.firstEstimateTimestamp=0,this.lastUpgradeRateKbps=0,this.timeBeforeAllowSubscribeMs=p.MIN_TIME_BETWEEN_SUBSCRIBE_MS,this.lastProbeTimestamp=Date.now(),this.timeBeforeAllowProbeMs=p.MIN_TIME_BETWEEN_PROBE_MS,this.downlinkStats=new f,this.prevDownlinkStats=new f,this.probeFailed=!1,this.serverSideNetworkAdaption=this.videoPriorityBasedPolicyConfig.serverSideNetworkAdaption}bindToTileController(e){this.tileController=e,this.logger.info("tileController bound")}chooseRemoteVideoSources(e){var t;(null===(t=this.videoPreferences)||void 0===t?void 0:t.equals(e))||(this.videoPreferences=null==e?void 0:e.clone(),this.videoPreferencesUpdated=!0,this.logger.info(`bwe: setVideoPreferences bwe: new preferences: ${JSON.stringify(e)}`))}updateIndex(e){this.videoIndex=e,this.videoPreferences||this.updateDefaultVideoPreferences()}updateDefaultVideoPreferences(){const e=new Set;for(const t of this.videoIndex.remoteStreamDescriptions())e.add(t.attendeeId);const t=d.VideoPreferences.prepare(),n=e.size;let i=l.default.High;n>8?i=l.default.Low:n>4&&(i=l.default.Medium);for(const n of e)t.add(new u.default(n,1,i));this.defaultVideoPreferences=t.build()}updateMetrics(e){if(!this.videoIndex||this.videoIndex.allStreams().empty())return;this.prevDownlinkStats=this.downlinkStats,this.downlinkStats=new f;const t=e.getObservableMetrics();this.downlinkStats.bandwidthEstimateKbps=t.availableIncomingBitrate/1e3;for(const t in e.streamMetricReports){const n=Number.parseInt(t,10),a=e.streamMetricReports[n];a.direction===i.default.DOWNSTREAM&&a.mediaType===r.default.VIDEO&&(a.currentMetrics.hasOwnProperty("nackCount")&&(this.downlinkStats.nackCount+=e.countPerSecond("nackCount",n)),a.currentMetrics.hasOwnProperty("packetsLost")&&(this.downlinkStats.packetsLost+=e.countPerSecond("packetsLost",n)),a.currentMetrics.hasOwnProperty("bytesReceived")&&(this.downlinkStats.usedBandwidthKbps+=e.bitsPerSecond("bytesReceived",n)/1e3))}}wantsResubscribe(){return this.calculateOptimalReceiveSet(),!this.subscribedReceiveSet.equal(this.optimalReceiveSet)}chooseSubscriptions(){return this.subscribedReceiveSet.equal(this.optimalReceiveSet)||(this.lastSubscribeTimestamp=Date.now()),this.subscribedReceiveSet=this.optimalReceiveSet.clone(),this.subscribedReceiveStreams=this.optimalReceiveStreams.slice(),this.subscribedReceiveSet.clone()}addObserver(e){this.observerQueue.add(e)}removeObserver(e){this.observerQueue.delete(e)}forEachObserver(e){for(const t of this.observerQueue)e(t)}setVideoPriorityBasedPolicyConfigs(e){this.videoPriorityBasedPolicyConfig=e}calculateOptimalReceiveStreams(){var e;const t=[],n=this.videoIndex.remoteStreamDescriptions();if(0===n.length||(null===(e=this.videoPreferences)||void 0===e?void 0:e.isEmpty()))return void(this.optimalReceiveStreams=[]);const i=this.rateProbeState;this.cleanBwPausedTiles(n),this.handleAppPausedStreams(t,n);const r=this.availStreamsSameAsLast(n),c=!this.startupPeriod&&r;if(c&&Date.now()-this.lastSubscribeTimestampe.maxBitrateKbps===t.maxBitrateKbps?e.streamId-t.streamId:e.maxBitrateKbps-t.maxBitrateKbps));for(const e of n)(0===e.avgBitrateKbps||e.avgBitrateKbps>e.maxBitrateKbps)&&(e.attendeeId.endsWith(a.default.Modality)&&e.maxBitrateKbps<100?e.maxBitrateKbps=e.avgBitrateKbps:e.avgBitrateKbps=e.maxBitrateKbps);const l={targetDownlinkBitrate:0,chosenTotalBitrate:0,deltaToNextUpgrade:0};l.targetDownlinkBitrate=this.determineTargetRate();const u=this.subscribedReceiveSet.size(),d=this.downlinkStats.bandwidthEstimateKbps,h=!this.videoPriorityBasedPolicyConfig.allowSubscribe(u,d);if(this.probeFailed&&(this.probeFailed=!1,this.timeBeforeAllowSubscribeMs=p.MIN_TIME_BETWEEN_SUBSCRIBE_MS,c&&h))return;const f=this.priorityPolicy(l,n,t);let m=0;if(this.serverSideNetworkAdaption!==s.default.None&&this.serverSideNetworkAdaption!==s.default.Default||this.startupPeriod||!r?(this.setProbeState("Not Probing"),this.lastUpgradeRateKbps=0):"Probing"===this.rateProbeState?m=this.handleProbe(t,l.targetDownlinkBitrate):0!==l.deltaToNextUpgrade&&(m=this.maybeOverrideOrProbe(t,l,f)),this.prevRemoteInfos=n,this.videoPreferencesUpdated=!1,1===m)return this.logger.info(`bwe: keepSameSubscriptions stats:${JSON.stringify(this.downlinkStats)}`),void(this.prevTargetRateKbps=l.targetDownlinkBitrate);if(2===m){const e=this.calculateSubscribeRate(this.preProbeNonPausedReceiveStreams);return this.optimalReceiveStreams=this.preProbeReceiveStreams.slice(),this.processBwPausedStreams(n,this.preProbeNonPausedReceiveStreams),void this.logger.info("bwe: Use Pre-Probe subscription subscribedRate:"+e)}this.optimalNonPausedReceiveStreams=t.slice();const g=this.pausedBwAttendeeIds.size;this.processBwPausedStreams(n,t),this.logger.getLogLevel()<=o.LogLevel.INFO&&(this.logCount%15==0||this.rateProbeState!==i||this.optimalReceiveStreams.length!==t.length||g!==this.pausedBwAttendeeIds.size)&&(this.logger.info(this.policyStateLogStr(n,l.targetDownlinkBitrate)),this.logCount=0),this.logCount++,this.prevTargetRateKbps=l.targetDownlinkBitrate,this.optimalReceiveStreams=t.slice()}calculateOptimalReceiveSet(){const e=new c.default;this.calculateOptimalReceiveStreams();for(const t of this.optimalReceiveStreams)e.add(t.streamId);if(!this.optimalReceiveSet.equal(e)){const t=this.calculateSubscribeRate(this.optimalReceiveStreams);this.logger.info(`bwe: new streamSelection: ${JSON.stringify(e)} subscribedRate:${t}`)}this.optimalReceiveSet=e}determineTargetRate(){let e=0;const t=Date.now();return 0!==this.downlinkStats.bandwidthEstimateKbps?(0===this.firstEstimateTimestamp&&(this.firstEstimateTimestamp=t),this.startupPeriod&&(this.downlinkStats.bandwidthEstimateKbps>p.DEFAULT_BANDWIDTH_KBPS||this.downlinkStats.packetsLost>0||t-this.firstEstimateTimestamp>p.STARTUP_PERIOD_MS&&this.downlinkStats.bandwidthEstimateKbps<=this.prevDownlinkStats.bandwidthEstimateKbps)&&(this.startupPeriod=!1,this.prevTargetRateKbps=this.downlinkStats.bandwidthEstimateKbps),this.startupPeriod?e=p.DEFAULT_BANDWIDTH_KBPS:"Probing"===this.rateProbeState&&this.downlinkStats.usedBandwidthKbps>this.downlinkStats.bandwidthEstimateKbps&&this.downlinkStats.packetsLost"bwe: ValidateRate: Using Previous rate "+this.prevTargetRateKbps)),this.usingPrevTargetRate=!0,e=this.prevTargetRateKbps):this.usingPrevTargetRate=!1,e}setProbeState(e){if(this.rateProbeState===e)return!1;const t=Date.now();switch(e){case"Not Probing":this.probePendingStartTimestamp=0;break;case"Probe Pending":if(!(0===this.lastProbeTimestamp||t-this.lastProbeTimestamp>p.MIN_TIME_BETWEEN_PROBE_MS))return!1;this.probePendingStartTimestamp=t;break;case"Probing":if(!(t-this.probePendingStartTimestamp>this.timeBeforeAllowProbeMs))return!1;this.lastProbeTimestamp=t,this.preProbeReceiveStreams=this.subscribedReceiveStreams.slice(),this.preProbeNonPausedReceiveStreams=this.optimalNonPausedReceiveStreams,this.timeBeforeAllowProbeMs=Math.min(2*this.timeBeforeAllowProbeMs,p.MAX_HOLD_BEFORE_PROBE_MS)}return this.logger.info("bwe: setProbeState to "+e+" from "+this.rateProbeState),this.rateProbeState=e,!0}upgradeToStream(e,t){for(let n=0;np.MAX_ALLOWED_PROBE_TIME_MS)return this.logger.info("bwe: Canceling probe due to timeout"),this.setProbeState("Not Probing"),0;if(this.downlinkStats.packetsLost>0&&(this.logger.info(`bwe: Probe encountering packets lost:${this.downlinkStats.packetsLost}`),this.downlinkStats.packetsLost>p.SPURIOUS_PACKET_LOST_THRESHOLD))return this.setProbeState("Not Probing"),this.logger.info(`bwe: Canceling probe due to packets lost:${this.downlinkStats.packetsLost}`),this.probeFailed=!0,this.timeBeforeAllowSubscribeMs=3*Math.max(p.MIN_TIME_BETWEEN_SUBSCRIBE_MS,this.timeBeforeAllowSubscribeMs),2;const n=this.calculateSubscribeRate(this.optimalReceiveStreams);return this.chosenStreamsSameAsLast(e)||t>n?(this.logger.info("bwe: Probe successful"),this.setProbeState("Not Probing"),this.timeBeforeAllowProbeMs=p.MIN_TIME_BETWEEN_PROBE_MS,0):1}maybeOverrideOrProbe(e,t,n){const i=this.chosenStreamsSameAsLast(e);let r=0;const a=t.targetDownlinkBitrate>p.LOW_BITRATE_THRESHOLD_KBPS?p.TARGET_RATE_CHANGE_TRIGGER_PERCENT:2*p.TARGET_RATE_CHANGE_TRIGGER_PERCENT,o=t.targetDownlinkBitrate*a/100;if(this.targetRateBaselineForDeltaCheckKbps=void 0!==this.targetRateBaselineForDeltaCheckKbps?this.targetRateBaselineForDeltaCheckKbps:this.prevTargetRateKbps,!i&&Math.abs(t.targetDownlinkBitrate-this.targetRateBaselineForDeltaCheckKbps)this.prevDownlinkStats.packetsLost)return this.setProbeState("Not Probing"),this.lastUpgradeRateKbps=0,r;if(i||1===r)switch(this.rateProbeState){case"Not Probing":this.setProbeState("Probe Pending");break;case"Probe Pending":this.setProbeState("Probing")&&(this.upgradeToStream(e,n),r=0)}else this.setProbeState("Not Probing");return r}calculateSubscribeRate(e){let t=0;for(const n of e)this.pausedStreamIds.contain(n.streamId)||this.pausedBwAttendeeIds.has(n.attendeeId)||(t+=n.maxBitrateKbps);return t}handleAppPausedStreams(e,t){if(!this.tileController)return void this.logger.warn("tileController not found!");this.pausedStreamIds=new c.default;const n=this.tileController.getAllRemoteVideoTiles();for(const i of n){const n=i.state();if(n.paused&&!this.pausedBwAttendeeIds.has(n.boundAttendeeId)){let i=t.length;for(;i--;)t[i].attendeeId===n.boundAttendeeId&&(this.logger.info("bwe: removed paused attendee "+n.boundAttendeeId+" streamId: "+t[i].streamId),this.pausedStreamIds.add(t[i].streamId),this.subscribedReceiveSet.contain(t[i].streamId)&&e.push(t[i]),t.splice(i,1))}}}processBwPausedStreams(e,t){if(!this.tileController)return void this.logger.warn("tileController not found!");const n=this.getCurrentVideoPreferences();if(n&&this.shouldPauseTiles){const i=this.tileController.getAllVideoTiles();for(const r of n){const n=this.getVideoTileForAttendeeId(r.attendeeId,i),a=(null==n?void 0:n.state().paused)||!1;if(t.some((e=>e.attendeeId===r.attendeeId)))a&&this.pausedBwAttendeeIds.has(r.attendeeId)&&(this.logger.info(`bwe: unpausing attendee ${r.attendeeId} due to bandwidth`),this.forEachObserver((e=>{e.tileWillBeUnpausedByDownlinkPolicy(n.id())})),this.tileController.unpauseVideoTile(n.id()),this.pausedBwAttendeeIds.delete(r.attendeeId));else{const i=e.some((e=>e.attendeeId===r.attendeeId));if(n&&i){const e=this.optimalReceiveStreams.find((e=>e.attendeeId===r.attendeeId));void 0!==e&&(a||(this.logger.info(`bwe: pausing streamId ${e.streamId} attendee ${r.attendeeId} due to bandwidth`),this.forEachObserver((e=>{e.tileWillBePausedByDownlinkPolicy(n.id())})),this.tileController.pauseVideoTile(n.id())),t.push(e)),this.pausedBwAttendeeIds.add(r.attendeeId)}else if(i){const e=this.tileController.addVideoTile();e.bindVideoStream(r.attendeeId,!1,null,0,0,0,null),this.forEachObserver((t=>{t.tileWillBePausedByDownlinkPolicy(e.id())})),e.pause(),this.logger.info(`bwe: Created video tile ${e.id()} for bw paused attendee ${r.attendeeId}`),this.pausedBwAttendeeIds.add(r.attendeeId)}}}}}cleanBwPausedTiles(e){if(!this.tileController)return void this.logger.warn("tileController not found!");const t=this.tileController.getAllRemoteVideoTiles(),n=this.getCurrentVideoPreferences();for(const i of t){const t=i.state();t.boundVideoStream||(e.some((e=>e.attendeeId===t.boundAttendeeId))?void 0===n||n.some((e=>e.attendeeId===t.boundAttendeeId))||this.tileController.removeVideoTile(t.tileId):(this.tileController.removeVideoTile(t.tileId),this.logger.info(`bwe: Removed video tile ${t.tileId} for bw paused attendee ${t.boundAttendeeId}`)))}}priorityPolicy(e,t,n){let i;const r=this.getCurrentVideoPreferences(),o=r.highestPriority();let s,c=o;for(;-1!==c;){s=-1;for(const a of r)if(a.priority===c)for(const r of t)r.attendeeId===a.attendeeId&&(n.some((e=>e.groupId===r.groupId))||(e.chosenTotalBitrate+r.avgBitrateKbps<=e.targetDownlinkBitrate?(n.push(r),e.chosenTotalBitrate+=r.avgBitrateKbps):0===e.deltaToNextUpgrade&&(e.deltaToNextUpgrade=r.avgBitrateKbps,i=r)));else if(a.priority>c){s=a.priority;break}for(const o of r)if(o.priority===c){for(const r of t)if(r.attendeeId===o.attendeeId){const s=n.findIndex((e=>e.groupId===r.groupId&&e.maxBitrateKbpsc)break;if(c===o&&0!==e.deltaToNextUpgrade)break;c=s}return i}getVideoTileForAttendeeId(e,t){for(const n of t)if(n.state().boundAttendeeId===e)return n;return null}canUpgrade(e,t,n,i){let r=!1;return i?(t===l.default.High||t===l.default.Medium&&e<=n)&&(r=!0):e<=n&&(r=!0),r?(this.logger.info(`bwe: canUpgrade: bitrateKbp: ${e} targetBitrateKbp: ${n}`),!0):(this.logger.info(`bwe: cannot Upgrade: bitrateKbp: ${e} targetBitrateKbp: ${n}`),!1)}hasSimulcastStreams(e,t,n){let i=0;for(const r of e)r.attendeeId===t&&r.groupId===n&&i++;return this.logger.info(`bwe: attendeeId: ${t} groupId: ${n} hasSimulcastStreams: streamCount: ${i}`),i>1}availStreamsSameAsLast(e){if(void 0===this.prevRemoteInfos||e.length!==this.prevRemoteInfos.length||!0===this.videoPreferencesUpdated)return!1;for(const t of e)if(void 0===this.prevRemoteInfos.find((e=>e.groupId===t.groupId&&e.streamId===t.streamId&&e.maxBitrateKbps===t.maxBitrateKbps)))return!1;return!0}chosenStreamsSameAsLast(e){if(this.optimalNonPausedReceiveStreams.length!==e.length)return!1;for(const t of this.optimalNonPausedReceiveStreams)if(!e.some((e=>e.streamId===t.streamId)))return!1;return!0}policyStateLogStr(e,t){const n={targetBitrate:t,subscribedRate:this.calculateSubscribeRate(this.optimalReceiveStreams),probeState:this.rateProbeState,startupPeriod:this.startupPeriod};let i="remoteInfos: [";for(const t of e)i+=`{grpId:${t.groupId} strId:${t.streamId} maxBr:${t.maxBitrateKbps} avgBr:${t.avgBitrateKbps}}, `;i+="]";let r=`bwe: optimalReceiveSet ${JSON.stringify(n)}\nbwe: prev ${JSON.stringify(this.prevDownlinkStats)}\nbwe: now ${JSON.stringify(this.downlinkStats)}\nbwe: ${i}\n`;return(this.pausedStreamIds.size()>0||this.pausedBwAttendeeIds.size>0)&&(r+=`bwe: paused: app stream ids ${JSON.stringify(this.pausedStreamIds)} bw attendees { ${Array.from(this.pausedBwAttendeeIds).join(" ")} }\n`),this.videoPreferences?r+=`bwe: preferences: ${JSON.stringify(this.videoPreferences)}`:r+=`bwe: default preferences: ${JSON.stringify(this.defaultVideoPreferences)}`,r}getCurrentVideoPreferences(){return this.videoPreferences||this.defaultVideoPreferences}getServerSideNetworkAdaption(){return this.serverSideNetworkAdaption}setServerSideNetworkAdaption(e){this.serverSideNetworkAdaption=e,this.setProbeState("Not Probing")}supportedServerSideNetworkAdaptions(){return[s.default.None,s.default.BandwidthProbing]}getVideoPreferences(){let e=this.getCurrentVideoPreferences();return e||(e=d.VideoPreferences.prepare().build()),e}}t.default=p,p.DEFAULT_BANDWIDTH_KBPS=2800,p.STARTUP_PERIOD_MS=6e3,p.LARGE_RATE_CHANGE_TRIGGER_PERCENT=20,p.TARGET_RATE_CHANGE_TRIGGER_PERCENT=15,p.LOW_BITRATE_THRESHOLD_KBPS=300,p.MIN_TIME_BETWEEN_PROBE_MS=5e3,p.MIN_TIME_BETWEEN_SUBSCRIBE_MS=2e3,p.MAX_HOLD_BEFORE_PROBE_MS=3e4,p.MAX_ALLOWED_PROBE_TIME_MS=6e4,p.SPURIOUS_PACKET_LOST_THRESHOLD=2,p.USED_BANDWIDTH_OVERRIDE_BUFFER_KBPS=100},1034:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7103);class r{constructor(e=0,t=0){this.networkIssueResponseDelayFactor=e,this.networkIssueRecoveryDelayFactor=t,this.currentNetworkEvent=0,this.bandwidthDecreaseTimestamp=0,this.referenceBitrate=0,this.serverSideNetworkAdaption=i.default.Default,e<0?e=0:e>1&&(e=1),this.networkIssueResponseDelayFactor=e,t<0?t=0:t>1&&(t=1),this.networkIssueRecoveryDelayFactor=t}allowSubscribe(e,t){let n=0;const i=this.currentNetworkEvent;if(t>this.referenceBitrate)return this.currentNetworkEvent=2,this.referenceBitrate=t,!0;if(tn)return this.referenceBitrate=t,!0;return!1}return this.currentNetworkEvent=0,!1}getSubscribeDelay(e,t){let n=r.MINIMUM_DELAY_MS;const i=r.MAXIMUM_DELAY_MS-r.MINIMUM_DELAY_MS,a=this.networkIssueResponseDelayFactor;return 1===e&&(n+=i*a*(1+t/10),n=Math.min(r.MAXIMUM_DELAY_MS,n)),n}}t.default=r,r.MINIMUM_DELAY_MS=2e3,r.MAXIMUM_DELAY_MS=8e3,r.Default=new r(0,0),r.UnstableNetworkPreset=new r(0,1),r.StableNetworkPreset=new r(1,0)},3663:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{create(){const e={clientWidth:400,clientHeight:300,width:400,height:300,videoWidth:400,videoHeight:300,style:{transform:""},hasAttribute:()=>!1,removeAttribute:()=>{},setAttribute:()=>{},srcObject:!1,paused:!0,pause:()=>{e.paused=!0},play:()=>(e.paused=!1,Promise.resolve())};return e}}},9807:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e){this.canvas=e,this.destroyed=!1}destroy(){this.canvas=null,this.destroyed=!0}asCanvasImageSource(){return n(this,void 0,void 0,(function*(){return this.destroyed?Promise.reject("canvas buffer is destroyed"):Promise.resolve(this.canvas)}))}asCanvasElement(){return this.canvas}}},8919:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9807);t.default=class{constructor(e,t){this.logger=e,this.stages=t,this.fr=15,this.outputMediaStream=new MediaStream,this.videoInput=document.createElement("video"),this.canvasOutput=document.createElement("canvas"),this.outputCtx=this.canvasOutput.getContext("2d"),this.canvasInput=document.createElement("canvas"),this.inputCtx=this.canvasInput.getContext("2d"),this.inputVideoStream=null,this.sourceBuffers=[],this.destBuffers=[],this.observers=new Set,this.hasStarted=!1,this.process=e=>i(this,void 0,void 0,(function*(){if(!this.inputVideoStream)return;const e=performance.now();this.videoInput.videoWidth&&(this.canvasInput.width!==this.videoInput.videoWidth&&(this.canvasInput.width=this.videoInput.videoWidth,this.canvasInput.height=this.videoInput.videoHeight,this.sourceBuffers[0].height=this.canvasInput.height,this.sourceBuffers[0].width=this.canvasInput.width,this.sourceBuffers[0].framerate=this.framerate),this.inputCtx.drawImage(this.videoInput,0,0));let t,n=[];n.push(this.sourceBuffers[0]);try{for(const e of this.processors)n=yield e.process(n)}catch(e){return void this.forEachObserver((e=>{e.processingDidFailToStart&&e.processingDidFailToStart()}))}this.destBuffers=n;try{t=yield this.destBuffers[0].asCanvasImageSource()}catch(e){return void(this.inputVideoStream&&(this.logger.info("buffers are destroyed and pipeline could not start"),this.forEachObserver((e=>{e.processingDidFailToStart&&e.processingDidFailToStart()}))))}const i=t.width,r=t.height;0!==i&&0!==r&&(this.canvasOutput.width!==i&&this.canvasOutput.height!==r&&(this.canvasOutput.width=i,this.canvasOutput.height=r),this.outputCtx.drawImage(t,0,0,i,r,0,0,i,r),this.hasStarted||(this.hasStarted=!0,this.forEachObserver((e=>{e.processingDidStart&&e.processingDidStart()}))));const a=performance.now()-e,o=2e3/this.framerate-a,s=Math.max(0,1e3/this.framerate-a);o<=0&&this.forEachObserver((e=>{e.processingLatencyTooHigh&&e.processingLatencyTooHigh(a)})),this.lastTimeOut=setTimeout(this.process,s)}))}destroy(){if(this.stop(),this.stages)for(const e of this.stages)e.destroy()}get framerate(){return this.fr}set framerate(e){this.fr=e<0?15:e}stop(){if(this.videoInput.removeEventListener("loadedmetadata",this.process),this.videoInput.srcObject=null,this.destroyInputMediaStreamAndBuffers(),this.outputMediaStream)for(const e of this.outputMediaStream.getVideoTracks())e.stop();this.lastTimeOut&&(clearTimeout(this.lastTimeOut),this.lastTimeOut=void 0),this.hasStarted&&(this.hasStarted=!1,this.forEachObserver((e=>{e.processingDidStop&&e.processingDidStop()})))}addObserver(e){this.observers.add(e)}removeObserver(e){this.observers.delete(e)}getInputMediaStream(){return i(this,void 0,void 0,(function*(){return this.inputVideoStream}))}getActiveOutputMediaStream(){return this.outputMediaStream&&this.outputMediaStream.active?this.outputMediaStream:this.outputMediaStream=this.canvasOutput.captureStream(this.framerate)}setInputMediaStream(e){return i(this,void 0,void 0,(function*(){if(!e)return void this.stop();if(0===e.getVideoTracks().length)return void this.logger.error("No video tracks in input media stream, ignoring");this.inputVideoStream=e;const t=this.inputVideoStream.getVideoTracks()[0].getSettings();this.logger.info(`processing pipeline input stream settings ${JSON.stringify(t)}`),this.canvasOutput.width=t.width,this.canvasOutput.height=t.height,this.videoInput.addEventListener("loadedmetadata",this.process),this.videoInput.srcObject=this.inputVideoStream,this.videoInput.setAttribute("playsinline","true");const n=new r.default(this.canvasInput);this.sourceBuffers.push(n),this.videoInput.load();try{yield this.videoInput.play()}catch(e){this.logger.warn("Video element play() overrided by another load().")}}))}set processors(e){this.stages=e}get processors(){return this.stages}forEachObserver(e){for(const t of this.observers)setTimeout((()=>{e(t)}),0)}destroyInputMediaStreamAndBuffers(){if(this.inputVideoStream)for(const e of this.inputVideoStream.getTracks())e.stop();this.inputVideoStream=null;for(const e of this.sourceBuffers)e.destroy();this.sourceBuffers=[]}}},7673:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543),a=n(8919);class o{constructor(e,t,n,i=new r.default){this.logger=e,this.device=t,this.processors=n,this.browserBehavior=i,this.observers=new Set,this.pipe=new a.default(this.logger,this.processors),this.pipe.addObserver(this)}get outputMediaStream(){return this.pipe.outputMediaStream}chooseNewInnerDevice(e){const t=new o(this.logger,e,this.processors,this.browserBehavior);return t.pipe=this.pipe,t}getInnerDevice(){return this.device}intrinsicDevice(){return i(this,void 0,void 0,(function*(){return this.device}))}transformStream(e){return i(this,void 0,void 0,(function*(){return yield this.pipe.setInputMediaStream(e),this.inputMediaStream=e,this.pipe.getActiveOutputMediaStream()}))}onOutputStreamDisconnect(){this.logger.info("DefaultVideoTransformDevice: detach stopping input media stream");const e=this.device&&this.device.id;if(this.pipe.stop(),!e&&this.inputMediaStream)for(const e of this.inputMediaStream.getVideoTracks())e.stop()}stop(){return i(this,void 0,void 0,(function*(){if(this.inputMediaStream)for(const e of this.inputMediaStream.getVideoTracks())e.stop();this.pipe.destroy(),this.inputMediaStream=null}))}addObserver(e){this.observers.add(e)}removeObserver(e){this.observers.delete(e)}processingDidStart(){this.logger.info("video transform device processing started"),this.forEachObserver((e=>{e.processingDidStart&&e.processingDidStart()}))}processingLatencyTooHigh(e){this.forEachObserver((t=>{t.processingLatencyTooHigh&&t.processingLatencyTooHigh(e)}))}processingDidFailToStart(){this.logger.info("video transform device processing failed to start"),this.forEachObserver((e=>{e.processingDidFailToStart&&e.processingDidFailToStart()}))}processingDidStop(){this.logger.info("video transform device processing stopped"),this.forEachObserver((e=>{e.processingDidStop&&e.processingDidStop()}))}forEachObserver(e){for(const t of this.observers)setTimeout((()=>{e(t)}),0)}}t.default=o},2801:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{process(e){return n(this,void 0,void 0,(function*(){return e}))}destroy(){return n(this,void 0,void 0,(function*(){}))}}},60:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},1508:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e){this.ids=new Set(e)}add(e){this.ids.add(e)}array(){return Array.from(this.ids.values()).sort(((e,t)=>e-t))}contain(e){return this.ids.has(e)}forEach(e){this.ids.forEach(e)}empty(){return 0===this.ids.size}size(){return this.ids.size}equal(e){if(!e)return 0===this.ids.size;const t=this.array(),n=e.array();if(t.length!==n.length)return!1;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289),r=n(1508),a=n(6876);t.default=class{constructor(e){this.logger=e,this.currentIndex=null,this.indexForSubscribe=null,this.currentSubscribeAck=null,this.subscribeTrackToStreamMap=null,this.subscribeStreamToAttendeeMap=null,this.subscribeStreamToExternalUserIdMap=null,this.subscribeSsrcToStreamMap=null,this.streamToAttendeeMap=null,this.streamToExternalUserIdMap=null,this.videoStreamDescription=new a.default,this.videoStreamDescription.trackLabel="AmazonChimeExpressVideo",this.videoStreamDescription.streamId=2,this.videoStreamDescription.groupId=2}localStreamDescriptions(){return[this.videoStreamDescription.clone()]}convertBpsToKbps(e){return e>0&&e<1e3?1:Math.trunc(e/1e3)}remoteStreamDescriptions(){if(!this.currentIndex||!this.currentIndex.sources)return[];const e=[];return this.currentIndex.sources.forEach((t=>{const n=new a.default;n.attendeeId=t.attendeeId,n.groupId=t.groupId,n.streamId=t.streamId,n.maxBitrateKbps=t.maxBitrateKbps,n.avgBitrateKbps=this.convertBpsToKbps(t.avgBitrateBps),e.push(n)})),e}integrateUplinkPolicyDecision(e){if(e&&e.length){const t=e[0];this.videoStreamDescription.maxBitrateKbps=t.maxBitrate/1e3,this.videoStreamDescription.maxFrameRate=t.maxFramerate}}integrateIndexFrame(e){this.currentIndex=e;const t=new Map;let n=!1;for(const i of e.sources){if(!t.has(i.attendeeId)){t.set(i.attendeeId,i.groupId);continue}const e=t.get(i.attendeeId);et.get(e.attendeeId)===e.groupId))),this.streamToAttendeeMap=null,this.streamToExternalUserIdMap=null}subscribeFrameSent(){this.indexForSubscribe=this.currentIndex}integrateSubscribeAckFrame(e){this.currentSubscribeAck=e,this.subscribeTrackToStreamMap=this.buildTrackToStreamMap(this.currentSubscribeAck),this.subscribeSsrcToStreamMap=this.buildSSRCToStreamMap(this.currentSubscribeAck),this.subscribeStreamToAttendeeMap=this.buildStreamToAttendeeMap(this.indexForSubscribe),this.subscribeStreamToExternalUserIdMap=this.buildStreamExternalUserIdMap(this.indexForSubscribe)}integrateBitratesFrame(e){if(this.currentIndex)for(const t of e.bitrates){const e=this.currentIndex.sources.find((e=>e.streamId===t.sourceStreamId));void 0!==e&&(e.avgBitrateBps=t.avgBitrateBps)}}allStreams(){const e=new r.default;if(this.currentIndex)for(const t of this.currentIndex.sources)e.add(t.streamId);return e}allVideoSendingSourcesExcludingSelf(e){const t=[],n=new Set;if(this.currentIndex&&this.currentIndex.sources&&this.currentIndex.sources.length)for(const r of this.currentIndex.sources){const{attendeeId:a,externalUserId:o,mediaType:s}=r;a!==e&&s===i.SdkStreamMediaType.VIDEO&&(n.has(a)||(t.push({attendee:{attendeeId:a,externalUserId:o}}),n.add(a)))}return t}streamSelectionUnderBandwidthConstraint(e,t,n,a){const o=new Set;if(this.currentIndex)for(const r of this.currentIndex.sources)r.attendeeId!==e&&r.mediaType===i.SdkStreamMediaType.VIDEO&&(t.has(r.attendeeId)||n.has(r.attendeeId)||o.add(r.attendeeId));const s=this.buildAttendeeToSortedStreamDescriptorMapExcludingSelf(e),c=new Map;let l=0;s.forEach(((e,t)=>{c.set(t,e[0]),l+=e[0].maxBitrateKbps})),l=this.trySelectHighBitrateForAttendees(s,t,l,a,c),this.trySelectHighBitrateForAttendees(s,o,l,a,c);const u=new r.default;for(const e of c.values())u.add(e.streamId);return u}highestQualityStreamFromEachGroupExcludingSelf(e){const t=new r.default;if(this.currentIndex){const n=new Map;for(const t of this.currentIndex.sources)t.attendeeId!==e&&t.mediaType===i.SdkStreamMediaType.VIDEO&&(!n.has(t.groupId)||t.maxBitrateKbps>n.get(t.groupId).maxBitrateKbps)&&n.set(t.groupId,t);for(const e of n.values())t.add(e.streamId)}return t}numberOfVideoPublishingParticipantsExcludingSelf(e){return this.highestQualityStreamFromEachGroupExcludingSelf(e).array().length}numberOfParticipants(){return this.currentIndex.numParticipants?this.currentIndex.numParticipants:-1}attendeeIdForTrack(e){const t=this.streamIdForTrack(e);if(void 0===t||!this.subscribeStreamToAttendeeMap)return this.logger.warn(`no attendee found for track ${e}`),"";return this.subscribeStreamToAttendeeMap.get(t)||(this.logger.info(`track ${e} (stream ${t}) does not correspond to a known attendee`),"")}externalUserIdForTrack(e){const t=this.streamIdForTrack(e);if(void 0===t||!this.subscribeStreamToExternalUserIdMap)return this.logger.warn(`no external user id found for track ${e}`),"";return this.subscribeStreamToExternalUserIdMap.get(t)||(this.logger.info(`track ${e} (stream ${t}) does not correspond to a known externalUserId`),"")}attendeeIdForStreamId(e){if(!this.streamToAttendeeMap){if(!this.currentIndex)return"";this.streamToAttendeeMap=this.buildStreamToAttendeeMap(this.currentIndex)}return this.streamToAttendeeMap.get(e)||(this.logger.info(`stream ${e}) does not correspond to a known attendee`),"")}groupIdForStreamId(e){if(this.currentIndex&&this.currentIndex.sources){for(const t of this.currentIndex.sources)if(t.streamId===e)return t.groupId;if(this.indexForSubscribe)for(const t of this.indexForSubscribe.sources)if(t.streamId===e)return t.groupId}}StreamIdsInSameGroup(e,t){return this.groupIdForStreamId(e)===this.groupIdForStreamId(t)}streamIdForTrack(e){if(this.subscribeTrackToStreamMap)return this.subscribeTrackToStreamMap.get(e)}streamIdForSSRC(e){if(this.subscribeSsrcToStreamMap)return this.subscribeSsrcToStreamMap.get(e)}overrideStreamIdMappings(e,t){if(this.subscribeTrackToStreamMap)for(const[n,i]of this.subscribeTrackToStreamMap.entries())if(e===i){this.subscribeTrackToStreamMap.set(n,t);break}if(this.subscribeSsrcToStreamMap)for(const[n,i]of this.subscribeSsrcToStreamMap.entries())if(e===i){this.subscribeSsrcToStreamMap.set(n,t);break}}streamsPausedAtSource(){const e=new r.default;if(this.currentIndex)for(const t of this.currentIndex.pausedAtSourceIds)e.add(t);return e}buildTrackToStreamMap(e){const t=new Map;this.logger.debug((()=>`trackMap ${JSON.stringify(e.tracks)}`));for(const n of e.tracks)n.trackLabel.length>0&&n.streamId>0&&t.set(n.trackLabel,n.streamId);return t}buildSSRCToStreamMap(e){const t=new Map;this.logger.debug((()=>`ssrcMap ${JSON.stringify(e.tracks)}`));for(const n of e.tracks)n.trackLabel.length>0&&n.streamId>0&&t.set(n.ssrc,n.streamId);return t}buildStreamToAttendeeMap(e){const t=new Map;if(e)for(const n of e.sources)t.set(n.streamId,n.attendeeId);return t}buildStreamExternalUserIdMap(e){const t=new Map;if(e)for(const n of e.sources)n.externalUserId&&t.set(n.streamId,n.externalUserId);return t}trySelectHighBitrateForAttendees(e,t,n,i,r){for(const a of t){if(n>=i)break;if(e.has(a)){const t=e.get(a);for(const e of t.reverse())if(n-r.get(a).maxBitrateKbps+e.maxBitrateKbps{e.sort(((e,t)=>e.maxBitrateKbps>t.maxBitrateKbps?1:e.maxBitrateKbps{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289),r=n(1318),a=n(6876);class o extends r.default{constructor(e){super(e),this.streamIdToBitrateKbpsMap=new Map,this._localStreamInfos=[],this._lastBitRateMsgTime=Date.now()}localStreamDescriptions(){const e=[];return this._localStreamInfos.forEach((t=>{e.push(t.clone())})),e}integrateUplinkPolicyDecision(e){let t=!0,n=0;for(let i=0;i0&&(this._localStreamInfos[n].timeEnabled=Date.now()),this._localStreamInfos[n].maxBitrateKbps=r,this._localStreamInfos[n].maxFrameRate=o,this._localStreamInfos[n].disabledByUplinkPolicy=0===r,!0===this._localStreamInfos[n].disabledByUplinkPolicy&&(this._localStreamInfos[n].disabledByWebRTC=!1),n++;else{t=!1;const e=new a.default;e.maxBitrateKbps=r,e.maxFrameRate=o,e.disabledByUplinkPolicy=0===r,0!==r&&(e.timeEnabled=Date.now()),this._localStreamInfos.push(e),n++}}t&&this._localStreamInfos.splice(n)}integrateBitratesFrame(e){super.integrateBitratesFrame(e);const t=new Set,n=new Set(this.streamIdToBitrateKbpsMap.keys());for(const n of e.bitrates)t.add(n.sourceStreamId),this.streamIdToBitrateKbpsMap.set(n.sourceStreamId,this.convertBpsToKbps(n.avgBitrateBps));for(const e of n)t.has(e)||(this.streamIdToBitrateKbpsMap.get(e)===o.UNSEEN_STREAM_BITRATE?this.streamIdToBitrateKbpsMap.set(e,o.RECENTLY_INACTIVE_STREAM_BITRATE):this.streamIdToBitrateKbpsMap.set(e,o.NOT_SENDING_STREAM_BITRATE));for(let e=0;eo.BitratesMsgFrequencyMs&&(this._localStreamInfos[e].disabledByWebRTC=!0):this._lastBitRateMsgTime-this._localStreamInfos[e].timeEnabled>o.BitratesMsgFrequencyMs&&(this._localStreamInfos[e].disabledByWebRTC=!0))}this._lastBitRateMsgTime=Date.now(),this.logLocalStreamDescriptions()}logLocalStreamDescriptions(){let e="";for(const t of this._localStreamInfos)e+=`streamId=${t.streamId} maxBitrate=${t.maxBitrateKbps} disabledByWebRTC=${t.disabledByWebRTC} disabledByUplink=${t.disabledByUplinkPolicy}\n`;this.logger.debug((()=>e))}integrateIndexFrame(e){super.integrateIndexFrame(e);const t=new Set,n=new Set(this.streamIdToBitrateKbpsMap.keys());for(const e of this.currentIndex.sources)e.mediaType===i.SdkStreamMediaType.VIDEO&&(t.add(e.streamId),this.streamIdToBitrateKbpsMap.has(e.streamId)||this.streamIdToBitrateKbpsMap.set(e.streamId,o.UNSEEN_STREAM_BITRATE));for(const e of n)t.has(e)||this.streamIdToBitrateKbpsMap.delete(e)}integrateSubscribeAckFrame(e){if(super.integrateSubscribeAckFrame(e),!e.allocations||void 0===e.allocations)return;let t=0;for(const n of e.allocations){if(this._localStreamInfos.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(289);class r{constructor(e,t,n,i,r){this.attendeeId="",this.groupId=0,this.streamId=0,this.ssrc=0,this.trackLabel="",this.maxBitrateKbps=0,this.avgBitrateKbps=0,this.maxFrameRate=0,this.timeEnabled=0,this.disabledByWebRTC=!1,this.disabledByUplinkPolicy=!1,this.attendeeId=e,this.groupId=t,this.streamId=n,this.maxBitrateKbps=i,this.avgBitrateKbps=r}clone(){const e=new r;return e.attendeeId=this.attendeeId,e.groupId=this.groupId,e.streamId=this.streamId,e.ssrc=this.ssrc,e.trackLabel=this.trackLabel,e.maxBitrateKbps=this.maxBitrateKbps,e.avgBitrateKbps=this.avgBitrateKbps,e.maxFrameRate=this.maxFrameRate,e.timeEnabled=this.timeEnabled,e.disabledByWebRTC=this.disabledByWebRTC,e.disabledByUplinkPolicy=this.disabledByUplinkPolicy,e}toStreamDescriptor(){const e=i.SdkStreamDescriptor.create();return e.mediaType=i.SdkStreamMediaType.VIDEO,e.trackLabel=this.trackLabel,e.attendeeId=this.attendeeId,e.streamId=this.streamId,e.groupId=this.groupId,e.framerate=this.maxFrameRate,e.maxBitrateKbps=this.disabledByUplinkPolicy||this.disabledByWebRTC?0:this.maxBitrateKbps,e.avgBitrateBps=this.avgBitrateKbps,e}}t.default=r},3327:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(543),r=n(214),a=n(7804);class o{constructor(e,t,n,i){this.tileController=n,this.devicePixelRatioMonitor=i,this.tileState=new a.default,this.tileState.tileId=e,this.tileState.localTile=t,this.devicePixelRatioMonitor.registerObserver(this)}static connectVideoStreamToVideoElement(e,t,n){const r=n&&"environment"!==e.getVideoTracks()[0].getSettings().facingMode?"rotateY(180deg)":"";o.setVideoElementFlag(t,"disablePictureInPicture",n),o.setVideoElementFlag(t,"disableRemotePlayback",n),t.style.transform!==r&&(t.style.transform=r),t.hasAttribute("controls")&&t.removeAttribute("controls"),t.hasAttribute("autoplay")||t.setAttribute("autoplay","true"),t.hasAttribute("playsinline")||t.setAttribute("playsinline","true"),t.hasAttribute("muted")||(t.setAttribute("muted","true"),t.muted=!0),t.srcObject!==e&&(t.srcObject=e,(new i.default).requiresVideoPlayWorkaround()&&t.paused&&t.play())}static disconnectVideoStreamFromVideoElement(e,t,n=!1){if(e)if(t)n||(e.srcObject=null,e.style.transform="");else{if(!e.srcObject)return;e.pause(),e.style.transform="",o.setVideoElementFlag(e,"disablePictureInPicture",!1),o.setVideoElementFlag(e,"disableRemotePlayback",!1),e.srcObject=null}}destroy(){this.devicePixelRatioMonitor.removeObserver(this),this.tileState.boundVideoElement&&this.tileState.boundVideoElement.srcObject===this.tileState.boundVideoStream&&o.disconnectVideoStreamFromVideoElement(this.tileState.boundVideoElement,!1),this.tileState=new a.default}devicePixelRatioChanged(e){this.tileState.devicePixelRatio=e,this.sendTileStateUpdate()}id(){return this.tileState.tileId}state(){return this.tileState.clone()}stateRef(){return this.tileState}bindVideoStream(e,t,n,i,a,o,s){let c=!1;this.tileState.boundAttendeeId!==e&&(this.tileState.boundAttendeeId=e,new r.default(e).hasModality(r.default.MODALITY_CONTENT)&&(this.tileState.isContent=!0),c=!0),this.tileState.boundExternalUserId!==s&&(this.tileState.boundExternalUserId=s,c=!0),this.tileState.localTile!==t&&(this.tileState.localTile=t,c=!0),this.tileState.boundVideoStream!==n&&(this.tileState.boundVideoStream=n,c=!0),this.tileState.videoStreamContentWidth!==i&&(this.tileState.videoStreamContentWidth=i,c=!0),this.tileState.videoStreamContentHeight!==a&&(this.tileState.videoStreamContentHeight=a,c=!0),this.tileState.streamId!==o&&(this.tileState.streamId=o,c=!0),c&&this.sendTileStateUpdate()}bindVideoElement(e){let t=!1;this.tileState.boundVideoElement!==e&&(this.tileState.boundVideoElement=e,t=!0),null!==this.tileState.boundVideoElement?(this.tileState.videoElementCSSWidthPixels!==e.clientWidth&&(this.tileState.videoElementCSSWidthPixels=e.clientWidth,t=!0),this.tileState.videoElementCSSHeightPixels!==e.clientHeight&&(this.tileState.videoElementCSSHeightPixels=e.clientHeight,t=!0)):(this.tileState.videoElementCSSWidthPixels=null,this.tileState.videoElementCSSHeightPixels=null),t&&this.sendTileStateUpdate()}pause(){this.tileState.paused||(this.tileState.paused=!0,this.sendTileStateUpdate())}unpause(){this.tileState.paused&&(this.tileState.paused=!1,this.sendTileStateUpdate())}markPoorConnection(){return!this.tileState.poorConnection&&(this.tileState.poorConnection=!0,this.sendTileStateUpdate(),!0)}unmarkPoorConnection(){return!!this.tileState.poorConnection&&(this.tileState.poorConnection=!1,this.sendTileStateUpdate(),!0)}capture(){if(!this.tileState.active)return null;const e=document.createElement("canvas"),t=this.tileState.boundVideoElement;e.width=t.videoWidth||t.width,e.height=t.videoHeight||t.height;const n=e.getContext("2d");return n.drawImage(t,0,0,e.width,e.height),n.getImageData(0,0,e.width,e.height)}setStreamId(e){this.tileState.streamId=e,this.tileController.sendTileStateUpdate(this.state())}sendTileStateUpdate(){this.updateActiveState(),this.updateVideoStreamOnVideoElement(),this.updateVideoElementPhysicalPixels(),this.tileController.sendTileStateUpdate(this.state())}updateActiveState(){this.tileState.active=!(this.tileState.paused||this.tileState.poorConnection||!this.tileState.boundAttendeeId||!this.tileState.boundVideoElement||!this.tileState.boundVideoStream)}updateVideoElementPhysicalPixels(){"number"==typeof this.tileState.videoElementCSSWidthPixels&&"number"==typeof this.tileState.videoElementCSSHeightPixels?(this.tileState.videoElementPhysicalWidthPixels=this.tileState.devicePixelRatio*this.tileState.videoElementCSSWidthPixels,this.tileState.videoElementPhysicalHeightPixels=this.tileState.devicePixelRatio*this.tileState.videoElementCSSHeightPixels):(this.tileState.videoElementPhysicalWidthPixels=null,this.tileState.videoElementPhysicalHeightPixels=null)}updateVideoStreamOnVideoElement(){this.tileState.active?o.connectVideoStreamToVideoElement(this.tileState.boundVideoStream,this.tileState.boundVideoElement,this.tileState.localTile):o.disconnectVideoStreamFromVideoElement(this.tileState.boundVideoElement,this.tileState.paused,this.tileController.keepLastFrameWhenPaused)}static setVideoElementFlag(e,t,n){t in e&&(e[t]=n)}}t.default=o},7804:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(){this.tileId=null,this.localTile=!1,this.localTileStarted=!1,this.isContent=!1,this.active=!1,this.paused=!1,this.poorConnection=!1,this.boundAttendeeId=null,this.boundExternalUserId=null,this.boundVideoStream=null,this.boundVideoElement=null,this.nameplate=null,this.videoStreamContentWidth=null,this.videoStreamContentHeight=null,this.videoElementCSSWidthPixels=null,this.videoElementCSSHeightPixels=null,this.devicePixelRatio=0,this.videoElementPhysicalWidthPixels=null,this.videoElementPhysicalHeightPixels=null,this.streamId=null}clone(){const e=new n;return e.tileId=this.tileId,e.localTile=this.localTile,e.isContent=this.isContent,e.active=this.active,e.paused=this.paused,e.poorConnection=this.poorConnection,e.boundAttendeeId=this.boundAttendeeId,e.boundExternalUserId=this.boundExternalUserId,e.boundVideoStream=this.boundVideoStream,e.boundVideoElement=this.boundVideoElement,e.nameplate=this.nameplate,e.videoStreamContentWidth=this.videoStreamContentWidth,e.videoStreamContentHeight=this.videoStreamContentHeight,e.videoElementCSSWidthPixels=this.videoElementCSSWidthPixels,e.videoElementCSSHeightPixels=this.videoElementCSSHeightPixels,e.devicePixelRatio=this.devicePixelRatio,e.videoElementPhysicalWidthPixels=this.videoElementPhysicalWidthPixels,e.videoElementPhysicalHeightPixels=this.videoElementPhysicalHeightPixels,e.streamId=this.streamId,e}}t.default=n},2958:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(8236),a=n(9190),o=n(8660),s=n(3327);t.default=class{constructor(e,t,n){this.tileFactory=e,this.audioVideoController=t,this.logger=n,this.tileMap=new Map,this.nextTileId=1,this.currentLocalTile=null,this.currentPausedTilesByIds=new Set,this.keepLastFrameWhenPaused=!1,this.keepLastFrameWhenPaused=t.configuration.keepLastFrameWhenPaused}createDevicePixelRatioMonitorIfNeeded(){this.devicePixelRatioMonitor||(this.devicePixelRatioMonitor=new r.default(new a.default,this.logger))}discardDevicePixelRatioMonitorIfNotNeeded(){return i(this,void 0,void 0,(function*(){if(this.tileMap.size||!this.devicePixelRatioMonitor)return;const e=this.devicePixelRatioMonitor;return this.devicePixelRatioMonitor=void 0,e.destroy()}))}bindVideoElement(e,t){const n=this.getVideoTile(e);null!==n?n.bindVideoElement(t):this.logger.warn(`Ignoring video element binding for unknown tile id ${e}`)}unbindVideoElement(e,t=!0){const n=this.getVideoTile(e);if(null===n)return void this.logger.warn(`Ignoring video element unbinding for unknown tile id ${e}`);this.logger.info("Unbinding the video element");const i=n.stateRef().boundVideoElement;n.bindVideoElement(null),t&&(this.logger.info("Cleaning up the video element"),s.default.disconnectVideoStreamFromVideoElement(i,!1))}startLocalVideoTile(){const e=this.findOrCreateLocalVideoTile();return this.currentLocalTile.stateRef().localTileStarted=!0,this.audioVideoController.update({needsRenegotiation:!0}),e.id()}stopLocalVideoTile(){this.currentLocalTile&&(this.currentLocalTile.stateRef().localTileStarted=!1,this.currentLocalTile.bindVideoStream(this.audioVideoController.configuration.credentials.attendeeId,!0,null,null,null,null,this.audioVideoController.configuration.credentials.externalUserId),this.audioVideoController.update({needsRenegotiation:!0}))}hasStartedLocalVideoTile(){return!(!this.currentLocalTile||!this.currentLocalTile.stateRef().localTileStarted)}removeLocalVideoTile(){this.currentLocalTile&&this.removeVideoTile(this.currentLocalTile.id())}getLocalVideoTile(){return this.currentLocalTile}pauseVideoTile(e){const t=this.getVideoTile(e);t&&(this.currentPausedTilesByIds.has(e)||(this.audioVideoController.pauseReceivingStream(t.stateRef().streamId),this.currentPausedTilesByIds.add(e)),t.pause())}unpauseVideoTile(e){const t=this.getVideoTile(e);t&&(this.currentPausedTilesByIds.has(e)&&(this.audioVideoController.resumeReceivingStream(t.stateRef().streamId),this.currentPausedTilesByIds.delete(e)),t.unpause())}getVideoTile(e){return this.tileMap.has(e)?this.tileMap.get(e):null}getVideoTileArea(e){const t=e.state();let n=0,i=0;return t.boundVideoElement&&(n=t.boundVideoElement.clientHeight*t.devicePixelRatio,i=t.boundVideoElement.clientWidth*t.devicePixelRatio),n*i}getAllRemoteVideoTiles(){const e=new Array;return this.tileMap.forEach(((t,n)=>{this.currentLocalTile&&n===this.currentLocalTile.id()||e.push(t)})),e}getAllVideoTiles(){return Array.from(this.tileMap.values())}addVideoTile(e=!1){const t=this.nextTileId;this.nextTileId+=1,this.createDevicePixelRatioMonitorIfNeeded();const n=this.tileFactory.makeTile(t,e,this,this.devicePixelRatioMonitor);return this.tileMap.set(t,n),n}removeVideoTile(e){if(!this.tileMap.has(e))return;const t=this.tileMap.get(e);this.currentLocalTile===t&&(this.currentLocalTile=null),t.destroy(),this.tileMap.delete(e),this.audioVideoController.forEachObserver((t=>{o.Maybe.of(t.videoTileWasRemoved).map((n=>n.bind(t)(e)))})),this.discardDevicePixelRatioMonitorIfNotNeeded()}removeVideoTilesByAttendeeId(e){const t=[];for(const n of this.getAllVideoTiles()){const i=n.state();i.boundAttendeeId===e&&(this.removeVideoTile(i.tileId),t.push(i.tileId))}return t}removeAllVideoTiles(){const e=Array.from(this.tileMap.keys());for(const t of e)this.removeVideoTile(t)}sendTileStateUpdate(e){this.audioVideoController.forEachObserver((t=>{o.Maybe.of(t.videoTileDidUpdate).map((n=>n.bind(t)(e)))}))}haveVideoTilesWithStreams(){for(const e of this.getAllVideoTiles())if(e.state().boundVideoStream)return!0;return!1}haveVideoTileForAttendeeId(e){return!!this.getVideoTileForAttendeeId(e)}getVideoTileForAttendeeId(e){for(const t of this.getAllVideoTiles())if(t.state().boundAttendeeId===e)return t}captureVideoTile(e){const t=this.getVideoTile(e);return t?t.capture():null}findOrCreateLocalVideoTile(){return this.currentLocalTile||(this.currentLocalTile=this.addVideoTile(!0),this.currentLocalTile.bindVideoStream(this.audioVideoController.configuration.credentials.attendeeId,!0,null,null,null,null,this.audioVideoController.configuration.credentials.externalUserId)),this.currentLocalTile}}},4922:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(3327);t.default=class{makeTile(e,t,n,r){return new i.default(e,t,n,r)}}},9394:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{}},4450:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7606),r=n(5785),a=n(8660),o=n(1133),s=n(9394);class c{constructor(e,t){this.selfAttendeeId=e,this.logger=t,this.numSenders=0,this.shouldDisableSimulcast=!1,this.newQualityMap=new Map,this.currentQualityMap=new Map,this.newActiveStreams=1,this.currentActiveStreams=1,this.lastUplinkBandwidthKbps=c.defaultUplinkBandwidthKbps,this.startTimeMs=0,this.lastUpdatedMs=Date.now(),this.videoIndex=null,this.currLocalDescriptions=[],this.nextLocalDescriptions=[],this.observerQueue=new Set,this.optimalParameters=new o.default(0,0,0,0,!0),this.parametersInEffect=new o.default(0,0,0,0,!0),this.lastUplinkBandwidthKbps=c.defaultUplinkBandwidthKbps,this.currentQualityMap=this.fillEncodingParamWithBitrates([300,0,1200]),this.newQualityMap=this.fillEncodingParamWithBitrates([300,0,1200])}updateConnectionMetric({uplinkKbps:e=0}){if(isNaN(e))return;0===this.startTimeMs&&(this.startTimeMs=Date.now()),Date.now()-this.startTimeMs`simulcast: uplink policy update metrics ${this.lastUplinkBandwidthKbps}`));let t=c.holdDownDurationMs;3===this.currentActiveStreams?t=2*c.holdDownDurationMs:(2===this.currentActiveStreams&&e<=c.kMidDisabledRate||1===this.currentActiveStreams&&e<=c.kHiDisabledRate)&&(t=c.holdDownDurationMs/2),Date.now()=n||this.lastUplinkBandwidthKbps<=i){this.shouldDisableSimulcast?(this.newActiveStreams=0,t[0].maxBitrateKbps=0,t[1].maxBitrateKbps=1200,t[2].maxBitrateKbps=0):this.numSenders<=4&&this.lastUplinkBandwidthKbps>=c.kHiDisabledRate?(this.newActiveStreams=1,t[0].maxBitrateKbps=300,t[1].maxBitrateKbps=0,t[2].maxBitrateKbps=1200):this.lastUplinkBandwidthKbps>=c.kMidDisabledRate?(this.newActiveStreams=2,t[0].maxBitrateKbps=this.lastUplinkBandwidthKbps>=350?200:150,t[1].maxBitrateKbps=this.numSenders<=6?600:350,t[2].maxBitrateKbps=0):(this.newActiveStreams=3,t[0].maxBitrateKbps=300,t[1].maxBitrateKbps=0,t[2].maxBitrateKbps=0);const e=t.map(((e,t,n)=>e.maxBitrateKbps));this.newQualityMap=this.fillEncodingParamWithBitrates(e),this.encodingParametersEqual()||this.logger.info(`simulcast: policy:calculateEncodingParameters bw:${this.lastUplinkBandwidthKbps} numSources:${this.numSenders} shouldDisableSimulcast:${this.shouldDisableSimulcast} newQualityMap: ${this.getQualityMapString(this.newQualityMap)}`)}return this.newQualityMap}chooseMediaTrackConstraints(){return{width:{ideal:1280},height:{ideal:768},frameRate:{ideal:15}}}chooseEncodingParameters(){return this.currentQualityMap=this.newQualityMap,this.currentActiveStreams=this.newActiveStreams,this.activeStreamsToPublish!==this.newActiveStreams&&(this.activeStreamsToPublish=this.newActiveStreams,this.publishEncodingSimulcastLayer()),this.currentQualityMap}updateIndex(e){const t=e.numberOfVideoPublishingParticipantsExcludingSelf(this.selfAttendeeId)+1,n=t!==this.numSenders,i=e.numberOfParticipants(),r=i>=0&&i<=2,a=this.shouldDisableSimulcast!==r;this.numSenders=t,this.shouldDisableSimulcast=r,this.optimalParameters=new o.default(this.captureWidth(),this.captureHeight(),this.captureFrameRate(),this.maxBandwidthKbps(),!1),this.videoIndex=e,this.newQualityMap=this.calculateEncodingParameters(n||a)}wantsResubscribe(){let e=!this.encodingParametersEqual();this.nextLocalDescriptions=this.videoIndex.localStreamDescriptions();for(let t=0;te.streamId===n));-1!==i&&this.nextLocalDescriptions[t].disabledByWebRTC!==this.currLocalDescriptions[i].disabledByWebRTC&&(e=!0)}}return e&&(this.lastUpdatedMs=Date.now()),this.currLocalDescriptions=this.nextLocalDescriptions,e}compareEncodingParameter(e,t){return JSON.stringify(e)===JSON.stringify(t)}encodingParametersEqual(){let e=!1;for(const t of r.default.NAME_ARR_ASCENDING)if(e=e||!this.compareEncodingParameter(this.newQualityMap.get(t),this.currentQualityMap.get(t)),e)break;return!e}chooseCaptureAndEncodeParameters(){return this.parametersInEffect=this.optimalParameters.clone(),this.parametersInEffect.clone()}captureWidth(){return 1280}captureHeight(){return 768}captureFrameRate(){return 15}maxBandwidthKbps(){return 1400}setIdealMaxBandwidthKbps(e){}setHasBandwidthPriority(e){}fillEncodingParamWithBitrates(e){const t=new Map,n=r.default.NAME_ARR_ASCENDING,i=e;let a=this.shouldDisableSimulcast?1:4;for(let e=0;e0,scaleResolutionDownBy:Math.max(a,1),maxBitrate:1e3*i[e]}),a/=2}return t}getQualityMapString(e){let t="";const n=this.videoIndex.localStreamDescriptions();return 3===n.length&&e.forEach((e=>{let i=!1;i="low"===e.rid?n[0].disabledByWebRTC:"mid"===e.rid?n[1].disabledByWebRTC:n[2].disabledByWebRTC,t+=`{ rid: ${e.rid} active:${e.active} disabledByWebRTC: ${i} maxBitrate:${e.maxBitrate}}`})),t}getEncodingSimulcastLayer(e){switch(e){case 0:return i.default.High;case 1:return i.default.LowAndHigh;case 2:return i.default.LowAndMedium;case 3:return i.default.Low}}publishEncodingSimulcastLayer(){const e=this.getEncodingSimulcastLayer(this.activeStreamsToPublish);this.forEachObserver((t=>{a.Maybe.of(t.encodingSimulcastLayersDidChange).map((n=>n.bind(t)(e)))}))}addObserver(e){this.logger.info("adding simulcast uplink observer"),this.observerQueue.add(e)}removeObserver(e){this.logger.info("removing simulcast uplink observer"),this.observerQueue.delete(e)}forEachObserver(e){for(const t of this.observerQueue)e(t)}}t.default=c,c.defaultUplinkBandwidthKbps=1200,c.startupDurationMs=6e3,c.holdDownDurationMs=4e3,c.defaultMaxFrameRate=15,c.kHiDisabledRate=700,c.kMidDisabledRate=240},3879:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(7377);t.default=class{constructor(e,t){this.logger=e,this.encodingParams=t,this.videoIndex=null,this.currLocalDescriptions=[],this.nextLocalDescriptions=[]}updateConnectionMetric(e){}chooseMediaTrackConstraints(){}chooseEncodingParameters(){var e,t,n,r,a,o,s,c,l,u,d,h;const f=new Map,p=i.default.NAME_ARR_ASCENDING;return f.set(p[0],{rid:p[0],active:!0,scaleResolutionDownBy:(null===(t=null===(e=this.encodingParams)||void 0===e?void 0:e.low)||void 0===t?void 0:t.scaleResolutionDownBy)||2,maxBitrate:1e3*((null===(r=null===(n=this.encodingParams)||void 0===n?void 0:n.low)||void 0===r?void 0:r.maxBitrateKbps)||300),maxFramerate:(null===(o=null===(a=this.encodingParams)||void 0===a?void 0:a.low)||void 0===o?void 0:o.maxFramerate)||5}),f.set(p[1],{rid:p[1],active:!0,scaleResolutionDownBy:(null===(c=null===(s=this.encodingParams)||void 0===s?void 0:s.high)||void 0===c?void 0:c.scaleResolutionDownBy)||1,maxBitrate:1e3*((null===(u=null===(l=this.encodingParams)||void 0===l?void 0:l.high)||void 0===u?void 0:u.maxBitrateKbps)||1200),maxFramerate:null===(h=null===(d=this.encodingParams)||void 0===d?void 0:d.high)||void 0===h?void 0:h.maxFramerate}),this.getQualityMapString(f),f}updateIndex(e){this.videoIndex=e}wantsResubscribe(){var e,t;let n=!1;this.nextLocalDescriptions=null===(e=this.videoIndex)||void 0===e?void 0:e.localStreamDescriptions();for(let e=0;e<(null===(t=this.nextLocalDescriptions)||void 0===t?void 0:t.length);e++){const t=this.nextLocalDescriptions[e].streamId;if(0!==t&&t){const i=this.currLocalDescriptions.findIndex((e=>e.streamId===t));-1!==i&&this.nextLocalDescriptions[e].disabledByWebRTC!==this.currLocalDescriptions[i].disabledByWebRTC&&(n=!0)}}return this.currLocalDescriptions=this.nextLocalDescriptions,n}chooseCaptureAndEncodeParameters(){}maxBandwidthKbps(){return 1200}setIdealMaxBandwidthKbps(e){}setHasBandwidthPriority(e){}getQualityMapString(e){var t;let n="";const i=null===(t=this.videoIndex)||void 0===t?void 0:t.localStreamDescriptions();(null==i?void 0:i.length)>0&&(e.forEach((e=>{let t=!1;t="low"===e.rid?i[0].disabledByWebRTC:i[1].disabledByWebRTC,n+=`{ rid: ${e.rid} active:${e.active} disabledByWebRTC: ${t} maxBitrate:${e.maxBitrate} scaleResolutionDownBy:${e.scaleResolutionDownBy} maxFrameRate:${e.maxFramerate}`})),this.logger.info(`simulcast: content policy:chooseEncodingParameters newQualityMap: ${n}`))}addObserver(e){}removeObserver(e){}forEachObserver(e){}}},4442:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(1133);class a{constructor(e,t=!0,n,i){this.selfAttendeeId=e,this.scaleResolution=t,this.logger=n,this.browserBehavior=i,this.numberOfPublishedVideoSources=0,this.idealMaxBandwidthKbps=1400,this.hasBandwidthPriority=!1,this.encodingParamMap=new Map,this.reset()}reset(){this.numberOfPublishedVideoSources=0,this.optimalParameters=new r.default(0,0,0,0,!1),this.parametersInEffect=new r.default(0,0,0,0,!1),this.encodingParamMap.set(a.encodingMapKey,{maxBitrate:0})}updateConnectionMetric(e){}chooseMediaTrackConstraints(){return{}}chooseEncodingParameters(){return new Map}updateIndex(e){var t;let n=!0,i=1;this.transceiverController&&(n=this.transceiverController.hasVideoInput());const a=e.numberOfVideoPublishingParticipantsExcludingSelf(this.selfAttendeeId)+(n?1:0);if(this.numberOfPublishedVideoSources!==a){if(this.numberOfPublishedVideoSources=a,this.transceiverController){const e=this.getStreamCaptureSetting();e&&(i=this.calculateEncodingParameters(e).scaleResolutionDownBy)}this.optimalParameters=new r.default(this.captureWidth(),this.captureHeight(),this.captureFrameRate(),this.maxBandwidthKbps(),!1,i)}else null===(t=this.logger)||void 0===t||t.debug("Skipping update index; Number of participants has not changed")}wantsResubscribe(){return!this.parametersInEffect.equal(this.optimalParameters)}chooseCaptureAndEncodeParameters(){return this.parametersInEffect=this.optimalParameters.clone(),this.parametersInEffect.clone()}captureWidth(){let e=640;return this.getNumberOfPublishedVideoSources()>4&&(e=320),e}captureHeight(){let e=384;return this.getNumberOfPublishedVideoSources()>4&&(e=192),e}captureFrameRate(){return 15}maxBandwidthKbps(){if(this.hasBandwidthPriority)return Math.trunc(this.idealMaxBandwidthKbps);let e=0;return e=this.getNumberOfPublishedVideoSources()<=2?this.idealMaxBandwidthKbps:this.getNumberOfPublishedVideoSources()<=4?2*this.idealMaxBandwidthKbps/3:(544/11+14880/(11*this.getNumberOfPublishedVideoSources()))/600*this.idealMaxBandwidthKbps,Math.trunc(e)}setIdealMaxBandwidthKbps(e){this.idealMaxBandwidthKbps=e}setHasBandwidthPriority(e){this.hasBandwidthPriority=e}setTransceiverController(e){this.transceiverController=e}updateTransceiverController(){return i(this,void 0,void 0,(function*(){const e=this.getStreamCaptureSetting();if(!e)return;const t=this.calculateEncodingParameters(e);this.shouldUpdateEndcodingParameters(t)&&(this.encodingParamMap.set(a.encodingMapKey,t),this.transceiverController.setEncodingParameters(this.encodingParamMap))}))}shouldUpdateEndcodingParameters(e){var t,n;const i=null===(n=null===(t=this.transceiverController.localVideoTransceiver().sender.getParameters())||void 0===t?void 0:t.encodings)||void 0===n?void 0:n[0];return e.maxBitrate!==(null==i?void 0:i.maxBitrate)||e.scaleResolutionDownBy!==(null==i?void 0:i.scaleResolutionDownBy)}calculateEncodingParameters(e){var t,n;const i=1e3*this.maxBandwidthKbps();let r=1;if(void 0!==e.height&&void 0!==e.width&&this.scaleResolution&&!this.hasBandwidthPriority&&this.getNumberOfPublishedVideoSources()>2){let i=a.targetHeightArray[Math.min(this.getNumberOfPublishedVideoSources(),a.targetHeightArray.length-1)];480===i&&(null===(t=this.browserBehavior)||void 0===t?void 0:t.disable480pResolutionScaleDown())&&(i=360),r=Math.max(Math.min(e.height,e.width)/i,1),null===(n=this.logger)||void 0===n||n.info(`Resolution scale factor is ${r} for capture resolution ${e.width}x${e.height}. New dimension is ${e.width/r}x${e.height/r}`)}return{scaleResolutionDownBy:r,maxBitrate:i}}getStreamCaptureSetting(){var e,t,n,i;return null===(i=null===(n=null===(t=null===(e=this.transceiverController)||void 0===e?void 0:e.localVideoTransceiver())||void 0===t?void 0:t.sender)||void 0===n?void 0:n.track)||void 0===i?void 0:i.getSettings()}getNumberOfPublishedVideoSources(){var e;return null!==(e=this.numberOfPublishedVideoSources)&&void 0!==e?e:0}}t.default=a,a.encodingMapKey="video",a.targetHeightArray=[0,0,0,540,540,480,480,480,480,360,360,360,360,270,270,270,270,180,180,180,180,180,180,180,180,180]},657:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(1133);t.default=class{constructor(){}updateConnectionMetric(e){}chooseMediaTrackConstraints(){return{}}chooseEncodingParameters(){return new Map}updateIndex(e){}wantsResubscribe(){return!1}chooseCaptureAndEncodeParameters(){return new i.default(0,0,0,0,!1)}maxBandwidthKbps(){return 0}setIdealMaxBandwidthKbps(e){}setHasBandwidthPriority(e){}}},3928:(e,t)=>{"use strict";function n(e){return e.map((e=>"object"==typeof e?JSON.stringify(e):`${e}`)).join(" ")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e){this.base=e}debug(...e){this.base.debug(n(e))}info(...e){this.base.info(n(e))}warn(...e){this.base.warn(n(e))}error(...e){this.base.error(n(e))}}},2497:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceFocusDeviceTransformer=void 0;const r=n(6035),a=n(8690),o=n(4046),s=n(3928),c=n(8878),l=n(851);class u{constructor(e,{preload:t=!0,logger:n,fetchBehavior:i=u.defaultFetchBehavior()},r){this.spec=e,this.supported=!0,this.logger=n,this.vfLogger=n?new s.default(n):void 0,this.preload=t,this.fetchBehavior=i,this.spec=u.augmentSpec(this.spec),r&&(this.configuration=Promise.resolve(r))}static isSupported(e,t){var n,i;const o={fetchBehavior:u.defaultFetchBehavior(),logger:(null==t?void 0:t.logger)?new s.default(t.logger):void 0};if(a.isIFramed()){if(!1===(null==t?void 0:t.allowIFrame))return null===(n=null==t?void 0:t.logger)||void 0===n||n.error("Amazon Voice Focus support check inside iframe: not supported."),Promise.resolve(!1);null===(i=null==t?void 0:t.logger)||void 0===i||i.warn("Amazon Voice Focus support check inside iframe: not recommended.")}return r.VoiceFocus.isSupported(u.augmentSpec(e),o)}static create(e={},t={},n,r,a){var o,s,c;return i(this,void 0,void 0,(function*(){r&&r.Meeting.Meeting&&(r=r.Meeting);const i="AVAILABLE"===(null===(c=null===(s=null===(o=null==r?void 0:r.Meeting)||void 0===o?void 0:o.MeetingFeatures)||void 0===s?void 0:s.Audio)||void 0===c?void 0:c.EchoReduction),a=n&&!0===n.supported&&"ns_es"===n.model.name&&!i,l="ns_es"===e.name&&!i;if(a||l)throw new Error("Echo Reduction requested but not enabled.");const d=new u(e,t,n);return yield d.init(),d}))}static configure(e={},t={}){return i(this,void 0,void 0,(function*(){return new u(e,t,void 0).configure(!0)}))}getConfiguration(){return this.configuration}isSupported(){return this.supported}createTransformDevice(e,t){return i(this,void 0,void 0,(function*(){if(this.supported)try{const n=!0,[i,r]=yield this.allocateVoiceFocus(n),a=Object.assign(Object.assign({},t),{es:"ns_es"===this.spec.name});return new c.default(e,i,r,a)}catch(e){return}}))}static augmentSpec(e){return e&&(e.assetGroup||e.revisionID)?e:Object.assign(Object.assign({},e),{assetGroup:u.currentSDKAssetGroup()})}configure(e=!1){return i(this,void 0,void 0,(function*(){const t={fetchBehavior:this.fetchBehavior,preResolve:e,logger:this.vfLogger};return r.VoiceFocus.configure(this.spec,t)}))}init(){var e;return i(this,void 0,void 0,(function*(){this.configuration||(this.configuration=this.configure());const t=yield this.configuration;if(t.supported){this.pendingVoiceFocus=this.createVoiceFocus(t,this.preload);try{yield this.pendingVoiceFocus}catch(t){null===(e=this.logger)||void 0===e||e.error(`Unable to initialize Amazon Voice Focus: ${t}`),this.supported=!1}}else this.supported=!1}))}createVoiceFocus(e,t){return i(this,void 0,void 0,(function*(){const n=new l.default;return[yield r.VoiceFocus.init(e,{delegate:n,preload:t,logger:this.vfLogger}),n]}))}allocateVoiceFocus(e){return i(this,void 0,void 0,(function*(){if(!this.supported)throw new Error("Not supported.");if(this.pendingVoiceFocus){const e=this.pendingVoiceFocus;return this.pendingVoiceFocus=void 0,e}return this.createVoiceFocus(yield this.configuration,e)}))}static majorVersion(){return o.default.sdkVersion.match(/^[1-9][0-9]*\.(?:0|[1-9][0-9]*)/)[0]}static majorMinorVersion(){return o.default.sdkVersion.match(/^[1-9][0-9]*\.(?:0|(?:[1-9][0-9]*))\.(?:0|[1-9][0-9]*)/)[0]}static currentSDKAssetGroup(){const e=this.majorVersion();return e?`sdk-${e}`:"stable-v1"}static defaultFetchBehavior(){const e=u.majorMinorVersion()||"unknown",t=o.default.sdkUserAgentLowResolution;return{escapedQueryString:`sdk=${encodeURIComponent(e)}&ua=${encodeURIComponent(t)}`}}}t.VoiceFocusDeviceTransformer=u,t.default=u},8878:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(543);class a{constructor(e,t,n,i,a=!1,o,s=new r.default,c=new Map,l,u){this.device=e,this.voiceFocus=t,this.delegate=n,this.nodeOptions=i,this.failed=a,this.node=o,this.browserBehavior=s,this.farEndStreamToAudioSourceNode=c,this.mixDestNode=l,this.mixSourceNode=u}getInnerDevice(){return this.device}mute(e){return i(this,void 0,void 0,(function*(){this.node&&(e?yield this.node.disable():yield this.node.enable())}))}stop(){return i(this,void 0,void 0,(function*(){this.node&&(this.node.disconnect(),yield this.node.stop())}))}chooseNewInnerDevice(e){return i(this,void 0,void 0,(function*(){return this.device!==e||("default"===(t=e)||t&&"object"==typeof t&&("deviceId"in t&&"default"===t.deviceId||"id"in t&&"default"===t.id))?new a(e,this.voiceFocus,this.delegate,this.nodeOptions,this.failed,this.node,this.browserBehavior,this.farEndStreamToAudioSourceNode,this.mixDestNode,this.mixSourceNode):this;var t}))}intrinsicDevice(){return i(this,void 0,void 0,(function*(){if(this.failed)return this.device;const e=this.nodeOptions.es,t={echoCancellation:!e,googEchoCancellation:!e,googEchoCancellation2:!e,noiseSuppression:!1,googNoiseSuppression:!1,googHighpassFilter:!1,googNoiseSuppression2:!1};let n;return n=!this.nodeOptions||void 0===this.nodeOptions.agc||this.nodeOptions.agc.useBuiltInAGC,t.autoGainControl=n,t.googAutoGainControl=n,t.googAutoGainControl2=n,this.device?"string"==typeof this.device?(this.browserBehavior.requiresNoExactMediaStreamConstraints()?t.deviceId=this.device:t.deviceId={exact:this.device},t):this.device.id?this.device:Object.assign(Object.assign({},this.device),t):t}))}createAudioNode(e){var t,n;return i(this,void 0,void 0,(function*(){if((null===(t=this.node)||void 0===t?void 0:t.context)===e)return{start:this.node,end:this.node};const i=Object.assign({enabled:!0,agc:{useVoiceFocusAGC:!1}},this.nodeOptions);try{if(null===(n=this.node)||void 0===n||n.disconnect(),this.node=yield this.voiceFocus.createNode(e,i),this.nodeOptions.es){this.mixDestNode=new MediaStreamAudioDestinationNode(e,{channelCount:1,channelCountMode:"explicit"});for(const e of this.farEndStreamToAudioSourceNode.keys())this.assignFarEndStreamToAudioSourceNode(e);this.createMixSourceNode()}return{start:this.node,end:this.node}}catch(e){throw this.failed=!0,this.delegate.onFallback(this,e),e}}))}observeMeetingAudio(e){return i(this,void 0,void 0,(function*(){if(!this.nodeOptions.es)return;e.addAudioMixObserver(this);const t=yield e.getCurrentMeetingAudioStream();t&&this.addFarEndStream(t)}))}unObserveMeetingAudio(e){return i(this,void 0,void 0,(function*(){if(!this.nodeOptions.es)return;e.removeAudioMixObserver(this);const t=yield e.getCurrentMeetingAudioStream();t&&this.removeFarendStream(t)}))}addObserver(e){this.delegate.addObserver(e)}removeObserver(e){this.delegate.removeObserver(e)}addFarEndStream(e){return i(this,void 0,void 0,(function*(){this.nodeOptions.es&&e&&!this.farEndStreamToAudioSourceNode.has(e)&&(this.node?this.assignFarEndStreamToAudioSourceNode(e):this.farEndStreamToAudioSourceNode.set(e,null))}))}removeFarendStream(e){var t;return i(this,void 0,void 0,(function*(){null===(t=this.farEndStreamToAudioSourceNode.get(e))||void 0===t||t.disconnect(),this.farEndStreamToAudioSourceNode.delete(e)}))}meetingAudioStreamBecameActive(e){return i(this,void 0,void 0,(function*(){this.addFarEndStream(e)}))}meetingAudioStreamBecameInactive(e){return i(this,void 0,void 0,(function*(){this.removeFarendStream(e)}))}assignFarEndStreamToAudioSourceNode(e){const t=this.node.context.createMediaStreamSource(e);t.channelCount=1,t.channelCountMode="explicit",this.farEndStreamToAudioSourceNode.set(e,t),t.connect(this.mixDestNode,0)}createMixSourceNode(){this.mixSourceNode=this.node.context.createMediaStreamSource(this.mixDestNode.stream),this.mixSourceNode.channelCount=1,this.mixSourceNode.channelCountMode="explicit",this.mixSourceNode.connect(this.node,0,1)}}t.default=a},851:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.observers=new Set}addObserver(e){this.observers.add(e)}removeObserver(e){this.observers.delete(e)}onFallback(e,t){var n;for(const i of this.observers)null===(n=i.voiceFocusFellBackToInnerStream)||void 0===n||n.call(i,e,t)}onCPUWarning(){var e;for(const t of this.observers)null===(e=t.voiceFocusInsufficientResources)||void 0===e||e.call(t)}}},9751:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e,t,n,i,r){this.logger=e,this.realtimeController=t,this.minVolumeDecibels=n,this.maxVolumeDecibels=i,this.selfAttendeeId=r,this.streamIdToAttendeeId={},this.streamIdToExternalUserId={},this.warnedAboutMissingStreamIdMapping={},this.attendeeIdToStreamId={},this.sessionReconnected=!1}onReconnect(){this.sessionReconnected=!0}sendRealtimeUpdatesForAudioStreamIdInfo(e){let t=0;for(const n of e.streams){const i=!!n.attendeeId,r=!!n.externalUserId,a=n.hasOwnProperty("muted"),o=!!n.dropped;if(i){this.attendeeIdToStreamId[n.attendeeId]&&this.attendeeIdToStreamId[n.attendeeId]n.audioStreamId&&this.streamIdToAttendeeId[t]===i){a=!0;break}}a||this.realtimeController.realtimeSetAttendeeIdPresence(i,!1,r,o,{attendeeIndex:t++,attendeesInFrame:e.streams.length})}}}this.sessionReconnected&&(this.cleanUpState(e),this.sessionReconnected=!1)}cleanUpState(e){const t=Object.values(this.streamIdToAttendeeId),n=e.streams.map((e=>e.attendeeId)),i=t.filter((e=>!n.includes(e)));for(const[e,t]of i.entries()){const n=this.attendeeIdToStreamId[t],i=this.streamIdToExternalUserId[n];delete this.streamIdToAttendeeId[n],delete this.streamIdToExternalUserId[n],delete this.warnedAboutMissingStreamIdMapping[n],delete this.attendeeIdToStreamId[t],t!==this.selfAttendeeId?this.realtimeController.realtimeSetAttendeeIdPresence(t,!1,i,!1,{attendeeIndex:e,attendeesInFrame:t.length}):this.logger.warn("the volume indicator adapter cleans up the current attendee (presence = false) after reconnection")}}sendRealtimeUpdatesForAudioMetadata(e){let t=null,n=null;for(const i of e.attendeeStates){const e=this.attendeeIdForStreamId(i.audioStreamId);i.hasOwnProperty("volume")&&(null===t&&(t={}),null!==e&&(t[e]=this.normalizedVolume(i))),i.hasOwnProperty("signalStrength")&&(null===n&&(n={}),null!==e&&(n[e]=this.normalizedSignalStrength(i)))}this.applyRealtimeUpdatesForAudioMetadata(t,n)}normalizedVolume(e){const t=1-(-e.volume-this.maxVolumeDecibels)/(this.minVolumeDecibels-this.maxVolumeDecibels);return Math.min(Math.max(t,0),1)}normalizedSignalStrength(e){const t=e.signalStrength/n.MAX_SIGNAL_STRENGTH_LEVELS;return Math.min(Math.max(t,0),1)}applyRealtimeUpdatesForAudioMetadata(e,t){for(const i in this.streamIdToAttendeeId){const r=this.streamIdToAttendeeId[i],a=this.streamIdToExternalUserId[i];let o=null,s=null;null!==e&&(o=e.hasOwnProperty(r)?e[r]:n.IMPLICIT_VOLUME),null!==t&&(s=t.hasOwnProperty(r)?t[r]:n.IMPLICIT_SIGNAL_STRENGTH),null===o&&null===s||this.realtimeController.realtimeUpdateVolumeIndicator(r,o,null,s,a)}}attendeeIdForStreamId(e){if(0===e)return null;return this.streamIdToAttendeeId[e]||(this.warnedAboutMissingStreamIdMapping[e]||(this.warnedAboutMissingStreamIdMapping[e]=!0,this.logger.warn(`volume indicator stream id ${e} seen before being defined`)),null)}}t.default=n,n.MAX_SIGNAL_STRENGTH_LEVELS=2,n.IMPLICIT_VOLUME=0,n.IMPLICIT_SIGNAL_STRENGTH=1},7631:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(4046),r=n(7387);t.default=class{constructor(e){this.logger=e}create(e,t,n){this.connection=new WebSocket(n?e:i.default.urlWithVersion(e),t),this.connection.binaryType="arraybuffer"}send(e){if(!this.connection)return this.logger.error("WebSocket not yet created or already destroyed."),!1;try{return e instanceof Uint8Array?this.connection.send(e.buffer):this.connection.send(e),!0}catch(e){return this.logger.debug((()=>`send error: ${e.message}, websocket state=${r.default[this.readyState()]}`)),!1}}close(e,t){var n;null===(n=this.connection)||void 0===n||n.close(e,t)}destroy(){this.connection=void 0}addEventListener(e,t){this.connection?this.connection.addEventListener(e,t):this.logger.warn("Cannot add event listener with no WebSocket connection.")}removeEventListener(e,t){var n;null===(n=this.connection)||void 0===n||n.removeEventListener(e,t)}readyState(){if(!this.connection)return r.default.None;switch(this.connection.readyState){case WebSocket.CONNECTING:return r.default.Connecting;case WebSocket.OPEN:return r.default.Open;case WebSocket.CLOSING:return r.default.Closing;case WebSocket.CLOSED:return r.default.Closed}}}},7387:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketReadyState=void 0,function(e){e[e.None=0]="None",e[e.Connecting=1]="Connecting",e[e.Open=2]="Open",e[e.Closing=3]="Closing",e[e.Closed=4]="Closed"}(n=t.WebSocketReadyState||(t.WebSocketReadyState={})),t.default=n},5995:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.decideModel=t.measureAndDecideExecutionApproach=void 0;const r=n(5021),a=n(9424),o={wasm:{noSupport:.07,inline:{c100:1,c50:.36,c20:.16,c10:.07},worker:{c100:.5,c50:.18,c20:.08,c10:.06}},simd:{noSupport:.1,inline:{c100:1,c50:.43,c20:.3,c10:.2},worker:{c100:.5,c50:.21,c20:.15,c10:.1}}};class s{constructor(e,t){this.fetchConfig=e,this.logger=t;const n=`${e.paths.workers}estimator-v1.js`;this.fetchBehavior={headers:e.headers,escapedQueryString:e.escapedQueryString},this.worker=r.loadWorker(n,"VoiceFocusEstimator",this.fetchBehavior,t)}roundtrip(e,t,n){return new Promise(((i,r)=>{this.worker.then((r=>{let a;a=e=>{const{message:o,key:s}=e.data;o===t&&s===n&&(r.removeEventListener("message",a),i(e.data))},r.addEventListener("message",a),r.postMessage(e)})).catch((e=>{var t;null===(t=this.logger)||void 0===t||t.error("Failed to load worker.",e),r(e)}))}))}supportsSIMD(e){const t="simd",n=e||`${this.fetchConfig.paths.wasm}simd-v1.wasm`,i={message:"supports-simd",fetchBehavior:this.fetchBehavior,path:n,key:t};return this.roundtrip(i,"simd-support",t).then((e=>e.supports))}measure(e,t){const n=`${this.fetchConfig.paths.wasm}bench-v1.wasm`,i=`${this.fetchConfig.paths.wasm}bench-v1_simd.wasm`,r=e?i:n,a=`bench:${e}`,o={message:"measure",fetchBehavior:this.fetchBehavior,budget:t,path:r,key:a};return this.roundtrip(o,"measurement",a).then((e=>{if(e.measurement)return e.measurement;throw new Error("Failed to measure.")}))}stop(){this.worker.then((e=>{var t;null===(t=this.logger)||void 0===t||t.debug("Stopping estimator worker."),e.terminate()})).catch((e=>{}))}}const c=(e,t,n,r)=>i(void 0,void 0,void 0,(function*(){const i={supportsSIMD:e,supportsSAB:a.supportsSharedArrayBuffer(globalThis,window,n),duration:-1};if(e)return null==n||n.info("Supports SIMD: true (force)"),i;const o=!r,c=r||new s(t,n);try{const t=!a.isOldChrome(window,n)&&(yield c.supportsSIMD());return null==n||n.info(`Supports SIMD: ${t} (force: ${e})`),i.supportsSIMD=t,i}finally{o&&c.stop()}}));t.measureAndDecideExecutionApproach=(e,t,n,r=o)=>i(void 0,void 0,void 0,(function*(){let l=e.executionPreference;const{usagePreference:u,variantPreference:d,namePreference:h,simdPreference:f,estimatorBudget:p,executionQuantaPreference:m}=e;"interactivity"===u&&"inline"!==l&&(null==n||n.debug(`Overriding execution preference ${l} to reflect interactivity preference.`),l="inline");const g="force"===f,C="auto"!==d,v="auto"!==l;let y;try{y=C&&v?yield c(g,t,n):yield((e,t,n,r)=>i(void 0,void 0,void 0,(function*(){const i=new s(t,r);try{const a=yield c(e,t,r,i);if(a.supportsSIMD)try{return a.duration=yield i.measure(!0,n),null==r||r.info("SIMD timing:",a.duration),a}catch(e){null==r||r.warn("Failed SIMD estimation; falling back to non-SIMD."),a.supportsSIMD=!1}return a.duration=yield i.measure(!1,n),null==r||r.info("No-SIMD timing:",a.duration),a}catch(e){throw null==r||r.error("Could not feature check.",e),e}finally{i.stop()}})))(g,t,p,n)}catch(e){throw null==n||n.error("Could not load estimator.",e),new Error("Could not load Voice Focus estimator.")}return(({supportsSIMD:e,supportsSAB:t,duration:n,executionPreference:i="auto",simdPreference:r,variantPreference:s="auto",namePreference:c="default",usagePreference:l,executionQuantaPreference:u=3},d=o,h)=>{const f="force"===r||"disable"!==r&&e,p=-1!==n,m=p?(f?2.5:2.63)/n:0,g=f?d.simd:d.wasm,C=p?((e,t)=>1===e?.6:"quality"===t?.65*e:.5*e)(u,l)*m:0,v=p?.7*m:0,y=c,b=e=>({supported:!1,reason:e});if(p){if(m({supported:!0,useSIMD:f,processor:e,executionApproach:t,variant:n,executionQuanta:"inline"===t?u:void 0,name:y}),x=(e,t,n)=>"auto"!==t?!p||e>n[t]?t:"failed":e>n.c100?"c100":e>n.c50?"c50":e>n.c20?"c20":e>n.c10?"c10":"failed",_=e=>{switch(e||"auto"){case"auto":{let e=_("inline"),t=_("worker");return null==h||h.debug(`Reducing auto preference: ${JSON.stringify(e)} vs ${JSON.stringify(t)}`),!1===e.supported||!1===t.supported?t:e.variant===t.variant||"c50"===e.variant?e:t}case"worker":return a.supportsSharedArrayBuffer(globalThis,window,h)?_("worker-sab"):_("worker-postMessage");case"inline":{const e=x(C,s,g.inline);return"failed"===e?b(`Performance score ${C} not sufficient for inline use with variant preference ${s}.`):M("voicefocus-inline-processor","inline",e)}case"worker-sab":{if(!t){const e="Requested worker-sab but no SharedArrayBuffer support.";return null==h||h.warn(e),{supported:!1,reason:e}}const e=x(v,s,g.worker);return"failed"===e?b(`Performance score ${v} not sufficient for worker use with variant preference ${s}.`):M("voicefocus-worker-sab-processor","worker-sab",e)}case"worker-postMessage":{const e=x(v,s,g.worker);if("failed"===e)return b(`Performance score ${v} not sufficient for worker use.`);if("ns_es"===y){const e="Requested echo suppression but postMessage executor does not support it.";return null==h||h.warn(e),{supported:!1,reason:e}}return M("voicefocus-worker-postMessage-processor","worker-postMessage",e)}}};return _(i)})(Object.assign(Object.assign({},y),{simdPreference:f,executionPreference:l,variantPreference:d,namePreference:h,usagePreference:u,executionQuantaPreference:m}),r,n)})),t.decideModel=({category:e,name:t,variant:n,simd:i,url:r})=>`${e}-${t}-${n}-v1${i?"_simd":""}`},623:(e,t)=>{"use strict";function n(e,t,n){if(!n)return fetch(e,t);const a=r(e,n),o=i(t,n);return fetch(a,o)}function i(e,t){return(null==t?void 0:t.headers)?e?Object.assign(Object.assign({},e),{headers:Object.assign(Object.assign({},e.headers||{}),t.headers)}):{headers:t.headers}:e}function r(e,t){if(!(null==t?void 0:t.escapedQueryString))return e;const n=-1!==e.lastIndexOf("?");return`${e}${n?"&":"?"}${t.escapedQueryString}`}Object.defineProperty(t,"__esModule",{value:!0}),t.isValidRevisionID=t.isValidAssetGroup=t.resolveURL=t.addQueryParams=t.withQueryString=t.withRequestHeaders=t.fetchWithBehavior=void 0,t.fetchWithBehavior=n,t.withRequestHeaders=i,t.withQueryString=r,t.addQueryParams=function(e,t){const n=Object.keys(t);if(!n.length)return e;const i=new URLSearchParams(null==e?void 0:e.escapedQueryString);for(const e of n)i.append(e,t[e]);return Object.assign(Object.assign({},e),{escapedQueryString:i.toString()})};const a={method:"HEAD",mode:"cors",credentials:"omit",redirect:"follow",referrerPolicy:"origin"};t.resolveURL=function(e,t){return n(e,a,t).then((t=>t.redirected?t.url:e))},t.isValidAssetGroup=function(e){return!!e&&/^[-.a-zA-Z0-9]+$/.test(e)},t.isValidRevisionID=function(e){return!!e&&/^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{22}$/.test(e)}},5021:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.loadWorker=void 0;const i=n(623),r={method:"GET",mode:"cors",credentials:"omit",redirect:"follow",referrerPolicy:"no-referrer"};t.loadWorker=(e,t,n,a)=>{null==a||a.debug(`Loading ${t} worker from ${e}.`);let o=!1;try{o=self.origin===new URL(e).origin}catch(e){null==a||a.error("Could not compare origins.",e)}if(o){const r=i.withQueryString(e,n);return Promise.resolve(new Worker(r,{name:t}))}return i.fetchWithBehavior(e,r,n).then((e=>{if(e.ok)return e.blob().then((e=>new Worker(window.URL.createObjectURL(e))));throw new Error("Fetch failed.")}))}},9424:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.isOldChrome=t.supportsWASMStreaming=t.supportsSharedArrayBuffer=t.supportsWASM=t.supportsAudioWorklet=t.supportsWorker=t.supportsVoiceFocusWorker=t.supportsWASMPostMessage=t.isSafari=void 0;const r=n(5021);t.isSafari=(e=globalThis)=>{const t=e.navigator.userAgent,n=t.match(/Safari\//),i=t.match(/Chrom(?:e|ium)\//);return!(!n||i)},t.supportsWASMPostMessage=(e=globalThis)=>!t.isSafari(e)&&(!((e=globalThis)=>!!e.navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)/))(e)||(a(e)||0)<95),t.supportsVoiceFocusWorker=(e=globalThis,n,a)=>i(void 0,void 0,void 0,(function*(){if(!t.supportsWorker(e,a))return!1;const i=`${n.paths.workers}worker-v1.js`;try{const e=yield r.loadWorker(i,"VoiceFocusTestWorker",n,a);try{e.terminate()}catch(e){null==a||a.debug("Failed to terminate worker.",e)}return!0}catch(e){return null==a||a.info("Failed to fetch and instantiate test worker",e),!1}})),t.supportsWorker=(e=globalThis,t)=>{try{return!!e.Worker}catch(e){return null==t||t.info("Does not support Worker",e),!1}},t.supportsAudioWorklet=(e=globalThis,t)=>{try{return!!e.AudioWorklet&&!!e.AudioWorkletNode}catch(e){return null==t||t.info("Does not support Audio Worklet",e),!1}},t.supportsWASM=(e=globalThis,t)=>{try{return!(!e.WebAssembly||!e.WebAssembly.compile&&!e.WebAssembly.compileStreaming)}catch(e){return null==t||t.info("Does not support WASM",e),!1}},t.supportsSharedArrayBuffer=(e=globalThis,t=globalThis,n)=>{try{return!(!e.SharedArrayBuffer||!t.chrome&&!e.crossOriginIsolated)}catch(e){return null==n||n.info("Does not support SharedArrayBuffer."),!1}},t.supportsWASMStreaming=(e=globalThis,t)=>{var n;try{return!!(null===(n=e.WebAssembly)||void 0===n?void 0:n.compileStreaming)}catch(e){return null==t||t.info("Does not support WASM streaming compilation",e),!1}};const a=(e=globalThis)=>{try{if(!e.chrome)return}catch(e){}const t=e.navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)/);if(t)return parseInt(t[1],10)};t.isOldChrome=(e=globalThis,t)=>{const n=a(e);return!!n&&n<90&&(null==t||t.debug(`Chrome ${n} has incomplete SIMD support.`),!0)}},103:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VoiceFocusAudioWorkletNode=void 0;class n extends("undefined"!=typeof globalThis&&globalThis.AudioWorkletNode||class{}){}t.VoiceFocusAudioWorkletNode=n},6035:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getAudioInput=t.createAudioContext=t.VoiceFocus=void 0;const r=n(5995),a=n(623),o=n(5021),s=n(9424),c=n(2633),l=n(1678),u=n(271),d={useVoiceFocusAGC:!1,useBuiltInAGC:!0},h="stable-v1",f="https://static.sdkassets.chime.aws",p={processors:`${f}/processors/`,workers:`${f}/workers/`,wasm:`${f}/wasm/`,models:`${f}/wasm/`},m={latencyHint:0},g={channelCount:1,echoCancellation:!0,googEchoCancellation:!0,noiseSuppression:!1,googNoiseSuppression:!1,googHighpassFilter:!1,googTypingNoiseDetection:!1},C=Object.assign(Object.assign({},g),{autoGainControl:!0,googAutoGainControl:!0,googAutoGainControl2:!0}),v=Object.assign(Object.assign({},g),{autoGainControl:!1,googAutoGainControl:!1,googAutoGainControl2:!1}),y={"voicefocus-worker-sab-processor":{file:"worklet-worker-sab-processor-v1.js",node:l.default},"voicefocus-worker-postMessage-processor":{file:"worklet-worker-postMessage-processor-v1.js",node:u.default},"voicefocus-inline-processor":{file:"worklet-inline-processor-v1.js",node:c.default}},b=(e,t)=>{if(void 0!==e&&!a.isValidAssetGroup(e))throw new Error(`Invalid asset group ${e}`);if(void 0!==t&&!a.isValidRevisionID(t))throw new Error(`Invalid revision ID ${t}`)},M=(e,t)=>`${t.models}${r.decideModel(e)}.wasm`;class x{constructor(e,t,n,i,r){this.processorURL=t,this.nodeConstructor=n,this.nodeOptions=i,this.executionQuanta=r,this.internal={worker:e,nodeOptions:i}}static isSupported(e,t){const{fetchBehavior:n,logger:i}=t||{};if("undefined"==typeof globalThis)return null==i||i.debug("Browser does not have globalThis."),Promise.resolve(!1);if(!s.supportsAudioWorklet(globalThis,i))return null==i||i.debug("Browser does not support Audio Worklet."),Promise.resolve(!1);if(!s.supportsWASM(globalThis,i))return null==i||i.debug("Browser does not support WASM."),Promise.resolve(!1);s.supportsWASMStreaming(globalThis,i)||null==i||i.debug("Browser does not support streaming WASM compilation.");const{assetGroup:r=h,revisionID:o,paths:c=p}=e||{};b(r,o);const l=o?{revisionID:o}:{assetGroup:r},u=a.addQueryParams(n,l),d=Object.assign(Object.assign({},u),{paths:c});return s.supportsVoiceFocusWorker(globalThis,d,i)}static mungeExecutionPreference(e,t){const n=void 0===e||"auto"===e;if(s.isSafari(globalThis)){if(n||"inline"===e)return"inline";if(!n)throw new Error(`Unsupported execution preference ${e}`)}if("worker-sab"===e&&!s.supportsSharedArrayBuffer(globalThis,globalThis,t))throw new Error(`Unsupported execution preference ${e}`);return e||"auto"}static configure(e,t){return i(this,void 0,void 0,(function*(){const{fetchBehavior:n,preResolve:i,logger:o}=t||{},{category:s="voicefocus",name:c="default",variant:l="auto",assetGroup:u=h,revisionID:d,simd:f="detect",executionPreference:m="auto",executionQuantaPreference:g,usagePreference:C="interactivity",estimatorBudget:v=100,paths:y=p,thresholds:x}=e||{};if(null==o||o.debug("Configuring Voice Focus with spec",e),void 0!==s&&"voicefocus"!==s)throw new Error(`Unrecognized category ${s}`);if(void 0!==c&&"default"!==c&&"ns_es"!==c)throw new Error(`Unrecognized feature name ${c}`);if(void 0!==l&&!["auto","c100","c50","c20","c10"].includes(l))throw new Error(`Unrecognized feature variant ${l}`);if(void 0!==g&&![1,2,3].includes(g))throw new Error(`Unrecognized execution quanta preference ${g}`);if(b(u,d),void 0!==f&&!["detect","force","disable"].includes(f))throw new Error(`Unrecognized SIMD option ${f}`);if(void 0!==m&&!["auto","inline","worker","worker-sab","worker-postMessage"].includes(m))throw new Error(`Unrecognized execution preference ${m}`);if(void 0!==C&&!["quality","interactivity"].includes(C))throw new Error(`Unrecognized usage preference ${C}`);const _={executionPreference:this.mungeExecutionPreference(m,o),usagePreference:C,executionQuantaPreference:g,variantPreference:l,namePreference:c,simdPreference:f,estimatorBudget:v},S=d?{revisionID:d}:{assetGroup:u},w=a.addQueryParams(n,S),L=Object.assign({paths:y},w),E=yield r.measureAndDecideExecutionApproach(_,L,o,x);if(!1===E.supported)return{supported:!1,reason:E.reason};null==o||o.info("Decided execution approach",E);const{useSIMD:T,processor:z,variant:A,executionQuanta:V}=E,H={category:s||"voicefocus",name:c||"default",variant:A,simd:T};if(i){const e=M(H,y);H.url=yield a.resolveURL(e,w)}return{fetchConfig:L,model:H,processor:z,executionQuanta:V,supported:!0}}))}static init(e,{delegate:t,preload:n=!0,logger:r}){return i(this,void 0,void 0,(function*(){if(!1===e.supported)throw new Error("Voice Focus not supported. Reason: "+e.reason);const{model:i,processor:a,fetchConfig:c,executionQuanta:l}=e,{simd:u,name:d}=i,{paths:h}=c;if("voicefocus-inline-processor"!==a&&"voicefocus-worker-postMessage-processor"!==a&&"voicefocus-worker-sab-processor"!==a)throw new Error(`Unknown processor ${a}`);const f=i.url||M(i,h);null==r||r.debug(`Using model URL ${f}.`);const p=`${h.wasm}audio_buffer-v1${u?"_simd":""}.wasm`,m=`${h.wasm}resampler-v1${u?"_simd":""}.wasm`,g=`${h.workers}worker-v1.js`,{file:C,node:v}=y[a],b=`${h.processors}${C}`,_=yield o.loadWorker(g,"VoiceFocusWorker",c,r);if(n){null==r||r.debug("Preloading",f);let e=s.supportsWASMPostMessage(globalThis)?"get-module":"get-module-buffer";_.postMessage({message:e,preload:!0,key:"model",fetchBehavior:c,path:f})}const S=new x(_,b,v,{processor:a,worker:_,audioBufferURL:p,resamplerURL:m,fetchBehavior:c,modelURL:f,delegate:t,logger:r,numberOfInputs:"ns_es"===d?2:1},l);return Promise.resolve(S)}))}createNode(e,t){var n;const{voiceFocusSampleRate:i=(16e3===e.sampleRate?16e3:48e3),enabled:r=!0,agc:o=d}=t||{},s=null==t?void 0:t.es,c={voiceFocusSampleRate:i,enabled:r,sendBufferCount:10,prefill:6,agc:o,executionQuanta:this.executionQuanta,supportFarendStream:s},l=a.withQueryString(this.processorURL,null===(n=this.nodeOptions)||void 0===n?void 0:n.fetchBehavior);return e.audioWorklet.addModule(l).then((()=>new this.nodeConstructor(e,Object.assign(Object.assign({},this.nodeOptions),{processorOptions:c}))))}applyToStream(e,t,n){return i(this,void 0,void 0,(function*(){const i=t.createMediaStreamSource(e),r=yield this.applyToSourceNode(i,t,n),a=t.createMediaStreamDestination();return r.connect(a),{node:r,source:i,destination:a,stream:a.stream}}))}applyToSourceNode(e,t,n){return i(this,void 0,void 0,(function*(){const i=yield this.createNode(t,n);return e.connect(i),i}))}}t.VoiceFocus=x,t.createAudioContext=(e=m)=>new(window.AudioContext||window.webkitAudioContext)(e),t.getAudioInput=(e,t,n)=>i(void 0,void 0,void 0,(function*(){var i,r;const{constraints:a,spec:o,delegate:s,preload:c=!0,options:l}=t,{logger:u}=n,h=yield x.configure(o,n);if(!h.supported)return null===(i=n.logger)||void 0===i||i.warn("Voice Focus not supported; returning standard stream."),window.navigator.mediaDevices.getUserMedia(a);const f=yield x.init(h,{delegate:s,preload:c,logger:u}),p=(null===(r=t.options)||void 0===r?void 0:r.agc)||d,m=yield window.navigator.mediaDevices.getUserMedia(((e,t)=>{let n;if(n=t.useBuiltInAGC?C:v,!e)return{audio:n};if(!e.audio)return e;if(e.video)throw new Error("Not adding Voice Focus to multi-device getUserMedia call.");return Object.assign(Object.assign({},e),{audio:!0===e.audio?n:Object.assign(Object.assign({},e.audio),n)})})(a,p));return f.applyToStream(m,e,l).then((e=>e.stream))}))},2633:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9424),a=n(103);class o extends a.VoiceFocusAudioWorkletNode{constructor(e,t){super(e,t.processor,t),this.cpuWarningCount=0,this.channelCountMode="explicit",this.channelCount=1;const{modelURL:n,worker:i,fetchBehavior:a,logger:o,delegate:s}=t;this.logger=o,this.port.onmessage=this.onProcessorMessage.bind(this),this.delegate=s,o&&o.debug("VoiceFocusInlineNode:",n),this.worker=i,this.worker.onmessage=this.onWorkerMessage.bind(this);const c=r.supportsWASMPostMessage(globalThis)?"get-module":"get-module-buffer";this.worker.postMessage({message:c,key:"model",fetchBehavior:a,path:n})}onModuleBufferLoaded(e,t){this.port.postMessage({message:"module-buffer",buffer:e,key:t})}onModuleLoaded(e,t){this.port.postMessage({message:"module",module:e,key:t})}enable(){return i(this,void 0,void 0,(function*(){this.port.postMessage({message:"enable"})}))}disable(){return i(this,void 0,void 0,(function*(){this.port.postMessage({message:"disable"})}))}stop(){var e;return i(this,void 0,void 0,(function*(){this.port.postMessage({message:"stop"});try{null===(e=this.worker)||void 0===e||e.terminate()}catch(e){console.error("failed to terminate worker:",e)}this.disconnect()}))}onProcessorMessage(e){var t,n,i;const r=e.data;if("cpu"===r.message){this.cpuWarningCount++;const e=Date.now(),i=this.cpuWarningLastTriggered||e,a=Math.abs(e-i);(!this.cpuWarningLastTriggered||a>5e3)&&(null===(t=this.logger)||void 0===t||t.warn(`CPU warning (count: ${this.cpuWarningCount}):`,r.message),this.cpuWarningCount=0,this.cpuWarningLastTriggered=e),null===(n=this.delegate)||void 0===n||n.onCPUWarning()}else null===(i=this.logger)||void 0===i||i.debug("Ignoring processor message.")}onWorkerMessage(e){const t=e.data;switch(t.message){case"module-buffer":if(!t.buffer||!t.key)return;this.onModuleBufferLoaded(t.buffer,t.key);break;case"module":if(!t.module||!t.key)return;this.onModuleLoaded(t.module,t.key);break;case"stopped":this.worker&&this.worker.terminate();break;default:return}}}t.default=o},271:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9424),a=n(103);class o extends a.VoiceFocusAudioWorkletNode{constructor(e,t){super(e,t.processor,t),this.channelCountMode="explicit",this.channelCount=1;const{modelURL:n,audioBufferURL:i,worker:a,fetchBehavior:o,delegate:s}=t;this.delegate=s,this.worker=a,this.worker.onmessage=this.onWorkerMessage.bind(this),this.port.onmessage=this.onProcessorMessage.bind(this);const{enabled:c,agc:l,supportFarendStream:u}=t.processorOptions;this.worker.postMessage({message:"init",approach:"postMessage",frames:16e3===e.sampleRate?160:480,enabled:c,agc:l,fetchBehavior:o,model:n,supportFarendStream:u});const d=r.supportsWASMPostMessage(globalThis)?"get-module":"get-module-buffer";this.worker.postMessage({message:d,key:"buffer",fetchBehavior:o,path:i})}enable(){return i(this,void 0,void 0,(function*(){this.worker.postMessage({message:"enable"})}))}disable(){return i(this,void 0,void 0,(function*(){this.worker.postMessage({message:"disable"})}))}stop(){return i(this,void 0,void 0,(function*(){try{this.worker.postMessage({message:"stop"})}catch(e){}this.disconnect()}))}onWorkerMessage(e){var t;const n=e.data;switch(n.message){case"ready":this.port.postMessage({message:"ready",shared:n.shared},n.shared?Object.values(n.shared):[]);break;case"data":if(!n.buffer)return;this.port.postMessage({message:"data",buffer:n.buffer},[n.buffer]);break;case"stopped":this.worker.terminate();break;case"module-buffer":case"module":case"processing":this.port.postMessage(n);break;case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;default:return}}onProcessorMessage(e){var t;const n=e.data;switch(n.message){case"data":if(!n.buffer)return;this.worker.postMessage({message:"data",buffer:n.buffer},[n.buffer]);break;case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;case"prepare-for-frames":this.worker.postMessage(n);break;default:return}}}t.default=o},1678:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(9424),a=n(103);class o extends a.VoiceFocusAudioWorkletNode{constructor(e,t){super(e,t.processor,t),this.channelCountMode="explicit",this.channelCount=1;const{modelURL:n,resamplerURL:i,worker:a,fetchBehavior:o,delegate:s}=t;this.delegate=s,this.worker=a,this.worker.onmessage=this.onWorkerMessage.bind(this),this.port.onmessage=this.onProcessorMessage.bind(this);const{enabled:c,supportFarendStream:l}=t.processorOptions;this.worker.postMessage({message:"init",approach:"sab",frames:16e3===e.sampleRate?160:480,enabled:c,model:n,supportFarendStream:l});const u=r.supportsWASMPostMessage(globalThis)?"get-module":"get-module-buffer";this.worker.postMessage({message:u,key:"resampler",fetchBehavior:o,path:i})}enable(){return i(this,void 0,void 0,(function*(){this.state?(Atomics.store(this.state,1,1),Atomics.notify(this.state,0,1)):this.worker.postMessage({message:"enable"})}))}disable(){return i(this,void 0,void 0,(function*(){this.state?(Atomics.store(this.state,1,0),Atomics.notify(this.state,0,1)):this.worker.postMessage({message:"disable"})}))}stop(){return i(this,void 0,void 0,(function*(){if(this.state)Atomics.store(this.state,1,2),Atomics.notify(this.state,0,1);else try{this.worker.postMessage({message:"stop"})}catch(e){}this.disconnect()}))}onWorkerMessage(e){var t;const n=e.data;switch(n.message){case"ready":if(!n.shared)throw new Error("No shared state.");this.state=new Int32Array(n.shared.state),this.port.postMessage(n);break;case"stopped":this.worker.terminate();break;case"module-buffer":case"module":case"processing":this.port.postMessage(n);break;case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;default:return}}onProcessorMessage(e){var t;const n=e.data;switch(n.message){case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;case"prepare-for-frames":this.worker.postMessage(n)}}}t.default=o},9742:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),n=t[0],i=t[1];return 3*(n+i)/4-i},t.toByteArray=function(e){var t,n,a=c(e),o=a[0],s=a[1],l=new r(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),u=0,d=s>0?o-4:o;for(n=0;n>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===s&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,l[u++]=255&t),1===s&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l},t.fromByteArray=function(e){for(var t,i=e.length,r=i%3,a=[],o=16383,s=0,c=i-r;sc?c:s+o));return 1===r?(t=e[i-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===r&&(t=(e[i-2]<<8)+e[i-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),a.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,s=a.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,i){for(var r,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},5420:(e,t,n)=>{var i=n(8764).Buffer,r=Object.prototype.toString,a=void 0!==i&&"function"==typeof i.alloc&&"function"==typeof i.allocUnsafe&&"function"==typeof i.from;e.exports=function(e,t,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return o=e,"ArrayBuffer"===r.call(o).slice(8,-1)?function(e,t,n){t>>>=0;var r=e.byteLength-t;if(r<0)throw new RangeError("'offset' is out of bounds");if(void 0===n)n=r;else if((n>>>=0)>r)throw new RangeError("'length' is out of bounds");return a?i.from(e.slice(t,t+n)):new i(new Uint8Array(e.slice(t,t+n)))}(e,t,n):"string"==typeof e?function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');return a?i.from(e,t):new i(e,t)}(e,t):a?i.from(e):new i(e);var o}},8764:(e,t,n)=>{"use strict";const i=n(9742),r=n(645),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,n)}function l(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|m(e,t);let i=s(n);const r=i.write(e,t);return r!==n&&(i=i.slice(0,r)),i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(J(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(J(e,ArrayBuffer)||e&&J(e.buffer,ArrayBuffer))return f(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(J(e,SharedArrayBuffer)||e&&J(e.buffer,SharedArrayBuffer)))return f(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,n);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||$(e.length)?s(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return u(e),s(e<0?0:0|p(e))}function h(e){const t=e.length<0?0:0|p(e.length),n=s(t);for(let i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||J(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(e).length;default:if(r)return i?-1:q(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){let i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,n);case"utf8":case"utf-8":return L(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return z(this,t,n);case"base64":return w(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function C(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function v(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,i,r);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,i,r){let a,o=1,s=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,s/=2,c/=2,n/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let i=-1;for(a=n;as&&(n=s-c),a=n;a>=0;a--){let n=!0;for(let i=0;ir&&(i=r):i=r;const a=t.length;let o;for(i>a/2&&(i=a/2),o=0;o>8,r=n%256,a.push(r),a.push(i);return a}(t,e.length-n),e,n,i)}function w(e,t,n){return 0===t&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function L(e,t,n){n=Math.min(e.length,n);const i=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=n){let n,i,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[r+1],128==(192&n)&&(c=(31&t)<<6|63&n,c>127&&(a=c));break;case 3:n=e[r+1],i=e[r+2],128==(192&n)&&128==(192&i)&&(c=(15&t)<<12|(63&n)<<6|63&i,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[r+1],i=e[r+2],s=e[r+3],128==(192&n)&&128==(192&i)&&128==(192&s)&&(c=(15&t)<<18|(63&n)<<12|(63&i)<<6|63&s,c>65535&&c<1114112&&(a=c))}}null===a?(a=65533,o=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|1023&a),i.push(a),r+=o}return function(e){const t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);let n="",i=0;for(;ii.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(i,r)):Uint8Array.prototype.set.call(i,t,r);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(i,r)}r+=t.length}return i},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tn&&(e+=" ... "),""},a&&(c.prototype[a]=c.prototype.inspect),c.prototype.compare=function(e,t,n,i,r){if(J(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;let a=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(t>>>=0);const s=Math.min(a,o),l=this.slice(i,r),u=e.slice(t,n);for(let e=0;e>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return M(this,e,t,n);case"ascii":case"latin1":case"binary":return x(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function T(e,t,n){let i="";n=Math.min(e.length,n);for(let r=t;ri)&&(n=i);let r="";for(let i=t;in)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,n,i,r,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function P(e,t,n,i,r){U(t,i,r,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function I(e,t,n,i,r){U(t,i,r,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}function k(e,t,n,i,r,a){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function N(e,t,n,i,a){return t=+t,n>>>=0,a||k(e,0,n,4),r.write(e,t,n,i,23,4),n+4}function D(e,t,n,i,a){return t=+t,n>>>=0,a||k(e,0,n,8),r.write(e,t,n,i,52,8),n+8}c.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e],r=1,a=0;for(;++a>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e+--t],r=1;for(;t>0&&(r*=256);)i+=this[e+--t]*r;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(i)+(BigInt(r)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(i)<>>=0,t>>>=0,n||H(e,t,this.length);let i=this[e],r=1,a=0;for(;++a=r&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let i=t,r=1,a=this[e+--i];for(;i>0&&(r*=256);)a+=this[e+--i]*r;return r*=128,a>=r&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||H(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){e>>>=0,t||H(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const i=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(i)<>>=0,t||H(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||H(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||H(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||H(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,n,i){e=+e,t>>>=0,n>>>=0,i||R(this,e,t,n,Math.pow(2,8*n)-1,0);let r=1,a=0;for(this[t]=255&e;++a>>=0,n>>>=0,i||R(this,e,t,n,Math.pow(2,8*n)-1,0);let r=n-1,a=1;for(this[t+r]=255&e;--r>=0&&(a*=256);)this[t+r]=e/a&255;return t+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return P(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return I(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}let r=0,a=1,o=0;for(this[t]=255&e;++r>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t>>>=0,!i){const i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}let r=n-1,a=1,o=0;for(this[t+r]=255&e;--r>=0&&(a*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/a>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return P(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return I(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,n){return N(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return N(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(r=t;r=i+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function U(e,t,n,i,r,a){if(e>n||e3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(a+1)}${i}`:`>= -(2${i} ** ${8*(a+1)-1}${i}) and < 2 ** ${8*(a+1)-1}${i}`:`>= ${t}${i} and <= ${n}${i}`,new O.ERR_OUT_OF_RANGE("value",r,e)}!function(e,t,n){W(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||G(t,e.length-(n+1))}(i,r,a)}function W(e,t){if("number"!=typeof e)throw new O.ERR_INVALID_ARG_TYPE(t,"number",e)}function G(e,t,n){if(Math.floor(e)!==e)throw W(e,n),new O.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new O.ERR_BUFFER_OUT_OF_BOUNDS;throw new O.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}B("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),B("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),B("ERR_OUT_OF_RANGE",(function(e,t,n){let i=`The value of "${e}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=F(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=F(r)),r+="n"),i+=` It must be ${t}. Received ${r}`,i}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function q(e,t){let n;t=t||1/0;const i=e.length;let r=null;const a=[];for(let o=0;o55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&a.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function X(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,n,i){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function J(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function $(e){return e!=e}const K=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)t[i+r]=e[n]+e[r]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},58:(e,t,n)=>{"use strict";n.d(t,{Z:()=>f});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a),s=n(8243),c=n(5301),l=n(8444),u=n(9789),d=n(3317),h=o()(r());h.push([e.id,"@import url(https://fonts.googleapis.com/css2?family=Chicle&family=Poppins:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&display=swap);"]),h.i(s.Z),h.i(c.Z),h.i(l.Z),h.i(u.Z),h.i(d.Z),h.push([e.id,':root {\n --text-color: #333;\n --company-color1: rgba(64, 119, 187, 1);\n --company-color2: rgba(29, 47, 78, 1);\n --company-color3: rgba(255, 255, 255, 1);\n --company-color1-alpha: rgba(64, 119, 187, 0.3);\n --company-color2-alpha: rgba(29, 47, 78, 0.3);\n --company-color3-alpha: rgba(255, 255, 255, 0.3);\n --global-shadow-color: rgba(0, 0, 0, 0.4);\n\n --sidebar-transition-time: 0.3s;\n --sidebar-transition-animation: ease-in-out;\n\n --header-height: 1.5rem;\n --right-sidebar-width: 320px;\n\n --dialog-border-color: rgba(100, 100, 100, 1);\n --dialog-shadow-color: rgba(0, 0, 0, 0.3);\n --dialog-background-color: rgba(255, 255, 255, 1);\n --dialog-primary-color: rgba(19, 70, 209, 1);\n --dialog-active-color: rgba(40, 70, 209, 1);\n --dialog-input-border-color: rgba(200, 200, 200, 1);\n --dialog-submit-button-color: rgba(180, 190, 230, 1);\n --dialog-cancel-button-color: rgba(235, 80, 80, 1);\n}\n\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: "Poppins", sans-serif;\n}\nhtml {\n font-size: 16px;\n}\nbody {\n height: 100%;\n width: 100%;\n color: var(--text-color);\n background: linear-gradient(45deg, var(--company-color1) 0, 5%, var(--company-color2) 5% 10%, var(--company-color3) 10% 80%, var(--company-color1) 80% 85%, var(--company-color2) 85% 100%);\n}\n\n.application-container {\n position: relative;\n height: 100vh;\n width: 100%;\n overflow: hidden;\n list-style-type: none;\n}\n\n.state-control-checkbox {\n display: none;\n}\n\n.video-for-recorder-container {\n position: absolute;\n left: -1000px;\n width: 30px;\n height: 30px;\n}\n\n/* */\n/* */\n/* */\n/* start button */\n.front-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n margin-top: 30px;\n}\n.front-title {\n font-size: 4rem;\n font-weight: 100;\n}\n.front-description {\n font-size: 0.9rem;\n text-align: center;\n}\n.front-description-img {\n height: 2rem;\n}\n.front-description-strong {\n color: #f66;\n font-size: 0.9rem;\n font-weight: 600;\n}\n.front-start-button {\n font-size: 4rem;\n border: 3px solid #333;\n background: #eef;\n width: 500px;\n padding: 15px;\n cursor: pointer;\n text-align: center;\n margin: 100px 0 0 0 auto;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.front-note {\n font-size: 1rem;\n}\n.front-attention {\n font-size: 0.8rem;\n color: #f55;\n font-weight: 600;\n}\n.front-disclaimer {\n font-size: 0.8rem;\n}\n\n.voice-loader-audio-player {\n height: 50px;\n width: 100%;\n margin: 5px 5% 5px 5%;\n background: #444;\n /* box-shadow: 0 0 20px 0 #000a; */\n\n font-family: arial;\n color: white;\n font-size: 0.75em;\n overflow: hidden;\n\n display: grid;\n grid-template-rows: 10px auto;\n}\n.voice-loader-audio-player-timeline {\n background: white;\n width: 100%;\n position: relative;\n cursor: pointer;\n box-shadow: 0 2px 10px 0 #0008;\n}\n.voice-loader-audio-player-progress {\n background: coral;\n width: 0%;\n height: 100%;\n transition: 0.25s;\n}\n.voice-loader-audio-player-controls {\n display: flex;\n justify-content: space-between;\n align-items: stretch;\n padding: 0 20px;\n font-weight: 100;\n}\n.voice-loader-audio-player-controls > * {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n.voice-loader-audio-player-controls .toggle-play.play {\n cursor: pointer;\n position: relative;\n left: 0;\n height: 0;\n width: 0;\n border: 7px solid #0000;\n border-left: 13px solid white;\n }\n.voice-loader-audio-player-controls .toggle-play.play:hover {\n transform: scale(1.1);\n }\n.voice-loader-audio-player-controls .toggle-play.pause {\n height: 15px;\n width: 20px;\n cursor: pointer;\n position: relative;\n }\n.voice-loader-audio-player-controls .toggle-play.pause:before {\n position: absolute;\n top: 0;\n left: 0px;\n background: white;\n content: "";\n height: 15px;\n width: 3px;\n }\n.voice-loader-audio-player-controls .toggle-play.pause:after {\n position: absolute;\n top: 0;\n right: 8px;\n background: white;\n content: "";\n height: 15px;\n width: 3px;\n }\n.voice-loader-audio-player-controls .toggle-play.pause:hover {\n transform: scale(1.1);\n }\n.voice-loader-audio-player-time {\n display: flex;\n widht: 200px;\n}\n.voice-loader-audio-player-time > * {\n padding: 2px;\n }\n\n.voice-loader-audio-player-volume-container {\n cursor: pointer;\n\n position: relative;\n z-index: 2;\n}\n\n.voice-loader-audio-player-volume-container .voice-loader-audio-player-volume-slider {\n position: absolute;\n left: -3px;\n top: 15px;\n z-index: -1;\n width: 0;\n height: 15px;\n background: white;\n box-shadow: 0 0 20px #000a;\n transition: 0.25s;\n }\n\n.voice-loader-audio-player-volume-container .voice-loader-audio-player-volume-slider .voice-loader-audio-player-volume-percentage {\n background: coral;\n height: 100%;\n width: 75%;\n }\n\n.voice-loader-audio-player-volume-container:hover .voice-loader-audio-player-volume-slider {\n left: -123px;\n width: 120px;\n }\n.voice-loader-audio-player-volume-button {\n height: 26px;\n display: flex;\n align-items: center;\n}\n.voice-loader-audio-player-volume-button .volume {\n transform: scale(0.7);\n }\n.voice-loader-audio-player-button {\n cursor: pointer;\n}\n.voice-loader-audio-player-button:hover {\n font-weight: 600;\n }\n',""]);const f=h},8243:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a)()(r());o.push([e.id,'/* Header */\n.header-container {\n position: fixed;\n top: 0px;\n left: 0px;\n height: var(--header-height);\n width: 100vw;\n}\n/* Body*/\n.body-container {\n position: fixed;\n top: var(--header-height);\n left: 0px;\n height: calc(100vh - var(--header-height));\n background: linear-gradient(45deg, var(--company-color1) 0, 5%, var(--company-color2) 5% 10%, var(--company-color3) 10% 80%, var(--company-color1) 80% 85%, var(--company-color2) 85% 100%);\n}\n/* .open-right-sidebar-checkbox:checked + .body-container {\n width: calc(100vw - var(--right-sidebar-width));\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n}\n.open-right-sidebar-checkbox + .body-container {\n width: calc(100vw);\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n} */\n\n/* RightSidebar*/\n.right-sidebar-container {\n position: fixed;\n top: var(--header-height);\n height: calc(100vh - var(--header-height));\n display: flex;\n flex-direction: column;\n width: var(--right-sidebar-width);\n background: var(--company-color3);\n z-index: 100;\n}\n\n.right-sidebar-container:before {\n content: "";\n position: absolute;\n height: 100vh;\n width: var(--right-sidebar-width);\n background: var(--company-color2-alpha);\n z-index: -1;\n}\n.right-sidebar-container:after {\n content: "";\n position: absolute;\n height: 100vh;\n width: var(--right-sidebar-width);\n background: var(--company-color1-alpha);\n -webkit-clip-path: ellipse(158% 41% at 60% 30%);\n clip-path: ellipse(158% 41% at 60% 30%);\n z-index: -1;\n}\n.open-right-sidebar-checkbox:checked + .right-sidebar-container {\n right: 0;\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n}\n.open-right-sidebar-checkbox + .right-sidebar-container {\n right: calc(-1 * var(--right-sidebar-width));\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n}\n',""]);const s=o},5301:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a)()(r());o.push([e.id,"/* Header */\n.header {\n height: 100%;\n width: 100vw;\n background: #ffe;\n display: flex;\n justify-content: space-between;\n}\n.header-application-title-container {\n display: flex;\n}\n.header-application-title-logo {\n width: var(--header-height);\n height: var(--header-height);\n padding: 2px 2px 2px 2px;\n margin: 0px 2px 0px 5px;\n}\n.header-application-title-text {\n font-weight: 600;\n margin: 0px 2px 0px 2px;\n}\n\n.header-device-selector-container {\n margin: 0 10px 0 0;\n display: flex;\n}\n.header-device-selector-text {\n margin: 0px 2px 0px 10px;\n}\n/* .device-selector-option {\n font-size: 1rem;\n}\n.device-selector-select {\n max-width: 10rem;\n font-size: 0.7rem;\n} */\n\n.header-button-container {\n}\n",""]);const s=o},8444:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a)()(r());o.push([e.id,".body-content {\n background: var(--company-color1);\n width: 100%;\n height: 100%;\n}\n.body {\n background: var(--company-color1);\n width: 100%;\n height: 100%;\n}\n.body-main-video-for-avatar {\n position: absolute;\n left: -100px;\n width: 1%;\n height: 1%;\n}\n.body-main-canvas-for-avatar {\n position: absolute;\n left: -100px;\n width: 1%;\n height: 1%;\n}\n.body-main-canvas {\n width: 100%;\n height: 100%;\n -o-object-fit: contain;\n object-fit: contain;\n}\n",""]);const s=o},9789:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a)()(r());o.push([e.id,".right-sidebar {\n}\n/* Partition */\n.sidebar-partition {\n position: static;\n display: flex;\n flex-direction: column;\n width: 100%;\n color: rgba(255, 255, 255, 1);\n background: rgba(0, 0, 0, 0);\n z-index: 10;\n overflow: hidden;\n}\n.state-control-checkbox:checked + .sidebar-partition .sidebar-content {\n max-height: 800px;\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n}\n.state-control-checkbox + .sidebar-partition .sidebar-content {\n max-height: 0px;\n transition: all var(--sidebar-transition-time) var(--sidebar-transition-animation);\n}\n\n/* Header */\n.sidebar-header {\n position: static;\n width: 100%;\n height: var(--header-height);\n font-size: 1.1rem;\n background: rgba(10, 10, 10, 0.5);\n display: flex;\n justify-content: space-between;\n}\n.sidebar-header .sidebar-header-title {\n padding-left: 1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n.sidebar-header .sidebar-header-caret {\n align-items: right;\n }\n/* Content */\n.sidebar-content {\n padding: 0px 5px 0px 5px;\n position: static;\n width: 100%;\n height: auto;\n /* height: calc(100% - var(--header-height)); */\n background: rgba(200, 0, 0, 1);\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.sidebar-content-row {\n display: flex;\n width: 100%;\n justify-content: center;\n}\n.sidebar-content-row .sidebar-content-row-label {\n left: 0px;\n width: 30%;\n }\n.sidebar-content-row .sidebar-content-row-label-long {\n left: 0px;\n width: 50%;\n }\n.sidebar-content-row .sidebar-content-row-label-whole {\n left: 0px;\n width: 100%;\n }\n.sidebar-content-row .sidebar-content-row-select {\n left: 30%;\n width: 70%;\n }\n.sidebar-content-row .sidebar-content-row-text {\n left: 30%;\n width: 70%;\n }\n.sidebar-content-row .sidebar-content-row-spacer {\n width: 90%;\n height: 3px;\n margin-top: 5px;\n margin-bottom: 5px;\n background: #ddd;\n box-shadow: 1px 1px 2px 2px #000;\n }\n.sidebar-content-row .sidebar-content-row-buttons {\n left: 30%;\n width: 70%;\n display: flex;\n justify-content: flex-end;\n }\n\n.device-selector-option {\n font-size: 1rem;\n}\n.device-selector-select {\n max-width: 90%;\n min-width: 50%;\n font-size: 0.7rem;\n}\n.sidebar-content-row-select-option {\n font-size: 1rem;\n}\n.sidebar-content-row-select-select {\n max-width: 90%;\n min-width: 50%;\n font-size: 0.7rem;\n}\n.sidebar-content-row-input {\n width: 100%;\n font-size: 0.7rem;\n}\n.sidebar-content-row-button-container {\n /* margin: 5px 0px 2px 0px; */\n display: flex;\n width: 100%;\n justify-content: center;\n}\n\n.sidebar-content-row-button,\n.sidebar-content-row-button-activated,\n.sidebar-content-row-button-stanby {\n padding: 0px 5px 0px 5px;\n margin: 0px 5px 0px 5px;\n border-radius: 2px;\n border: 1px solid #446;\n cursor: pointer;\n /* width: 30%; */\n text-align: center;\n font-weight: 100;\n}\n.sidebar-content-row-button-activated {\n /* width: 50%; */\n background: #2e4;\n color: #000;\n}\n.sidebar-content-row-button-activated:hover {\n /* background: #4f5; */\n font-weight: 600;\n}\n.sidebar-content-row-button,\n.sidebar-content-row-button-stanby {\n background: #555;\n}\n.sidebar-content-row-button:hover,\n.sidebar-content-row-button-stanby:hover {\n /* background: #666; */\n font-weight: 400;\n}\n\n.sidebar-content-row-status-text {\n font-size: 1rem;\n display: flex;\n align-items: flex-end;\n width: 50%;\n}\n\n.output-audio-visializer {\n margin: 5%;\n width: 40%;\n height: 50px;\n}\n.output-audio-visializer-canvas {\n width: 100%;\n height: 100%;\n}\n.avatar-controller-video-setting-container {\n display: flex;\n}\n.avatar-controller-video {\n width: 50%;\n margin: 10px 0 10px 0;\n transform: scaleX(-1);\n}\n.avatar-controller-video-setting-items-container {\n display: flex;\n flex-direction: column;\n width: 50%;\n margin-left: 5px;\n}\n.avatar-controller-video-setting-item-row {\n display: flex;\n flex-direction: row;\n}\n.avatar-controller-video-setting-item-checkbox {\n margin-left: 5px;\n margin-right: 5px;\n}\n.avatar-controller-video-setting-item-label {\n width: 80%;\n}\n.avatar-controller-avatar-area {\n width: 100%;\n display: flex;\n flex-direction: column;\n -o-object-fit: contain;\n object-fit: contain;\n padding: 10px;\n}\n.avatar-controller-background-video {\n width: 1px;\n height: 1px;\n position: absolute;\n left: -100px;\n}\n.avatar-center-position-canvas {\n width: 100%;\n margin: 5px;\n}\n",""]);const s=o},3317:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var i=n(8081),r=n.n(i),a=n(3645),o=n.n(a)()(r());o.push([e.id,"/* 前提条件 */\n\n.rotate-button-container {\n height: var(--header-height);\n width: var(--header-height);\n position: relative;\n}\n.rotate-button {\n display: none;\n}\n.rotate-button ~ .rotate-lable {\n padding: 2px;\n position: absolute;\n transition: all 0.3s;\n cursor: pointer;\n height: var(--header-height);\n width: var(--header-height);\n}\n.rotate-button ~ .rotate-lable > * {\n width: 100%;\n height: 100%;\n float: left;\n transition: all 0.3s;\n}\n.rotate-button ~ .rotate-lable > * .spin-on {\n width: 100%;\n height: 100%;\n display: none;\n }\n.rotate-button ~ .rotate-lable > * .spin-off {\n width: 100%;\n height: 100%;\n display: blcok;\n }\n.rotate-button ~ .rotate-lable > .colored {\n color: rgba(200, 200, 200, 0.8);\n background: rgba(0, 0, 0, 1);\n transition: all 0.3s;\n}\n.rotate-button ~ .rotate-lable > .colored .spin-on {\n display: none;\n }\n.rotate-button ~ .rotate-lable > .colored .spin-off {\n display: block;\n }\n.rotate-button:checked ~ .rotate-lable > .colored {\n color: rgba(50, 240, 50, 0.8);\n background: rgba(60, 60, 60, 1);\n transition: all 0.3s;\n}\n.rotate-button:checked ~ .rotate-lable > .colored .spin-on {\n display: block;\n }\n.rotate-button:checked ~ .rotate-lable > .colored .spin-off {\n display: none;\n }\n\n.rotate-button:checked ~ .rotate-lable > .spinner {\n width: 100%;\n height: 100%;\n transform: rotate(-180deg);\n transition: all 0.3s;\n box-sizing: border-box;\n}\n\n.rotate-button:checked ~ .rotate-lable > .spinner .spin-on {\n display: block;\n }\n\n.rotate-button:checked ~ .rotate-lable > .spinner .spin-off {\n display: none;\n }\n",""]);const s=o},3645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,i,r,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(i)for(var s=0;s0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},8081:e=>{"use strict";e.exports=function(e){return e[1]}},3631:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BotInfo:()=>c,BrowserInfo:()=>a,NodeInfo:()=>o,ReactNativeInfo:()=>l,SearchBotDeviceInfo:()=>s,browserName:()=>m,detect:()=>f,detectOS:()=>C,getNodeVersion:()=>v,parseUserAgent:()=>g});var i=n(4155),r=function(e,t,n){if(n||2===arguments.length)for(var i,r=0,a=t.length;r{"use strict";var t,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,a),i(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}m(e,t,a,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,r)}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function l(e,t,n,i){var r,a,o,l;if(s(n),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]),void 0===o)o=a[t]=n,++e._eventsCount;else if("function"==typeof o?o=a[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=c(e))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function h(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var c=a[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var l=c.length,u=p(c,l);for(n=0;n=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,r=a;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},a.prototype.listenerCount=f,a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},645:(e,t)=>{t.read=function(e,t,n,i,r){var a,o,s=8*r-i-1,c=(1<>1,u=-7,d=n?r-1:0,h=n?-1:1,f=e[t+d];for(d+=h,a=f&(1<<-u)-1,f>>=-u,u+=s;u>0;a=256*a+e[t+d],d+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=i;u>0;o=256*o+e[t+d],d+=h,u-=8);if(0===a)a=1-l;else{if(a===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,i),a-=l}return(f?-1:1)*o*Math.pow(2,a-i)},t.write=function(e,t,n,i,r,a){var o,s,c,l=8*a-r-1,u=(1<>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:a-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*Math.pow(2,r),o+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[n+f]=255&s,f+=p,s/=256,r-=8);for(o=o<0;e[n+f]=255&o,f+=p,o/=256,l-=8);e[n+f-p]|=128*m}},9483:(e,t,n)=>{e.exports=function e(t,n,i){function r(o,s){if(!n[o]){if(!t[o]){if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};t[o][0].call(l.exports,(function(e){return r(t[o][1][e]||e)}),l,l.exports,e,t,n,i)}return n[o].exports}for(var a=void 0,o=0;o=43)}})).catch((function(){return!1}))}(e).then((function(e){return h=e}))}function y(e){var t=f[e.name],n={};n.promise=new o((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function b(e){var t=f[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function M(e,t){var n=f[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function x(e,t){return new o((function(n,i){if(f[e.name]=f[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);y(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var o=r.open.apply(r,a);t&&(o.onupgradeneeded=function(t){var n=o.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(d)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),i(o.error)},o.onsuccess=function(){var t=o.result;t.onversionchange=function(e){e.target.close()},n(t),b(e)}}))}function _(e){return x(e,!1)}function S(e){return x(e,!0)}function w(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.versione.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),r||n){if(n){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function L(e){return a([C(atob(e.data))],{type:e.type})}function E(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,n=t._initReady().then((function(){var e=f[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(n,e,e),n}function z(e,t,n,i){void 0===i&&(i=1);try{var r=e.db.transaction(e.storeName,t);n(null,r)}catch(r){if(i>0&&(!e.db||"InvalidStateError"===r.name||"NotFoundError"===r.name))return o.resolve().then((function(){if(!e.db||"NotFoundError"===r.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),S(e)})).then((function(){return function(e){y(e);for(var t=f[e.name],n=t.forages,i=0;i>4,u[c++]=(15&i)<<4|r>>2,u[c++]=(3&r)<<6|63&a;return l}function J(e){var t,n=new Uint8Array(e),i="";for(t=0;t>2],i+=V[(3&n[t])<<4|n[t+1]>>4],i+=V[(15&n[t+1])<<2|n[t+2]>>6],i+=V[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}var $={serialize:function(e,t){var n="";if(e&&(n=X.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===X.call(e.buffer))){var i,r=R;e instanceof ArrayBuffer?(i=e,r+=I):(i=e.buffer,"[object Int8Array]"===n?r+=N:"[object Uint8Array]"===n?r+=D:"[object Uint8ClampedArray]"===n?r+=O:"[object Int16Array]"===n?r+=B:"[object Uint16Array]"===n?r+=U:"[object Int32Array]"===n?r+=F:"[object Uint32Array]"===n?r+=W:"[object Float32Array]"===n?r+=G:"[object Float64Array]"===n?r+=j:t(new Error("Failed to get type for BinaryArray"))),t(r+J(i))}else if("[object Blob]"===n){var a=new FileReader;a.onload=function(){var n="~~local_forage_type~"+e.type+"~"+J(this.result);t("__lfsc__:blob"+n)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,P)!==R)return JSON.parse(e);var t,n=e.substring(q),i=e.substring(P,q);if(i===k&&H.test(n)){var r=n.match(H);t=r[1],n=n.substring(r[0].length)}var o=Y(n);switch(i){case I:return o;case k:return a([o],{type:t});case N:return new Int8Array(o);case D:return new Uint8Array(o);case O:return new Uint8ClampedArray(o);case B:return new Int16Array(o);case U:return new Uint16Array(o);case F:return new Int32Array(o);case W:return new Uint32Array(o);case G:return new Float32Array(o);case j:return new Float64Array(o);default:throw new Error("Unkown type: "+i)}},stringToBuffer:Y,bufferToString:J};function K(e,t,n,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,i)}function Z(e,t,n,i,r,a){e.executeSql(n,i,r,(function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,s){s.rows.length?a(e,o):K(e,t,(function(){e.executeSql(n,i,r,a)}),a)}),a):a(e,o)}),a)}function Q(e,t,n,i){var r=this;e=l(e);var a=new o((function(a,o){r.ready().then((function(){void 0===t&&(t=null);var s=t,c=r._dbInfo;c.serializer.serialize(t,(function(t,l){l?o(l):c.db.transaction((function(n){Z(n,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){a(s)}),(function(e,t){o(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void a(Q.apply(r,[e,s,n,i-1]));o(t)}}))}))})).catch(o)}));return s(a,n),a}function ee(e){return new o((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var r=[],a=0;a0}var re={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=ne(e,this._defaultConfig),ie()?(this._dbInfo=t,t.serializer=$,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,r=i.length,a=localStorage.length,o=1,s=0;s=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return s(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return s(t,e),t},key:function(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return s(i,t),i},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],r=0;r=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):o.reject("Invalid arguments"),s(i,t),i}},ae=function(e,t){for(var n=e.length,i=0;i{"use strict";const{Deflate:i,deflate:r,deflateRaw:a,gzip:o}=n(4555),{Inflate:s,inflate:c,inflateRaw:l,ungzip:u}=n(8843),d=n(1619);e.exports.Deflate=i,e.exports.deflate=r,e.exports.deflateRaw=a,e.exports.gzip=o,e.exports.Inflate=s,e.exports.inflate=c,e.exports.inflateRaw=l,e.exports.ungzip=u,e.exports.constants=d},4555:(e,t,n)=>{"use strict";const i=n(405),r=n(6247),a=n(9373),o=n(8898),s=n(2292),c=Object.prototype.toString,{Z_NO_FLUSH:l,Z_SYNC_FLUSH:u,Z_FULL_FLUSH:d,Z_FINISH:h,Z_OK:f,Z_STREAM_END:p,Z_DEFAULT_COMPRESSION:m,Z_DEFAULT_STRATEGY:g,Z_DEFLATED:C}=n(1619);function v(e){this.options=r.assign({level:m,method:C,chunkSize:16384,windowBits:15,memLevel:8,strategy:g},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;let n=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==f)throw new Error(o[n]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?a.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=i.deflateSetDictionary(this.strm,e),n!==f)throw new Error(o[n]);this._dict_set=!0}}function y(e,t){const n=new v(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}v.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let o,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?h:l,"string"==typeof e?n.input=a.string2buf(e):"[object ArrayBuffer]"===c.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===u||s===d)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(o=i.deflate(n,s),o===p)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),o=i.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===f;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},v.prototype.onData=function(e){this.chunks.push(e)},v.prototype.onEnd=function(e){e===f&&(this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},e.exports.Deflate=v,e.exports.deflate=y,e.exports.deflateRaw=function(e,t){return(t=t||{}).raw=!0,y(e,t)},e.exports.gzip=function(e,t){return(t=t||{}).gzip=!0,y(e,t)},e.exports.constants=n(1619)},8843:(e,t,n)=>{"use strict";const i=n(6351),r=n(6247),a=n(9373),o=n(8898),s=n(2292),c=n(2401),l=Object.prototype.toString,{Z_NO_FLUSH:u,Z_FINISH:d,Z_OK:h,Z_STREAM_END:f,Z_NEED_DICT:p,Z_STREAM_ERROR:m,Z_DATA_ERROR:g,Z_MEM_ERROR:C}=n(1619);function v(e){this.options=r.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;let n=i.inflateInit2(this.strm,t.windowBits);if(n!==h)throw new Error(o[n]);if(this.header=new c,i.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=a.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=i.inflateSetDictionary(this.strm,t.dictionary),n!==h)))throw new Error(o[n])}function y(e,t){const n=new v(t);if(n.push(e),n.err)throw n.msg||o[n.err];return n.result}v.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,o=this.options.dictionary;let s,c,v;if(this.ended)return!1;for(c=t===~~t?t:!0===t?d:u,"[object ArrayBuffer]"===l.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=i.inflate(n,c),s===p&&o&&(s=i.inflateSetDictionary(n,o),s===h?s=i.inflate(n,c):s===g&&(s=p));n.avail_in>0&&s===f&&n.state.wrap>0&&0!==e[n.next_in];)i.inflateReset(n),s=i.inflate(n,c);switch(s){case m:case g:case p:case C:return this.onEnd(s),this.ended=!0,!1}if(v=n.avail_out,n.next_out&&(0===n.avail_out||s===f))if("string"===this.options.to){let e=a.utf8border(n.output,n.next_out),t=n.next_out-e,i=a.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==h||0!==v){if(s===f)return s=i.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},v.prototype.onData=function(e){this.chunks.push(e)},v.prototype.onEnd=function(e){e===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},e.exports.Inflate=v,e.exports.inflate=y,e.exports.inflateRaw=function(e,t){return(t=t||{}).raw=!0,y(e,t)},e.exports.ungzip=y,e.exports.constants=n(1619)},6247:e=>{"use strict";const t=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);e.exports.assign=function(e){const n=Array.prototype.slice.call(arguments,1);for(;n.length;){const i=n.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const n in i)t(i,n)&&(e[n]=i[n])}}return e},e.exports.flattenChunks=e=>{let t=0;for(let n=0,i=e.length;n{"use strict";let t=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){t=!1}const n=new Uint8Array(256);for(let e=0;e<256;e++)n[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;n[254]=n[254]=1,e.exports.string2buf=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,i,r,a,o=e.length,s=0;for(r=0;r>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},e.exports.buf2string=(e,i)=>{const r=i||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,i));let a,o;const s=new Array(2*r);for(o=0,a=0;a4)s[o++]=65533,a+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&a1?s[o++]=65533:t<65536?s[o++]=t:(t-=65536,s[o++]=55296|t>>10&1023,s[o++]=56320|1023&t)}}return((e,n)=>{if(n<65534&&e.subarray&&t)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let i="";for(let t=0;t{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+n[e[i]]>t?i:t}},6069:e=>{"use strict";e.exports=(e,t,n,i)=>{let r=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+t[i++]|0,a=a+r|0}while(--o);r%=65521,a%=65521}return r|a<<16|0}},1619:e=>{"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},2869:e=>{"use strict";const t=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());e.exports=(e,n,i,r)=>{const a=t,o=r+i;e^=-1;for(let t=r;t>>8^a[255&(e^n[t])];return-1^e}},405:(e,t,n)=>{"use strict";const{_tr_init:i,_tr_stored_block:r,_tr_flush_block:a,_tr_tally:o,_tr_align:s}=n(342),c=n(6069),l=n(2869),u=n(8898),{Z_NO_FLUSH:d,Z_PARTIAL_FLUSH:h,Z_FULL_FLUSH:f,Z_FINISH:p,Z_BLOCK:m,Z_OK:g,Z_STREAM_END:C,Z_STREAM_ERROR:v,Z_DATA_ERROR:y,Z_BUF_ERROR:b,Z_DEFAULT_COMPRESSION:M,Z_FILTERED:x,Z_HUFFMAN_ONLY:_,Z_RLE:S,Z_FIXED:w,Z_DEFAULT_STRATEGY:L,Z_UNKNOWN:E,Z_DEFLATED:T}=n(1619),z=258,A=262,V=103,H=113,R=666,P=(e,t)=>(e.msg=u[t],t),I=e=>(e<<1)-(e>4?9:0),k=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let N=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},O=(e,t)=>{a(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,D(e.strm)},B=(e,t)=>{e.pending_buf[e.pending++]=t},F=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},U=(e,t,n,i)=>{let r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),n),1===e.state.wrap?e.adler=c(e.adler,t,r,n):2===e.state.wrap&&(e.adler=l(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)},W=(e,t)=>{let n,i,r=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-A?e.strstart-(e.w_size-A):0,l=e.window,u=e.w_mask,d=e.prev,h=e.strstart+z;let f=l[a+o-1],p=l[a+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do{if(n=t,l[n+o]===p&&l[n+o-1]===f&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do{}while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ao){if(e.match_start=t,o=i,i>=s)break;f=l[a+o-1],p=l[a+o]}}}while((t=d[t&u])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},G=e=>{const t=e.w_size;let n,i,r,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-A)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,n=i;do{r=e.head[--n],e.head[n]=r>=t?r-t:0}while(--i);i=t,n=i;do{r=e.prev[--n],e.prev[n]=r>=t?r-t:0}while(--i);a+=t}if(0===e.strm.avail_in)break;if(i=U(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=N(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=N(e,e.ins_h,e.window[o+3-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,i;for(;;){if(e.lookahead=3&&(e.ins_h=N(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-A&&(e.match_length=W(e,n)),e.match_length>=3)if(i=o(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=N(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=N(e,e.ins_h,e.window[e.strstart+1]);else i=o(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(O(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===p?(O(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?1:2},q=(e,t)=>{let n,i,r;for(;;){if(e.lookahead=3&&(e.ins_h=N(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,i=o(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=N(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(O(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=o(e,0,e.window[e.strstart-1]),i&&O(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=o(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===p?(O(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?1:2};function X(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}const Y=[new X(0,0,0,0,((e,t)=>{let n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(G(e),0===e.lookahead&&t===d)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,O(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-A&&(O(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===p?(O(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(O(e,!1),e.strm.avail_out),1)})),new X(4,4,8,4,j),new X(4,5,16,8,j),new X(4,6,32,32,j),new X(4,4,16,16,q),new X(8,16,32,32,q),new X(8,16,128,128,q),new X(8,32,128,256,q),new X(32,128,258,1024,q),new X(32,258,258,4096,q)];function J(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=T,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),k(this.dyn_ltree),k(this.dyn_dtree),k(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),k(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),k(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const $=e=>{if(!e||!e.state)return P(e,v);e.total_in=e.total_out=0,e.data_type=E;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:H,e.adler=2===t.wrap?0:1,t.last_flush=d,i(t),g},K=e=>{const t=$(e);var n;return t===g&&((n=e.state).window_size=2*n.w_size,k(n.head),n.max_lazy_match=Y[n.level].max_lazy,n.good_match=Y[n.level].good_length,n.nice_match=Y[n.level].nice_length,n.max_chain_length=Y[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Z=(e,t,n,i,r,a)=>{if(!e)return v;let o=1;if(t===M&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==T||i<8||i>15||t<0||t>9||a<0||a>w)return P(e,v);8===i&&(i=9);const s=new J;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=i,s.w_size=1<Z(e,t,T,15,8,L),e.exports.deflateInit2=Z,e.exports.deflateReset=K,e.exports.deflateResetKeep=$,e.exports.deflateSetHeader=(e,t)=>e&&e.state?2!==e.state.wrap?v:(e.state.gzhead=t,g):v,e.exports.deflate=(e,t)=>{let n,i;if(!e||!e.state||t>m||t<0)return e?P(e,v):v;const a=e.state;if(!e.output||!e.input&&0!==e.avail_in||a.status===R&&t!==p)return P(e,0===e.avail_out?b:v);a.strm=e;const c=a.last_flush;if(a.last_flush=t,42===a.status)if(2===a.wrap)e.adler=0,B(a,31),B(a,139),B(a,8),a.gzhead?(B(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),B(a,255&a.gzhead.time),B(a,a.gzhead.time>>8&255),B(a,a.gzhead.time>>16&255),B(a,a.gzhead.time>>24&255),B(a,9===a.level?2:a.strategy>=_||a.level<2?4:0),B(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(B(a,255&a.gzhead.extra.length),B(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=l(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69):(B(a,0),B(a,0),B(a,0),B(a,0),B(a,0),B(a,9===a.level?2:a.strategy>=_||a.level<2?4:0),B(a,3),a.status=H);else{let t=T+(a.w_bits-8<<4)<<8,n=-1;n=a.strategy>=_||a.level<2?0:a.level<6?1:6===a.level?2:3,t|=n<<6,0!==a.strstart&&(t|=32),t+=31-t%31,a.status=H,F(a,t),0!==a.strstart&&(F(a,e.adler>>>16),F(a,65535&e.adler)),e.adler=1}if(69===a.status)if(a.gzhead.extra){for(n=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>n&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),D(e),n=a.pending,a.pending!==a.pending_buf_size));)B(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>n&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=73)}else a.status=73;if(73===a.status)if(a.gzhead.name){n=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>n&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),D(e),n=a.pending,a.pending===a.pending_buf_size)){i=1;break}i=a.gzindexn&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),0===i&&(a.gzindex=0,a.status=91)}else a.status=91;if(91===a.status)if(a.gzhead.comment){n=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>n&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),D(e),n=a.pending,a.pending===a.pending_buf_size)){i=1;break}i=a.gzindexn&&(e.adler=l(e.adler,a.pending_buf,a.pending-n,n)),0===i&&(a.status=V)}else a.status=V;if(a.status===V&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&D(e),a.pending+2<=a.pending_buf_size&&(B(a,255&e.adler),B(a,e.adler>>8&255),e.adler=0,a.status=H)):a.status=H),0!==a.pending){if(D(e),0===e.avail_out)return a.last_flush=-1,g}else if(0===e.avail_in&&I(t)<=I(c)&&t!==p)return P(e,b);if(a.status===R&&0!==e.avail_in)return P(e,b);if(0!==e.avail_in||0!==a.lookahead||t!==d&&a.status!==R){let n=a.strategy===_?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(G(e),0===e.lookahead)){if(t===d)return 1;break}if(e.match_length=0,n=o(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(O(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===p?(O(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?1:2})(a,t):a.strategy===S?((e,t)=>{let n,i,r,a;const s=e.window;for(;;){if(e.lookahead<=z){if(G(e),e.lookahead<=z&&t===d)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,i=s[r],i===s[++r]&&i===s[++r]&&i===s[++r])){a=e.strstart+z;do{}while(i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(O(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===p?(O(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(O(e,!1),0===e.strm.avail_out)?1:2})(a,t):Y[a.level].func(a,t);if(3!==n&&4!==n||(a.status=R),1===n||3===n)return 0===e.avail_out&&(a.last_flush=-1),g;if(2===n&&(t===h?s(a):t!==m&&(r(a,0,0,!1),t===f&&(k(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),D(e),0===e.avail_out))return a.last_flush=-1,g}return t!==p?g:a.wrap<=0?C:(2===a.wrap?(B(a,255&e.adler),B(a,e.adler>>8&255),B(a,e.adler>>16&255),B(a,e.adler>>24&255),B(a,255&e.total_in),B(a,e.total_in>>8&255),B(a,e.total_in>>16&255),B(a,e.total_in>>24&255)):(F(a,e.adler>>>16),F(a,65535&e.adler)),D(e),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?g:C)},e.exports.deflateEnd=e=>{if(!e||!e.state)return v;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&t!==V&&t!==H&&t!==R?P(e,v):(e.state=null,t===H?P(e,y):g)},e.exports.deflateSetDictionary=(e,t)=>{let n=t.length;if(!e||!e.state)return v;const i=e.state,r=i.wrap;if(2===r||1===r&&42!==i.status||i.lookahead)return v;if(1===r&&(e.adler=c(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){0===r&&(k(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(n-i.w_size,n),0),t=e,n=i.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,G(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=N(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,G(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,i.wrap=r,g},e.exports.deflateInfo="pako deflate (from Nodeca project)"},2401:e=>{"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},4264:e=>{"use strict";e.exports=function(e,t){let n,i,r,a,o,s,c,l,u,d,h,f,p,m,g,C,v,y,b,M,x,_,S,w;const L=e.state;n=e.next_in,S=e.input,i=n+(e.avail_in-5),r=e.next_out,w=e.output,a=r-(t-e.avail_out),o=r+(e.avail_out-257),s=L.dmax,c=L.wsize,l=L.whave,u=L.wnext,d=L.window,h=L.hold,f=L.bits,p=L.lencode,m=L.distcode,g=(1<>>24,h>>>=y,f-=y,y=v>>>16&255,0===y)w[r++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=p[(65535&v)+(h&(1<>>=y,f-=y),f<15&&(h+=S[n++]<>>24,h>>>=y,f-=y,y=v>>>16&255,!(16&y)){if(0==(64&y)){v=m[(65535&v)+(h&(1<s){e.msg="invalid distance too far back",L.mode=30;break e}if(h>>>=y,f-=y,y=r-a,M>y){if(y=M-y,y>l&&L.sane){e.msg="invalid distance too far back",L.mode=30;break e}if(x=0,_=d,0===u){if(x+=c-y,y2;)w[r++]=_[x++],w[r++]=_[x++],w[r++]=_[x++],b-=3;b&&(w[r++]=_[x++],b>1&&(w[r++]=_[x++]))}else{x=r-M;do{w[r++]=w[x++],w[r++]=w[x++],w[r++]=w[x++],b-=3}while(b>2);b&&(w[r++]=w[x++],b>1&&(w[r++]=w[x++]))}break}}break}}while(n>3,n-=b,f-=b<<3,h&=(1<{"use strict";const i=n(6069),r=n(2869),a=n(4264),o=n(9241),{Z_FINISH:s,Z_BLOCK:c,Z_TREES:l,Z_OK:u,Z_STREAM_END:d,Z_NEED_DICT:h,Z_STREAM_ERROR:f,Z_DATA_ERROR:p,Z_MEM_ERROR:m,Z_BUF_ERROR:g,Z_DEFLATED:C}=n(1619),v=12,y=30,b=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const x=e=>{if(!e||!e.state)return f;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,u},_=e=>{if(!e||!e.state)return f;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,x(e)},S=(e,t)=>{let n;if(!e||!e.state)return f;const i=e.state;return t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?f:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,_(e))},w=(e,t)=>{if(!e)return f;const n=new M;e.state=n,n.window=null;const i=S(e,t);return i!==u&&(e.state=null),i};let L,E,T=!0;const z=e=>{if(T){L=new Int32Array(512),E=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(o(1,e.lens,0,288,L,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;o(2,e.lens,0,32,E,0,e.work,{bits:5}),T=!1}e.lencode=L,e.lenbits=9,e.distcode=E,e.distbits=5},A=(e,t,n,i)=>{let r;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>i&&(r=i),a.window.set(t.subarray(n-i,n-i+r),a.wnext),(i-=r)?(a.window.set(t.subarray(n-i,n),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whavew(e,15),e.exports.inflateInit2=w,e.exports.inflate=(e,t)=>{let n,M,x,_,S,w,L,E,T,V,H,R,P,I,k,N,D,O,B,F,U,W,G=0;const j=new Uint8Array(4);let q,X;const Y=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return f;n=e.state,n.mode===v&&(n.mode=13),S=e.next_out,x=e.output,L=e.avail_out,_=e.next_in,M=e.input,w=e.avail_in,E=n.hold,T=n.bits,V=w,H=L,W=u;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;T<16;){if(0===w)break e;w--,E+=M[_++]<>>8&255,n.check=r(n.check,j,2,0),E=0,T=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&E)<<8)+(E>>8))%31){e.msg="incorrect header check",n.mode=y;break}if((15&E)!==C){e.msg="unknown compression method",n.mode=y;break}if(E>>>=4,T-=4,U=8+(15&E),0===n.wbits)n.wbits=U;else if(U>n.wbits){e.msg="invalid window size",n.mode=y;break}n.dmax=1<>8&1),512&n.flags&&(j[0]=255&E,j[1]=E>>>8&255,n.check=r(n.check,j,2,0)),E=0,T=0,n.mode=3;case 3:for(;T<32;){if(0===w)break e;w--,E+=M[_++]<>>8&255,j[2]=E>>>16&255,j[3]=E>>>24&255,n.check=r(n.check,j,4,0)),E=0,T=0,n.mode=4;case 4:for(;T<16;){if(0===w)break e;w--,E+=M[_++]<>8),512&n.flags&&(j[0]=255&E,j[1]=E>>>8&255,n.check=r(n.check,j,2,0)),E=0,T=0,n.mode=5;case 5:if(1024&n.flags){for(;T<16;){if(0===w)break e;w--,E+=M[_++]<>>8&255,n.check=r(n.check,j,2,0)),E=0,T=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(R=n.length,R>w&&(R=w),R&&(n.head&&(U=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(M.subarray(_,_+R),U)),512&n.flags&&(n.check=r(n.check,M,R,_)),w-=R,_+=R,n.length-=R),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===w)break e;R=0;do{U=M[_+R++],n.head&&U&&n.length<65536&&(n.head.name+=String.fromCharCode(U))}while(U&&R>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=v;break;case 10:for(;T<32;){if(0===w)break e;w--,E+=M[_++]<>>=7&T,T-=7&T,n.mode=27;break}for(;T<3;){if(0===w)break e;w--,E+=M[_++]<>>=1,T-=1,3&E){case 0:n.mode=14;break;case 1:if(z(n),n.mode=20,t===l){E>>>=2,T-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=y}E>>>=2,T-=2;break;case 14:for(E>>>=7&T,T-=7&T;T<32;){if(0===w)break e;w--,E+=M[_++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=y;break}if(n.length=65535&E,E=0,T=0,n.mode=15,t===l)break e;case 15:n.mode=16;case 16:if(R=n.length,R){if(R>w&&(R=w),R>L&&(R=L),0===R)break e;x.set(M.subarray(_,_+R),S),w-=R,_+=R,L-=R,S+=R,n.length-=R;break}n.mode=v;break;case 17:for(;T<14;){if(0===w)break e;w--,E+=M[_++]<>>=5,T-=5,n.ndist=1+(31&E),E>>>=5,T-=5,n.ncode=4+(15&E),E>>>=4,T-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=y;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,T-=3}for(;n.have<19;)n.lens[Y[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,q={bits:n.lenbits},W=o(0,n.lens,0,19,n.lencode,0,n.work,q),n.lenbits=q.bits,W){e.msg="invalid code lengths set",n.mode=y;break}n.have=0,n.mode=19;case 19:for(;n.have>>24,N=G>>>16&255,D=65535&G,!(k<=T);){if(0===w)break e;w--,E+=M[_++]<>>=k,T-=k,n.lens[n.have++]=D;else{if(16===D){for(X=k+2;T>>=k,T-=k,0===n.have){e.msg="invalid bit length repeat",n.mode=y;break}U=n.lens[n.have-1],R=3+(3&E),E>>>=2,T-=2}else if(17===D){for(X=k+3;T>>=k,T-=k,U=0,R=3+(7&E),E>>>=3,T-=3}else{for(X=k+7;T>>=k,T-=k,U=0,R=11+(127&E),E>>>=7,T-=7}if(n.have+R>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=y;break}for(;R--;)n.lens[n.have++]=U}}if(n.mode===y)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=y;break}if(n.lenbits=9,q={bits:n.lenbits},W=o(1,n.lens,0,n.nlen,n.lencode,0,n.work,q),n.lenbits=q.bits,W){e.msg="invalid literal/lengths set",n.mode=y;break}if(n.distbits=6,n.distcode=n.distdyn,q={bits:n.distbits},W=o(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,q),n.distbits=q.bits,W){e.msg="invalid distances set",n.mode=y;break}if(n.mode=20,t===l)break e;case 20:n.mode=21;case 21:if(w>=6&&L>=258){e.next_out=S,e.avail_out=L,e.next_in=_,e.avail_in=w,n.hold=E,n.bits=T,a(e,H),S=e.next_out,x=e.output,L=e.avail_out,_=e.next_in,M=e.input,w=e.avail_in,E=n.hold,T=n.bits,n.mode===v&&(n.back=-1);break}for(n.back=0;G=n.lencode[E&(1<>>24,N=G>>>16&255,D=65535&G,!(k<=T);){if(0===w)break e;w--,E+=M[_++]<>O)],k=G>>>24,N=G>>>16&255,D=65535&G,!(O+k<=T);){if(0===w)break e;w--,E+=M[_++]<>>=O,T-=O,n.back+=O}if(E>>>=k,T-=k,n.back+=k,n.length=D,0===N){n.mode=26;break}if(32&N){n.back=-1,n.mode=v;break}if(64&N){e.msg="invalid literal/length code",n.mode=y;break}n.extra=15&N,n.mode=22;case 22:if(n.extra){for(X=n.extra;T>>=n.extra,T-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;G=n.distcode[E&(1<>>24,N=G>>>16&255,D=65535&G,!(k<=T);){if(0===w)break e;w--,E+=M[_++]<>O)],k=G>>>24,N=G>>>16&255,D=65535&G,!(O+k<=T);){if(0===w)break e;w--,E+=M[_++]<>>=O,T-=O,n.back+=O}if(E>>>=k,T-=k,n.back+=k,64&N){e.msg="invalid distance code",n.mode=y;break}n.offset=D,n.extra=15&N,n.mode=24;case 24:if(n.extra){for(X=n.extra;T>>=n.extra,T-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=y;break}n.mode=25;case 25:if(0===L)break e;if(R=H-L,n.offset>R){if(R=n.offset-R,R>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=y;break}R>n.wnext?(R-=n.wnext,P=n.wsize-R):P=n.wnext-R,R>n.length&&(R=n.length),I=n.window}else I=x,P=S-n.offset,R=n.length;R>L&&(R=L),L-=R,n.length-=R;do{x[S++]=I[P++]}while(--R);0===n.length&&(n.mode=21);break;case 26:if(0===L)break e;x[S++]=n.length,L--,n.mode=21;break;case 27:if(n.wrap){for(;T<32;){if(0===w)break e;w--,E|=M[_++]<{if(!e||!e.state)return f;let t=e.state;return t.window&&(t.window=null),e.state=null,u},e.exports.inflateGetHeader=(e,t)=>{if(!e||!e.state)return f;const n=e.state;return 0==(2&n.wrap)?f:(n.head=t,t.done=!1,u)},e.exports.inflateSetDictionary=(e,t)=>{const n=t.length;let r,a,o;return e&&e.state?(r=e.state,0!==r.wrap&&11!==r.mode?f:11===r.mode&&(a=1,a=i(a,t,n,0),a!==r.check)?p:(o=A(e,t,n,n),o?(r.mode=31,m):(r.havedict=1,u))):f},e.exports.inflateInfo="pako inflate (from Nodeca project)"},9241:e=>{"use strict";const t=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),n=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),i=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),r=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);e.exports=(e,a,o,s,c,l,u,d)=>{const h=d.bits;let f,p,m,g,C,v,y=0,b=0,M=0,x=0,_=0,S=0,w=0,L=0,E=0,T=0,z=null,A=0;const V=new Uint16Array(16),H=new Uint16Array(16);let R,P,I,k=null,N=0;for(y=0;y<=15;y++)V[y]=0;for(b=0;b=1&&0===V[x];x--);if(_>x&&(_=x),0===x)return c[l++]=20971520,c[l++]=20971520,d.bits=1,0;for(M=1;M0&&(0===e||1!==x))return-1;for(H[1]=0,y=1;y<15;y++)H[y+1]=H[y]+V[y];for(b=0;b852||2===e&&E>592)return 1;for(;;){R=y-w,u[b]v?(P=k[N+u[b]],I=z[A+u[b]]):(P=96,I=0),f=1<>w)+p]=R<<24|P<<16|I|0}while(0!==p);for(f=1<>=1;if(0!==f?(T&=f-1,T+=f):T=0,b++,0==--V[y]){if(y===x)break;y=a[o+u[b]]}if(y>_&&(T&g)!==m){for(0===w&&(w=_),C+=M,S=y-w,L=1<852||2===e&&E>592)return 1;m=T&g,c[m]=_<<24|S<<16|C-l|0}}return 0!==T&&(c[C+T]=y-w<<24|64<<16|0),d.bits=_,0}},8898:e=>{"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},342:e=>{"use strict";function t(e){let t=e.length;for(;--t>=0;)e[t]=0}const n=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),i=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),a=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=new Array(576);t(o);const s=new Array(60);t(s);const c=new Array(512);t(c);const l=new Array(256);t(l);const u=new Array(29);t(u);const d=new Array(30);function h(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let f,p,m;function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(d);const C=e=>e<256?c[e]:c[256+(e>>>7)],v=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},y=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{y(e,n[2*t],n[2*t+1])},M=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},x=(e,t,n)=>{const i=new Array(16);let r,a,o=0;for(r=1;r<=15;r++)i[r]=o=o+n[r-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=M(i[t]++,t))}},_=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},S=e=>{e.bi_valid>8?v(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},w=(e,t,n,i)=>{const r=2*t,a=2*n;return e[r]{const i=e.heap[n];let r=n<<1;for(;r<=e.heap_len&&(r{let a,o,s,c,h=0;if(0!==e.last_lit)do{a=e.pending_buf[e.d_buf+2*h]<<8|e.pending_buf[e.d_buf+2*h+1],o=e.pending_buf[e.l_buf+h],h++,0===a?b(e,o,t):(s=l[o],b(e,s+256+1,t),c=n[s],0!==c&&(o-=u[s],y(e,o,c)),a--,s=C(a),b(e,s,r),c=i[s],0!==c&&(a-=d[s],y(e,a,c)))}while(h{const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)L(e,n,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],L(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[2*c]=n[2*o]+n[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[2*o+1]=n[2*s+1]=c,e.heap[1]=c++,L(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let l,u,d,h,f,p,m=0;for(h=0;h<=15;h++)e.bl_count[h]=0;for(n[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)u=e.heap[l],h=n[2*n[2*u+1]+1]+1,h>c&&(h=c,m++),n[2*u+1]=h,u>i||(e.bl_count[h]++,f=0,u>=s&&(f=o[u-s]),p=n[2*u],e.opt_len+=p*(h+f),a&&(e.static_len+=p*(r[2*u+1]+f)));if(0!==m){do{for(h=c-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[c]--,m-=2}while(m>0);for(h=c;0!==h;h--)for(u=e.bl_count[h];0!==u;)d=e.heap[--l],d>i||(n[2*d+1]!==h&&(e.opt_len+=(h-n[2*d+1])*n[2*d],n[2*d+1]=h),u--)}})(e,t),x(n,l,e.bl_count)},z=(e,t,n)=>{let i,r,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++s{let i,r,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++s{y(e,0+(i?1:0),3),((e,t,n,i)=>{S(e),v(e,n),v(e,~n),e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n})(e,t,n)};e.exports._tr_init=e=>{V||((()=>{let e,t,a,g,C;const v=new Array(16);for(a=0,g=0;g<28;g++)for(u[g]=a,e=0;e<1<>=7;g<30;g++)for(d[g]=C<<7,e=0;e<1<{let r,c,l=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),T(e,e.l_desc),T(e,e.d_desc),l=(e=>{let t;for(z(e,e.dyn_ltree,e.l_desc.max_code),z(e,e.dyn_dtree,e.d_desc.max_code),T(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*a[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,c=e.static_len+3+7>>>3,c<=r&&(r=c)):r=c=n+5,n+4<=r&&-1!==t?H(e,t,n,i):4===e.strategy||c===r?(y(e,2+(i?1:0),3),E(e,o,s)):(y(e,4+(i?1:0),3),((e,t,n,i)=>{let r;for(y(e,t-257,5),y(e,n-1,5),y(e,i-4,4),r=0;r(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(l[n]+256+1)]++,e.dyn_dtree[2*C(t)]++),e.last_lit===e.lit_bufsize-1),e.exports._tr_align=e=>{y(e,2,3),b(e,256,o),(e=>{16===e.bi_valid?(v(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}},2292:e=>{"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},4155:e=>{var t,n,i=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:r}catch(e){t=r}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var s,c=[],l=!1,u=-1;function d(){l&&s&&(l=!1,s.length?c=s.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=o(d);l=!0;for(var t=c.length;t;){for(s=c,c=[];++u1)for(var n=1;n{"use strict";var i=n(414);function r(){}function a(){}a.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,a,o){if(o!==i){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:r};return n.PropTypes=n,n}},5697:(e,t,n)=>{e.exports=n(2703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},2100:(e,t,n)=>{"use strict";e.exports=n(9482)},9482:(e,t,n)=>{"use strict";var i=t;function r(){i.util._configure(),i.Writer._configure(i.BufferWriter),i.Reader._configure(i.BufferReader)}i.build="minimal",i.Writer=n(1173),i.BufferWriter=n(3155),i.Reader=n(1408),i.BufferReader=n(593),i.util=n(9693),i.rpc=n(5994),i.roots=n(5054),i.configure=r,r()},1408:(e,t,n)=>{"use strict";e.exports=c;var i,r=n(9693),a=r.LongBits,o=r.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var l,u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},d=function(){return r.Buffer?function(e){return(c.create=function(e){return r.Buffer.isBuffer(e)?new i(e):u(e)})(e)}:u};function h(){var e=new a(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw s(this,8);return new a(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}c.create=d(),c.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,c.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return l;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return l}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return f(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|f(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw s(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},c.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},c.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){i=e,c.create=d(),i._configure();var t=r.Long?"toLong":"toNumber";r.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return p.call(this)[t](!0)},sfixed64:function(){return p.call(this)[t](!1)}})}},593:(e,t,n)=>{"use strict";e.exports=a;var i=n(1408);(a.prototype=Object.create(i.prototype)).constructor=a;var r=n(9693);function a(e){i.call(this,e)}a._configure=function(){r.Buffer&&(a.prototype._slice=r.Buffer.prototype.slice)},a.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},a._configure()},5054:e=>{"use strict";e.exports={}},5994:(e,t,n)=>{"use strict";t.Service=n(7948)},7948:(e,t,n)=>{"use strict";e.exports=r;var i=n(9693);function r(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");i.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(r.prototype=Object.create(i.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function e(t,n,r,a,o){if(!a)throw TypeError("request must be specified");var s=this;if(!o)return i.asPromise(e,s,t,n,r,a);if(s.rpcImpl)try{return s.rpcImpl(t,n[s.requestDelimited?"encodeDelimited":"encode"](a).finish(),(function(e,n){if(e)return s.emit("error",e,t),o(e);if(null!==n){if(!(n instanceof r))try{n=r[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),o(e)}return s.emit("data",n,t),o(null,n)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},r.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(e,t,n)=>{"use strict";e.exports=r;var i=n(9693);function r(e,t){this.lo=e>>>0,this.hi=t>>>0}var a=r.zero=new r(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var o=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(e){if(0===e)return a;var t=e<0;t&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)},r.from=function(e){if("number"==typeof e)return r.fromNumber(e);if(i.isString(e)){if(!i.Long)return r.fromNumber(parseInt(e,10));e=i.Long.fromString(e)}return e.low||e.high?new r(e.low>>>0,e.high>>>0):a},r.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},r.prototype.toLong=function(e){return i.Long?new i.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var s=String.prototype.charCodeAt;r.fromHash=function(e){return e===o?a:new r((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},r.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},r.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},9693:function(e,t,n){"use strict";var i=t;function r(e,t,n){for(var i=Object.keys(t),r=0;r0)},i.Buffer=function(){try{var e=i.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),i._Buffer_from=null,i._Buffer_allocUnsafe=null,i.newBuffer=function(e){return"number"==typeof e?i.Buffer?i._Buffer_allocUnsafe(e):new i.Array(e):i.Buffer?i._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},i.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,i.Long=i.global.dcodeIO&&i.global.dcodeIO.Long||i.global.Long||i.inquire("long"),i.key2Re=/^true|false|0|1$/,i.key32Re=/^-?(?:0|[1-9][0-9]*)$/,i.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,i.longToHash=function(e){return e?i.LongBits.from(e).toHash():i.LongBits.zeroHash},i.longFromHash=function(e,t){var n=i.LongBits.fromHash(e);return i.Long?i.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},i.merge=r,i.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},i.newError=a,i.ProtocolError=a("ProtocolError"),i.oneOfGetter=function(e){for(var t={},n=0;n-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},i.oneOfSetter=function(e){return function(t){for(var n=0;n{"use strict";e.exports=d;var i,r=n(9693),a=r.LongBits,o=r.base64,s=r.utf8;function c(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function l(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new c(l,0,0),this.tail=this.head,this.states=null}var h=function(){return r.Buffer?function(){return(d.create=function(){return new i})()}:function(){return new d}};function f(e,t,n){t[n]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function m(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function g(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}d.create=h(),d.alloc=function(e){return new r.Array(e)},r.Array!==Array&&(d.alloc=r.pool(d.alloc,r.Array.prototype.subarray)),d.prototype._push=function(e,t,n){return this.tail=this.tail.next=new c(e,t,n),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},d.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},d.prototype.int32=function(e){return e<0?this._push(m,10,a.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=a.from(e);return this._push(m,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=a.from(e).zzEncode();return this._push(m,t.length(),t)},d.prototype.bool=function(e){return this._push(f,1,e?1:0)},d.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=a.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(r.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(r.float.writeDoubleLE,8,e)};var C=r.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var i=0;i>>0;if(!t)return this._push(f,1,0);if(r.isString(e)){var n=d.alloc(t=o.length(e));o.decode(e,n,0),e=n}return this.uint32(t)._push(C,t,e)},d.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(f,1,0)},d.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new c(l,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(l,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},d._configure=function(e){i=e,d.create=h(),i._configure()}},3155:(e,t,n)=>{"use strict";e.exports=a;var i=n(1173);(a.prototype=Object.create(i.prototype)).constructor=a;var r=n(9693);function a(){i.call(this)}function o(e,t,n){e.length<40?r.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}a._configure=function(){a.alloc=r._Buffer_allocUnsafe,a.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var i=0;i>>0;return this.uint32(t),t&&this._push(a.writeBytesBuffer,t,e),this},a.prototype.string=function(e){var t=r.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},a._configure()},4448:(e,t,n)=>{"use strict";var i=n(7294),r=n(3840);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n