vendor: 7,349 bytes, lines 1-5
1import{g as og,i as Xy,a as jy,_ as Vi,b as ud,C as dd,r as cl,c as Lh,d as Ky,e as ag,f as Yy,S as uo,h as oi,E as Dh,j as Qy,k as Zy,q as Va,L as ui,l as Jy,m as yn,n as cg,F as Nl,o as $y,p as eE,s as tE,t as nE,u as iE}from"./app-7bbb6fa2.js";/** 2 * @license 3 * Copyright 2010-2024 Three.js Authors 4 * SPDX-License-Identifier: MIT 5 */const Nh="170",ek={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},tk={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},rE=0,hf=1,sE=2,lg=1,oE=2,Ui=3,Er=0,bn=1,Oi=2,vr=0,Us=1,pf=2,ff=3,_f=4,aE=5,Fr=100,cE=101,lE=102,uE=103,dE=104,hE=200,pE=201,fE=202,_E=203,hd=204,pd=205,mE=206,gE=207,vE=208,yE=209,EE=210,TE=211,bE=212,SE=213,AE=214,fd=0,_d=1,md=2,Xs=3,gd=4,vd=5,yd=6,Ed=7,kh=0,xE=1,wE=2,yr=0,IE=1,ME=2,CE=3,RE=4,PE=5,LE=6,DE=7,ug=300,js=301,Ks=302,Td=303,bd=304,kl=306,Sd=1e3,Br=1001,Ad=1002,ri=1003,NE=1004,cc=1005,di=1006,_u=1007,zr=1008,Yi=1009,dg=1010,hg=1011,ya=1012,Uh=1013,Kr=1014,Bi=1015,Ba=1016,Oh=1017,Fh=1018,Ys=1020,pg=35902,fg=1021,_g=1022,ei=1023,mg=1024,gg=1025,Os=1026,Qs=1027,vg=1028,Vh=1029,yg=1030,Bh=1031,zh=1033,qc=33776,Xc=33777,jc=33778,Kc=33779,xd=35840,wd=35841,Id=35842,Md=35843,Cd=36196,Rd=37492,Pd=37496,Ld=37808,Dd=37809,Nd=37810,kd=37811,Ud=37812,Od=37813,Fd=37814,Vd=37815,Bd=37816,zd=37817,Hd=37818,Gd=37819,Wd=37820,qd=37821,Yc=36492,Xd=36494,jd=36495,Eg=36283,Kd=36284,Yd=36285,Qd=36286,kE=3200,UE=3201,Tg=0,OE=1,pr="",Vn="srgb",ho="srgb-linear",Ul="linear",St="srgb",us=7680,mf=519,FE=512,VE=513,BE=514,bg=515,zE=516,HE=517,GE=518,WE=519,Zd=35044,gf="300 es",zi=2e3,ll=2001;class ts{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const cn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let vf=1234567;const la=Math.PI/180,Ea=180/Math.PI;function pi(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(cn[n&255]+cn[n>>8&255]+cn[n>>16&255]+cn[n>>24&255]+"-"+cn[e&255]+cn[e>>8&255]+"-"+cn[e>>16&15|64]+cn[e>>24&255]+"-"+cn[t&63|128]+cn[t>>8&255]+"-"+cn[t>>16&255]+cn[t>>24&255]+cn[i&255]+cn[i>>8&255]+cn[i>>16&255]+cn[i>>24&255]).toLowerCase()}function Qt(n,e,t){return Math.max(e,Math.min(t,n))}function Hh(n,e){return(n%e+e)%e}function qE(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function XE(n,e,t){return n!==e?(t-n)/(e-n):0}function ua(n,e,t){return(1-t)*n+t*e}function jE(n,e,t,i){return ua(n,e,1-Math.exp(-t*i))}function KE(n,e=1){return e-Math.abs(Hh(n,e*2)-e)}function YE(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function QE(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function ZE(n,e){return n+Math.floor(Math.random()*(e-n+1))}function JE(n,e){return n+Math.random()*(e-n)}function $E(n){return n*(.5-Math.random())}function eT(n){n!==void 0&&(vf=n);let e=vf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function tT(n){return n*la}function nT(n){return n*Ea}function iT(n){return(n&n-1)===0&&n!==0}function rT(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function sT(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function oT(n,e,t,i,r){const s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),d=o((e+i)/2),h=s((e-i)/2),p=o((e-i)/2),_=s((i-e)/2),g=o((i-e)/2);switch(r){case"XYX":n.set(a*d,c*h,c*p,a*l);break;case"YZY":n.set(c*p,a*d,c*h,a*l);break;case"ZXZ":n.set(c*h,c*p,a*d,a*l);break;case"XZX":n.set(a*d,c*g,c*_,a*l);break;case"YXY":n.set(c*_,a*d,c*g,a*l);break;case"ZYZ":n.set(c*g,c*_,a*d,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function $n(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function vt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const nk={DEG2RAD:la,RAD2DEG:Ea,generateUUID:pi,clamp:Qt,euclideanModulo:Hh,mapLinear:qE,inverseLerp:XE,lerp:ua,damp:jE,pingpong:KE,smoothstep:YE,smootherstep:QE,randInt:ZE,randFloat:JE,randFloatSpread:$E,seededRandom:eT,degToRad:tT,radToDeg:nT,isPowerOfTwo:iT,ceilPowerOfTwo:rT,floorPowerOfTwo:sT,setQuaternionFromProperEuler:oT,normalize:vt,denormalize:$n};class xe{constructor(e=0,t=0){xe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}
vendor: 7,693 bytes, line 5
5sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class it{constructor(e,t,i,r,s,o,a,c,l){it.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){const d=this.elements;return d[0]=e,d[1]=r,d[2]=a,d[3]=t,d[4]=s,d[5]=c,d[6]=i,d[7]=o,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],d=i[4],h=i[7],p=i[2],_=i[5],g=i[8],S=r[0],m=r[3],f=r[6],M=r[1],w=r[4],b=r[7],R=r[2],P=r[5],T=r[8];return s[0]=o*S+a*M+c*R,s[3]=o*m+a*w+c*P,s[6]=o*f+a*b+c*T,s[1]=l*S+d*M+h*R,s[4]=l*m+d*w+h*P,s[7]=l*f+d*b+h*T,s[2]=p*S+_*M+g*R,s[5]=p*m+_*w+g*P,s[8]=p*f+_*b+g*T,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],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8];return t*o*d-t*a*l-i*s*d+i*a*c+r*s*l-r*o*c}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8],h=d*o-a*l,p=a*c-d*s,_=l*s-o*c,g=t*h+i*p+r*_;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/g;return e[0]=h*S,e[1]=(r*l-d*i)*S,e[2]=(a*i-r*o)*S,e[3]=p*S,e[4]=(d*t-r*c)*S,e[5]=(r*s-a*t)*S,e[6]=_*S,e[7]=(i*c-l*t)*S,e[8]=(o*t-i*s)*S,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,i,r,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(mu.makeScale(e,t)),this}rotate(e){return this.premultiply(mu.makeRotation(-e)),this}translate(e,t){return this.premultiply(mu.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const mu=new it;function Sg(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ta(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function aT(){const n=Ta("canvas");return n.style.display="block",n}const yf={};function Jo(n){n in yf||(yf[n]=!0,console.warn(n))}function cT(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}function lT(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function uT(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const ft={enabled:!0,workingColorSpace:ho,spaces:{},convert:function(n,e,t){return this.enabled===!1||e===t||!e||!t||(this.spaces[e].transfer===St&&(n.r=Xi(n.r),n.g=Xi(n.g),n.b=Xi(n.b)),this.spaces[e].primaries!==this.spaces[t].primaries&&(n.applyMatrix3(this.spaces[e].toXYZ),n.applyMatrix3(this.spaces[t].fromXYZ)),this.spaces[t].transfer===St&&(n.r=Fs(n.r),n.g=Fs(n.g),n.b=Fs(n.b))),n},fromWorkingColorSpace:function(n,e){return this.convert(n,this.workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===pr?Ul:this.spaces[n].transfer},getLuminanceCoefficients:function(n,e=this.workingColorSpace){return n.fromArray(this.spaces[e].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,e,t){return n.copy(this.spaces[e].toXYZ).multiply(this.spaces[t].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace}};function Xi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}
vendor: 4,610 bytes, line 5
5function Fs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const Ef=[.64,.33,.3,.6,.15,.06],Tf=[.2126,.7152,.0722],bf=[.3127,.329],Sf=new it().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Af=new it().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);ft.define({[ho]:{primaries:Ef,whitePoint:bf,transfer:Ul,toXYZ:Sf,fromXYZ:Af,luminanceCoefficients:Tf,workingColorSpaceConfig:{unpackColorSpace:Vn},outputColorSpaceConfig:{drawingBufferColorSpace:Vn}},[Vn]:{primaries:Ef,whitePoint:bf,transfer:St,toXYZ:Sf,fromXYZ:Af,luminanceCoefficients:Tf,outputColorSpaceConfig:{drawingBufferColorSpace:Vn}}});let ds;class dT{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{ds===void 0&&(ds=Ta("canvas")),ds.width=e.width,ds.height=e.height;const i=ds.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=ds}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ta("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Xi(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Xi(t[i]/255)*255):t[i]=Xi(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hT=0;class Ag{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hT++}),this.uuid=pi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(gu(r[o].image)):s.push(gu(r[o]))}else s=gu(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function gu(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?dT.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let pT=0;class vn extends ts{constructor(e=vn.DEFAULT_IMAGE,t=vn.DEFAULT_MAPPING,i=Br,r=Br,s=di,o=zr,a=ei,c=Yi,l=vn.DEFAULT_ANISOTROPY,d=pr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:pT++}),this.uuid=pi(),this.name="",this.source=new Ag(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new xe(0,0),this.repeat=new xe(1,1),this.center=new xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new it,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace
vendor: 44,833 bytes, line 5
5=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ug)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Sd:e.x=e.x-Math.floor(e.x);break;case Br:e.x=e.x<0?0:1;break;case Ad:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Sd:e.y=e.y-Math.floor(e.y);break;case Br:e.y=e.y<0?0:1;break;case Ad:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}vn.DEFAULT_IMAGE=null;vn.DEFAULT_MAPPING=ug;vn.DEFAULT_ANISOTROPY=1;class Ot{constructor(e=0,t=0,i=0,r=1){Ot.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,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,i,r,s;const c=e.elements,l=c[0],d=c[4],h=c[8],p=c[1],_=c[5],g=c[9],S=c[2],m=c[6],f=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-S)<.01&&Math.abs(g-m)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+S)<.1&&Math.abs(g+m)<.1&&Math.abs(l+_+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(l+1)/2,b=(_+1)/2,R=(f+1)/2,P=(d+p)/4,T=(h+S)/4,A=(g+m)/4;return w>b&&w>R?w<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(w),r=P/i,s=T/i):b>R?b<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),i=P/r,s=A/r):R<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(R),i=T/s,r=A/s),this.set(i,r,s,t),this}let M=Math.sqrt((m-g)*(m-g)+(h-S)*(h-S)+(p-d)*(p-d));return Math.abs(M)<.001&&(M=1),this.x=(m-g)/M,this.y=(h-S)/M,this.z=(p-d)/M,this.w=Math.acos((l+_+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fT extends ts{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ot(0,0,e,t),this.scissorTest=!1,this.viewport=new Ot(0,0,e,t);const r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:di,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const s=new vn(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Ag(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Yr extends fT{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class xg extends vn{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ri,this.minFilter=ri,this.wrapR=Br,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class _T extends vn{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ri,this.minFilter=ri,this.wrapR=Br,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class po{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],d=i[r+2],h=i[r+3];const p=s[o+0],_=s[o+1],g=s[o+2],S=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=d,e[t+3]=h;return}if(a===1){e[t+0]=p,e[t+1]=_,e[t+2]=g,e[t+3]=S;return}if(h!==S||c!==p||l!==_||d!==g){let m=1-a;const f=c*p+l*_+d*g+h*S,M=f>=0?1:-1,w=1-f*f;if(w>Number.EPSILON){const R=Math.sqrt(w),P=Math.atan2(R,f*M);m=Math.sin(m*P)/R,a=Math.sin(a*P)/R}const b=a*M;if(c=c*m+p*b,l=l*m+_*b,d=d*m+g*b,h=h*m+S*b,m===1-a){const R=1/Math.sqrt(c*c+l*l+d*d+h*h);c*=R,l*=R,d*=R,h*=R}}e[t]=c,e[t+1]=l,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],c=i[r+1],l=i[r+2],d=i[r+3],h=s[o],p=s[o+1],_=s[o+2],g=s[o+3];return e[t]=a*g+d*h+c*_-l*p,e[t+1]=c*g+d*p+l*h-a*_,e[t+2]=l*g+d*_+a*p-c*h,e[t+3]=d*g-a*h-c*p-l*_,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,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),d=a(r/2),h=a(s/2),p=c(i/2),_=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=p*d*h+l*_*g,this._y=l*_*h-p*d*g,this._z=l*d*g+p*_*h,this._w=l*d*h-p*_*g;break;case"YXZ":this._x=p*d*h+l*_*g,this._y=l*_*h-p*d*g,this._z=l*d*g-p*_*h,this._w=l*d*h+p*_*g;break;case"ZXY":this._x=p*d*h-l*_*g,this._y=l*_*h+p*d*g,this._z=l*d*g+p*_*h,this._w=l*d*h-p*_*g;break;case"ZYX":this._x=p*d*h-l*_*g,this._y=l*_*h+p*d*g,this._z=l*d*g-p*_*h,this._w=l*d*h+p*_*g;break;case"YZX":this._x=p*d*h+l*_*g,this._y=l*_*h+p*d*g,this._z=l*d*g-p*_*h,this._w=l*d*h-p*_*g;break;case"XZY":this._x=p*d*h-l*_*g,this._y=l*_*h-p*d*g,this._z=l*d*g+p*_*h,this._w=l*d*h+p*_*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],d=t[6],h=t[10],p=i+a+h;if(p>0){const _=.5/Math.sqrt(p+1);this._w=.25/_,this._x=(d-c)*_,this._y=(s-l)*_,this._z=(o-r)*_}else if(i>a&&i>h){const _=2*Math.sqrt(1+i-a-h);this._w=(d-c)/_,this._x=.25*_,this._y=(r+o)/_,this._z=(s+l)/_}else if(a>h){const _=2*Math.sqrt(1+a-i-h);this._w=(s-l)/_,this._x=(r+o)/_,this._y=.25*_,this._z=(c+d)/_}else{const _=2*Math.sqrt(1+h-i-a);this._w=(o-r)/_,this._x=(s+l)/_,this._y=(c+d)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Qt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,d=t._w;return this._x=i*d+o*a+r*l-s*c,this._y=r*d+o*c+s*a-i*l,this._z=s*d+o*l+i*c-r*a,this._w=o*d-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const _=1-t;return this._w=_*o+t*this._w,this._x=_*i+t*this._x,this._y=_*r+t*this._y,this._z=_*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),d=Math.atan2(l,a),h=Math.sin((1-t)*d)/l,p=Math.sin(t*d)/l;return this._w=o*h+this._w*p,this._x=i*h+this._x*p,this._y=r*h+this._y*p,this._z=s*h+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,i=0){O.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(xf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),d=2*(a*t-s*r),h=2*(s*i-o*t);return this.x=t+c*l+o*h-a*d,this.y=i+c*d+a*l-s*h,this.z=r+c*h+s*d-o*l,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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return vu.copy(this).projectOnVector(e),this.sub(vu)}reflect(e){return this.sub(vu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}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,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const vu=new O,xf=new po;class za{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(jn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=jn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,jn):jn.fromBufferAttribute(s,o),jn.applyMatrix4(e.matrixWorld),this.expandByPoint(jn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),lc.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),lc.copy(i.boundingBox)),lc.applyMatrix4(e.matrixWorld),this.union(lc)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(No),uc.subVectors(this.max,No),hs.subVectors(e.a,No),ps.subVectors(e.b,No),fs.subVectors(e.c,No),rr.subVectors(ps,hs),sr.subVectors(fs,ps),Cr.subVectors(hs,fs);let t=[0,-rr.z,rr.y,0,-sr.z,sr.y,0,-Cr.z,Cr.y,rr.z,0,-rr.x,sr.z,0,-sr.x,Cr.z,0,-Cr.x,-rr.y,rr.x,0,-sr.y,sr.x,0,-Cr.y,Cr.x,0];return!yu(t,hs,ps,fs,uc)||(t=[1,0,0,0,1,0,0,0,1],!yu(t,hs,ps,fs,uc))?!1:(dc.crossVectors(rr,sr),t=[dc.x,dc.y,dc.z],yu(t,hs,ps,fs,uc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wi),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)}}const wi=[new O,new O,new O,new O,new O,new O,new O,new O],jn=new O,lc=new za,hs=new O,ps=new O,fs=new O,rr=new O,sr=new O,Cr=new O,No=new O,uc=new O,dc=new O,Rr=new O;function yu(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Rr.fromArray(n,s);const a=r.x*Math.abs(Rr.x)+r.y*Math.abs(Rr.y)+r.z*Math.abs(Rr.z),c=e.dot(Rr),l=t.dot(Rr),d=i.dot(Rr);if(Math.max(-Math.max(c,l,d),Math.min(c,l,d))>a)return!1}return!0}const mT=new za,ko=new O,Eu=new O;class Ol{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):mT.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ko.subVectors(e,this.center);const t=ko.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(ko,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Eu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ko.copy(e.center).add(Eu)),this.expandByPoint(ko.copy(e.center).sub(Eu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ii=new O,Tu=new O,hc=new O,or=new O,bu=new O,pc=new O,Su=new O;class Gh{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ii)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ii.copy(this.origin).addScaledVector(this.direction,t),Ii.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Tu.copy(e).add(t).multiplyScalar(.5),hc.copy(t).sub(e).normalize(),or.copy(this.origin).sub(Tu);const s=e.distanceTo(t)*.5,o=-this.direction.dot(hc),a=or.dot(this.direction),c=-or.dot(hc),l=or.lengthSq(),d=Math.abs(1-o*o);let h,p,_,g;if(d>0)if(h=o*c-a,p=o*a-c,g=s*d,h>=0)if(p>=-g)if(p<=g){const S=1/d;h*=S,p*=S,_=h*(h+o*p+2*a)+p*(o*h+p+2*c)+l}else p=s,h=Math.max(0,-(o*p+a)),_=-h*h+p*(p+2*c)+l;else p=-s,h=Math.max(0,-(o*p+a)),_=-h*h+p*(p+2*c)+l;else p<=-g?(h=Math.max(0,-(-o*s+a)),p=h>0?-s:Math.min(Math.max(-s,-c),s),_=-h*h+p*(p+2*c)+l):p<=g?(h=0,p=Math.min(Math.max(-s,-c),s),_=p*(p+2*c)+l):(h=Math.max(0,-(o*s+a)),p=h>0?s:Math.min(Math.max(-s,-c),s),_=-h*h+p*(p+2*c)+l);else p=o>0?-s:s,h=Math.max(0,-(o*p+a)),_=-h*h+p*(p+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Tu).addScaledVector(hc,p),_}intersectSphere(e,t){Ii.subVectors(e.center,this.origin);const i=Ii.dot(this.direction),r=Ii.dot(Ii)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c;const l=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,p=this.origin;return l>=0?(i=(e.min.x-p.x)*l,r=(e.max.x-p.x)*l):(i=(e.max.x-p.x)*l,r=(e.min.x-p.x)*l),d>=0?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(a=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Ii)!==null}intersectTriangle(e,t,i,r,s){bu.subVectors(t,e),pc.subVectors(i,e),Su.crossVectors(bu,pc);let o=this.direction.dot(Su),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;or.subVectors(this.origin,e);const c=a*this.direction.dot(pc.crossVectors(or,pc));if(c<0)return null;const l=a*this.direction.dot(bu.cross(or));if(l<0||c+l>o)return null;const d=-a*or.dot(Su);return d<0?null:this.at(d/o,s)}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 wt{constructor(e,t,i,r,s,o,a,c,l,d,h,p,_,g,S,m){wt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,d,h,p,_,g,S,m)}set(e,t,i,r,s,o,a,c,l,d,h,p,_,g,S,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=o,f[9]=a,f[13]=c,f[2]=l,f[6]=d,f[10]=h,f[14]=p,f[3]=_,f[7]=g,f[11]=S,f[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 wt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/_s.setFromMatrixColumn(e,0).length(),s=1/_s.setFromMatrixColumn(e,1).length(),o=1/_s.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,_=o*h,g=a*d,S=a*h;t[0]=c*d,t[4]=-c*h,t[8]=l,t[1]=_+g*l,t[5]=p-S*l,t[9]=-a*c,t[2]=S-p*l,t[6]=g+_*l,t[10]=o*c}else if(e.order==="YXZ"){const p=c*d,_=c*h,g=l*d,S=l*h;t[0]=p+S*a,t[4]=g*a-_,t[8]=o*l,t[1]=o*h,t[5]=o*d,t[9]=-a,t[2]=_*a-g,t[6]=S+p*a,t[10]=o*c}else if(e.order==="ZXY"){const p=c*d,_=c*h,g=l*d,S=l*h;t[0]=p-S*a,t[4]=-o*h,t[8]=g+_*a,t[1]=_+g*a,t[5]=o*d,t[9]=S-p*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const p=o*d,_=o*h,g=a*d,S=a*h;t[0]=c*d,t[4]=g*l-_,t[8]=p*l+S,t[1]=c*h,t[5]=S*l+p,t[9]=_*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const p=o*c,_=o*l,g=a*c,S=a*l;t[0]=c*d,t[4]=S-p*h,t[8]=g*h+_,t[1]=h,t[5]=o*d,t[9]=-a*d,t[2]=-l*d,t[6]=_*h+g,t[10]=p-S*h}else if(e.order==="XZY"){const p=o*c,_=o*l,g=a*c,S=a*l;t[0]=c*d,t[4]=-h,t[8]=l*d,t[1]=p*h+S,t[5]=o*d,t[9]=_*h-g,t[2]=g*h-_,t[6]=a*d,t[10]=S*h+p}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(gT,e,vT)}lookAt(e,t,i){const r=this.elements;return Ln.subVectors(e,t),Ln.lengthSq()===0&&(Ln.z=1),Ln.normalize(),ar.crossVectors(i,Ln),ar.lengthSq()===0&&(Math.abs(i.z)===1?Ln.x+=1e-4:Ln.z+=1e-4,Ln.normalize(),ar.crossVectors(i,Ln)),ar.normalize(),fc.crossVectors(Ln,ar),r[0]=ar.x,r[4]=fc.x,r[8]=Ln.x,r[1]=ar.y,r[5]=fc.y,r[9]=Ln.y,r[2]=ar.z,r[6]=fc.z,r[10]=Ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],d=i[1],h=i[5],p=i[9],_=i[13],g=i[2],S=i[6],m=i[10],f=i[14],M=i[3],w=i[7],b=i[11],R=i[15],P=r[0],T=r[4],A=r[8],E=r[12],y=r[1],I=r[5],D=r[9],C=r[13],W=r[2],Z=r[6],Y=r[10],ce=r[14],K=r[3],ue=r[7],ve=r[11],ye=r[15];return s[0]=o*P+a*y+c*W+l*K,s[4]=o*T+a*I+c*Z+l*ue,s[8]=o*A+a*D+c*Y+l*ve,s[12]=o*E+a*C+c*ce+l*ye,s[1]=d*P+h*y+p*W+_*K,s[5]=d*T+h*I+p*Z+_*ue,s[9]=d*A+h*D+p*Y+_*ve,s[13]=d*E+h*C+p*ce+_*ye,s[2]=g*P+S*y+m*W+f*K,s[6]=g*T+S*I+m*Z+f*ue,s[10]=g*A+S*D+m*Y+f*ve,s[14]=g*E+S*C+m*ce+f*ye,s[3]=M*P+w*y+b*W+R*K,s[7]=M*T+w*I+b*Z+R*ue,s[11]=M*A+w*D+b*Y+R*ve,s[15]=M*E+w*C+b*ce+R*ye,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],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],d=e[2],h=e[6],p=e[10],_=e[14],g=e[3],S=e[7],m=e[11],f=e[15];return g*(+s*c*h-r*l*h-s*a*p+i*l*p+r*a*_-i*c*_)+S*(+t*c*_-t*l*p+s*o*p-r*o*_+r*l*d-s*c*d)+m*(+t*l*h-t*a*_-s*o*h+i*o*_+s*a*d-i*l*d)+f*(-r*a*d-t*c*h+t*a*p+r*o*h-i*o*p+i*c*d)}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,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],d=e[8],h=e[9],p=e[10],_=e[11],g=e[12],S=e[13],m=e[14],f=e[15],M=h*m*l-S*p*l+S*c*_-a*m*_-h*c*f+a*p*f,w=g*p*l-d*m*l-g*c*_+o*m*_+d*c*f-o*p*f,b=d*S*l-g*h*l+g*a*_-o*S*_-d*a*f+o*h*f,R=g*h*c-d*S*c-g*a*p+o*S*p+d*a*m-o*h*m,P=t*M+i*w+r*b+s*R;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/P;return e[0]=M*T,e[1]=(S*p*s-h*m*s-S*r*_+i*m*_+h*r*f-i*p*f)*T,e[2]=(a*m*s-S*c*s+S*r*l-i*m*l-a*r*f+i*c*f)*T,e[3]=(h*c*s-a*p*s-h*r*l+i*p*l+a*r*_-i*c*_)*T,e[4]=w*T,e[5]=(d*m*s-g*p*s+g*r*_-t*m*_-d*r*f+t*p*f)*T,e[6]=(g*c*s-o*m*s-g*r*l+t*m*l+o*r*f-t*c*f)*T,e[7]=(o*p*s-d*c*s+d*r*l-t*p*l-o*r*_+t*c*_)*T,e[8]=b*T,e[9]=(g*h*s-d*S*s-g*i*_+t*S*_+d*i*f-t*h*f)*T,e[10]=(o*S*s-g*a*s+g*i*l-t*S*l-o*i*f+t*a*f)*T,e[11]=(d*a*s-o*h*s-d*i*l+t*h*l+o*i*_-t*a*_)*T,e[12]=R*T,e[13]=(d*S*r-g*h*r+g*i*p-t*S*p-d*i*m+t*h*m)*T,e[14]=(g*a*r-o*S*r-g*i*c+t*S*c+o*i*m-t*a*m)*T,e[15]=(o*h*r-d*a*r+d*i*c-t*h*c-o*i*p+t*a*p)*T,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,d=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,d*a+i,d*c-r*o,0,l*c-r*a,d*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,d=o+o,h=a+a,p=s*l,_=s*d,g=s*h,S=o*d,m=o*h,f=a*h,M=c*l,w=c*d,b=c*h,R=i.x,P=i.y,T=i.z;return r[0]=(1-(S+f))*R,r[1]=(_+b)*R,r[2]=(g-w)*R,r[3]=0,r[4]=(_-b)*P,r[5]=(1-(p+f))*P,r[6]=(m+M)*P,r[7]=0,r[8]=(g+w)*T,r[9]=(m-M)*T,r[10]=(1-(p+S))*T,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=_s.set(r[0],r[1],r[2]).length();const o=_s.set(r[4],r[5],r[6]).length(),a=_s.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Kn.copy(this);const l=1/s,d=1/o,h=1/a;return Kn.elements[0]*=l,Kn.elements[1]*=l,Kn.elements[2]*=l,Kn.elements[4]*=d,Kn.elements[5]*=d,Kn.elements[6]*=d,Kn.elements[8]*=h,Kn.elements[9]*=h,Kn.elements[10]*=h,t.setFromRotationMatrix(Kn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=zi){const c=this.elements,l=2*s/(t-e),d=2*s/(i-r),h=(t+e)/(t-e),p=(i+r)/(i-r);let _,g;if(a===zi)_=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===ll)_=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=zi){const c=this.elements,l=1/(t-e),d=1/(i-r),h=1/(o-s),p=(t+e)*l,_=(i+r)*d;let g,S;if(a===zi)g=(o+s)*h,S=-2*h;else if(a===ll)g=s*h,S=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-_,c[2]=0,c[6]=0,c[10]=S,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const _s=new O,Kn=new wt,gT=new O(0,0,0),vT=new O(1,1,1),ar=new O,fc=new O,Ln=new O,wf=new wt,If=new po;class vi{constructor(e=0,t=0,i=0,r=vi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}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,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,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,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],d=r[9],h=r[2],p=r[6],_=r[10];switch(t){case"XYZ":this._y=Math.asin(Qt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,_),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Qt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,_),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Qt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,_),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Qt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,_),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Qt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,_));break;case"XZY":this._z=Math.asin(-Qt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-d,_),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return wf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return If.setFromEuler(this),this.setFromQuaternion(If,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}vi.DEFAULT_ORDER="XYZ";class Wh{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}
vendor: 9,688 bytes, line 5
5isEnabled(e){return(this.mask&(1<<e|0))!==0}}let yT=0;const Mf=new O,ms=new po,Mi=new wt,_c=new O,Uo=new O,ET=new O,TT=new po,Cf=new O(1,0,0),Rf=new O(0,1,0),Pf=new O(0,0,1),Lf={type:"added"},bT={type:"removed"},gs={type:"childadded",child:null},Au={type:"childremoved",child:null};class Zt extends ts{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yT++}),this.uuid=pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zt.DEFAULT_UP.clone();const e=new O,t=new vi,i=new po,r=new O(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new wt},normalMatrix:{value:new it}}),this.matrix=new wt,this.matrixWorld=new wt,this.matrixAutoUpdate=Zt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Wh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ms.setFromAxisAngle(e,t),this.quaternion.multiply(ms),this}rotateOnWorldAxis(e,t){return ms.setFromAxisAngle(e,t),this.quaternion.premultiply(ms),this}rotateX(e){return this.rotateOnAxis(Cf,e)}rotateY(e){return this.rotateOnAxis(Rf,e)}rotateZ(e){return this.rotateOnAxis(Pf,e)}translateOnAxis(e,t){return Mf.copy(e).applyQuaternion(this.quaternion),this.position.add(Mf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Cf,e)}translateY(e){return this.translateOnAxis(Rf,e)}translateZ(e){return this.translateOnAxis(Pf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Mi.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?_c.copy(e):_c.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Uo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mi.lookAt(Uo,_c,this.up):Mi.lookAt(_c,Uo,this.up),this.quaternion.setFromRotationMatrix(Mi),r&&(Mi.extractRotation(r.matrixWorld),ms.setFromRotationMatrix(Mi),this.quaternion.premultiply(ms.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Lf),gs.child=e,this.dispatchEvent(gs),gs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(bT),Au.child=e,this.dispatchEvent(Au),Au.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Mi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Mi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Mi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lf),gs.child=e,this.dispatchEvent(gs),gs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Uo,e,ET),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Uo,TT,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,d=c.length;l<d;l++){const h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),d=o(e.images),h=o(e.shapes),p=o(e.skeletons),_=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),d.length>0&&(i.images=d),h.length>0&&(i.shapes=h),p.length>
vendor: 13,988 bytes, line 5
50&&(i.skeletons=p),_.length>0&&(i.animations=_),g.length>0&&(i.nodes=g)}return i.object=r,i;function o(a){const c=[];for(const l in a){const d=a[l];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Zt.DEFAULT_UP=new O(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yn=new O,Ci=new O,xu=new O,Ri=new O,vs=new O,ys=new O,Df=new O,wu=new O,Iu=new O,Mu=new O,Cu=new Ot,Ru=new Ot,Pu=new Ot;class zn{constructor(e=new O,t=new O,i=new O){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Yn.subVectors(e,t),r.cross(Yn);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Yn.subVectors(r,t),Ci.subVectors(i,t),xu.subVectors(e,t);const o=Yn.dot(Yn),a=Yn.dot(Ci),c=Yn.dot(xu),l=Ci.dot(Ci),d=Ci.dot(xu),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;const p=1/h,_=(l*c-a*d)*p,g=(o*d-a*c)*p;return s.set(1-_-g,g,_)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Ri)===null?!1:Ri.x>=0&&Ri.y>=0&&Ri.x+Ri.y<=1}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,Ri)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Ri.x),c.addScaledVector(o,Ri.y),c.addScaledVector(a,Ri.z),c)}static getInterpolatedAttribute(e,t,i,r,s,o){return Cu.setScalar(0),Ru.setScalar(0),Pu.setScalar(0),Cu.fromBufferAttribute(e,t),Ru.fromBufferAttribute(e,i),Pu.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(Cu,s.x),o.addScaledVector(Ru,s.y),o.addScaledVector(Pu,s.z),o}static isFrontFacing(e,t,i,r){return Yn.subVectors(i,t),Ci.subVectors(e,t),Yn.cross(Ci).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),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 Yn.subVectors(this.c,this.b),Ci.subVectors(this.a,this.b),Yn.cross(Ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return zn.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let o,a;vs.subVectors(r,i),ys.subVectors(s,i),wu.subVectors(e,i);const c=vs.dot(wu),l=ys.dot(wu);if(c<=0&&l<=0)return t.copy(i);Iu.subVectors(e,r);const d=vs.dot(Iu),h=ys.dot(Iu);if(d>=0&&h<=d)return t.copy(r);const p=c*h-d*l;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(i).addScaledVector(vs,o);Mu.subVectors(e,s);const _=vs.dot(Mu),g=ys.dot(Mu);if(g>=0&&_<=g)return t.copy(s);const S=_*l-c*g;if(S<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(i).addScaledVector(ys,a);const m=d*g-_*h;if(m<=0&&h-d>=0&&_-g>=0)return Df.subVectors(s,r),a=(h-d)/(h-d+(_-g)),t.copy(r).addScaledVector(Df,a);const f=1/(m+S+p);return o=S*f,a=p*f,t.copy(i).addScaledVector(vs,o).addScaledVector(ys,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wg={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},cr={h:0,s:0,l:0},mc={h:0,s:0,l:0};function Lu(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class ut{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ft.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=ft.workingColorSpace){return this.r=e,this.g=t,this.b=i,ft.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=ft.workingColorSpace){if(e=Hh(e,1),t=Qt(t,0,1),i=Qt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Lu(o,s,e+1/3),this.g=Lu(o,s,e),this.b=Lu(o,s,e-1/3)}return ft.toWorkingColorSpace(this,r),this}setStyle(e,t=Vn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vn){const i=wg[e.toLowerCase()];return i!==void 0?this.setHex(i,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=Xi(e.r),this.g=Xi(e.g),this.b=Xi(e.b),this}copyLinearToSRGB(e){return this.r=Fs(e.r),this.g=Fs(e.g),this.b=Fs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vn){return ft.fromWorkingColorSpace(ln.copy(this),e),Math.round(Qt(ln.r*255,0,255))*65536+Math.round(Qt(ln.g*255,0,255))*256+Math.round(Qt(ln.b*255,0,255))}getHexString(e=Vn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ft.workingColorSpace){ft.fromWorkingColorSpace(ln.copy(this),t);const i=ln.r,r=ln.g,s=ln.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let c,l;const d=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=d<=.5?h/(o+a):h/(2-o-a),o){case i:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-i)/h+2;break;case s:c=(i-r)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=d,e}getRGB(e,t=ft.workingColorSpace){return ft.fromWorkingColorSpace(ln.copy(this),t),e.r=ln.r,e.g=ln.g,e.b=ln.b,e}getStyle(e=Vn){ft.fromWorkingColorSpace(ln.copy(this),e);const t=ln.r,i=ln.g,r=ln.b;return e!==Vn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(cr),this.setHSL(cr.h+e,cr.s+t,cr.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(cr),e.getHSL(mc);const i=ua(cr.h,mc.h,t),r=ua(cr.s,mc.s,t),s=ua(cr.l,mc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ln=new ut;ut.NAMES=wg;let ST=0;class ns extends ts{static get type(){return"Material"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ST++}),this.uuid=pi(),this.name="",this.blending=Us,this.side=Er,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=hd,this.blendDst=pd,this.blendEquation=Fr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ut(0,0,0),this.blendAlpha=0,this.depthFunc=Xs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=us,this.stencilZFail=us,this.stencilZPass=us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};
vendor: 6,152 bytes, line 5
5i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Us&&(i.blending=this.blending),this.side!==Er&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==hd&&(i.blendSrc=this.blendSrc),this.blendDst!==pd&&(i.blendDst=this.blendDst),this.blendEquation!==Fr&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==mf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==us&&
vendor: 5,260 bytes, line 5
5(i.stencilFail=this.stencilFail),this.stencilZFail!==us&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==us&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Ig extends ns{static get type(){return"MeshBasicMaterial"}constructor(e){super(),this.isMeshBasicMaterial=!0,this.color=new ut(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vi,this.combine=kh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Bt=new O,gc=new xe;class Gn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Zd,this.updateRanges=[],this.gpuType=Bi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;
vendor: 3,089 bytes, line 5
5for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)gc.fromBufferAttribute(this,t),gc.applyMatrix3(e),this.setXY(t,gc.x,gc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyMatrix3(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyMatrix4(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.applyNormalMatrix(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Bt.fromBufferAttribute(this,t),Bt.transformDirection(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=$n(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$n(t,this.array)),t}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$n(t,this.array)),t}setY(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=$n(t,this.array)),t}setZ(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=$n(t,this.array)),t}setW(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),r=vt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),r=vt(r,this.array),s=vt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Zd&&(e.usage=this.usage),e}}class Mg extends Gn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Cg extends Gn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ft extends Gn{constructor(e,t,i){super(new Float32Array(e),t,i)}}let AT=0;const Fn=new wt,Du=new Zt,Es=new O,Dn=new za,Oo=new za,Kt=new O;class An extends ts{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:AT++}
vendor: 3,071 bytes, line 5
5),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Sg(e)?Cg:Mg)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new it().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,i){return Fn.makeTranslation(e,t,i),this.applyMatrix4(Fn),this}scale(e,t,i){return Fn.makeScale(e,t,i),this.applyMatrix4(Fn),this}lookAt(e){return Du.lookAt(e),Du.updateMatrix(),this.applyMatrix4(Du.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Es).negate(),this.translate(Es.x,Es.y,Es.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ft(i,3))}else{for(let i=0,r=t.count;i<r;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new za);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];Dn.setFromBufferAttribute(s),this.morphTargetsRelative?(Kt.addVectors(this.boundingBox.min,Dn.min),this.boundingBox.expandByPoint(Kt),Kt.addVectors(this.boundingBox.max,Dn.max),this.boundingBox.expandByPoint(Kt)):(this.boundingBox.expandByPoint(Dn.min),this.boundingBox.expandByPoint(Dn.max)
vendor: 4,533 bytes, line 5
5)}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ol);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const i=this.boundingSphere.center;if(Dn.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Oo.setFromBufferAttribute(a),this.morphTargetsRelative?(Kt.addVectors(Dn.min,Oo.min),Dn.expandByPoint(Kt),Kt.addVectors(Dn.max,Oo.max),Dn.expandByPoint(Kt)):(Dn.expandByPoint(Oo.min),Dn.expandByPoint(Oo.max))}Dn.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Kt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Kt));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],c=this.morphTargetsRelative;for(let l=0,d=a.count;l<d;l++)Kt.fromBufferAttribute(a,l),c&&(Es.fromBufferAttribute(e,l),Kt.add(Es)),r=Math.max(r,i.distanceToSquared(Kt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Gn(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let A=0;A<i.count;A++)a[A]=new O,c[A]=new O;const l=new O,d=new O,h=new O,p=new xe,_=new xe,g=new xe,S=new O,m=new O;function f(A,E,y){l.fromBufferAttribute(i,A),d.fromBufferAttribute(i,E),h.fromBufferAttribute(i,y),p.fromBufferAttribute(s,A),_.fromBufferAttribute(s,E),g.fromBufferAttribute(s,y),d.sub(l),h.sub(l),_.sub(p),g.sub(p);const I=1/(_.x*g.y-g.x*_.y);isFinite(I)&&(S.copy(d).multiplyScalar(g.y).addScaledVector(h,-_.y).multiplyScalar(I),m.copy(h).multiplyScalar(_.x).addScaledVector(d,-g.x).multiplyScalar(I),a[A].add(S),a[E].add(S),a[y].add(S),c[A].add(m),c[E].add(m),c[y].add(m))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let A=0,E=M.length;A<E;++A){const y=M[A],I=y.start,D=y.count;for(let C=I,W=I+D;C<W;C+=3)f(e.getX(C+0),e.getX(C+1),e.getX(C+2))}const w=new O,b=new O,R=new O,P=new O;function T(A){R.fromBufferAttribute(r,A),P.copy(R);const E=a[A];w.copy(E),w.sub(R.multiplyScalar(R.dot(E))).normalize(),b.crossVectors(P,E);const I=b.dot(c[A])<0?-1:1;o.setXYZW(A,w.x,w.y,w.z,I)}for(let A=0,E=M.length;A<E;++A){const y=M[A],I=y.start,D=y.count;for(let C=I,W=I+D;C<W;C+=3)T(e.getX(C+0)),T(e.getX(C+1)),T(e.getX(C+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Gn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,_=i.count;p<_;p++)i.setXYZ(p,0,0,0);const r=new O,s=new O,o=new O,a=new O,c=new O,l=new O,d=new O,h=new O;if(e)for(let p=0,_=e.count;p<_;p+=3){const g=e.getX(p+0),S=e.getX(p+1),m=e.getX(p+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,S),o.fromBufferAttribute(t,m),d.subVectors(o,s),h.subVectors(r,s),d.cross(h),a.fromBufferAttribute(i,g),c.fromBufferAttribute(i,S),l.fromBufferAttribute(i,m),a.add(d),c.add(d),l.add(d),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(S,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let p=0,_=t.count;p<_;p+=3)r.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),d.subVectors(o,s),h.subVectors(r,s),d.cross(h),i.setXYZ(p+0,d.x,d.y,d.z),i.setXYZ(p+1,d.x,d.y,d.z),i.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Kt.fromBufferAttribute(e,t),Kt.normalize(),e.setXYZ(t,Kt.x,Kt.y,Kt.z)}toNonIndexed(){function e(a,c){const l=a.array,d=a.itemSize,h=a.normalized,p=new l.constructor(c.length*d);let _=0,g=0;for(let S=0,m=c.length;S<m;S++){a.isInterleavedBufferAttribute?_=c[S]*a.data.stride+a.offset:_=c[S]*d;for(let f=0;f<d;f++)p[g++]=l[_++]}
vendor: 6,806 bytes, line 5
5return new Gn(p,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new An,i=this.index.array,r=this.attributes;for(const a in r){const c=r[a],l=e(c,i);t.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let d=0,h=l.length;d<h;d++){const p=l[d],_=e(p,i);c.push(_)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],d=[];for(let h=0,p=l.length;h<p;h++){const _=l[h];d.push(_.toJSON(e.data))}d.length>0&&(r[c]=d,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const l in r){const d=r[l];this.setAttribute(l,d.clone(t))}const s=e.morphAttributes;for(const l in s){const d=[],h=s[l];for(let p=0,_=h.length;p<_;p++)d.push(h[p].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,d=o.length;l<d;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Nf=new wt,Pr=new Gh,vc=new Ol,kf=new O,yc=new O,Ec=new O,Tc=new O,Nu=new O,bc=new O,Uf=new O,Sc=new O;class Hi extends Zt{constructor(e=new An,t=new Ig){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const a=this.morphTargetInfluences;if(s&&a){bc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const d=a[c],h=s[c];d!==0&&(Nu.fromBufferAttribute(h,e),o?bc.addScaledVector(Nu,d):bc.addScaledVector(Nu.sub(t),d))}t.add(bc)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),vc.copy(i.boundingSphere),vc.applyMatrix4(s),Pr.copy(e.ray).recast(e.near),!(vc.containsPoint(Pr.origin)===!1&&(Pr.intersectSphere(vc,kf)===null||Pr.origin.distanceToSquared(kf)>(e.far-e.near)**2))&&(Nf.copy(s).invert(),Pr.copy(e.ray).applyMatrix4(Nf),!(i.boundingBox!==null&&Pr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Pr)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,_=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,S=p.length;g<S;g++){const m=p[g],f=o[m.materialIndex],M=Math.max(m.start,_.start),w=Math.min(a.count,Math.min(m.start+m.count,_.start+_.count));for(let b=M,R=w;b<R;b+=3){const P=a.getX(b),T=a.getX(b+1),A=a.getX(b+2);r=Ac(this,f,e,i,l,d,h,P,T,A),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,_.start),S=Math.min(a.count,_.start+_.count);for(let m=g,f=S;m<f;m+=3){const M=a.getX(m),w=a.getX(m+1),b=a.getX(m+2);r=Ac(this,o,e,i,l,d,h,M,w,b),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,S=p.length;g<S;g++){const m=p[g],f=o[m.materialIndex],M=Math.max(m.start,_.start),w=Math.min(c.count,Math.min(m.start+m.count,_.start+_.count));for(let b=M,R=w;b<R;b+=3){const P=b,T=b+1,A=b+2;r=Ac(this,f,e,i,l,d,h,P,T,A),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,_.start),S=Math.min(c.count,_.start+_.count);for(let m=g,f=S;m<f;m+=3){const M=m,w=m+1,b=m+2;r=Ac(this,o,e,i,l,d,h,M,w,b),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function xT(n,e,t,i,r,s,o,a){let c;if(e.side===bn?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===Er,a),c===null)return null;Sc.copy(a),Sc.applyMatrix4(n.matrixWorld);const l=t.ray.origin.distanceTo(Sc);return l<t.near||l>t.far?null:{distance:l,point:Sc.clone(),object:n}}function Ac(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,yc),n.getVertexPosition(c,Ec),n.getVertexPosition(l,Tc);const d=xT(n,e,t,i,yc,Ec,Tc,Uf);if(d){const h=new O;zn.getBarycoord(Uf,yc,Ec,Tc,h),r&&(d.uv=zn.getInterpolatedAttribute(r,a,c,l,h,new xe)),s&&(d.uv1=zn.getInterpolatedAttribute(s,a,c,l,h,new xe)),o&&(d.normal=zn.getInterpolatedAttribute(o,a,c,l,h,new O),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const p={a,b:c,c:l,normal:new O,materialIndex:0};zn.getNormal(yc,Ec,Tc,p.normal),d.face=p,d.barycoord=h}return d}class Ha extends An{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],d=[],h=[];let p=0,_=0;g("z","y","x",-1,-1,i,t,e,o,s,0),g("z","y","x",1,-1,i,t,-e,o,s,1
vendor: 9,705 bytes, lines 5-9
5),g("x","z","y",1,1,e,i,t,r,o,2),g("x","z","y",1,-1,e,i,-t,r,o,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new Ft(l,3)),this.setAttribute("normal",new Ft(d,3)),this.setAttribute("uv",new Ft(h,2));function g(S,m,f,M,w,b,R,P,T,A,E){const y=b/T,I=R/A,D=b/2,C=R/2,W=P/2,Z=T+1,Y=A+1;let ce=0,K=0;const ue=new O;for(let ve=0;ve<Y;ve++){const ye=ve*I-C;for(let Oe=0;Oe<Z;Oe++){const Ve=Oe*y-D;ue[S]=Ve*M,ue[m]=ye*w,ue[f]=W,l.push(ue.x,ue.y,ue.z),ue[S]=0,ue[m]=0,ue[f]=P>0?1:-1,d.push(ue.x,ue.y,ue.z),h.push(Oe/T),h.push(1-ve/A),ce+=1}}for(let ve=0;ve<A;ve++)for(let ye=0;ye<T;ye++){const Oe=p+ye+Z*ve,Ve=p+ye+Z*(ve+1),J=p+(ye+1)+Z*(ve+1),re=p+(ye+1)+Z*ve;c.push(Oe,Ve,re),c.push(Ve,J,re),K+=6}a.addGroup(_,K,E),_+=K,p+=ce}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ha(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Zs(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function mn(n){const e={};for(let t=0;t<n.length;t++){const i=Zs(n[t]);for(const r in i)e[r]=i[r]}return e}function wT(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Rg(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ft.workingColorSpace}const IT={clone:Zs,merge:mn};var MT=`void main() { 6 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 7}`,CT=`void main() { 8 gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); 9}`;class Tr extends ns{static get type(){return"ShaderMaterial"}constructor(e){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=MT,this.fragmentShader=CT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Zs(e.uniforms),this.uniformsGroups=wT(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Pg extends Zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new wt,this.projectionMatrix=new wt,this.projectionMatrixInverse=new wt,this.coordinateSystem=zi}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const lr=new O,Of=new xe,Ff=new xe;class Jn extends Pg{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ea*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(la*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ea*2*Math.atan(Math.tan(la*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){lr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(lr.x,lr.y).multiplyScalar(-e/lr.z),lr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(lr.x,lr.y).multiplyScalar(-e/lr.z)}getViewSize(e,t){return this.getViewBounds(e,Of,Ff),t.subVectors(Ff,Of)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(la*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ts=-90,bs=1;class RT extends Zt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Jn(Ts,bs,e,t);r.layers=this.layers,this.add(r);const s=new Jn(Ts,bs,e,t);s.layers=this.layers,this.add(s);const o=new Jn(Ts,bs,e,t);o.layers=this.layers,this.add(o);const a=new Jn(Ts,bs,e,t);a.layers=this.layers,this.add(a);const c=new Jn(Ts,bs,e,t);c.layers=this.layers,this.add(c);const l=new Jn(Ts,bs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(const l of t)this.remove(l);if(e===zi)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ll)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,c,l,d]=this.children,h=e.getRenderTarget(),p=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const S=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=S,e.setRenderTarget(i,5,r),e.render(t,d),e.setRenderTarget(h,p,_),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class Lg extends vn{constructor(e,t,i,r,s,o,a,c,l,d){e=e!==void 0?e:[],t=t!==void 0?t:js,super(e,t,i,r,s,o,a,c,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class PT extends Yr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Lg(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:di}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace
vendor: 12,245 bytes, lines 9-157
9=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` 10 11 varying vec3 vWorldDirection; 12 13 vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 14 15 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 16 17 } 18 19 void main() { 20 21 vWorldDirection = transformDirection( position, modelMatrix ); 22 23 #include <begin_vertex> 24 #include <project_vertex> 25 26 } 27 `,fragmentShader:` 28 29 uniform sampler2D tEquirect; 30 31 varying vec3 vWorldDirection; 32 33 #include <common> 34 35 void main() { 36 37 vec3 direction = normalize( vWorldDirection ); 38 39 vec2 sampleUV = equirectUv( direction ); 40 41 gl_FragColor = texture2D( tEquirect, sampleUV ); 42 43 } 44 `},r=new Ha(5,5,5),s=new Tr({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:bn,blending:vr});s.uniforms.tEquirect.value=t;const o=new Hi(r,s),a=t.minFilter;return t.minFilter===zr&&(t.minFilter=di),new RT(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}}const ku=new O,LT=new O,DT=new it;class kr{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=ku.subVectors(i,t).cross(LT.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(ku),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||DT.getNormalMatrix(e),r=this.coplanarPoint(ku).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),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)}}const Lr=new Ol,xc=new O;class Fl{constructor(e=new kr,t=new kr,i=new kr,r=new kr,s=new kr,o=new kr){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=zi){const i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],d=r[5],h=r[6],p=r[7],_=r[8],g=r[9],S=r[10],m=r[11],f=r[12],M=r[13],w=r[14],b=r[15];if(i[0].setComponents(c-s,p-l,m-_,b-f).normalize(),i[1].setComponents(c+s,p+l,m+_,b+f).normalize(),i[2].setComponents(c+o,p+d,m+g,b+M).normalize(),i[3].setComponents(c-o,p-d,m-g,b-M).normalize(),i[4].setComponents(c-a,p-h,m-S,b-w).normalize(),t===zi)i[5].setComponents(c+a,p+h,m+S,b+w).normalize();else if(t===ll)i[5].setComponents(a,h,S,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){return Lr.center.set(0,0,0),Lr.radius=.7071067811865476,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(xc.x=r.normal.x>0?e.max.x:e.min.x,xc.y=r.normal.y>0?e.max.y:e.min.y,xc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(xc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Dg(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function NT(n){const e=new WeakMap;function t(a,c){const l=a.array,d=a.usage,h=l.byteLength,p=n.createBuffer();n.bindBuffer(c,p),n.bufferData(c,l,d),a.onUploadCallback();let _;if(l instanceof Float32Array)_=n.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?_=n.HALF_FLOAT:_=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)_=n.SHORT;else if(l instanceof Uint32Array)_=n.UNSIGNED_INT;else if(l instanceof Int32Array)_=n.INT;else if(l instanceof Int8Array)_=n.BYTE;else if(l instanceof Uint8Array)_=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)_=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:p,type:_,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function i(a,c,l){const d=c.array,h=c.updateRanges;if(n.bindBuffer(l,a),h.length===0)n.bufferSubData(l,0,d);else{h.sort((_,g)=>_.start-g.start);let p=0;for(let _=1;_<h.length;_++){const g=h[p],S=h[_];S.start<=g.start+g.count+1?g.count=Math.max(g.count,S.start+S.count-g.start):(++p,h[p]=S)}h.length=p+1;for(let _=0,g=h.length;_<g;_++){const S=h[_];n.bufferSubData(l,S.start*d.BYTES_PER_ELEMENT,d,S.start,S.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);c&&(n.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const d=e.get(a);(!d||d.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}class Vl extends An{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,d=c+1,h=e/a,p=t/c,_=[],g=[],S=[],m=[];for(let f=0;f<d;f++){const M=f*p-o;for(let w=0;w<l;w++){const b=w*h-s;g.push(b,-M,0),S.push(0,0,1),m.push(w/a),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let M=0;M<a;M++){const w=M+l*f,b=M+l*(f+1),R=M+1+l*(f+1),P=M+1+l*f;_.push(w,b,P),_.push(b,R,P)}this.setIndex(_),this.setAttribute("position",new Ft(g,3)),this.setAttribute("normal",new Ft(S,3)),this.setAttribute("uv",new Ft(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vl(e.width,e.height,e.widthSegments,e.heightSegments)}}var kT=`#ifdef USE_ALPHAHASH 45 if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; 46#endif`,UT=`#ifdef USE_ALPHAHASH 47 const float ALPHA_HASH_SCALE = 0.05; 48 float hash2D( vec2 value ) { 49 return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); 50 } 51 float hash3D( vec3 value ) { 52 return hash2D( vec2( hash2D( value.xy ), value.z ) ); 53 } 54 float getAlphaHashThreshold( vec3 position ) { 55 float maxDeriv = max( 56 length( dFdx( position.xyz ) ), 57 length( dFdy( position.xyz ) ) 58 ); 59 float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); 60 vec2 pixScales = vec2( 61 exp2( floor( log2( pixScale ) ) ), 62 exp2( ceil( log2( pixScale ) ) ) 63 ); 64 vec2 alpha = vec2( 65 hash3D( floor( pixScales.x * position.xyz ) ), 66 hash3D( floor( pixScales.y * position.xyz ) ) 67 ); 68 float lerpFactor = fract( log2( pixScale ) ); 69 float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; 70 float a = min( lerpFactor, 1.0 - lerpFactor ); 71 vec3 cases = vec3( 72 x * x / ( 2.0 * a * ( 1.0 - a ) ), 73 ( x - 0.5 * a ) / ( 1.0 - a ), 74 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) 75 ); 76 float threshold = ( x < ( 1.0 - a ) ) 77 ? ( ( x < a ) ? cases.x : cases.y ) 78 : cases.z; 79 return clamp( threshold , 1.0e-6, 1.0 ); 80 } 81#endif`,OT=`#ifdef USE_ALPHAMAP 82 diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; 83#endif`,FT=`#ifdef USE_ALPHAMAP 84 uniform sampler2D alphaMap; 85#endif`,VT=`#ifdef USE_ALPHATEST 86 #ifdef ALPHA_TO_COVERAGE 87 diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); 88 if ( diffuseColor.a == 0.0 ) discard; 89 #else 90 if ( diffuseColor.a < alphaTest ) discard; 91 #endif 92#endif`,BT=`#ifdef USE_ALPHATEST 93 uniform float alphaTest; 94#endif`,zT=`#ifdef USE_AOMAP 95 float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; 96 reflectedLight.indirectDiffuse *= ambientOcclusion; 97 #if defined( USE_CLEARCOAT ) 98 clearcoatSpecularIndirect *= ambientOcclusion; 99 #endif 100 #if defined( USE_SHEEN ) 101 sheenSpecularIndirect *= ambientOcclusion; 102 #endif 103 #if defined( USE_ENVMAP ) && defined( STANDARD ) 104 float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); 105 reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); 106 #endif 107#endif`,HT=`#ifdef USE_AOMAP 108 uniform sampler2D aoMap; 109 uniform float aoMapIntensity; 110#endif`,GT=`#ifdef USE_BATCHING 111 #if ! defined( GL_ANGLE_multi_draw ) 112 #define gl_DrawID _gl_DrawID 113 uniform int _gl_DrawID; 114 #endif 115 uniform highp sampler2D batchingTexture; 116 uniform highp usampler2D batchingIdTexture; 117 mat4 getBatchingMatrix( const in float i ) { 118 int size = textureSize( batchingTexture, 0 ).x; 119 int j = int( i ) * 4; 120 int x = j % size; 121 int y = j / size; 122 vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); 123 vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); 124 vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); 125 vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); 126 return mat4( v1, v2, v3, v4 ); 127 } 128 float getIndirectIndex( const in int i ) { 129 int size = textureSize( batchingIdTexture, 0 ).x; 130 int x = i % size; 131 int y = i / size; 132 return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); 133 } 134#endif 135#ifdef USE_BATCHING_COLOR 136 uniform sampler2D batchingColorTexture; 137 vec3 getBatchingColor( const in float i ) { 138 int size = textureSize( batchingColorTexture, 0 ).x; 139 int j = int( i ); 140 int x = j % size; 141 int y = j / size; 142 return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb; 143 } 144#endif`,WT=`#ifdef USE_BATCHING 145 mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); 146#endif`,qT=`vec3 transformed = vec3( position ); 147#ifdef USE_ALPHAHASH 148 vPosition = vec3( position ); 149#endif`,XT=`vec3 objectNormal = vec3( normal ); 150#ifdef USE_TANGENT 151 vec3 objectTangent = vec3( tangent.xyz ); 152#endif`,jT=`float G_BlinnPhong_Implicit( ) { 153 return 0.25; 154} 155float D_BlinnPhong( const in float shininess, const in float dotNH ) { 156 return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); 157}
158vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { 159 vec3 halfDir = normalize( lightDir + viewDir ); 160 float dotNH = saturate( dot( normal, halfDir ) ); 161 float dotVH = saturate( dot( viewDir, halfDir ) ); 162 vec3 F = F_Schlick( specularColor, 1.0, dotVH ); 163 float G = G_BlinnPhong_Implicit( ); 164 float D = D_BlinnPhong( shininess, dotNH ); 165 return F * ( G * D ); 166} // validated`,KT=`#ifdef USE_IRIDESCENCE 167 const mat3 XYZ_TO_REC709 = mat3( 168 3.2404542, -0.9692660, 0.0556434, 169 -1.5371385, 1.8760108, -0.2040259, 170 -0.4985314, 0.0415560, 1.0572252 171 ); 172 vec3 Fresnel0ToIor( vec3 fresnel0 ) { 173 vec3 sqrtF0 = sqrt( fresnel0 ); 174 return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); 175 } 176 vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { 177 return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); 178 } 179 float IorToFresnel0( float transmittedIor, float incidentIor ) { 180 return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); 181 } 182 vec3 evalSensitivity( float OPD, vec3 shift ) { 183 float phase = 2.0 * PI * OPD * 1.0e-9; 184 vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); 185 vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); 186 vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); 187 vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); 188 xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); 189 xyz /= 1.0685e-7; 190 vec3 rgb = XYZ_TO_REC709 * xyz; 191 return rgb; 192 } 193 vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { 194 vec3 I; 195 float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); 196 float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); 197 float cosTheta2Sq = 1.0 - sinTheta2Sq; 198 if ( cosTheta2Sq < 0.0 ) { 199 return vec3( 1.0 ); 200 } 201 float cosTheta2 = sqrt( cosTheta2Sq ); 202 float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); 203 float R12 = F_Schlick( R0, 1.0, cosTheta1 );
204 float T121 = 1.0 - R12; 205 float phi12 = 0.0; 206 if ( iridescenceIOR < outsideIOR ) phi12 = PI; 207 float phi21 = PI - phi12; 208 vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); 209 vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); 210 vec3 phi23 = vec3( 0.0 ); 211 if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; 212 if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; 213 if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; 214 float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; 215 vec3 phi = vec3( phi21 ) + phi23; 216 vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); 217 vec3 r123 = sqrt( R123 ); 218 vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); 219 vec3 C0 = R12 + Rs; 220 I = C0; 221 vec3 Cm = Rs - T121; 222 for ( int m = 1; m <= 2; ++ m ) { 223 Cm *= r123; 224 vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); 225 I += Cm * Sm; 226 } 227 return max( I, vec3( 0.0 ) ); 228 } 229#endif`,YT=`#ifdef USE_BUMPMAP 230 uniform sampler2D bumpMap; 231 uniform float bumpScale; 232 vec2 dHdxy_fwd() { 233 vec2 dSTdx = dFdx( vBumpMapUv ); 234 vec2 dSTdy = dFdy( vBumpMapUv ); 235 float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; 236 float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; 237 float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; 238 return vec2( dBx, dBy ); 239 } 240 vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { 241 vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); 242 vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); 243 vec3 vN = surf_norm; 244 vec3 R1 = cross( vSigmaY, vN ); 245 vec3 R2 = cross( vN, vSigmaX ); 246 float fDet = dot( vSigmaX, R1 ) * faceDirection; 247 vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 248 return normalize( abs( fDet ) * surf_norm - vGrad ); 249 } 250#endif`,QT=`#if NUM_CLIPPING_PLANES > 0 251 vec4 plane; 252 #ifdef ALPHA_TO_COVERAGE 253 float distanceToPlane, distanceGradient; 254 float clipOpacity = 1.0; 255 #pragma unroll_loop_start 256 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 257 plane = clippingPlanes[ i ]; 258 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 259 distanceGradient = fwidth( distanceToPlane ) / 2.0; 260 clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 261 if ( clipOpacity == 0.0 ) discard; 262 } 263 #pragma unroll_loop_end 264 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 265 float unionClipOpacity = 1.0; 266 #pragma unroll_loop_start 267 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 268 plane = clippingPlanes[ i ]; 269 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 270 distanceGradient = fwidth( distanceToPlane ) / 2.0; 271 unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 272 } 273 #pragma unroll_loop_end 274 clipOpacity *= 1.0 - unionClipOpacity; 275 #endif 276 diffuseColor.a *= clipOpacity; 277 if ( diffuseColor.a == 0.0 ) discard; 278 #else 279 #pragma unroll_loop_start 280 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 281 plane = clippingPlanes[ i ]; 282 if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; 283 } 284 #pragma unroll_loop_end 285 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 286 bool clipped = true; 287 #pragma unroll_loop_start 288 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 289 plane = clippingPlanes[ i ]; 290 clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; 291 } 292 #pragma unroll_loop_end 293 if ( clipped ) discard; 294 #endif 295 #endif 296#endif`,ZT=`#if NUM_CLIPPING_PLANES > 0 297 varying vec3 vClipPosition; 298 uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 299#endif`,JT=`#if NUM_CLIPPING_PLANES > 0 300 varying vec3 vClipPosition; 301#endif`,$T=`#if NUM_CLIPPING_PLANES > 0 302 vClipPosition = - mvPosition.xyz; 303#endif`,eb=`#if defined( USE_COLOR_ALPHA ) 304 diffuseColor *= vColor; 305#elif defined( USE_COLOR ) 306 diffuseColor.rgb *= vColor; 307#endif`,tb=`#if defined( USE_COLOR_ALPHA ) 308 varying vec4 vColor; 309#elif defined( USE_COLOR ) 310 varying vec3 vColor; 311#endif`,nb=`#if defined( USE_COLOR_ALPHA ) 312 varying vec4 vColor; 313#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 314 varying vec3 vColor; 315#endif`,ib=`#if defined( USE_COLOR_ALPHA ) 316 vColor = vec4( 1.0 ); 317#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 318 vColor = vec3( 1.0 ); 319#endif 320#ifdef USE_COLOR 321 vColor *= color; 322#endif 323#ifdef USE_INSTANCING_COLOR 324 vColor.xyz *= instanceColor.xyz; 325#endif 326#ifdef USE_BATCHING_COLOR 327 vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); 328 vColor.xyz *= batchingColor.xyz; 329#endif`,rb=`#define PI 3.141592653589793 330#define PI2 6.283185307179586 331#define PI_HALF 1.5707963267948966 332#define RECIPROCAL_PI 0.3183098861837907 333#define RECIPROCAL_PI2 0.15915494309189535 334#define EPSILON 1e-6 335#ifndef saturate 336#define saturate( a ) clamp( a, 0.0, 1.0 ) 337#endif 338#define whiteComplement( a ) ( 1.0 - saturate( a ) ) 339float pow2( const in float x ) { return x*x; } 340vec3 pow2( const in vec3 x ) { return x*x; } 341float pow3( const in float x ) { return x*x*x; } 342float pow4( const in float x ) { float x2 = x*x; return x2*x2; } 343float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } 344float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } 345highp float rand( const in vec2 uv ) { 346 const highp float a = 12.9898, b = 78.233, c = 43758.5453; 347 highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); 348 return fract( sin( sn ) * c ); 349} 350#ifdef HIGH_PRECISION 351 float precisionSafeLength( vec3 v ) { return length( v ); } 352#else 353 float precisionSafeLength( vec3 v ) { 354 float maxComponent = max3( abs( v ) ); 355 return length( v / maxComponent ) * maxComponent; 356 } 357#endif 358struct IncidentLight { 359 vec3 color; 360 vec3 direction; 361 bool visible; 362}; 363struct ReflectedLight { 364 vec3 directDiffuse; 365 vec3 directSpecular; 366 vec3 indirectDiffuse; 367 vec3 indirectSpecular; 368}; 369#ifdef USE_ALPHAHASH 370 varying vec3 vPosition; 371#endif 372vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 373 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 374} 375vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { 376 return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); 377} 378mat3 transposeMat3( const in mat3 m ) { 379 mat3 tmp; 380 tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); 381 tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); 382 tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); 383 return tmp; 384} 385bool isPerspectiveMatrix( mat4 m ) { 386 return m[ 2 ][ 3 ] == - 1.0; 387} 388vec2 equirectUv( in vec3 dir ) { 389 float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; 390 float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 391 return vec2( u, v ); 392}
393vec3 BRDF_Lambert( const in vec3 diffuseColor ) { 394 return RECIPROCAL_PI * diffuseColor; 395} 396vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { 397 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 398 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 399} 400float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { 401 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 402 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 403} // validated`,sb=`#ifdef ENVMAP_TYPE_CUBE_UV 404 #define cubeUV_minMipLevel 4.0 405 #define cubeUV_minTileSize 16.0 406 float getFace( vec3 direction ) { 407 vec3 absDirection = abs( direction ); 408 float face = - 1.0; 409 if ( absDirection.x > absDirection.z ) { 410 if ( absDirection.x > absDirection.y ) 411 face = direction.x > 0.0 ? 0.0 : 3.0; 412 else 413 face = direction.y > 0.0 ? 1.0 : 4.0; 414 } else { 415 if ( absDirection.z > absDirection.y ) 416 face = direction.z > 0.0 ? 2.0 : 5.0; 417 else 418 face = direction.y > 0.0 ? 1.0 : 4.0; 419 } 420 return face; 421 } 422 vec2 getUV( vec3 direction, float face ) { 423 vec2 uv; 424 if ( face == 0.0 ) { 425 uv = vec2( direction.z, direction.y ) / abs( direction.x ); 426 } else if ( face == 1.0 ) { 427 uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); 428 } else if ( face == 2.0 ) { 429 uv = vec2( - direction.x, direction.y ) / abs( direction.z ); 430 } else if ( face == 3.0 ) { 431 uv = vec2( - direction.z, direction.y ) / abs( direction.x ); 432 } else if ( face == 4.0 ) { 433 uv = vec2( - direction.x, direction.z ) / abs( direction.y ); 434 } else { 435 uv = vec2( direction.x, direction.y ) / abs( direction.z ); 436 } 437 return 0.5 * ( uv + 1.0 ); 438 } 439 vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { 440 float face = getFace( direction ); 441 float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); 442 mipInt = max( mipInt, cubeUV_minMipLevel ); 443 float faceSize = exp2( mipInt ); 444 highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; 445 if ( face > 2.0 ) { 446 uv.y += faceSize; 447 face -= 3.0; 448 } 449 uv.x += face * faceSize; 450 uv.x += filterInt * 3.0 * cubeUV_minTileSize; 451 uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); 452 uv.x *= CUBEUV_TEXEL_WIDTH; 453 uv.y *= CUBEUV_TEXEL_HEIGHT; 454 #ifdef texture2DGradEXT 455 return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; 456 #else 457 return texture2D( envMap, uv ).rgb; 458 #endif 459 } 460 #define cubeUV_r0 1.0 461 #define cubeUV_m0 - 2.0 462 #define cubeUV_r1 0.8 463 #define cubeUV_m1 - 1.0 464 #define cubeUV_r4 0.4 465 #define cubeUV_m4 2.0 466 #define cubeUV_r5 0.305 467 #define cubeUV_m5 3.0 468 #define cubeUV_r6 0.21 469 #define cubeUV_m6 4.0 470 float roughnessToMip( float roughness ) { 471 float mip = 0.0; 472 if ( roughness >= cubeUV_r1 ) { 473 mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; 474 } else if ( roughness >= cubeUV_r4 ) { 475 mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; 476 } else if ( roughness >= cubeUV_r5 ) { 477 mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; 478 } else if ( roughness >= cubeUV_r6 ) { 479 mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; 480 } else { 481 mip = - 2.0 * log2( 1.16 * roughness ); } 482 return mip; 483 } 484 vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { 485 float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); 486 float mipF = fract( mip ); 487 float mipInt = floor( mip ); 488 vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); 489 if ( mipF == 0.0 ) { 490 return vec4( color0, 1.0 ); 491 } else { 492 vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); 493 return vec4( mix( color0, color1, mipF ), 1.0 ); 494 } 495 } 496#endif`,ob=`vec3 transformedNormal = objectNormal; 497#ifdef USE_TANGENT 498 vec3 transformedTangent = objectTangent; 499#endif 500#ifdef USE_BATCHING 501 mat3 bm = mat3( batchingMatrix ); 502 transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); 503 transformedNormal = bm * transformedNormal; 504 #ifdef USE_TANGENT 505 transformedTangent = bm * transformedTangent; 506 #endif 507#endif 508#ifdef USE_INSTANCING 509 mat3 im = mat3( instanceMatrix ); 510 transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); 511 transformedNormal = im * transformedNormal; 512 #ifdef USE_TANGENT 513 transformedTangent = im * transformedTangent; 514 #endif 515#endif 516transformedNormal = normalMatrix * transformedNormal; 517#ifdef FLIP_SIDED 518 transformedNormal = - transformedNormal; 519#endif 520#ifdef USE_TANGENT 521 transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; 522 #ifdef FLIP_SIDED 523 transformedTangent = - transformedTangent; 524 #endif 525#endif`,ab=`#ifdef USE_DISPLACEMENTMAP 526 uniform sampler2D displacementMap; 527 uniform float displacementScale; 528 uniform float displacementBias; 529#endif`,cb=`#ifdef USE_DISPLACEMENTMAP 530 transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + dis
530placementBias ); 531#endif`,lb=`#ifdef USE_EMISSIVEMAP 532 vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); 533 #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE 534 emissiveColor = sRGBTransferEOTF( emissiveColor ); 535 #endif 536 totalEmissiveRadiance *= emissiveColor.rgb; 537#endif`,ub=`#ifdef USE_EMISSIVEMAP 538 uniform sampler2D emissiveMap; 539#endif`,db="gl_FragColor = linearToOutputTexel( gl_FragColor );",hb=`vec4 LinearTransferOETF( in vec4 value ) { 540 return value; 541} 542vec4 sRGBTransferEOTF( in vec4 value ) { 543 return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); 544} 545vec4 sRGBTransferOETF( in vec4 value ) { 546 return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); 547}`,pb=`#ifdef USE_ENVMAP 548 #ifdef ENV_WORLDPOS 549 vec3 cameraToFrag; 550 if ( isOrthographic ) { 551 cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 552 } else { 553 cameraToFrag = normalize( vWorldPosition - cameraPosition ); 554 } 555 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 556 #ifdef ENVMAP_MODE_REFLECTION 557 vec3 reflectVec = reflect( cameraToFrag, worldNormal ); 558 #else 559 vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); 560 #endif 561 #else 562 vec3 reflectVec = vReflect; 563 #endif 564 #ifdef ENVMAP_TYPE_CUBE 565 vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); 566 #else 567 vec4 envColor = vec4( 0.0 ); 568 #endif 569 #ifdef ENVMAP_BLENDING_MULTIPLY 570 outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 571 #elif defined( ENVMAP_BLENDING_MIX ) 572 outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 573 #elif defined( ENVMAP_BLENDING_ADD ) 574 outgoingLight += envColor.xyz * specularStrength * reflectivity; 575 #endif 576#endif`,fb=`#ifdef USE_ENVMAP 577 uniform float envMapIntensity; 578 uniform float flipEnvMap; 579 uniform mat3 envMapRotation; 580 #ifdef ENVMAP_TYPE_CUBE 581 uniform samplerCube envMap; 582 #else 583 uniform sampler2D envMap; 584 #endif 585 586#endif`,_b=`#ifdef USE_ENVMAP 587 uniform float reflectivity; 588 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 589 #define ENV_WORLDPOS 590 #endif 591 #ifdef ENV_WORLDPOS 592 varying vec3 vWorldPosition; 593 uniform float refractionRatio; 594 #else 595 varying vec3 vReflect; 596 #endif 597#endif`,mb=`#ifdef USE_ENVMAP 598 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 599 #define ENV_WORLDPOS 600 #endif 601 #ifdef ENV_WORLDPOS 602 603 varying vec3 vWorldPosition; 604 #else 605 varying vec3 vReflect; 606 uniform float refractionRatio; 607 #endif 608#endif`,gb=`#ifdef USE_ENVMAP 609 #ifdef ENV_WORLDPOS 610 vWorldPosition = worldPosition.xyz; 611 #else 612 vec3 cameraToVertex; 613 if ( isOrthographic ) { 614 cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 615 } else {
616 cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 617 } 618 vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 619 #ifdef ENVMAP_MODE_REFLECTION 620 vReflect = reflect( cameraToVertex, worldNormal ); 621 #else 622 vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 623 #endif 624 #endif 625#endif`,vb=`#ifdef USE_FOG 626 vFogDepth = - mvPosition.z; 627#endif`,yb=`#ifdef USE_FOG 628 varying float vFogDepth; 629#endif`,Eb=`#ifdef USE_FOG 630 #ifdef FOG_EXP2 631 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); 632 #else 633 float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); 634 #endif 635 gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 636#endif`,Tb=`#ifdef USE_FOG 637 uniform vec3 fogColor; 638 varying float vFogDepth; 639 #ifdef FOG_EXP2 640 uniform float fogDensity; 641 #else 642 uniform float fogNear; 643 uniform float fogFar; 644 #endif 645#endif`,bb=`#ifdef USE_GRADIENTMAP 646 uniform sampler2D gradientMap; 647#endif 648vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 649 float dotNL = dot( normal, lightDirection ); 650 vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 651 #ifdef USE_GRADIENTMAP 652 return vec3( texture2D( gradientMap, coord ).r ); 653 #else 654 vec2 fw = fwidth( coord ) * 0.5; 655 return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); 656 #endif 657}`,Sb=`#ifdef USE_LIGHTMAP 658 uniform sampler2D lightMap; 659 uniform float lightMapIntensity; 660#endif`,Ab=`LambertMaterial material; 661material.diffuseColor = diffuseColor.rgb; 662material.specularStrength = specularStrength;`,xb=`varying vec3 vViewPosition; 663struct LambertMaterial { 664 vec3 diffuseColor; 665 float specularStrength; 666}; 667void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 668 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 669 vec3 irradiance = dotNL * directLight.color; 670 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 671} 672void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 673 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 674} 675#define RE_Direct RE_Direct_Lambert 676#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wb=`uniform bool receiveShadow; 677uniform vec3 ambientLightColor; 678#if defined( USE_LIGHT_PROBES ) 679 uniform vec3 lightProbe[ 9 ]; 680#endif 681vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { 682 float x = normal.x, y = normal.y, z = normal.z; 683 vec3 result = shCoefficients[ 0 ] * 0.886227; 684 result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; 685 result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; 686 result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; 687 result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; 688 result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; 689 result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); 690 result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; 691 result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); 692 return result; 693} 694vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { 695 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 696 vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); 697 return irradiance; 698} 699vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { 700 vec3 irradiance = ambientLightColor; 701 return irradiance; 702} 703float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { 704 float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); 705 if ( cutoffDistance > 0.0 ) { 706 distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); 707 } 708 return distanceFalloff; 709} 710float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { 711 return smoothstep( coneCosine, penumbraCosine, angleCosine ); 712} 713#if NUM_DIR_LIGHTS > 0 714 struct DirectionalLight { 715 vec3 direction; 716 vec3 color; 717 }; 718 uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; 719 void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { 720 light.color = directionalLight.color; 721 light.direction = directionalLight.direction; 722 light.visible = true; 723 } 724#endif 725#if NUM_POINT_LIGHTS > 0 726 struct PointLight { 727 vec3 position; 728 vec3 color; 729 float distance; 730 float decay; 731 }; 732 uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; 733 void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { 734 vec3 lVector = pointLight.position - geometryPosition; 735 light.direction = normalize( lVector ); 736 float lightDistance = length( lVector ); 737 light.color = pointLight.color; 738 light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); 739 light.visible = ( light.color != vec3( 0.0 ) ); 740 } 741#endif
742#if NUM_SPOT_LIGHTS > 0 743 struct SpotLight { 744 vec3 position; 745 vec3 direction; 746 vec3 color; 747 float distance; 748 float decay; 749 float coneCos; 750 float penumbraCos; 751 }; 752 uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; 753 void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { 754 vec3 lVector = spotLight.position - geometryPosition; 755 light.direction = normalize( lVector ); 756 float angleCos = dot( light.direction, spotLight.direction ); 757 float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); 758 if ( spotAttenuation > 0.0 ) { 759 float lightDistance = length( lVector ); 760 light.color = spotLight.color * spotAttenuation; 761 light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); 762 light.visible = ( light.color != vec3( 0.0 ) ); 763 } else { 764 light.color = vec3( 0.0 ); 765 light.visible = false; 766 } 767 } 768#endif 769#if NUM_RECT_AREA_LIGHTS > 0 770 struct RectAreaLight { 771 vec3 color; 772 vec3 position; 773 vec3 halfWidth; 774 vec3 halfHeight; 775 }; 776 uniform sampler2D ltc_1; uniform sampler2D ltc_2; 777 uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; 778#endif 779#if NUM_HEMI_LIGHTS > 0 780 struct HemisphereLight { 781 vec3 direction; 782 vec3 skyColor; 783 vec3 groundColor; 784 }; 785 uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; 786 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { 787 float dotNL = dot( normal, hemiLight.direction ); 788 float hemiDiffuseWeight = 0.5 * dotNL + 0.5; 789 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); 790 return irradiance; 791 } 792#endif`,Ib=`#ifdef USE_ENVMAP 793 vec3 getIBLIrradiance( const in vec3 normal ) { 794 #ifdef ENVMAP_TYPE_CUBE_UV 795 vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 796 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); 797 return PI * envMapColor.rgb * envMapIntensity; 798 #else 799 return vec3( 0.0 ); 800 #endif 801 } 802 vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { 803 #ifdef ENVMAP_TYPE_CUBE_UV 804 vec3 reflectVec = reflect( - viewDir, normal ); 805 reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); 806 reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); 807 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); 808 return envMapColor.rgb * envMapIntensity; 809 #else 810 return vec3( 0.0 ); 811 #endif 812 } 813 #ifdef USE_ANISOTROPY 814 vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { 815 #ifdef ENVMAP_TYPE_CUBE_UV 816 vec3 bentNormal = cross( bitangent, viewDir ); 817 bentNormal = normalize( cross( bentNormal, bitangent ) ); 818 bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); 819 return getIBLRadiance( viewDir, bentNormal, roughness ); 820 #else 821 return vec3( 0.0 ); 822 #endif 823 } 824 #endif 825#endif`,Mb=`ToonMaterial material; 826material.diffuseColor = diffuseColor.rgb;`,Cb=`varying vec3 vViewPosition; 827struct ToonMaterial { 828 vec3 diffuseColor; 829}; 830void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 831 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; 832 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 833} 834void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 835 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 836} 837#define RE_Direct RE_Direct_Toon 838#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Rb=`BlinnPhongMaterial material; 839material.diffuseColor = diffuseColor.rgb; 840material.specularColor = specular; 841material.specularShininess = shininess; 842material.specularStrength = specularStrength;`,Pb=`varying vec3 vViewPosition; 843struct BlinnPhongMaterial { 844 vec3 diffuseColor; 845 vec3 specularColor; 846 float specularShininess; 847 float specularStrength; 848}; 849void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
850 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 851 vec3 irradiance = dotNL * directLight.color; 852 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 853 reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; 854} 855void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 856 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 857} 858#define RE_Direct RE_Direct_BlinnPhong 859#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Lb=`PhysicalMaterial material; 860material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); 861vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); 862float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); 863material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; 864material.roughness = min( material.roughness, 1.0 ); 865#ifdef IOR 866 material.ior = ior; 867 #ifdef USE_SPECULAR 868 float specularIntensityFactor = specularIntensity; 869 vec3 specularColorFactor = specularColor; 870 #ifdef USE_SPECULAR_COLORMAP 871 specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; 872 #endif 873 #ifdef USE_SPECULAR_INTENSITYMAP 874 specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; 875 #endif 876 material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); 877 #else 878 float specularIntensityFactor = 1.0; 879 vec3 specularColorFactor = vec3( 1.0 ); 880 material.specularF90 = 1.0; 881 #endif 882 material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); 883#else 884 material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); 885 material.specularF90 = 1.0; 886#endif 887#ifdef USE_CLEARCOAT 888 material.clearcoat = clearcoat; 889 material.clearcoatRoughness = clearcoatRoughness; 890 material.clearcoatF0 = vec3( 0.04 ); 891 material.clearcoatF90 = 1.0; 892 #ifdef USE_CLEARCOATMAP 893 material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; 894 #endif 895 #ifdef USE_CLEARCOAT_ROUGHNESSMAP 896 material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; 897 #endif 898 material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); 899 material.clearcoatRoughness += geometryRoughness; 900 material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); 901#endif 902#ifdef USE_DISPERSION 903 material.dispersion = dispersion; 904#endif 905#ifdef USE_IRIDESCENCE 906 material.iridescence = iridescence; 907 material.iridescenceIOR = iridescenceIOR; 908 #ifdef USE_IRIDESCENCEMAP 909 material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; 910 #endif 911 #ifdef USE_IRIDESCENCE_THICKNESSMAP 912 material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; 913 #else 914 material.iridescenceThickness = iridescenceThicknessMaximum; 915 #endif 916#endif 917#ifdef USE_SHEEN 918 material.sheenColor = sheenColor; 919 #ifdef USE_SHEEN_COLORMAP 920 material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; 921 #endif 922 material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); 923 #ifdef USE_SHEEN_ROUGHNESSMAP 924 material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; 925 #endif 926#endif 927#ifdef USE_ANISOTROPY 928 #ifdef USE_ANISOTROPYMAP 929 mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); 930 vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; 931 vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; 932 #else 933 vec2 anisotropyV = anisotropyVector; 934 #endif 935 material.anisotropy = length( anisotropyV ); 936 if( material.anisotropy == 0.0 ) { 937 anisotropyV = vec2( 1.0, 0.0 ); 938 } else { 939 anisotropyV /= material.anisotropy; 940 material.anisotropy = saturate( material.anisotropy ); 941 } 942 material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
943 material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; 944 material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; 945#endif`,Db
vendor: 14,687 bytes, lines 945-1246
945=`struct PhysicalMaterial { 946 vec3 diffuseColor; 947 float roughness; 948 vec3 specularColor; 949 float specularF90; 950 float dispersion; 951 #ifdef USE_CLEARCOAT 952 float clearcoat; 953 float clearcoatRoughness; 954 vec3 clearcoatF0; 955 float clearcoatF90; 956 #endif 957 #ifdef USE_IRIDESCENCE 958 float iridescence; 959 float iridescenceIOR; 960 float iridescenceThickness; 961 vec3 iridescenceFresnel; 962 vec3 iridescenceF0; 963 #endif 964 #ifdef USE_SHEEN 965 vec3 sheenColor; 966 float sheenRoughness; 967 #endif 968 #ifdef IOR 969 float ior; 970 #endif 971 #ifdef USE_TRANSMISSION 972 float transmission; 973 float transmissionAlpha; 974 float thickness; 975 float attenuationDistance; 976 vec3 attenuationColor; 977 #endif 978 #ifdef USE_ANISOTROPY 979 float anisotropy; 980 float alphaT; 981 vec3 anisotropyT; 982 vec3 anisotropyB; 983 #endif 984}; 985vec3 clearcoatSpecularDirect = vec3( 0.0 ); 986vec3 clearcoatSpecularIndirect = vec3( 0.0 ); 987vec3 sheenSpecularDirect = vec3( 0.0 ); 988vec3 sheenSpecularIndirect = vec3(0.0 ); 989vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { 990 float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); 991 float x2 = x * x; 992 float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); 993 return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); 994} 995float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { 996 float a2 = pow2( alpha ); 997 float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); 998 float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); 999 return 0.5 / max( gv + gl, EPSILON ); 1000} 1001float D_GGX( const in float alpha, const in float dotNH ) { 1002 float a2 = pow2( alpha ); 1003 float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; 1004 return RECIPROCAL_PI * a2 / pow2( denom ); 1005} 1006#ifdef USE_ANISOTROPY 1007 float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { 1008 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); 1009 float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); 1010 float v = 0.5 / ( gv + gl ); 1011 return saturate(v); 1012 } 1013 float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { 1014 float a2 = alphaT * alphaB; 1015 highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); 1016 highp float v2 = dot( v, v ); 1017 float w2 = a2 / v2; 1018 return RECIPROCAL_PI * a2 * pow2 ( w2 ); 1019 } 1020#endif 1021#ifdef USE_CLEARCOAT 1022 vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { 1023 vec3 f0 = material.clearcoatF0; 1024 float f90 = material.clearcoatF90; 1025 float roughness = material.clearcoatRoughness; 1026 float alpha = pow2( roughness ); 1027 vec3 halfDir = normalize( lightDir + viewDir ); 1028 float dotNL = saturate( dot( normal, lightDir ) ); 1029 float dotNV = saturate( dot( normal, viewDir ) ); 1030 float dotNH = saturate( dot( normal, halfDir ) ); 1031 float dotVH = saturate( dot( viewDir, halfDir ) ); 1032 vec3 F = F_Schlick( f0, f90, dotVH ); 1033 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1034 float D = D_GGX( alpha, dotNH ); 1035 return F * ( V * D ); 1036 } 1037#endif 1038vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1039 vec3 f0 = material.specularColor; 1040 float f90 = material.specularF90; 1041 float roughness = material.roughness; 1042 float alpha = pow2( roughness ); 1043 vec3 halfDir = normalize( lightDir + viewDir ); 1044 float dotNL = saturate( dot( normal, lightDir ) ); 1045 float dotNV = saturate( dot( normal, viewDir ) ); 1046 float dotNH = saturate( dot( normal, halfDir ) ); 1047 float dotVH = saturate( dot( viewDir, halfDir ) ); 1048 vec3 F = F_Schlick( f0, f90, dotVH ); 1049 #ifdef USE_IRIDESCENCE 1050 F = mix( F, material.iridescenceFresnel, material.iridescence ); 1051 #endif 1052 #ifdef USE_ANISOTROPY 1053 float dotTL = dot( material.anisotropyT, lightDir ); 1054 float dotTV = dot( material.anisotropyT, viewDir ); 1055 float dotTH = dot( material.anisotropyT, halfDir ); 1056 float dotBL = dot( material.anisotropyB, lightDir ); 1057 float dotBV = dot( material.anisotropyB, viewDir ); 1058 float dotBH = dot( material.anisotropyB, halfDir ); 1059 float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); 1060 float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); 1061 #else 1062 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1063 float D = D_GGX( alpha, dotNH ); 1064 #endif 1065 return F * ( V * D ); 1066} 1067vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { 1068 const float LUT_SIZE = 64.0; 1069 const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; 1070 const float LUT_BIAS = 0.5 / LUT_SIZE; 1071 float dotNV = saturate( dot( N, V ) ); 1072 vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); 1073 uv = uv * LUT_SCALE + LUT_BIAS; 1074 return uv; 1075} 1076float LTC_ClippedSphereFormFactor( const in vec3 f ) { 1077 float l = length( f ); 1078 return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); 1079} 1080vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { 1081 float x = dot( v1, v2 ); 1082 float y = abs( x ); 1083 float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; 1084 float b = 3.4175940 + ( 4.1616724 + y ) * y; 1085 float v = a / b; 1086 float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; 1087 return cross( v1, v2 ) * theta_sintheta; 1088} 1089vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { 1090 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; 1091 vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; 1092 vec3 lightNormal = cross( v1, v2 ); 1093 if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); 1094 vec3 T1, T2; 1095 T1 = normalize( V - N * dot( V, N ) ); 1096 T2 = - cross( N, T1 ); 1097 mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); 1098 vec3 coords[ 4 ]; 1099 coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); 1100 coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); 1101 coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); 1102 coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); 1103 coords[ 0 ] = normalize( coords[ 0 ] ); 1104 coords[ 1 ] = normalize( coords[ 1 ] ); 1105 coords[ 2 ] = normalize( coords[ 2 ] ); 1106 coords[ 3 ] = normalize( coords[ 3 ] ); 1107 vec3 vectorFormFactor = vec3( 0.0 ); 1108 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); 1109 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); 1110 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); 1111 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); 1112 float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); 1113 return vec3( result ); 1114} 1115#if defined( USE_SHEEN ) 1116float D_Charlie( float roughness, float dotNH ) { 1117 float alpha = pow2( roughness ); 1118 float invAlpha = 1.0 / alpha; 1119 float cos2h = dotNH * dotNH; 1120 float sin2h = max( 1.0 - cos2h, 0.0078125 ); 1121 return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); 1122} 1123float V_Neubelt( float dotNV, float dotNL ) { 1124 return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); 1125} 1126vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { 1127 vec3 halfDir = normalize( lightDir + viewDir ); 1128 float dotNL = saturate( dot( normal, lightDir ) ); 1129 float dotNV = saturate( dot( normal, viewDir ) ); 1130 float dotNH = saturate( dot( normal, halfDir ) ); 1131 float D = D_Charlie( sheenRoughness, dotNH ); 1132 float V = V_Neubelt( dotNV, dotNL ); 1133 return sheenColor * ( D * V ); 1134} 1135#endif 1136float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { 1137 float dotNV = saturate( dot( normal, viewDir ) ); 1138 float r2 = roughness * roughness; 1139 float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; 1140 float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; 1141 float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); 1142 return saturate( DG * RECIPROCAL_PI ); 1143} 1144vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { 1145 float dotNV = saturate( dot( normal, viewDir ) ); 1146 const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); 1147 const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); 1148 vec4 r = roughness * c0 + c1; 1149 float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; 1150 vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; 1151 return fab; 1152} 1153vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { 1154 vec2 fab = DFGApprox( normal, viewDir, roughness ); 1155 return specularColor * fab.x + specularF90 * fab.y; 1156} 1157#ifdef USE_IRIDESCENCE 1158void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { 1159#else 1160void 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 ) { 1161#endif 1162 vec2 fab = DFGApprox( normal, viewDir, roughness ); 1163 #ifdef USE_IRIDESCENCE 1164 vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); 1165 #else 1166 vec3 Fr = specularColor; 1167 #endif 1168 vec3 FssEss = Fr * fab.x + specularF90 * fab.y; 1169 float Ess = fab.x + fab.y; 1170 float Ems = 1.0 - Ess; 1171 vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); 1172 singleScatter += FssEss; 1173 multiScatter += Fms * Ems; 1174} 1175#if NUM_RECT_AREA_LIGHTS > 0 1176 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1177 vec3 normal = geometryNormal; 1178 vec3 viewDir = geometryViewDir; 1179 vec3 position = geometryPosition; 1180 vec3 lightPos = rectAreaLight.position; 1181 vec3 halfWidth = rectAreaLight.halfWidth; 1182 vec3 halfHeight = rectAreaLight.halfHeight; 1183 vec3 lightColor = rectAreaLight.color; 1184 float roughness = material.roughness; 1185 vec3 rectCoords[ 4 ]; 1186 rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; 1187 rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; 1188 rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; 1189 vec2 uv = LTC_Uv( normal, viewDir, roughness ); 1190 vec4 t1 = texture2D( ltc_1, uv ); 1191 vec4 t2 = texture2D( ltc_2, uv ); 1192 mat3 mInv = mat3( 1193 vec3( t1.x, 0, t1.y ), 1194 vec3( 0, 1, 0 ), 1195 vec3( t1.z, 0, t1.w ) 1196 ); 1197 vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); 1198 reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); 1199 reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); 1200 } 1201#endif 1202void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1203 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1204 vec3 irradiance = dotNL * directLight.color; 1205 #ifdef USE_CLEARCOAT 1206 float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); 1207 vec3 ccIrradiance = dotNLcc * directLight.color; 1208 clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); 1209 #endif 1210 #ifdef USE_SHEEN 1211 sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); 1212 #endif 1213 reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); 1214 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1215} 1216void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1217 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 1218} 1219void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { 1220 #ifdef USE_CLEARCOAT 1221 clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); 1222 #endif 1223 #ifdef USE_SHEEN 1224 sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1225 #endif 1226 vec3 singleScattering = vec3( 0.0 ); 1227 vec3 multiScattering = vec3( 0.0 ); 1228 vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; 1229 #ifdef USE_IRIDESCENCE 1230 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); 1231 #else 1232 computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); 1233 #endif 1234 vec3 totalScattering = singleScattering + multiScattering; 1235 vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); 1236 reflectedLight.indirectSpecular += radiance * singleScattering; 1237 reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; 1238 reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; 1239} 1240#define RE_Direct RE_Direct_Physical 1241#define RE_Direct_RectArea RE_Direct_RectArea_Physical 1242#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical 1243#define RE_IndirectSpecular RE_IndirectSpecular_Physical 1244float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { 1245 return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); 1246}`,
1246Nb=` 1247vec3 geometryPosition = - vViewPosition; 1248vec3 geometryNormal = normal; 1249vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); 1250vec3 geometryClearcoatNormal = vec3( 0.0 ); 1251#ifdef USE_CLEARCOAT 1252 geometryClearcoatNormal = clearcoatNormal; 1253#endif 1254#ifdef USE_IRIDESCENCE 1255 float dotNVi = saturate( dot( normal, geometryViewDir ) ); 1256 if ( material.iridescenceThickness == 0.0 ) { 1257 material.iridescence = 0.0; 1258 } else { 1259 material.iridescence = saturate( material.iridescence ); 1260 } 1261 if ( material.iridescence > 0.0 ) { 1262 material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); 1263 material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); 1264 } 1265#endif 1266IncidentLight directLight; 1267#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) 1268 PointLight pointLight; 1269 #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 1270 PointLightShadow pointLightShadow; 1271 #endif 1272 #pragma unroll_loop_start 1273 for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 1274 pointLight = pointLights[ i ]; 1275 getPointLightInfo( pointLight, geometryPosition, directLight ); 1276 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) 1277 pointLightShadow = pointLightShadows[ i ]; 1278 directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; 1279 #endif 1280 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1281 } 1282 #pragma unroll_loop_end 1283#endif 1284#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) 1285 SpotLight spotLight; 1286 vec4 spotColor; 1287 vec3 spotLightCoord; 1288 bool inSpotLightMap; 1289 #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 1290 SpotLightShadow spotLightShadow; 1291 #endif 1292 #pragma unroll_loop_start 1293 for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 1294 spotLight = spotLights[ i ]; 1295 getSpotLightInfo( spotLight, geometryPosition, directLight ); 1296 #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1297 #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX 1298 #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1299 #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS 1300 #else 1301 #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1302 #endif 1303 #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) 1304 spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; 1305 inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); 1306 spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); 1307 directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; 1308 #endif 1309 #undef SPOT_LIGHT_MAP_INDEX 1310 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1311 spotLightShadow = spotLightShadows[ i ]; 1312 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 1313 #endif 1314 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1315 } 1316 #pragma unroll_loop_end 1317#endif 1318#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) 1319 DirectionalLight directionalLight; 1320 #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 1321 DirectionalLightShadow directionalLightShadow; 1322 #endif 1323 #pragma unroll_loop_start 1324 for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 1325 directionalLight = directionalLights[ i ]; 1326 getDirectionalLightInfo( directionalLight, directLight ); 1327 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) 1328 directionalLightShadow = directionalLightShadows[ i ]; 1329 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1330 #endif 1331 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1332 } 1333 #pragma unroll_loop_end 1334#endif 1335#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) 1336 RectAreaLight rectAreaLight; 1337 #pragma unroll_loop_start 1338 for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { 1339 rectAreaLight = rectAreaLights[ i ]; 1340 RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1341 } 1342 #pragma unroll_loop_end 1343#endif 1344#if defined( RE_IndirectDiffuse ) 1345 vec3 iblIrradiance = vec3( 0.0 ); 1346 vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); 1347 #if defined( USE_LIGHT_PROBES ) 1348 irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); 1349 #endif 1350 #if ( NUM_HEMI_LIGHTS > 0 ) 1351 #pragma unroll_loop_start 1352 for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { 1353 irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); 1354 } 1355 #pragma unroll_loop_end 1356 #endif 1357#endif 1358#if defined( RE_IndirectSpecular ) 1359 vec3 radiance = vec3( 0.0 ); 1360 vec3 clearcoatRadiance = vec3( 0.0 ); 1361#endif`,kb=`#if defined( RE_IndirectDiffuse ) 1362 #ifdef USE_LIGHTMAP 1363 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 1364 vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 1365 irradiance += lightMapIrradiance; 1366 #endif 1367 #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) 1368 iblIrradiance += getIBLIrradiance( geometryNormal ); 1369 #endif 1370#endif 1371#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 1372 #ifdef USE_ANISOTROPY 1373 radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); 1374 #else 1375 radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); 1376 #endif 1377 #ifdef USE_CLEARCOAT 1378 clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); 1379 #endif 1380#endif`,Ub=`#if defined( RE_IndirectDiffuse ) 1381 RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1382#endif 1383#if defined( RE_IndirectSpecular ) 1384 RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1385#endif`,Ob=`#if defined( USE_LOGDEPTHBUF ) 1386 gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; 1387#endif`,Fb=`#if defined( USE_LOGDEPTHBUF ) 1388 uniform float logDepthBufFC; 1389 varying float vFragDepth; 1390 varying float vIsPerspective; 1391#endif`,Vb=`#ifdef USE_LOGDEPTHBUF 1392 varying float vFragDepth; 1393 varying float vIsPerspective; 1394#endif`,Bb=`#ifdef USE_LOGDEPTHBUF 1395 vFragDepth = 1.0 + gl_Position.w; 1396 vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); 1397#endif`,zb=`#ifdef USE_MAP 1398 vec4 sampledDiffuseColor = texture2D( map, vMapUv ); 1399 #ifdef DECODE_VIDEO_TEXTURE 1400 sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); 1401 #endif 1402 diffuseColor *= sampledDiffuseColor; 1403#endif`,Hb=`#ifdef USE_MAP 1404 uniform sampler2D map; 1405#endif`,Gb=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1406 #if defined( USE_POINTS_UV ) 1407 vec2 uv = vUv; 1408 #else 1409 vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 1410 #endif 1411#endif 1412#ifdef USE_MAP 1413 diffuseColor *= texture2D( map, uv ); 1414#endif 1415#ifdef USE_ALPHAMAP 1416 diffuseColor.a *= texture2D( alphaMap, uv ).g; 1417#endif`,Wb=`#if defined( USE_POINTS_UV ) 1418 varying vec2 vUv; 1419#else 1420 #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1421 uniform mat3 uvTransform; 1422 #endif 1423#endif 1424#ifdef USE_MAP 1425 uniform sampler2D map; 1426#endif 1427#ifdef USE_ALPHAMAP 1428 uniform sampler2D alphaMap; 1429#endif`,qb=`float metalnessFactor = metalness; 1430#ifdef USE_METALNESSMAP 1431 vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); 1432 metalnessFactor *= texelMetalness.b; 1433#endif`,Xb=`#ifdef USE_METALNESSMAP 1434 uniform sampler2D metalnessMap; 1435#endif`,jb=`#ifdef USE_INSTANCING_MORPH 1436 float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1437 float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; 1438 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1439 morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; 1440 } 1441#endif`,Kb=`#if defined( USE_MORPHCOLORS ) 1442 vColor *= morphTargetBaseInfluence; 1443 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1444 #if defined( USE_COLOR_ALPHA ) 1445 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; 1446 #elif defined( USE_COLOR ) 1447 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; 1448 #endif 1449 } 1450#endif`,Yb=`#ifdef USE_MORPHNORMALS 1451 objectNormal *= morphTargetBaseInfluence; 1452 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1453 if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; 1454 } 1455#endif`,Qb=`#ifdef USE_MORPHTARGETS 1456 #ifndef USE_INSTANCING_MORPH 1457 uniform float morphTargetBaseInfluence; 1458 uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1459 #endif 1460 uniform sampler2DArray morphTargetsTexture; 1461 uniform ivec2 morphTargetsTextureSize; 1462 vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { 1463 int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; 1464 int y = texelIndex / morphTargetsTextureSize.x; 1465 int x = texelIndex - y * morphTargetsTextureSize.x; 1466 ivec3 morphUV = ivec3( x, y, morphTargetIndex ); 1467 return texelFetch( morphTargetsTexture, morphUV, 0 ); 1468 } 1469#endif`,Zb=`#ifdef USE_MORPHTARGETS 1470 transformed *= morphTargetBaseInfluence; 1471 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1472 if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; 1473 } 1474#endif`,Jb=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; 1475#ifdef FLAT_SHADED 1476 vec3 fdx = dFdx( vViewPosition ); 1477 vec3 fdy = dFdy( vViewPosition ); 1478 vec3 normal = normalize( cross( fdx, fdy ) ); 1479#else 1480 vec3 normal = normalize( vNormal ); 1481 #ifdef DOUBLE_SIDED 1482 normal *= faceDirection; 1483 #endif 1484#endif 1485#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) 1486 #ifdef USE_TANGENT 1487 mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1488 #else 1489 mat3 tbn = getTangentFrame( - vViewPosition, normal, 1490 #if defined( USE_NORMALMAP ) 1491 vNormalMapUv 1492 #elif defined( USE_CLEARCOAT_NORMALMAP ) 1493 vClearcoatNormalMapUv 1494 #else 1495 vUv 1496 #endif 1497 ); 1498 #endif 1499 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1500 tbn[0] *= faceDirection; 1501 tbn[1] *= faceDirection; 1502 #endif 1503#endif 1504#ifdef USE_CLEARCOAT_NORMALMAP 1505 #ifdef USE_TANGENT 1506 mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1507 #else 1508 mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); 1509 #endif 1510 #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 1511 tbn2[0] *= faceDirection; 1512 tbn2[1] *= faceDirection; 1513 #endif 1514#endif 1515vec3 nonPerturbedNormal = normal;`,$b=`#ifdef USE_NORMALMAP_OBJECTSPACE 1516 normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1517 #ifdef FLIP_SIDED 1518 normal = - normal; 1519 #endif 1520 #ifdef DOUBLE_SIDED 1521 normal = normal * faceDirection; 1522 #endif 1523 normal = normalize( normalMatrix * normal ); 1524#elif defined( USE_NORMALMAP_TANGENTSPACE ) 1525 vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1526 mapN.xy *= normalScale; 1527 normal = normalize( tbn * mapN ); 1528#elif defined( USE_BUMPMAP )
1529 normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); 1530#endif`,eS=`#ifndef FLAT_SHADED 1531 varying vec3 vNormal; 1532 #ifdef USE_TANGENT 1533 varying vec3 vTangent; 1534 varying vec3 vBitangent; 1535 #endif 1536#endif`,tS=`#ifndef FLAT_SHADED 1537 varying vec3 vNormal; 1538 #ifdef USE_TANGENT 1539 varying vec3 vTangent; 1540 varying vec3 vBitangent; 1541 #endif 1542#endif`,nS=`#ifndef FLAT_SHADED 1543 vNormal = normalize( transformedNormal ); 1544 #ifdef USE_TANGENT 1545 vTangent = normalize( transformedTangent ); 1546 vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); 1547 #endif 1548#endif`,iS=`#ifdef USE_NORMALMAP 1549 uniform sampler2D normalMap; 1550 uniform vec2 normalScale; 1551#endif 1552#ifdef USE_NORMALMAP_OBJECTSPACE 1553 uniform mat3 normalMatrix; 1554#endif 1555#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) 1556 mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { 1557 vec3 q0 = dFdx( eye_pos.xyz ); 1558 vec3 q1 = dFdy( eye_pos.xyz ); 1559 vec2 st0 = dFdx( uv.st ); 1560 vec2 st1 = dFdy( uv.st ); 1561 vec3 N = surf_norm; 1562 vec3 q1perp = cross( q1, N ); 1563 vec3 q0perp = cross( N, q0 ); 1564 vec3 T = q1perp * st0.x + q0perp * st1.x; 1565 vec3 B = q1perp * st0.y + q0perp * st1.y; 1566 float det = max( dot( T, T ), dot( B, B ) ); 1567 float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); 1568 return mat3( T * scale, B * scale, N ); 1569 } 1570#endif`,rS=`#ifdef USE_CLEARCOAT 1571 vec3 clearcoatNormal = nonPerturbedNormal; 1572#endif`,sS=`#ifdef USE_CLEARCOAT_NORMALMAP 1573 vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; 1574 clearcoatMapN.xy *= clearcoatNormalScale; 1575 clearcoatNormal = normalize( tbn2 * clearcoatMapN ); 1576#endif`,oS=`#ifdef USE_CLEARCOATMAP 1577 uniform sampler2D clearcoatMap; 1578#endif 1579#ifdef USE_CLEARCOAT_NORMALMAP 1580 uniform sampler2D clearcoatNormalMap; 1581 uniform vec2 clearcoatNormalScale; 1582#endif 1583#ifdef USE_CLEARCOAT_ROUGHNESSMAP 1584 uniform sampler2D clearcoatRoughnessMap; 1585#endif`,aS=`#ifdef USE_IRIDESCENCEMAP 1586 uniform sampler2D iridescenceMap; 1587#endif 1588#ifdef USE_IRIDESCENCE_THICKNESSMAP 1589 uniform sampler2D iridescenceThicknessMap; 1590#endif`,cS=`#ifdef OPAQUE 1591diffuseColor.a = 1.0; 1592#endif 1593#ifdef USE_TRANSMISSION 1594diffuseColor.a *= material.transmissionAlpha; 1595#endif 1596gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,lS=`vec3 packNormalToRGB( const in vec3 normal ) { 1597 return normalize( normal ) * 0.5 + 0.5; 1598} 1599vec3 unpackRGBToNormal( const in vec3 rgb ) { 1600 return 2.0 * rgb.xyz - 1.0; 1601} 1602const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; 1603const float Inv255 = 1. / 255.; 1604const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); 1605const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); 1606const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); 1607const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); 1608vec4 packDepthToRGBA( const in float v ) { 1609 if( v <= 0.0 ) 1610 return vec4( 0., 0., 0., 0. ); 1611 if( v >= 1.0 ) 1612 return vec4( 1., 1., 1., 1. ); 1613 float vuf; 1614 float af = modf( v * PackFactors.a, vuf ); 1615 float bf = modf( vuf * ShiftRight8, vuf ); 1616 float gf = modf( vuf * ShiftRight8, vuf ); 1617 return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); 1618} 1619vec3 packDepthToRGB( const in float v ) { 1620 if( v <= 0.0 ) 1621 return vec3( 0., 0., 0. ); 1622 if( v >= 1.0 ) 1623 return vec3( 1., 1., 1. ); 1624 float vuf; 1625 float bf = modf( v * PackFactors.b, vuf ); 1626 float gf = modf( vuf * ShiftRight8, vuf ); 1627 return vec3( vuf * Inv255, gf * PackUpscale, bf ); 1628} 1629vec2 packDepthToRG( const in float v ) { 1630 if( v <= 0.0 ) 1631 return vec2( 0., 0. ); 1632 if( v >= 1.0 ) 1633 return vec2( 1., 1. ); 1634 float vuf; 1635 float gf = modf( v * 256., vuf ); 1636 return vec2( vuf * Inv255, gf ); 1637} 1638float unpackRGBAToDepth( const in vec4 v ) { 1639 return dot( v, UnpackFactors4 ); 1640} 1641float unpackRGBToDepth( const in vec3 v ) { 1642 return dot( v, UnpackFactors3 ); 1643} 1644float unpackRGToDepth( const in vec2 v ) { 1645 return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; 1646} 1647vec4 pack2HalfToRGBA( const in vec2 v ) {
1648 vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); 1649 return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); 1650} 1651vec2 unpackRGBATo2Half( const in vec4 v ) { 1652 return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); 1653} 1654float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { 1655 return ( viewZ + near ) / ( near - far ); 1656} 1657float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { 1658 return depth * ( near - far ) - near; 1659} 1660float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { 1661 return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); 1662} 1663float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { 1664 return ( near * far ) / ( ( far - near ) * depth - far ); 1665}`,uS=`#ifdef PREMULTIPLIED_ALPHA 1666 gl_FragColor.rgb *= gl_FragColor.a; 1667#endif`,dS=`vec4 mvPosition = vec4( transformed, 1.0 ); 1668#ifdef USE_BATCHING 1669 mvPosition = batchingMatrix * mvPosition; 1670#endif 1671#ifdef USE_INSTANCING 1672 mvPosition = instanceMatrix * mvPosition; 1673#endif 1674mvPosition = modelViewMatrix * mvPosition; 1675gl_Position = projectionMatrix * mvPosition;`,hS=`#ifdef DITHERING 1676 gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 1677#endif`,pS=`#ifdef DITHERING 1678 vec3 dithering( vec3 color ) { 1679 float grid_position = rand( gl_FragCoord.xy ); 1680 vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 1681 dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 1682 return color + dither_shift_RGB; 1683 } 1684#endif`,fS=`float roughnessFactor = roughness; 1685#ifdef USE_ROUGHNESSMAP 1686 vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); 1687 roughnessFactor *= texelRoughness.g; 1688#endif`,_S=`#ifdef USE_ROUGHNESSMAP 1689 uniform sampler2D roughnessMap; 1690#endif`,mS=
vendor: 8,887 bytes, lines 1690-1876
1690`#if NUM_SPOT_LIGHT_COORDS > 0 1691 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1692#endif 1693#if NUM_SPOT_LIGHT_MAPS > 0 1694 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; 1695#endif 1696#ifdef USE_SHADOWMAP 1697 #if NUM_DIR_LIGHT_SHADOWS > 0 1698 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 1699 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1700 struct DirectionalLightShadow { 1701 float shadowIntensity; 1702 float shadowBias; 1703 float shadowNormalBias; 1704 float shadowRadius; 1705 vec2 shadowMapSize; 1706 }; 1707 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1708 #endif 1709 #if NUM_SPOT_LIGHT_SHADOWS > 0 1710 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 1711 struct SpotLightShadow { 1712 float shadowIntensity; 1713 float shadowBias; 1714 float shadowNormalBias; 1715 float shadowRadius; 1716 vec2 shadowMapSize; 1717 }; 1718 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 1719 #endif 1720 #if NUM_POINT_LIGHT_SHADOWS > 0 1721 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 1722 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 1723 struct PointLightShadow { 1724 float shadowIntensity; 1725 float shadowBias; 1726 float shadowNormalBias; 1727 float shadowRadius; 1728 vec2 shadowMapSize; 1729 float shadowCameraNear; 1730 float shadowCameraFar; 1731 }; 1732 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 1733 #endif 1734 float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { 1735 return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); 1736 } 1737 vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { 1738 return unpackRGBATo2Half( texture2D( shadow, uv ) ); 1739 } 1740 float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ 1741 float occlusion = 1.0; 1742 vec2 distribution = texture2DDistribution( shadow, uv ); 1743 float hard_shadow = step( compare , distribution.x ); 1744 if (hard_shadow != 1.0 ) { 1745 float distance = compare - distribution.x ; 1746 float variance = max( 0.00000, distribution.y * distribution.y ); 1747 float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); 1748 } 1749 return occlusion; 1750 } 1751 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1752 float shadow = 1.0; 1753 shadowCoord.xyz /= shadowCoord.w; 1754 shadowCoord.z += shadowBias; 1755 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1756 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1757 if ( frustumTest ) { 1758 #if defined( SHADOWMAP_TYPE_PCF ) 1759 vec2 texelSize = vec2( 1.0 ) / shadowMapSize; 1760 float dx0 = - texelSize.x * shadowRadius; 1761 float dy0 = - texelSize.y * shadowRadius; 1762 float dx1 = + texelSize.x * shadowRadius; 1763 float dy1 = + texelSize.y * shadowRadius; 1764 float dx2 = dx0 / 2.0; 1765 float dy2 = dy0 / 2.0; 1766 float dx3 = dx1 / 2.0; 1767 float dy3 = dy1 / 2.0; 1768 shadow = ( 1769 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + 1770 texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + 1771 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + 1772 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + 1773 texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + 1774 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + 1775 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + 1776 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + 1777 texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + 1778 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + 1779 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + 1780 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + 1781 texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + 1782 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + 1783 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + 1784 texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + 1785 texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) 1786 ) * ( 1.0 / 17.0 ); 1787 #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) 1788 vec2 texelSize = vec2( 1.0 ) / shadowMapSize; 1789 float dx = texelSize.x; 1790 float dy = texelSize.y; 1791 vec2 uv = shadowCoord.xy; 1792 vec2 f = fract( uv * shadowMapSize + 0.5 ); 1793 uv -= f * texelSize; 1794 shadow = ( 1795 texture2DCompare( shadowMap, uv, shadowCoord.z ) + 1796 texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + 1797 texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + 1798 texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + 1799 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 1800 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), 1801 f.x ) + 1802 mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 1803 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), 1804 f.x ) + 1805 mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 1806 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), 1807 f.y ) + 1808 mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 1809 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), 1810 f.y ) + 1811 mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 1812 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), 1813 f.x ), 1814 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 1815 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), 1816 f.x ), 1817 f.y ) 1818 ) * ( 1.0 / 9.0 ); 1819 #elif defined( SHADOWMAP_TYPE_VSM ) 1820 shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); 1821 #else 1822 shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); 1823 #endif 1824 } 1825 return mix( 1.0, shadow, shadowIntensity ); 1826 } 1827 vec2 cubeToUV( vec3 v, float texelSizeY ) { 1828 vec3 absV = abs( v ); 1829 float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); 1830 absV *= scaleToCube; 1831 v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); 1832 vec2 planar = v.xy; 1833 float almostATexel = 1.5 * texelSizeY; 1834 float almostOne = 1.0 - almostATexel; 1835 if ( absV.z >= almostOne ) { 1836 if ( v.z > 0.0 ) 1837 planar.x = 4.0 - v.x; 1838 } else if ( absV.x >= almostOne ) { 1839 float signX = sign( v.x ); 1840 planar.x = v.z * signX + 2.0 * signX; 1841 } else if ( absV.y >= almostOne ) { 1842 float signY = sign( v.y ); 1843 planar.x = v.x + 2.0 * signY + 2.0; 1844 planar.y = v.z * signY - 2.0; 1845 } 1846 return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); 1847 } 1848 float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 1849 float shadow = 1.0; 1850 vec3 lightToPosition = shadowCoord.xyz; 1851 1852 float lightToPositionLength = length( lightToPosition ); 1853 if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { 1854 float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; 1855 vec3 bd3D = normalize( lightToPosition ); 1856 vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); 1857 #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) 1858 vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; 1859 shadow = ( 1860 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + 1861 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + 1862 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + 1863 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + 1864 texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + 1865 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + 1866 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + 1867 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + 1868 texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) 1869 ) * ( 1.0 / 9.0 ); 1870 #else 1871 shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); 1872 #endif 1873 } 1874 return mix( 1.0, shadow, shadowIntensity ); 1875 } 1876#endif`,
1876gS=`#if NUM_SPOT_LIGHT_COORDS > 0 1877 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; 1878 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1879#endif 1880#ifdef USE_SHADOWMAP 1881 #if NUM_DIR_LIGHT_SHADOWS > 0 1882 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; 1883 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1884 struct DirectionalLightShadow { 1885 float shadowIntensity; 1886 float shadowBias; 1887 float shadowNormalBias; 1888 float shadowRadius; 1889 vec2 shadowMapSize; 1890 }; 1891 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1892 #endif 1893 #if NUM_SPOT_LIGHT_SHADOWS > 0 1894 struct SpotLightShadow { 1895 float shadowIntensity; 1896 float shadowBias; 1897 float shadowNormalBias; 1898 float shadowRadius; 1899 vec2 shadowMapSize; 1900 }; 1901 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 1902 #endif 1903 #if NUM_POINT_LIGHT_SHADOWS > 0 1904 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; 1905 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 1906 struct PointLightShadow { 1907 float shadowIntensity; 1908 float shadowBias; 1909 float shadowNormalBias; 1910 float shadowRadius; 1911 vec2 shadowMapSize; 1912 float shadowCameraNear; 1913 float shadowCameraFar; 1914 }; 1915 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 1916 #endif 1917#endif`,vS=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) 1918 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 1919 vec4 shadowWorldPosition; 1920#endif 1921#if defined( USE_SHADOWMAP ) 1922 #if NUM_DIR_LIGHT_SHADOWS > 0 1923 #pragma unroll_loop_start 1924 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 1925 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); 1926 vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; 1927 } 1928 #pragma unroll_loop_end 1929 #endif 1930 #if NUM_POINT_LIGHT_SHADOWS > 0 1931 #pragma unroll_loop_start 1932 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 1933 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); 1934 vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; 1935 } 1936 #pragma unroll_loop_end 1937 #endif 1938#endif 1939#if NUM_SPOT_LIGHT_COORDS > 0 1940 #pragma unroll_loop_start 1941 for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { 1942 shadowWorldPosition = worldPosition; 1943 #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1944 shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; 1945 #endif 1946 vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; 1947 } 1948 #pragma unroll_loop_end 1949#endif`,yS=`float getShadowMask() { 1950 float shadow = 1.0; 1951 #ifdef USE_SHADOWMAP 1952 #if NUM_DIR_LIGHT_SHADOWS > 0 1953 DirectionalLightShadow directionalLight; 1954 #pragma unroll_loop_start 1955 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 1956 directionalLight = directionalLightShadows[ i ]; 1957 shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1958 } 1959 #pragma unroll_loop_end 1960 #endif 1961 #if NUM_SPOT_LIGHT_SHADOWS > 0 1962 SpotLightShadow spotLight; 1963 #pragma unroll_loop_start 1964 for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { 1965 spotLight = spotLightShadows[ i ]; 1966 shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 1967 } 1968 #pragma unroll_loop_end 1969 #endif 1970 #if NUM_POINT_LIGHT_SHADOWS > 0 1971 PointLightShadow pointLight; 1972 #pragma unroll_loop_start 1973 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 1974 pointLight = pointLightShadows[ i ]; 1975 shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 1976 } 1977 #pragma unroll_loop_end 1978 #endif 1979 #endif 1980 return shadow; 1981}`,ES=`#ifdef USE_SKINNING 1982 mat4 boneMatX = getBoneMatrix( skinIndex.x ); 1983 mat4 boneMatY = getBoneMatrix( skinIndex.y ); 1984 mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 1985 mat4 boneMatW = getBoneMatrix( skinIndex.w ); 1986#endif`,TS=`#ifdef USE_SKINNING 1987 uniform mat4 bindMatrix; 1988 uniform mat4 bindMatrixInverse; 1989 uniform highp sampler2D boneTexture; 1990 mat4 getBoneMatrix( const in float i ) { 1991 int size = textureSize( boneTexture, 0 ).x; 1992 int j = int( i ) * 4; 1993 int x = j % size; 1994 int y = j / size; 1995 vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); 1996 vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); 1997 vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); 1998 vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); 1999 return mat4( v1, v2, v3, v4 ); 2000 } 2001#endif`,bS=`#ifdef USE_SKINNING 2002 vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 2003 vec4 skinned = vec4( 0.0 ); 2004 skinned += boneMatX * skinVertex * skinWeight.x; 2005 skinned += boneMatY * skinVertex * skinWeight.y; 2006 skinned += boneMatZ * skinVertex * skinWeight.z; 2007 skinned += boneMatW * skinVertex * skinWeight.w; 2008 transformed = ( bindMatrixInverse * skinned ).xyz; 2009#endif`,SS=`#ifdef USE_SKINNING 2010 mat4 skinMatrix = mat4( 0.0 ); 2011 skinMatrix += skinWeight.x * boneMatX; 2012 skinMatrix += skinWeight.y * boneMatY; 2013 skinMatrix += skinWeight.z * boneMatZ; 2014 skinMatrix += skinWeight.w * boneMatW; 2015 skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 2016 objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 2017 #ifdef USE_TANGENT 2018 objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; 2019 #endif 2020#endif`,AS=`float specularStrength; 2021#ifdef USE_SPECULARMAP 2022 vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); 2023 specularStrength = texelSpecular.r; 2024#else 2025 specularStrength = 1.0; 2026#endif`,xS=`#ifdef USE_SPECULARMAP 2027 uniform sampler2D specularMap; 2028#endif`,wS=`#if defined( TONE_MAPPING ) 2029 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 2030#endif`,IS=`#ifndef saturate 2031#define saturate( a ) clamp( a, 0.0, 1.0 ) 2032#endif 2033uniform float toneMappingExposure; 2034vec3 LinearToneMapping( vec3 color ) { 2035 return saturate( toneMappingExposure * color ); 2036} 2037vec3 ReinhardToneMapping( vec3 color ) { 2038 color *= toneMappingExposure; 2039 return saturate( color / ( vec3( 1.0 ) + color ) ); 2040} 2041vec3 CineonToneMapping( vec3 color ) { 2042 color *= toneMappingExposure; 2043 color = max( vec3( 0.0 ), color - 0.004 ); 2044 return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); 2045} 2046vec3 RRTAndODTFit( vec3 v ) { 2047 vec3 a = v * ( v + 0.0245786 ) - 0.000090537; 2048 vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; 2049 return a / b; 2050} 2051vec3 ACESFilmicToneMapping( vec3 color ) { 2052 const mat3 ACESInputMat = mat3( 2053 vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), 2054 vec3( 0.04823, 0.01566, 0.83777 ) 2055 ); 2056 const mat3 ACESOutputMat = mat3( 2057 vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), 2058 vec3( -0.07367, -0.00605, 1.07602 ) 2059 ); 2060 color *= toneMappingExposure / 0.6; 2061 color = ACESInputMat * color; 2062 color = RRTAndODTFit( color ); 2063 color = ACESOutputMat * color; 2064 return saturate( color ); 2065} 2066const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( 2067 vec3( 1.6605, - 0.1246, - 0.0182 ), 2068 vec3( - 0.5876, 1.1329, - 0.1006 ), 2069 vec3( - 0.0728, - 0.0083, 1.1187 ) 2070); 2071const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( 2072 vec3( 0.6274, 0.0691, 0.0164 ), 2073 vec3( 0.3293, 0.9195, 0.0880 ), 2074 vec3( 0.0433, 0.0113, 0.8956 ) 2075); 2076vec3 agxDefaultContrastApprox( vec3 x ) { 2077 vec3 x2 = x * x; 2078 vec3 x4 = x2 * x2; 2079 return + 15.5 * x4 * x2 2080 - 40.14 * x4 * x 2081 + 31.96 * x4 2082 - 6.868 * x2 * x 2083 + 0.4298 * x2 2084 + 0.1191 * x 2085 - 0.00232; 2086} 2087vec3 AgXToneMapping( vec3 color ) { 2088 const mat3 AgXInsetMatrix = mat3( 2089 vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), 2090 vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), 2091 vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) 2092 );
2093 const mat3 AgXOutsetMatrix = mat3( 2094 vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), 2095 vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), 2096 vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) 2097 ); 2098 const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; 2099 color *= toneMappingExposure; 2100 color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; 2101 color = AgXInsetMatrix * color; 2102 color = max( color, 1e-10 ); color = log2( color ); 2103 color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); 2104 color = clamp( color, 0.0, 1.0 ); 2105 color = agxDefaultContrastApprox( color ); 2106 color = AgXOutsetMatrix * color; 2107 color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); 2108 color = LINEAR_REC2020_TO_LINEAR_SRGB * color; 2109 color = clamp( color, 0.0, 1.0 ); 2110 return color; 2111} 2112vec3 NeutralToneMapping( vec3 color ) { 2113 const float StartCompression = 0.8 - 0.04; 2114 const float Desaturation = 0.15; 2115 color *= toneMappingExposure; 2116 float x = min( color.r, min( color.g, color.b ) ); 2117 float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; 2118 color -= offset; 2119 float peak = max( color.r, max( color.g, color.b ) ); 2120 if ( peak < StartCompression ) return color; 2121 float d = 1. - StartCompression; 2122 float newPeak = 1. - d * d / ( peak + d - StartCompression ); 2123 color *= newPeak / peak; 2124 float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); 2125 return mix( color, vec3( newPeak ), g ); 2126} 2127vec3 CustomToneMapping( vec3 color ) { return color; }`,MS=`#ifdef USE_TRANSMISSION 2128 material.transmission = transmission; 2129 material.transmissionAlpha = 1.0; 2130 material.thickness = thickness; 2131 material.attenuationDistance = attenuationDistance; 2132 material.attenuationColor = attenuationColor; 2133 #ifdef USE_TRANSMISSIONMAP 2134 material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; 2135 #endif 2136 #ifdef USE_THICKNESSMAP 2137 material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; 2138 #endif 2139 vec3 pos = vWorldPosition; 2140 vec3 v = normalize( cameraPosition - pos ); 2141 vec3 n = inverseTransformDirection( normal, viewMatrix ); 2142 vec4 transmitted = getIBLVolumeRefraction( 2143 n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, 2144 pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, 2145 material.attenuationColor, material.attenuationDistance ); 2146 material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); 2147 totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); 2148#endif`,CS=`#ifdef USE_TRANSMISSION 2149 uniform float transmission; 2150 uniform float thickness; 2151 uniform float attenuationDistance; 2152 uniform vec3 attenuationColor; 2153 #ifdef USE_TRANSMISSIONMAP 2154 uniform sampler2D transmissionMap; 2155 #endif 2156 #ifdef USE_THICKNESSMAP 2157 uniform sampler2D thicknessMap; 2158 #endif 2159 uniform vec2 transmissionSamplerSize; 2160 uniform sampler2D transmissionSamplerMap; 2161 uniform mat4 modelMatrix; 2162 uniform mat4 projectionMatrix; 2163 varying vec3 vWorldPosition; 2164 float w0( float a ) { 2165 return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); 2166 } 2167 float w1( float a ) { 2168 return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); 2169 } 2170 float w2( float a ){ 2171 return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); 2172 } 2173 float w3( float a ) { 2174 return ( 1.0 / 6.0 ) * ( a * a * a ); 2175 } 2176 float g0( float a ) { 2177 return w0( a ) + w1( a ); 2178 } 2179 float g1( float a ) { 2180 return w2( a ) + w3( a ); 2181 } 2182 float h0( float a ) { 2183 return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); 2184 } 2185 float h1( float a ) { 2186 return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); 2187 } 2188 vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { 2189 uv = uv * texelSize.zw + 0.5; 2190 vec2 iuv = floor( uv ); 2191 vec2 fuv = fract( uv ); 2192 float g0x = g0( fuv.x ); 2193 float g1x = g1( fuv.x ); 2194 float h0x = h0( fuv.x ); 2195 float h1x = h1( fuv.x ); 2196 float h0y = h0( fuv.y ); 2197 float h1y = h1( fuv.y ); 2198 vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2199 vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2200 vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2201 vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2202 return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + 2203 g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); 2204 } 2205 vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { 2206 vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); 2207 vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); 2208 vec2 fLodSizeInv = 1.0 / fLodSize; 2209 vec2 cLodSizeInv = 1.0 / cLodSize; 2210 vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); 2211 vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); 2212 return mix( fSample, cSample, fract( lod ) ); 2213 } 2214 vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { 2215 vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); 2216 vec3 modelScale; 2217 modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); 2218 modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); 2219 modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); 2220 return normalize( refractionVector ) * thickness * modelScale; 2221 } 2222 float applyIorToRoughness( const in float roughness, const in float ior ) { 2223 return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); 2224 } 2225 vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { 2226 float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); 2227 return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); 2228 } 2229 vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { 2230 if ( isinf( attenuationDistance ) ) { 2231 return vec3( 1.0 ); 2232 } else { 2233 vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; 2234 vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; 2235 } 2236 } 2237 vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, 2238 const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, 2239 const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, 2240 const in vec3 attenuationColor, const in float attenuationDistance ) { 2241 vec4 transmittedLight; 2242 vec3 transmittance; 2243 #ifdef USE_DISPERSION 2244 float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; 2245 vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); 2246 for ( int i = 0; i < 3; i ++ ) { 2247 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); 2248 vec3 refractedRayExit = position + transmissionRay; 2249 2250 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2251 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2252 refractionCoords += 1.0; 2253 refractionCoords /= 2.0; 2254 2255 vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); 2256 transmittedLight[ i ] = transmissionSample[ i ]; 2257 transmittedLight.a += transmissionSample.a; 2258 transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; 2259 } 2260 transmittedLight.a /= 3.0; 2261 2262 #else 2263 2264 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); 2265 vec3 refractedRayExit = position + transmissionRay; 2266 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2267 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2268 refractionCoords += 1.0; 2269 refractionCoords /= 2.0; 2270 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); 2271 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); 2272 2273 #endif 2274 vec3 attenuatedColor = transmittance * transmittedLight.rgb; 2275 vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); 2276 float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; 2277 return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); 2278 } 2279#endif`,RS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2280 varying vec2 vUv; 2281#endif 2282#ifdef USE_MAP 2283 varying vec2 vMapUv; 2284#endif 2285#ifdef USE_ALPHAMAP
2286 varying vec2 vAlphaMapUv; 2287#endif 2288#ifdef USE_LIGHTMAP 2289 varying vec2 vLightMapUv; 2290#endif 2291#ifdef USE_AOMAP 2292 varying vec2 vAoMapUv; 2293#endif 2294#ifdef USE_BUMPMAP 2295 varying vec2 vBumpMapUv; 2296#endif 2297#ifdef USE_NORMALMAP 2298 varying vec2 vNormalMapUv; 2299#endif 2300#ifdef USE_EMISSIVEMAP 2301 varying vec2 vEmissiveMapUv; 2302#endif 2303#ifdef USE_METALNESSMAP 2304 varying vec2 vMetalnessMapUv; 2305#endif 2306#ifdef USE_ROUGHNESSMAP 2307 varying vec2 vRoughnessMapUv; 2308#endif 2309#ifdef USE_ANISOTROPYMAP 2310 varying vec2 vAnisotropyMapUv; 2311#endif 2312#ifdef USE_CLEARCOATMAP 2313 varying vec2 vClearcoatMapUv; 2314#endif 2315#ifdef USE_CLEARCOAT_NORMALMAP 2316 varying vec2 vClearcoatNormalMapUv; 2317#endif 2318#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2319 varying vec2 vClearcoatRoughnessMapUv; 2320#endif 2321#ifdef USE_IRIDESCENCEMAP 2322 varying vec2 vIridescenceMapUv; 2323#endif 2324#ifdef USE_IRIDESCENCE_THICKNESSMAP 2325 varying vec2 vIridescenceThicknessMapUv; 2326#endif 2327#ifdef USE_SHEEN_COLORMAP 2328 varying vec2 vSheenColorMapUv; 2329#endif 2330#ifdef USE_SHEEN_ROUGHNESSMAP 2331 varying vec2 vSheenRoughnessMapUv; 2332#endif 2333#ifdef USE_SPECULARMAP 2334 varying vec2 vSpecularMapUv; 2335#endif 2336#ifdef USE_SPECULAR_COLORMAP 2337 varying vec2 vSpecularColorMapUv; 2338#endif 2339#ifdef USE_SPECULAR_INTENSITYMAP 2340 varying vec2 vSpecularIntensityMapUv; 2341#endif 2342#ifdef USE_TRANSMISSIONMAP 2343 uniform mat3 transmissionMapTransform; 2344 varying vec2 vTransmissionMapUv; 2345#endif 2346#ifdef USE_THICKNESSMAP 2347 uniform mat3 thicknessMapTransform; 2348 varying vec2 vThicknessMapUv; 2349#endif`,PS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2350 varying vec2 vUv; 2351#endif 2352#ifdef USE_MAP 2353 uniform mat3 mapTransform; 2354 varying vec2 vMapUv; 2355#endif 2356#ifdef USE_ALPHAMAP 2357 uniform mat3 alphaMapTransform; 2358 varying vec2 vAlphaMapUv; 2359#endif 2360#ifdef USE_LIGHTMAP 2361 uniform mat3 lightMapTransform; 2362 varying vec2 vLightMapUv; 2363#endif 2364#ifdef USE_AOMAP 2365 uniform mat3 aoMapTransform; 2366 varying vec2 vAoMapUv; 2367#endif 2368#ifdef USE_BUMPMAP 2369 uniform mat3 bumpMapTransform; 2370 varying vec2 vBumpMapUv; 2371#endif 2372#ifdef USE_NORMALMAP 2373 uniform mat3 normalMapTransform; 2374 varying vec2 vNormalMapUv; 2375#endif 2376#ifdef USE_DISPLACEMENTMAP 2377 uniform mat3 displacementMapTransform; 2378 varying vec2 vDisplacementMapUv; 2379#endif 2380#ifdef USE_EMISSIVEMAP 2381 uniform mat3 emissiveMapTransform; 2382 varying vec2 vEmissiveMapUv; 2383#endif 2384#ifdef USE_METALNESSMAP 2385 uniform mat3 metalnessMapTransform; 2386 varying vec2 vMetalnessMapUv; 2387#endif 2388#ifdef USE_ROUGHNESSMAP 2389 uniform mat3 roughnessMapTransform; 2390 varying vec2 vRoughnessMapUv; 2391#endif 2392#ifdef USE_ANISOTROPYMAP 2393 uniform mat3 anisotropyMapTransform; 2394 varying vec2 vAnisotropyMapUv; 2395#endif 2396#ifdef USE_CLEARCOATMAP 2397 uniform mat3 clearcoatMapTransform; 2398 varying vec2 vClearcoatMapUv; 2399#endif 2400#ifdef USE_CLEARCOAT_NORMALMAP 2401 uniform mat3 clearcoatNormalMapTransform; 2402 varying vec2 vClearcoatNormalMapUv; 2403#endif 2404#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2405 uniform mat3 clearcoatRoughnessMapTransform; 2406 varying vec2 vClearcoatRoughnessMapUv; 2407#endif 2408#ifdef USE_SHEEN_COLORMAP 2409 uniform mat3 sheenColorMapTransform; 2410 varying vec2 vSheenColorMapUv; 2411#endif 2412#ifdef USE_SHEEN_ROUGHNESSMAP 2413 uniform mat3 sheenRoughnessMapTransform; 2414 varying vec2 vSheenRoughnessMapUv; 2415#endif 2416#ifdef USE_IRIDESCENCEMAP 2417 uniform mat3 iridescenceMapTransform; 2418 varying vec2 vIridescenceMapUv; 2419#endif 2420#ifdef USE_IRIDESCENCE_THICKNESSMAP 2421 uniform mat3 iridescenceThicknessMapTransform; 2422 varying vec2 vIridescenceThicknessMapUv; 2423#endif 2424#ifdef USE_SPECULARMAP 2425 uniform mat3 specularMapTransform; 2426 varying vec2 vSpecularMapUv; 2427#endif 2428#ifdef USE_SPECULAR_COLORMAP 2429 uniform mat3 specularColorMapTransform; 2430 varying vec2 vSpecularColorMapUv; 2431#endif 2432#ifdef USE_SPECULAR_INTENSITYMAP 2433 uniform mat3 specularIntensityMapTransform; 2434 varying vec2 vSpecularIntensityMapUv; 2435#endif 2436#ifdef USE_TRANSMISSIONMAP 2437 uniform mat3 transmissionMapTransform; 2438 varying vec2 vTransmissionMapUv; 2439#endif 2440#ifdef USE_THICKNESSMAP 2441 uniform mat3 thicknessMapTransform; 2442 varying vec2 vThicknessMapUv; 2443#endif`,LS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2444 vUv = vec3( uv, 1 ).xy; 2445#endif 2446#ifdef USE_MAP 2447 vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; 2448#endif 2449#ifdef USE_ALPHAMAP 2450 vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; 2451#endif 2452#ifdef USE_LIGHTMAP 2453 vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; 2454#endif 2455#ifdef USE_AOMAP 2456 vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; 2457#endif 2458#ifdef USE_BUMPMAP 2459 vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; 2460#endif 2461#ifdef USE_NORMALMAP 2462 vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; 2463#endif 2464#ifdef USE_DISPLACEMENTMAP 2465 vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; 2466#endif 2467#ifdef USE_EMISSIVEMAP 2468 vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; 2469#endif 2470#ifdef USE_METALNESSMAP 2471 vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; 2472#endif 2473#ifdef USE_ROUGHNESSMAP 2474 vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; 2475#endif 2476#ifdef USE_ANISOTROPYMAP 2477 vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; 2478#endif 2479#ifdef USE_CLEARCOATMAP 2480 vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; 2481#endif 2482#ifdef USE_CLEARCOAT_NORMALMAP 2483 vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; 2484#endif 2485#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2486 vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; 2487#endif
2488#ifdef USE_IRIDESCENCEMAP 2489 vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; 2490#endif 2491#ifdef USE_IRIDESCENCE_THICKNESSMAP 2492 vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; 2493#endif 2494#ifdef USE_SHEEN_COLORMAP 2495 vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; 2496#endif 2497#ifdef USE_SHEEN_ROUGHNESSMAP 2498 vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; 2499#endif 2500#ifdef USE_SPECULARMAP 2501 vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; 2502#endif 2503#ifdef USE_SPECULAR_COLORMAP 2504 vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; 2505#endif 2506#ifdef USE_SPECULAR_INTENSITYMAP 2507 vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; 2508#endif 2509#ifdef USE_TRANSMISSIONMAP 2510 vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; 2511#endif 2512#ifdef USE_THICKNESSMAP 2513 vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; 2514#endif`,DS=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 2515 vec4 worldPosition = vec4( transformed, 1.0 ); 2516 #ifdef USE_BATCHING 2517 worldPosition = batchingMatrix * worldPosition; 2518 #endif 2519 #ifdef USE_INSTANCING 2520 worldPosition = instanceMatrix * worldPosition; 2521 #endif 2522 worldPosition = modelMatrix * worldPosition; 2523#endif`;const NS=`varying vec2 vUv; 2524uniform mat3 uvTransform; 2525void main() { 2526 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 2527 gl_Position = vec4( position.xy, 1.0, 1.0 ); 2528}`,kS=`uniform sampler2D t2D; 2529uniform float backgroundIntensity; 2530varying vec2 vUv; 2531void main() { 2532 vec4 texColor = texture2D( t2D, vUv ); 2533 #ifdef DECODE_VIDEO_TEXTURE 2534 texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); 2535 #endif 2536 texColor.rgb *= backgroundIntensity; 2537 gl_FragColor = texColor; 2538 #include <tonemapping_fragment> 2539 #include <colorspace_fragment> 2540}`,US=`varying vec3 vWorldDirection; 2541#include <common> 2542void main() { 2543 vWorldDirection = transformDirection( position, modelMatrix ); 2544 #include <begin_vertex> 2545 #include <project_vertex> 2546 gl_Position.z = gl_Position.w; 2547}`,OS=`#ifdef ENVMAP_TYPE_CUBE 2548 uniform samplerCube envMap; 2549#elif defined( ENVMAP_TYPE_CUBE_UV ) 2550 uniform sampler2D envMap; 2551#endif 2552uniform float flipEnvMap; 2553uniform float backgroundBlurriness; 2554uniform float backgroundIntensity; 2555uniform mat3 backgroundRotation; 2556varying vec3 vWorldDirection; 2557#include <cube_uv_reflection_fragment> 2558void main() { 2559 #ifdef ENVMAP_TYPE_CUBE 2560 vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); 2561 #elif defined( ENVMAP_TYPE_CUBE_UV ) 2562 vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); 2563 #else 2564 vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 2565 #endif 2566 texColor.rgb *= backgroundIntensity; 2567 gl_FragColor = texColor; 2568 #include <tonemapping_fragment> 2569 #include <colorspace_fragment> 2570}`,FS=`varying vec3 vWorldDirection; 2571#include <common> 2572void main() { 2573 vWorldDirection = transformDirection( position, modelMatrix ); 2574 #include <begin_vertex> 2575 #include <project_vertex> 2576 gl_Position.z = gl_Position.w; 2577}`,VS=`uniform samplerCube tCube; 2578uniform float tFlip; 2579uniform float opacity; 2580varying vec3 vWorldDirection; 2581void main() { 2582 vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 2583 gl_FragColor = texColor; 2584 gl_FragColor.a *= opacity; 2585 #include <tonemapping_fragment> 2586 #include <colorspace_fragment> 2587}`,BS=`#include <common> 2588#include <batching_pars_vertex> 2589#include <uv_pars_vertex> 2590#include <displacementmap_pars_vertex> 2591#include <morphtarget_pars_vertex> 2592#include <skinning_pars_vertex> 2593#include <logdepthbuf_pars_vertex> 2594#include <clipping_planes_pars_vertex> 2595varying vec2 vHighPrecisionZW; 2596void main() { 2597 #include <uv_vertex> 2598 #include <batching_vertex> 2599 #include <skinbase_vertex> 2600 #include <morphinstance_vertex> 2601 #ifdef USE_DISPLACEMENTMAP 2602 #include <beginnormal_vertex> 2603 #include <morphnormal_vertex> 2604 #include <skinnormal_vertex> 2605 #endif 2606 #include <begin_vertex> 2607 #include <morphtarget_vertex> 2608 #include <skinning_vertex> 2609 #include <displacementmap_vertex> 2610 #include <project_vertex> 2611 #include <logdepthbuf_vertex> 2612 #include <clipping_planes_vertex> 2613 vHighPrecisionZW = gl_Position.zw; 2614}`,zS=`#if DEPTH_PACKING == 3200 2615 uniform float opacity; 2616#endif 2617#include <common> 2618#include <packing> 2619#include <uv_pars_fragment> 2620#include <map_pars_fragment> 2621#include <alphamap_pars_fragment> 2622#include <alphatest_pars_fragment> 2623#include <alphahash_pars_fragment> 2624#include <logdepthbuf_pars_fragment> 2625#include <clipping_planes_pars_fragment> 2626varying vec2 vHighPrecisionZW; 2627void main() { 2628 vec4 diffuseColor = vec4( 1.0 ); 2629 #include <clipping_planes_fragment> 2630 #if DEPTH_PACKING == 3200 2631 diffuseColor.a = opacity; 2632 #endif 2633 #include <map_fragment> 2634 #include <alphamap_fragment> 2635 #include <alphatest_fragment> 2636 #include <alphahash_fragment> 2637 #include <logdepthbuf_fragment> 2638 float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; 2639 #if DEPTH_PACKING == 3200 2640 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); 2641 #elif DEPTH_PACKING == 3201 2642 gl_FragColor = packDepthToRGBA( fragCoordZ ); 2643 #elif DEPTH_PACKING == 3202 2644 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); 2645 #elif DEPTH_PACKING == 3203 2646 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); 2647 #endif 2648}`,HS=`#define DISTANCE 2649varying vec3 vWorldPosition; 2650#include <common> 2651#include <batching_pars_vertex> 2652#include <uv_pars_vertex> 2653#include <displacementmap_pars_vertex> 2654#include <morphtarget_pars_vertex> 2655#include <skinning_pars_vertex> 2656#include <clipping_planes_pars_vertex> 2657void main() { 2658 #include <uv_vertex> 2659 #include <batching_vertex> 2660 #include <skinbase_vertex> 2661 #include <morphinstance_vertex> 2662 #ifdef USE_DISPLACEMENTMAP 2663 #include <beginnormal_vertex> 2664 #include <morphnormal_vertex> 2665 #include <skinnormal_vertex> 2666 #endif 2667 #include <begin_vertex> 2668 #include <morphtarget_vertex> 2669 #include <skinning_vertex> 2670 #include <displacementmap_vertex> 2671 #include <project_vertex> 2672 #include <worldpos_vertex> 2673 #include <clipping_planes_vertex> 2674 vWorldPosition = worldPosition.xyz; 2675}`,GS=`#define DISTANCE 2676uniform vec3 referencePosition; 2677uniform float nearDistance; 2678uniform float farDistance; 2679varying vec3 vWorldPosition; 2680#include <common> 2681#include <packing> 2682#include <uv_pars_fragment> 2683#include <map_pars_fragment> 2684#include <alphamap_pars_fragment> 2685#include <alphatest_pars_fragment> 2686#include <alphahash_pars_fragment> 2687#include <clipping_planes_pars_fragment> 2688void main () { 2689 vec4 diffuseColor = vec4( 1.0 ); 2690 #include <clipping_planes_fragment> 2691 #include <map_fragment> 2692 #include <alphamap_fragment> 2693 #include <alphatest_fragment> 2694 #include <alphahash_fragment> 2695 float dist = length( vWorldPosition - referencePosition ); 2696 dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 2697 dist = saturate( dist ); 2698 gl_FragColor = packDepthToRGBA( dist ); 2699}`,WS=`varying vec3 vWorldDirection; 2700#include <common> 2701void main() { 2702 vWorldDirection = transformDirection( position, modelMatrix ); 2703 #include <begin_vertex> 2704 #include <project_vertex> 2705}`,qS=`uniform sampler2D tEquirect; 2706varying vec3 vWorldDirection; 2707#include <common> 2708void main() { 2709 vec3 direction = normalize( vWorldDirection ); 2710 vec2 sampleUV = equirectUv( direction ); 2711 gl_FragColor = texture2D( tEquirect, sampleUV ); 2712 #include <tonemapping_fragment> 2713 #include <colorspace_fragment> 2714}`,XS=`uniform float scale; 2715attribute float lineDistance; 2716varying float vLineDistance; 2717#include <common> 2718#include <uv_pars_vertex> 2719#include <color_pars_vertex> 2720#include <fog_pars_vertex> 2721#include <morphtarget_pars_vertex> 2722#include <logdepthbuf_pars_vertex> 2723#include <clipping_planes_pars_vertex> 2724void main() { 2725 vLineDistance = scale * lineDistance; 2726 #include <uv_vertex> 2727 #include <color_vertex> 2728 #include <morphinstance_vertex> 2729 #include <morphcolor_vertex> 2730 #include <begin_vertex> 2731 #include <morphtarget_vertex> 2732 #include <project_vertex> 2733 #include <logdepthbuf_vertex> 2734 #include <clipping_planes_vertex> 2735 #include <fog_vertex> 2736}`,jS=`uniform vec3 diffuse; 2737uniform float opacity; 2738uniform float dashSize; 2739uniform float totalSize; 2740varying float vLineDistance; 2741#include <common> 2742#include <color_pars_fragment> 2743#include <uv_pars_fragment> 2744#include <map_pars_fragment> 2745#include <fog_pars_fragment> 2746#include <logdepthbuf_pars_fragment> 2747#include <clipping_planes_pars_fragment> 2748void main() { 2749 vec4 diffuseColor = vec4( diffuse, opacity ); 2750 #include <clipping_planes_fragment> 2751 if ( mod( vLineDistance, totalSize ) > dashSize ) { 2752 discard; 2753 } 2754 vec3 outgoingLight = vec3( 0.0 ); 2755 #include <logdepthbuf_fragment> 2756 #include <map_fragment> 2757 #include <color_fragment> 2758 outgoingLight = diffuseColor.rgb; 2759 #include <opaque_fragment> 2760 #include <tonemapping_fragment> 2761 #include <colorspace_fragment> 2762 #include <fog_fragment> 2763 #include <premultiplied_alpha_fragment> 2764}`,KS=`#include <common> 2765#include <batching_pars_vertex> 2766#include <uv_pars_vertex> 2767#include <envmap_pars_vertex> 2768#include <color_pars_vertex> 2769#include <fog_pars_vertex> 2770#include <morphtarget_pars_vertex> 2771#include <skinning_pars_vertex> 2772#include <logdepthbuf_pars_vertex> 2773#include <clipping_planes_pars_vertex> 2774void main() { 2775 #include <uv_vertex> 2776 #include <color_vertex> 2777 #include <morphinstance_vertex> 2778 #include <morphcolor_vertex> 2779 #include <batching_vertex> 2780 #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) 2781 #include <beginnormal_vertex> 2782 #include <morphnormal_vertex> 2783 #include <skinbase_vertex> 2784 #include <skinnormal_vertex> 2785 #include <defaultnormal_vertex> 2786 #endif 2787 #include <begin_vertex> 2788 #include <morphtarget_vertex> 2789 #include <skinning_vertex> 2790 #include <project_vertex> 2791 #include <logdepthbuf_vertex> 2792 #include <clipping_planes_vertex> 2793 #include <worldpos_vertex> 2794 #include <envmap_vertex> 2795 #include <fog_vertex> 2796}`,YS=`uniform vec3 diffuse; 2797uniform float opacity; 2798#ifndef FLAT_SHADED 2799 varying vec3 vNormal; 2800#endif 2801#include <common> 2802#include <dithering_pars_fragment> 2803#include <color_pars_fragment> 2804#include <uv_pars_fragment> 2805#include <map_pars_fragment> 2806#include <alphamap_pars_fragment> 2807#include <alphatest_pars_fragment> 2808#include <alphahash_pars_fragment> 2809#include <aomap_pars_fragment> 2810#include <lightmap_pars_fragment> 2811#include <envmap_common_pars_fragment> 2812#include <envmap_pars_fragment> 2813#include <fog_pars_fragment> 2814#include <specularmap_pars_fragment> 2815#include <logdepthbuf_pars_fragment> 2816#include <clipping_planes_pars_fragment> 2817void main() { 2818 vec4 diffuseColor = vec4( diffuse, opacity ); 2819 #include <clipping_planes_fragment> 2820 #include <logdepthbuf_fragment> 2821 #include <map_fragment> 2822 #include <color_fragment> 2823 #include <alphamap_fragment> 2824 #include <alphatest_fragment> 2825 #include <alphahash_fragment> 2826 #include <specularmap_fragment> 2827 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 2828 #ifdef USE_LIGHTMAP 2829 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 2830 reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; 2831 #else 2832 reflectedLight.indirectDiffuse += vec3( 1.0 ); 2833 #endif 2834 #include <aomap_fragment> 2835 reflectedLight.indirectDiffuse *= diffuseColor.rgb; 2836 vec3 outgoingLight = reflectedLight.indirectDiffuse; 2837 #include <envmap_fragment> 2838 #include <opaque_fragment> 2839 #include <tonemapping_fragment> 2840 #include <colorspace_fragment> 2841 #include <fog_fragment> 2842 #include <premultiplied_alpha_fragment> 2843 #include <dithering_fragment> 2844}`,QS=`#define LAMBERT 2845varying vec3 vViewPosition; 2846#include <common> 2847#include <batching_pars_vertex> 2848#include <uv_pars_vertex> 2849#include <displacementmap_pars_vertex> 2850#include <envmap_pars_vertex> 2851#include <color_pars_vertex> 2852#include <fog_pars_vertex> 2853#include <normal_pars_vertex> 2854#include <morphtarget_pars_vertex> 2855#include <skinning_pars_vertex> 2856#include <shadowmap_pars_vertex> 2857#include <logdepthbuf_pars_vertex> 2858#include <clipping_planes_pars_vertex> 2859void main() { 2860 #include <uv_vertex> 2861 #include <color_vertex> 2862 #include <morphinstance_vertex> 2863 #include <morphcolor_vertex> 2864 #include <batching_vertex> 2865 #include <beginnormal_vertex> 2866 #include <morphnormal_vertex> 2867 #include <skinbase_vertex> 2868 #include <skinnormal_vertex> 2869 #include <defaultnormal_vertex> 2870 #include <normal_vertex> 2871 #include <begin_vertex> 2872 #include <morphtarget_vertex> 2873 #include <skinning_vertex> 2874 #include <displacementmap_vertex> 2875 #include <project_vertex> 2876 #include <logdepthbuf_vertex> 2877 #include <clipping_planes_vertex> 2878 vViewPosition = - mvPosition.xyz; 2879 #include <worldpos_vertex> 2880 #include <envmap_vertex> 2881 #include <shadowmap_vertex> 2882 #include <fog_vertex> 2883}`,ZS=`#define LAMBERT 2884uniform vec3 diffuse; 2885uniform vec3 emissive; 2886uniform float opacity; 2887#include <common> 2888#include <packing> 2889#include <dithering_pars_fragment> 2890#include <color_pars_fragment> 2891#include <uv_pars_fragment> 2892#include <map_pars_fragment> 2893#include <alphamap_pars_fragment> 2894#include <alphatest_pars_fragment> 2895#include <alphahash_pars_fragment> 2896#include <aomap_pars_fragment> 2897#include <lightmap_pars_fragment> 2898#include <emissivemap_pars_fragment> 2899#include <envmap_common_pars_fragment> 2900#include <envmap_pars_fragment> 2901#include <fog_pars_fragment> 2902#include <bsdfs> 2903#include <lights_pars_begin> 2904#include <normal_pars_fragment> 2905#include <lights_lambert_pars_fragment> 2906#include <shadowmap_pars_fragment> 2907#include <bumpmap_pars_fragment> 2908#include <normalmap_pars_fragment> 2909#include <specularmap_pars_fragment> 2910#include <logdepthbuf_pars_fragment> 2911#include <clipping_planes_pars_fragment> 2912void main() { 2913 vec4 diffuseColor = vec4( diffuse, opacity ); 2914 #include <clipping_planes_fragment> 2915 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 2916 vec3 totalEmissiveRadiance = emissive; 2917 #include <logdepthbuf_fragment> 2918 #include <map_fragment> 2919 #include <color_fragment> 2920 #include <alphamap_fragment> 2921 #include <alphatest_fragment> 2922 #include <alphahash_fragment> 2923 #include <specularmap_fragment> 2924 #include <normal_fragment_begin> 2925 #include <normal_fragment_maps> 2926 #include <emissivemap_fragment> 2927 #include <lights_lambert_fragment> 2928 #include <lights_fragment_begin> 2929 #include <lights_fragment_maps> 2930 #include <lights_fragment_end> 2931 #include <aomap_fragment> 2932 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 2933 #include <envmap_fragment> 2934 #include <opaque_fragment> 2935 #include <tonemapping_fragment> 2936 #include <colorspace_fragment> 2937 #include <fog_fragment> 2938 #include <premultiplied_alpha_fragment> 2939 #include <dithering_fragment> 2940}`,JS=`#define MATCAP 2941varying vec3 vViewPosition; 2942#include <common> 2943#include <batching_pars_vertex> 2944#include <uv_pars_vertex> 2945#include <color_pars_vertex> 2946#include <displacementmap_pars_vertex> 2947#include <fog_pars_vertex> 2948#include <normal_pars_vertex> 2949#include <morphtarget_pars_vertex> 2950#include <skinning_pars_vertex> 2951#include <logdepthbuf_pars_vertex> 2952#include <clipping_planes_pars_vertex> 2953void main() { 2954 #include <uv_vertex> 2955 #include <color_vertex> 2956 #include <morphinstance_vertex> 2957 #include <morphcolor_vertex> 2958 #include <batching_vertex> 2959 #include <beginnormal_vertex> 2960 #include <morphnormal_vertex> 2961 #include <skinbase_vertex> 2962 #include <skinnormal_vertex> 2963 #include <defaultnormal_vertex> 2964 #include <normal_vertex> 2965 #include <begin_vertex> 2966 #include <morphtarget_vertex> 2967 #include <skinning_vertex> 2968 #include <displacementmap_vertex> 2969 #include <project_vertex> 2970 #include <logdepthbuf_vertex> 2971 #include <clipping_planes_vertex> 2972 #include <fog_vertex> 2973 vViewPosition = - mvPosition.xyz; 2974}`,$S=`#define MATCAP 2975uniform vec3 diffuse; 2976uniform float opacity; 2977uniform sampler2D matcap; 2978varying vec3 vViewPosition; 2979#include <common> 2980#include <dithering_pars_fragment> 2981#include <color_pars_fragment> 2982#include <uv_pars_fragment> 2983#include <map_pars_fragment> 2984#include <alphamap_pars_fragment> 2985#include <alphatest_pars_fragment> 2986#include <alphahash_pars_fragment> 2987#include <fog_pars_fragment> 2988#include <normal_pars_fragment> 2989#include <bumpmap_pars_fragment> 2990#include <normalmap_pars_fragment> 2991#include <logdepthbuf_pars_fragment> 2992#include <clipping_planes_pars_fragment> 2993void main() { 2994 ve
2994c4 diffuseColor = vec4( diffuse, opacity ); 2995 #include <clipping_planes_fragment> 2996 #include <logdepthbuf_fragment> 2997 #include <map_fragment> 2998 #include <color_fragment> 2999 #include <alphamap_fragment> 3000 #include <alphatest_fragment> 3001 #include <alphahash_fragment> 3002 #include <normal_fragment_begin> 3003 #include <normal_fragment_maps> 3004 vec3 viewDir = normalize( vViewPosition ); 3005 vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); 3006 vec3 y = cross( viewDir, x ); 3007 vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; 3008 #ifdef USE_MATCAP 3009 vec4 matcapColor = texture2D( matcap, uv ); 3010 #else 3011 vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); 3012 #endif 3013 vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; 3014 #include <opaque_fragment> 3015 #include <tonemapping_fragment> 3016 #include <colorspace_fragment> 3017 #include <fog_fragment> 3018 #include <premultiplied_alpha_fragment> 3019 #include <dithering_fragment> 3020}`,eA=`#define NORMAL 3021#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3022 varying vec3 vViewPosition; 3023#endif 3024#include <common> 3025#include <batching_pars_vertex> 3026#include <uv_pars_vertex> 3027#include <displacementmap_pars_vertex> 3028#include <normal_pars_vertex> 3029#include <morphtarget_pars_vertex> 3030#include <skinning_pars_vertex> 3031#include <logdepthbuf_pars_vertex> 3032#include <clipping_planes_pars_vertex> 3033void main() { 3034 #include <uv_vertex> 3035 #include <batching_vertex> 3036 #include <beginnormal_vertex> 3037 #include <morphinstance_vertex> 3038 #include <morphnormal_vertex> 3039 #include <skinbase_vertex> 3040 #include <skinnormal_vertex> 3041 #include <defaultnormal_vertex> 3042 #include <normal_vertex> 3043 #include <begin_vertex> 3044 #include <morphtarget_vertex> 3045 #include <skinning_vertex> 3046 #include <displacementmap_vertex> 3047 #include <project_vertex> 3048 #include <logdepthbuf_vertex> 3049 #include <clipping_planes_vertex> 3050#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3051 vViewPosition = - mvPosition.xyz; 3052#endif 3053}`,tA=`#define NORMAL 3054uniform float opacity; 3055#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3056 varying vec3 vViewPosition; 3057#endif 3058#include <packing> 3059#include <uv_pars_fragment> 3060#include <normal_pars_fragment> 3061#include <bumpmap_pars_fragment> 3062#include <normalmap_pars_fragment> 3063#include <logdepthbuf_pars_fragment> 3064#include <clipping_planes_pars_fragment> 3065void main() { 3066 vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); 3067 #include <clipping_planes_fragment> 3068 #include <logdepthbuf_fragment> 3069 #include <normal_fragment_begin> 3070 #include <normal_fragment_maps> 3071 gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); 3072 #ifdef OPAQUE 3073 gl_FragColor.a = 1.0; 3074 #endif 3075}`,nA=`#define PHONG 3076varying vec3 vViewPosition; 3077#include <common> 3078#include <batching_pars_vertex> 3079#include <uv_pars_vertex> 3080#include <displacementmap_pars_vertex> 3081#include <envmap_pars_vertex> 3082#include <color_pars_vertex> 3083#include <fog_pars_vertex> 3084#include <normal_pars_vertex> 3085#include <morphtarget_pars_vertex> 3086#include <skinning_pars_vertex> 3087#include <shadowmap_pars_vertex> 3088#include <logdepthbuf_pars_vertex> 3089#include <clipping_planes_pars_vertex> 3090void main() { 3091 #include <uv_vertex> 3092 #include <color_vertex> 3093 #include <morphcolor_vertex> 3094 #include <batching_vertex> 3095 #include <beginnormal_vertex> 3096 #include <morphinstance_vertex> 3097 #include <morphnormal_vertex> 3098 #include <skinbase_vertex> 3099 #include <skinnormal_vertex> 3100 #include <defaultnormal_vertex> 3101 #include <normal_vertex> 3102 #include <begin_vertex> 3103 #include <morphtarget_vertex> 3104 #include <skinning_vertex> 3105 #include <displacementmap_vertex> 3106 #include <project_vertex> 3107 #include <logdepthbuf_vertex> 3108 #include <clipping_planes_vertex> 3109 vViewPosition = - mvPosition.xyz; 3110 #include <worldpos_vertex> 3111 #include <envmap_vertex> 3112 #include <shadowmap_vertex> 3113 #include <fog_vertex> 3114}`,iA=`#define PHONG 3115uniform vec3 diffuse; 3116uniform vec3 emissive; 3117uniform vec3 specular; 3118uniform float shininess; 3119uniform float opacity; 3120#include <common> 3121#include <packing> 3122#include <dithering_pars_fragment> 3123#include <color_pars_fragment> 3124#include <uv_pars_fragment> 3125#include <map_pars_fragment> 3126#include <alphamap_pars_fragment> 3127#include <alphatest_pars_fragment> 3128#include <alphahash_pars_fragment> 3129#include <aomap_pars_fragment> 3130#include <lightmap_pars_fragment> 3131#include <emissivemap_pars_fragment> 3132#include <envmap_common_pars_fragment> 3133#include <envmap_pars_fragment> 3134#include <fog_pars_fragment> 3135#include <bsdfs> 3136#include <lights_pars_begin> 3137#include <normal_pars_fragment> 3138#include <lights_phong_pars_fragment> 3139#include <shadowmap_pars_fragment> 3140#include <bumpmap_pars_fragment> 3141#include <normalmap_pars_fragment> 3142#include <specularmap_pars_fragment> 3143#include <logdepthbuf_pars_fragment> 3144#include <clipping_planes_pars_fragment> 3145void main() { 3146 vec4 diffuseColor = vec4( diffuse, opacity ); 3147 #include <clipping_planes_fragment> 3148 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3149 vec3 totalEmissiveRadiance = emissive; 3150 #include <logdepthbuf_fragment> 3151 #include <map_fragment> 3152 #include <color_fragment> 3153 #include <alphamap_fragment> 3154 #include <alphatest_fragment> 3155 #include <alphahash_fragment> 3156 #include <specularmap_fragment> 3157 #include <normal_fragment_begin> 3158 #include <normal_fragment_maps> 3159 #include <emissivemap_fragment> 3160 #include <lights_phong_fragment> 3161 #include <lights_fragment_begin> 3162 #include <lights_fragment_maps> 3163 #include <lights_fragment_end> 3164 #include <aomap_fragment> 3165 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; 3166 #include <envmap_fragment> 3167 #include <opaque_fragment> 3168 #include <tonemapping_fragment> 3169 #include <colorspace_fragment> 3170 #include <fog_fragment> 3171 #include <premultiplied_alpha_fragment> 3172 #include <dithering_fragment> 3173}`,rA=`#define STANDARD 3174varying vec3 vViewPosition; 3175#ifdef USE_TRANSMISSION 3176 varying vec3 vWorldPosition; 3177#endif 3178#include <common> 3179#include <batching_pars_vertex> 3180#include <uv_pars_vertex> 3181#include <displacementmap_pars_vertex> 3182#include <color_pars_vertex> 3183#include <fog_pars_vertex> 3184#include <normal_pars_vertex> 3185#include <morphtarget_pars_vertex> 3186#include <skinning_pars_vertex> 3187#include <shadowmap_pars_vertex> 3188#include <logdepthbuf_pars_vertex> 3189#include <clipping_planes_pars_vertex> 3190void main() { 3191 #include <uv_vertex> 3192 #include <color_vertex> 3193 #include <morphinstance_vertex> 3194 #include <morphcolor_vertex> 3195 #include <batching_vertex> 3196 #include <beginnormal_vertex> 3197 #include <morphnormal_vertex> 3198 #include <skinbase_vertex> 3199 #include <skinnormal_vertex> 3200 #include <defaultnormal_vertex> 3201 #include <normal_vertex> 3202 #include <begin_vertex> 3203 #include <morphtarget_vertex> 3204 #include <skinning_vertex> 3205 #include <displacementmap_vertex> 3206 #include <project_vertex> 3207 #include <logdepthbuf_vertex> 3208 #include <clipping_planes_vertex> 3209 vViewPosition = - mvPosition.xyz; 3210 #include <worldpos_vertex> 3211 #include <shadowmap_vertex> 3212 #include <fog_vertex> 3213#ifdef USE_TRANSMISSION 3214 vWorldPosition = worldPosition.xyz; 3215#endif 3216}`,sA=`#define STANDARD 3217#ifdef PHYSICAL 3218 #define IOR 3219 #define USE_SPECULAR 3220#endif 3221uniform vec3 diffuse; 3222uniform vec3 emissive; 3223uniform float roughness; 3224uniform float metalness; 3225uniform float opacity; 3226#ifdef IOR 3227 uniform float ior; 3228#endif 3229#ifdef USE_SPECULAR 3230 uniform float specularIntensity; 3231 uniform vec3 specularColor; 3232 #ifdef USE_SPECULAR_COLORMAP 3233 uniform sampler2D specularColorMap; 3234 #endif 3235 #ifdef USE_SPECULAR_INTENSITYMAP 3236 uniform sampler2D specularIntensityMap; 3237 #endif 3238#endif 3239#ifdef USE_CLEARCOAT 3240 uniform float clearcoat; 3241 uniform float clearcoatRoughness; 3242#endif 3243#ifdef USE_DISPERSION 3244 uniform float dispersion; 3245#endif
3246#ifdef USE_IRIDESCENCE 3247 uniform float iridescence; 3248 uniform float iridescenceIOR; 3249 uniform float iridescenceThicknessMinimum; 3250 uniform float iridescenceThicknessMaximum; 3251#endif 3252#ifdef USE_SHEEN 3253 uniform vec3 sheenColor; 3254 uniform float sheenRoughness; 3255 #ifdef USE_SHEEN_COLORMAP 3256 uniform sampler2D sheenColorMap; 3257 #endif 3258 #ifdef USE_SHEEN_ROUGHNESSMAP 3259 uniform sampler2D sheenRoughnessMap; 3260 #endif 3261#endif 3262#ifdef USE_ANISOTROPY 3263 uniform vec2 anisotropyVector; 3264 #ifdef USE_ANISOTROPYMAP 3265 uniform sampler2D anisotropyMap; 3266 #endif 3267#endif 3268varying vec3 vViewPosition; 3269#include <common> 3270#include <packing> 3271#include <dithering_pars_fragment> 3272#include <color_pars_fragment> 3273#include <uv_pars_fragment> 3274#include <map_pars_fragment> 3275#include <alphamap_pars_fragment> 3276#include <alphatest_pars_fragment> 3277#include <alphahash_pars_fragment> 3278#include <aomap_pars_fragment> 3279#include <lightmap_pars_fragment> 3280#include <emissivemap_pars_fragment> 3281#include <iridescence_fragment> 3282#include <cube_uv_reflection_fragment> 3283#include <envmap_common_pars_fragment> 3284#include <envmap_physical_pars_fragment> 3285#include <fog_pars_fragment> 3286#include <lights_pars_begin> 3287#include <normal_pars_fragment> 3288#include <lights_physical_pars_fragment> 3289#include <transmission_pars_fragment> 3290#include <shadowmap_pars_fragment> 3291#include <bumpmap_pars_fragment> 3292#include <normalmap_pars_fragment> 3293#include <clearcoat_pars_fragment> 3294#include <iridescence_pars_fragment> 3295#include <roughnessmap_pars_fragment> 3296#include <metalnessmap_pars_fragment> 3297#include <logdepthbuf_pars_fragment> 3298#include <clipping_planes_pars_fragment> 3299void main() { 3300 vec4 diffuseColor = vec4( diffuse, opacity ); 3301 #include <clipping_planes_fragment> 3302 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3303 vec3 totalEmissiveRadiance = emissive; 3304 #include <logdepthbuf_fragment> 3305 #include <map_fragment> 3306 #include <color_fragment> 3307 #include <alphamap_fragment> 3308 #include <alphatest_fragment> 3309 #include <alphahash_fragment> 3310 #include <roughnessmap_fragment> 3311 #include <metalnessmap_fragment> 3312 #include <normal_fragment_begin> 3313 #include <normal_fragment_maps> 3314 #include <clearcoat_normal_fragment_begin> 3315 #include <clearcoat_normal_fragment_maps> 3316 #include <emissivemap_fragment> 3317 #include <lights_physical_fragment> 3318 #include <lights_fragment_begin> 3319 #include <lights_fragment_maps> 3320 #include <lights_fragment_end> 3321 #include <aomap_fragment> 3322 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; 3323 vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; 3324 #include <transmission_fragment> 3325 vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; 3326 #ifdef USE_SHEEN 3327 float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); 3328 outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; 3329 #endif 3330 #ifdef USE_CLEARCOAT 3331 float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); 3332 vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); 3333 outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; 3334 #endif 3335 #include <opaque_fragment> 3336 #include <tonemapping_fragment> 3337 #include <colorspace_fragment> 3338 #include <fog_fragment> 3339 #include <premultiplied_alpha_fragment> 3340 #include <dithering_fragment> 3341}`,oA=`#define TOON 3342varying vec3 vViewPosition; 3343#include <common> 3344#include <batching_pars_vertex> 3345#include <uv_pars_vertex> 3346#include <displacementmap_pars_vertex> 3347#include <color_pars_vertex> 3348#include <fog_pars_vertex> 3349#include <normal_pars_vertex> 3350#include <morphtarget_pars_vertex> 3351#include <skinning_pars_vertex> 3352#include <shadowmap_pars_vertex> 3353#include <logdepthbuf_pars_vertex> 3354#include <clipping_planes_pars_vertex> 3355void main() { 3356 #include <uv_vertex> 3357 #include <color_vertex> 3358 #include <morphinstance_vertex> 3359 #include <morphcolor_vertex> 3360 #include <batching_vertex> 3361 #include <beginnormal_vertex> 3362 #include <morphnormal_vertex> 3363 #include <skinbase_vertex> 3364 #include <skinnormal_vertex> 3365 #include <defaultnormal_vertex> 3366 #include <normal_vertex> 3367 #include <begin_vertex> 3368 #include <morphtarget_vertex> 3369 #include <skinning_vertex> 3370 #include <displacementmap_vertex> 3371 #include <project_vertex> 3372 #include <logdepthbuf_vertex> 3373 #include <clipping_planes_vertex> 3374 vViewPosition = - mvPosition.xyz; 3375 #include <worldpos_vertex> 3376 #include <shadowmap_vertex> 3377 #include <fog_vertex> 3378}`,aA=`#define TOON 3379uniform vec3 diffuse; 3380uniform vec3 emissive; 3381uniform float opacity; 3382#include <common> 3383#include <packing> 3384#include <dithering_pars_fragment> 3385#include <color_pars_fragment> 3386#include <uv_pars_fragment> 3387#include <map_pars_fragment> 3388#include <alphamap_pars_fragment> 3389#include <alphatest_pars_fragment> 3390#include <alphahash_pars_fragment> 3391#include <aomap_pars_fragment> 3392#include <lightmap_pars_fragment> 3393#include <emissivemap_pars_fragment> 3394#include <gradientmap_pars_fragment> 3395#include <fog_pars_fragment> 3396#include <bsdfs> 3397#include <lights_pars_begin> 3398#include <normal_pars_fragment> 3399#include <lights_toon_pars_fragment> 3400#include <shadowmap_pars_fragment> 3401#include <bumpmap_pars_fragment> 3402#include <normalmap_pars_fragment> 3403#include <logdepthbuf_pars_fragment> 3404#include <clipping_planes_pars_fragment> 3405void main() { 3406 vec4 diffuseColor = vec4( diffuse, opacity ); 3407 #include <clipping_planes_fragment> 3408 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3409 vec3 totalEmissiveRadiance = emissive; 3410 #include <logdepthbuf_fragment> 3411 #include <map_fragment> 3412 #include <color_fragment> 3413 #include <alphamap_fragment> 3414 #include <alphatest_fragment> 3415 #include <alphahash_fragment> 3416 #include <normal_fragment_begin> 3417 #include <normal_fragment_maps> 3418 #include <emissivemap_fragment> 3419 #include <lights_toon_fragment> 3420 #include <lights_fragment_begin> 3421 #include <lights_fragment_maps> 3422 #include <lights_fragment_end> 3423 #include <aomap_fragment> 3424 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3425 #include <opaque_fragment> 3426 #include <tonemapping_fragment> 3427 #include <colorspace_fragment> 3428 #include <fog_fragment> 3429 #include <premultiplied_alpha_fragment> 3430 #include <dithering_fragment> 3431}`,cA=`uniform float size; 3432uniform float scale; 3433#include <common> 3434#include <color_pars_vertex> 3435#include <fog_pars_vertex> 3436#include <morphtarget_pars_vertex> 3437#include <logdepthbuf_pars_vertex> 3438#include <clipping_planes_pars_vertex> 3439#ifdef USE_POINTS_UV 3440 varying vec2 vUv; 3441 uniform mat3 uvTransform; 3442#endif 3443void main() { 3444 #ifdef USE_POINTS_UV 3445 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 3446 #endif 3447 #include <color_vertex> 3448 #include <morphinstance_vertex> 3449 #include <morphcolor_vertex> 3450 #include <begin_vertex> 3451 #include <morphtarget_vertex> 3452 #include <project_vertex> 3453 gl_PointSize = size; 3454 #ifdef USE_SIZEATTENUATION 3455 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3456 if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); 3457 #endif 3458 #include <logdepthbuf_vertex> 3459 #include <clipping_planes_vertex> 3460 #include <worldpos_vertex> 3461 #include <fog_vertex> 3462}`,lA=`uniform vec3 diffuse; 3463uniform float opacity; 3464#include <common> 3465#include <color_pars_fragment> 3466#include <map_particle_pars_fragment> 3467#include <alphatest_pars_fragment> 3468#include <alphahash_pars_fragment> 3469#include <fog_pars_fragment> 3470#include <logdepthbuf_pars_fragment> 3471#include <clipping_planes_pars_fragment> 3472void main() { 3473 vec4 diffuseColor = vec4( diffuse, opacity ); 3474 #include <clipping_planes_fragment> 3475 vec3 outgoingLight = vec3( 0.0 ); 3476 #include <logdepthbuf_fragment> 3477 #include <map_particle_fragment> 3478 #include <color_fragment> 3479 #include <alphatest_fragment> 3480 #include <alphahash_fragment> 3481 outgoingLight = diffuseColor.rgb; 3482 #include <opaque_fragment> 3483 #include <tonemapping_fragment> 3484 #include <colorspace_fragment> 3485 #include <fog_fragment> 3486 #include <premultiplied_alpha_fragment> 3487}`,uA=`#include <common> 3488#include <batching_pars_vertex> 3489#include <fog_pars_vertex> 3490#include <morphtarget_pars_vertex> 3491#include <skinning_pars_vertex> 3492#include <logdepthbuf_pars_vertex> 3493#include <shadowmap_pars_vertex> 3494void main() { 3495 #include <batching_vertex> 3496 #include <beginnormal_vertex> 3497 #include <morphinstance_vertex> 3498 #include <morphnormal_vertex> 3499 #include <skinbase_vertex> 3500 #include <skinnormal_vertex> 3501 #include <defaultnormal_vertex> 3502 #include <begin_vertex> 3503 #include <morphtarget_vertex> 3504 #include <skinning_vertex> 3505 #include <project_vertex> 3506 #include <logdepthbuf_vertex> 3507 #include <worldpos_vertex> 3508 #include <shadowmap_vertex> 3509 #include <fog_vertex> 3510}`,dA=`uniform vec3 color; 3511uniform float opacity; 3512#include <common> 3513#include <packing> 3514#include <fog_pars_fragment> 3515#include <bsdfs> 3516#include <lights_pars_begin> 3517#include <logdepthbuf_pars_fragment> 3518#include <shadowmap_pars_fragment> 3519#include <shadowmask_pars_fragment> 3520void main() { 3521 #include <logdepthbuf_fragment> 3522 gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 3523 #include <tonemapping_fragment> 3524 #include <colorspace_fragment> 3525 #include <fog_fragment> 3526}`,hA=`uniform float rotation; 3527uniform vec2 center; 3528#include <common> 3529#include <uv_pars_vertex> 3530#include <fog_pars_vertex> 3531#include <logdepthbuf_pars_vertex> 3532#include <clipping_planes_pars_vertex> 3533void main() { 3534 #include <uv_vertex> 3535 vec4 mvPosition = modelViewMatrix[ 3 ]; 3536 vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); 3537 #ifndef USE_SIZEATTENUATION 3538 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3539 if ( isPerspective ) scale *= - mvPosition.z; 3540 #endif 3541 vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; 3542 vec2 rotatedPosition; 3543 rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; 3544 rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; 3545 mvPosition.xy += rotatedPosition; 3546 gl_Position = projectionMatrix * mvPosition; 3547 #include <logdepthbuf_vertex> 3548 #include <clipping_planes_vertex> 3549 #include <fog_vertex> 3550}`,pA=`uniform vec3 diffuse; 3551uniform float opacity; 3552#include <common> 3553#include <uv_pars_fragment> 3554#include <map_pars_fragment> 3555#include <alphamap_pars_fragment> 3556#include <alphatest_pars_fragment> 3557#include <alphahash_pars_fragment> 3558#include <fog_pars_fragment> 3559#include <logdepthbuf_pars_fragment> 3560#include <clipping_planes_pars_fragment> 3561void main() { 3562 vec4 diffuseColor = vec4( diffuse, opacity ); 3563 #include <clipping_planes_fragment> 3564 vec3 outgoingLight = vec3( 0.0 ); 3565 #include <logdepthbuf_fragment> 3566 #include <map_fragment> 3567 #include <alphamap_fragment> 3568 #include <alphatest_fragment> 3569 #include <alphahash_fragment> 3570 outgoingLight = diffuseColor.rgb; 3571 #include <opaque_fragment> 3572 #include <tonemapping_fragment> 3573 #include <colorspace_fragment> 3574 #include <fog_fragment> 3575}`,st={alphahash_fragment:kT,alphahash_pars_fragment:UT,alphamap_fragment:OT,alphamap_pars_fragment:FT,alphatest_fragment:VT,alphatest_pars_fragment:BT,aomap_fragment:zT,aomap_pars_fragment:HT,batching_pars_vertex:GT,batching_vertex:WT,begin_vertex:qT,beginnormal_vertex:XT,bsdfs:jT,iridescence_fragment:KT,bumpmap_pars_fragment:YT,clipping_planes_fragment:QT,clipping_planes_pars_fragment:ZT,clipping_planes_pars_vertex:JT,clipping_planes_vertex:$T,color_fragment:eb,color_pars_fragment:tb,color_pars_vertex:nb,color_vertex:ib,common:rb,cube_uv_reflection_fragment:sb,defaultnormal_vertex:ob,displacementmap_pars_vertex:ab,displacementmap_vertex:cb,emissivemap_fragment:lb,emissivemap_pars_fragment:ub,colorspace_fragment:db,colorspace_pars_fragment:hb,envmap_fragment:pb,envmap_common_pars_fragment:fb,envmap_pars_fragment:_b,envmap_pars_vertex:mb,envmap_physical_pars_fragment:Ib,envmap_vertex:gb,fog_vertex:vb,fog_pars_vertex:yb,fog_fragment:Eb,fog_pars_fragment:Tb,gradientmap_pars_fragment:bb,lightmap_pars_fragment:Sb,lights_lambert_fragment:Ab,lights_lambert_pars_fragment:xb,lights_pars_begin:wb,lights_toon_fragment:Mb,lights_toon_pars_fragment:Cb,lights_phong_fragment:Rb,lights_phong_pars_fragment:Pb,lights_physical_fragment:Lb,lights_physical_pars_fragment:Db,lights_fragment_begin:Nb,lights_fragment_maps:kb,lights_fragment_end:Ub,logdepthbuf_fragment:Ob,logdepthbuf_pars_fragment:Fb,logdepthbuf_pars_vertex:Vb,logdepthbuf_vertex:Bb,map_fragment:zb,map_pars_fragment:Hb,map_particle_fragment:Gb,map_particle_pars_fragment:Wb,metalnessmap_fragment:qb,metalnessmap_pars_fragment:Xb,morphinstance_vertex:jb,morphcolor_vertex:Kb,morphnormal_vertex:Yb,morphtarget_pars_vertex:Qb,morphtarget_vertex:Zb,normal_fragment_begin:Jb,normal_fragment_maps:$b,normal_pars_fragment:eS,normal_pars_vertex:tS,normal_vertex:nS,normalmap_pars_fragment:iS,clearcoat_normal_fragment_begin:rS,clearcoat_normal_fragment_maps:sS,clearcoat_pars_fragment:oS,iridescence_pars_fragment:aS,opaque_fragment:cS,packing:lS,premultiplied_alpha_fragment:uS,project_vertex:dS,dithering_fragment:hS,dithering_pars_fragment:pS,roughnessmap_fragment:fS,roughnessmap_pars_fragment:_S,shadowmap_pars_fragment:mS,shadowmap_pars_vertex:gS,shadowmap_vertex:vS,shadowmask_pars_fragment:yS,skinbase_vertex:ES,skinning_pars_vertex:TS,skinning_vertex:bS,skinnormal_vertex:SS,specularmap_fragment:AS,specularmap_pars_fragment:xS,tonemapping_fragment:wS,tonemapping_pars_fragment:IS,transmission_fragment:MS,transmission_pars_fragment:CS,uv_pars_fragment:RS,uv_pars_vertex:PS,uv_vertex:LS,worldpos_vertex:DS,background_vert:NS,background_frag:kS,backgroundCube_vert:US,backgroundCube_frag:OS,cube_vert:FS,cube_frag:VS,depth_vert:BS,depth_frag:zS,distanceRGBA_vert:HS,distanceRGBA_frag:GS,equirect_vert:WS,equirect_frag:qS,linedashed_vert:XS,linedashed_frag:jS,meshbasic_vert:KS,meshbasic_frag:YS,meshlambert_vert:QS,meshlambert_frag:ZS,meshmatcap_vert:JS,meshmatcap_frag:$S,meshnormal_vert:eA,meshnormal_frag:tA,meshphong_vert:nA,meshphong_frag:iA,meshphysical_vert:rA,meshphysical_frag:sA,meshtoon_vert:oA,meshtoon_frag:aA,points_vert:cA,points_frag:lA,shadow_vert:uA,shadow_frag:dA,sprite_vert:hA,sprite_frag:pA},ge={common:{diffuse:{value:new ut(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new it},alphaMap:{value:null},alphaMapTransform:{value:new it},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new it}},envmap:{envMap:{value:null},envMapRotation:{value:new it},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new it}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new it}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new it},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new it},normalScale:{value:new xe(1,1)}}
vendor: 7,500 bytes, line 3575
3575,displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new it},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new it}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new it}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new it}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ut(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ut(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new it},alphaTest:{value:0},uvTransform:{value:new it}},sprite:{diffuse:{value:new ut(16777215)},opacity:{value:1},center:{value:new xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new it},alphaMap:{value:null},alphaMapTransform:{value:new it},alphaTest:{value:0}}},li={basic:{uniforms:mn([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:mn([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ut(0)}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:mn([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ut(0)},specular:{value:new ut(1118481)},shininess:{value:30}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:mn([ge.common,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.roughnessmap,ge.metalnessmap,ge.fog,ge.lights,{emissive:{value:new ut(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:mn([ge.common,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.gradientmap,ge.fog,ge.lights,{emissive:{value:new ut(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:mn([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:mn([ge.points,ge.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:mn([ge.common,ge.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:mn([ge.common,ge.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:mn([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:mn([ge.sprite,ge.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new it},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new it}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distanceRGBA:{uniforms:mn([ge.common,ge.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:st.distanceRGBA_vert,fragmentShader:st.distanceRGBA_frag},shadow:{uniforms:mn([ge.lights,ge.fog,{color:{value:new ut(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};li.physical={uniforms:mn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new it},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new it},clearcoatNormalScale:{value:new xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new it},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new it},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new it},sheen:{value:0},sheenColor:{value:new ut(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new it},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new it},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new it},transmissionSamplerSize:{value:new xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new it},attenuationDistance:{value:0},attenuationColor:{value:new ut(0)},specularColor:{value:new ut(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new it},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new it},anisotropyVector:{value:new xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new it}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};const wc={r:0,b:0,g:0},Dr=new vi,fA=new wt;function _A(n,e,t,i,r,s,o){const a=new ut(0);let c=s===!0?0:1,l,d,h=null,p=0,_=null;function g(M){let w=M.isScene===!0?M.background:null;return w&&w.isTexture&&(w=(M.backgroundBlurriness>0?t:e).get(w)),w}function S(M){let w=!1;const b=g(M);b===null?f(a,c):b&&b.isColor&&(f(b,1),w=!0);const R=n.xr.getEnvironmentBlendMode();R==="additive"?i.buffers.color.setClear(0,0,0,1,o):R==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||w)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function m(M,w){const b=g(w);b&&(b.isCubeTexture||b.mapping===kl)?(d===void 0&&(d=new Hi(new Ha(1,1,1),new Tr({name:"Backgroun
3575dCubeMaterial",uniforms:Zs(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(R,P,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),Dr.copy(w.backgroundRotation),Dr.x*=-1,Dr.y*=-1,Dr.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Dr.y*=-1,Dr.z*=-1),d.material.uniforms.envMap.value=b,d.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(fA.makeRotationFromEuler(Dr)),d.material.toneMapped=ft.getTransfer(b.colorSpace)!==St,(h!==b||p!==b.version||_!==n.toneMapping)&&(d.material.needsUpdate=!0,h=b,p=b.version,_=n.toneMapping),d.layers.enableAll(),M.unshift(d,d.geometry,d.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new Hi(new Vl(2,2),new Tr({name:"BackgroundMaterial",uniforms:Zs(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:Er,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=ft.getTransfer(b.colorSpace)!==St,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(h!==b||p!==b.version||_!==n.toneMapping)&&(l.material.needsUpdate=!0,h=b,p=b.version,_=n.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function f(M,w){M.getRGB(wc,Rg(n)),i.buffers.color.setClear(wc.r,wc.g,wc.b,w,o)}return{getClearColor:function(){return a},setClearColor:function(M,w=1){a.set(M),c=w,f(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,f(a,c)},render:S,addToRenderList:m}}function mA(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=p(null);let s=r,o=!1;function a(y,I,D,C,W){let Z=!1;const Y=h(C,D,I);s!==Y&&(s=Y,l(s.object)),Z=_(y,C,D,W),Z&&g(y,C,D,W),W!==null&&e.update(W,n.ELEMENT_ARRAY_BUFFER),(Z||o)&&(o=!1,b(y,I,D,C),W!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(W).buffer))}function c(){return n.createVertexArray()}function l(y){return n.bindVertexArray(y)}function d(y){return n.deleteVertexArray(y)}function h(y,I,D){const C=D.wireframe===!0;let W=i[y.id];W===void 0&&(W={},i[y.id]=W);let Z=W[I.id];Z===void 0&&(Z={},W[I.id]=Z);let Y=Z[C];return Y===void 0&&(Y=p(c()),Z[C]=Y),Y}function p(y){const I=[],D=[],C=[];for(let W=0;W<t;W++)I[W]=0,D[W]=0,C[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:D,attributeDivisors:C,object:y,attributes:{},index:null}}function _(y,I,D,C){const W=s.attributes,Z=I.attributes;let Y=0;const ce=D.getAttributes();for(const K in ce)if(ce[K].location>=0){const ve=W[K];let ye=Z[K];if(ye===void 0&&(K==="instanceMatrix"&&y.instanceMatrix&&(ye=y.instanceMatrix),K==="instanceColor"&&y.instanceColor&&(ye=y.instanceColor)),ve===void 0||ve.attribute!==ye||ye&&ve.data!==ye.data)return!0;Y++}return s.attributesNum!==Y||s.index!==C}function g(y,I,D,C){const W={},Z=I.attributes;let Y=0;const ce=D.getAttributes();for(const K in ce)if(ce[K].location>=0){let ve=Z[K];ve===void 0&&(K==="instanceMatrix"&&y.instanceMatrix&&(ve=y.instanceMatrix),K==="instanceColor"&&y.instanceColor&&(ve=y.instanceColor));const ye={};ye.attribute=ve,ve&&ve.data&&(ye.data=ve.data),W[K]=ye,Y++}s.attributes=W,s.attributesNum=Y,s.index=C}function S(){const y=s.newAttributes;for(let I=0,D=y.length;I<D;I++)y[I]=0}function m(y){f(y,0)}function f(y,I){const D=s.newAttributes,C=s.enabledAttributes,W=s.attributeDivisors;D[y]=1,C[y]===0&&(n.enableVertexAttribArray(y),C[y]=1),W[y]!==I&&(n.vertexAttribDivisor(y,I),W[y]=I)}function M(){const y=s.newAttributes,I=s.enabledAttributes;for(let D=0,C=I.length;D<C;D++)I[D]!==y[D]&&(n.disableVertexAttribArray(D),I[D]=0)}function w(y,I,D,C,W,Z,Y){Y===!0?n.vertexAttribIPointer(y,I,D,W,Z):n.vertexAttribPointer(y,I,D,C,W,Z)}function b(y,I,D,C){S();const W=C.attributes,Z=D.getAttributes(),Y=I.defaultAttributeValues;for(const ce in Z){const K=Z[ce];if(K.location>=0){let ue=W[ce];if(ue===void 0&&(ce==="instanceMatrix"&&y.instanceMatrix&&(ue=y.instanceMatrix),ce==="instanceColor"&&y.instanceColor&&(ue=y.instanceColor)),ue!==void 0){const ve=ue.normalized,ye=ue.itemSize,Oe=e.get(ue);if(Oe===void 0)continue;const Ve=Oe.buffer,J=Oe.type,re=Oe.bytesPerElement,De=J===n.INT||J===n.UNSIGNED_INT||ue.gpuType===Uh;if(ue.isInterleavedBufferAttribute){const pe=ue.data,ze=pe.stride,se=ue.offset;if(pe.isInstancedInterleavedBuffer){for(let Ee=0;Ee<K.locationSize;Ee++)f(K.location+Ee,pe.meshPerAttribute);y.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let Ee=0;Ee<K.locationSize;Ee++)m(K.location+Ee);n.bindBuffer(n.ARRAY_BUFFER,Ve);for(let Ee=0;Ee<K.locationSize;Ee++)w(K.location+Ee,ye/K.locationSize,J,ve,ze*re,(se+ye/K.locationSize*Ee)*re,De)}else{if(ue.isInstancedBufferAttribute){for(let pe=0;pe<K.locationSize;pe++)f(K.location+pe,ue.meshPerAttribute);y.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let pe=0;pe<K.locationSize;pe++)m(K.location+pe);n.bindBuffer(n.ARRAY_BUFFER,Ve);for(let pe=0;pe<K.locationSize;pe++)w(K.location+pe,ye/K.locationSize,J,ve,ye*re,ye/K.locationSize*pe*re,De)}}else if(Y!==void 0){const ve=Y[ce];if(ve!==void 0)switch(ve.length){case 2:n.vertexAttrib2fv(K.location,ve);break;case 3:n.vertexAttrib3fv(K.location,ve);break;case 4:n.vertexAttrib4fv(K.location,ve);break;default:n.vertexAttrib1fv(K.location,ve)}}}}M()}function R(){A();for(const y in i){const I=i[y];for(const D in I){const C=I[D];for(const W in C)d(C[W].object),delete C[W];delete I[D]}delete i[y]}}function P(y){if(i[y.id]===void 0)return;const I=i[y.id];for(const D in I){const C=I[D];for(const W in C)d(C[W].object),delete C[W];delete I[D]}delete i[y.id]}function T(y){for(const I in i){const D=i[I];if(D[y.id]===void 0)continue;const C=D[y.id];for(const W in C)d(C[W].object),delete C[W];delete D[y.id]}}function A(){E(),o=!0,s!==r&&(s=r,l(s.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:A,resetDefaultState:E,dispose:R,releaseStatesOfGeometry:P,releaseStatesOfProgram:T,initAttributes:S,enableAttribute:m,disableUnusedAttributes:M}}function gA(n,e,t){let i;function r(l){i=l}function s(l,d){n.drawArrays(i,l,d),t.update(d,i,1)}function o(l,d,h){h!==0&&(n.drawArraysInstanced(i,l,d,h),t.update(d,i,h))}function a(l,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,d,0,h);let _=0;for(let g=0;g<h;g++)_+=d[g];t.update(_,i,1)}function c(l,d,h,p){if(h===0)return;const _=e.get("WEBGL_multi_draw");if(_===null)for(let g=0;g<l.length;g++)o(l[g],d[g],p[g]);
vendor: 14,146 bytes, lines 3575-3650
3575else{_.multiDrawArraysInstancedWEBGL(i,l,0,d,0,p,0,h);let g=0;for(let S=0;S<h;S++)g+=d[S]*p[S];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function vA(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(T){return!(T!==ei&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(T){const A=T===Ba&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==Yi&&i.convert(T)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Bi&&!A)}function c(T){if(T==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const d=c(l);d!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);const h=t.logarithmicDepthBuffer===!0,p=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),_=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),M=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),w=n.getParameter(n.MAX_VARYING_VECTORS),b=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,P=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:p,maxTextures:_,maxVertexTextures:g,maxTextureSize:S,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:b,vertexTextures:R,maxSamples:P}}function yA(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new kr,a=new it,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const _=h.length!==0||p||i!==0||r;return r=p,i=h.length,_},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){t=d(h,p,0)},this.setState=function(h,p,_){const g=h.clippingPlanes,S=h.clipIntersection,m=h.clipShadows,f=n.get(h);if(!r||g===null||g.length===0||s&&!m)s?d(null):l();else{const M=s?0:i,w=M*4;let b=f.clippingState||null;c.value=b,b=d(g,p,w,_);for(let R=0;R!==w;++R)b[R]=t[R];f.clippingState=b,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=M}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(h,p,_,g){const S=h!==null?h.length:0;let m=null;if(S!==0){if(m=c.value,g!==!0||m===null){const f=_+S*4,M=p.matrixWorldInverse;a.getNormalMatrix(M),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,b=_;w!==S;++w,b+=4)o.copy(h[w]).applyMatrix4(M,a),o.normal.toArray(m,b),m[b+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,m}}function EA(n){let e=new WeakMap;function t(o,a){return a===Td?o.mapping=js:a===bd&&(o.mapping=Ks),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Td||a===bd)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new PT(c.height);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class Ng extends Pg{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=d*this.view.offsetY,c=a-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),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,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ds=4,Vf=[.125,.215,.35,.446,.526,.582],Vr=20,Uu=new Ng,Bf=new ut;let Ou=null,Fu=0,Vu=0,Bu=!1;const Ur=(1+Math.sqrt(5))/2,Ss=1/Ur,zf=[new O(-Ur,Ss,0),new O(Ur,Ss,0),new O(-Ss,0,Ur),new O(Ss,0,Ur),new O(0,Ur,-Ss),new O(0,Ur,Ss),new O(-1,1,-1),new O(1,1,-1),new O(-1,1,1),new O(1,1,1)];class Hf{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){Ou=this._renderer.getRenderTarget(),Fu=this._renderer.getActiveCubeFace(),Vu=this._renderer.getActiveMipmapLevel(),Bu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=qf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Wf(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ou,Fu,Vu),this._renderer.xr.enabled=Bu,e.scissorTest=!1,Ic(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===js||e.mapping===Ks?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ou=this._renderer.getRenderTarget(),Fu=this._renderer.getActiveCubeFace(),Vu=this._renderer.getActiveMipmapLevel(),Bu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:di,minFilter:di,generateMipmaps:!1,type:Ba,format:ei,colorSpace:ho,depthBuffer:!1},r=Gf(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Gf(e,t,i);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=TA(s)),this._blurMaterial=bA(s,e,t)}return r}_compileMaterial(e){const t=new Hi(this._lodPlanes[0],e);this._renderer.compile(t,Uu)}_sceneToCubeUV(e,t,i,r){const a=new Jn(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,p=d.toneMapping;d.getClearColor(Bf),d.toneMapping=yr,d.autoClear=!1;const _=new Ig({name:"PMREM.Background",side:bn,depthWrite:!1,depthTest:!1}),g=new Hi(new Ha,_);let S=!1;const m=e.background;m?m.isColor&&(_.color.copy(m),e.background=null,S=!0):(_.color.copy(Bf),S=!0);for(let f=0;f<6;f++){const M=f%3;M===0?(a.up.set(0,c[f],0),a.lookAt(l[f],0,0)):M===1?(a.up.set(0,0,c[f]),a.lookAt(0,l[f],0)):(a.up.set(0,c[f],0),a.lookAt(0,0,l[f]));const w=this._cubeSize;Ic(r,M*w,f>2?w:0,w,w),d.setRenderTarget(r),S&&d.render(g,a),d.render(e,a)}g.geometry.dispose(),g.material.dispose(),d.toneMapping=p,d.autoClear=h,e.background=m}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===js||e.mapping===Ks;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=qf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Wf());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new Hi(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const c=this._cubeSize;Ic(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,Uu)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=zf[(r-s-1)%zf.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=new Hi(this._lodPlanes[r],l),p=l.uniforms,_=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*_):2*Math.PI/(2*Vr-1),S=s/g,m=isFinite(s)?1+Math.floor(d*S):Vr;m>Vr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vr}`);const f=[];let M=0;for(let T=0;T<Vr;++T){const A=T/S,E=Math.exp(-A*A/2);f.push(E),T===0?M+=E:T<m&&(M+=2*E)}for(let T=0;T<f.length;T++)f[T]=f[T]/M;p.envMap.value=e.texture,p.samples.value=m,p.weights.value=f,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:w}=this;p.dTheta.value=g,p.mipInt.value=w-i;const b=this._sizeLods[r],R=3*b*(r>w-Ds?r-w+Ds:0),P=4*(this._cubeSize-b);Ic(t,R,P,3*b,2*b),c.setRenderTarget(t),c.render(h,Uu)}}function TA(n){const e=[],t=[],i=[];let r=n;const s=n-Ds+1+Vf.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Ds?c=Vf[o-n+Ds-1]:o===0&&(c=0),i.push(c);const l=1/(a-2),d=-l,h=1+l,p=[d,d,h,d,h,h,d,d,h,h,d,h],_=6,g=6,S=3,m=2,f=1,M=new Float32Array(S*g*_),w=new Float32Array(m*g*_),b=new Float32Array(f*g*_);for(let P=0;P<_;P++){const T=P%3*2/3-1,A=P>2?0:-1,E=[T,A,0,T+2/3,A,0,T+2/3,A+1,0,T,A,0,T+2/3,A+1,0,T,A+1,0];M.set(E,S*g*P),w.set(p,m*g*P);const y=[P,P,P,P,P,P];b.set(y,f*g*P)}const R=new An;R.setAttribute("position",new Gn(M,S)),R.setAttribute("uv",new Gn(w,m)),R.setAttribute("faceIndex",new Gn(b,f)),e.push(R),r>Ds&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Gf(n,e,t){const i=new Yr(n,e,t);return i.texture.mapping=kl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ic(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function bA(n,e,t){const i=new Float32Array(Vr),r=new O(0,1,0);return new Tr({name:"SphericalGaussianBlur",defines:{n:Vr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:qh(),fragmentShader:` 3576 3577 precision mediump float; 3578 precision mediump int; 3579 3580 varying vec3 vOutputDirection; 3581 3582 uniform sampler2D envMap; 3583 uniform int samples; 3584 uniform float weights[ n ]; 3585 uniform bool latitudinal; 3586 uniform float dTheta; 3587 uniform float mipInt; 3588 uniform vec3 poleAxis; 3589 3590 #define ENVMAP_TYPE_CUBE_UV 3591 #include <cube_uv_reflection_fragment> 3592 3593 vec3 getSample( float theta, vec3 axis ) { 3594 3595 float cosTheta = cos( theta ); 3596 // Rodrigues' axis-angle rotation 3597 vec3 sampleDirection = vOutputDirection * cosTheta 3598 + cross( axis, vOutputDirection ) * sin( theta ) 3599 + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); 3600 3601 return bilinearCubeUV( envMap, sampleDirection, mipInt ); 3602 3603 } 3604 3605 void main() { 3606 3607 vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); 3608 3609 if ( all( equal( axis, vec3( 0.0 ) ) ) ) { 3610 3611 axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); 3612 3613 } 3614 3615 axis = normalize( axis ); 3616 3617 gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 3618 gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); 3619 3620 for ( int i = 1; i < n; i++ ) { 3621 3622 if ( i >= samples ) { 3623 3624 break; 3625 3626 } 3627 3628 float theta = dTheta * float( i ); 3629 gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); 3630 gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); 3631 3632 } 3633 3634 } 3635 `,blending:vr,depthTest:!1,depthWrite:!1})}function Wf(){return new Tr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:qh(),fragmentShader:` 3636 3637 precision mediump float; 3638 precision mediump int; 3639 3640 varying vec3 vOutputDirection; 3641 3642 uniform sampler2D envMap; 3643 3644 #include <common> 3645 3646 void main() { 3647 3648 vec3 outputDirection = normalize( vOutputDirection ); 3649 vec2 uv = equirectUv( outputDirection ); 3650
3651 gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); 3652 3653 } 3654 `,blending:vr,depthTest:!1,depthWrite:!1})}function qf(){return new Tr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:qh(),fragmentShader:` 3655 3656 precision mediump float; 3657 precision mediump int; 3658 3659 uniform float flipEnvMap; 3660 3661 varying vec3 vOutputDirection; 3662 3663 uniform samplerCube envMap; 3664 3665 void main() { 3666 3667 gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); 3668 3669 } 3670 `,blending:vr,depthTest:!1,depthWrite:!1})}function qh(){return` 3671 3672 precision mediump float; 3673 precision mediump int; 3674 3675 attribute float faceIndex; 3676 3677 varying vec3 vOutputDirection; 3678 3679 // RH coordinate system; PMREM face-indexing convention 3680 vec3 getDirection( vec2 uv, float face ) { 3681 3682 uv = 2.0 * uv - 1.0; 3683 3684 vec3 direction = vec3( uv, 1.0 ); 3685 3686 if ( face == 0.0 ) { 3687 3688 direction = direction.zyx; // ( 1, v, u ) pos x 3689 3690 } else if ( face == 1.0 ) { 3691 3692 direction = direction.xzy; 3693 direction.xz *= -1.0; // ( -u, 1, -v ) pos y 3694 3695 } else if ( face == 2.0 ) { 3696 3697 direction.x *= -1.0; // ( -u, v, 1 ) pos z 3698 3699 } else if ( face == 3.0 ) { 3700 3701 direction = direction.zyx; 3702 direction.xz *= -1.0; // ( -1, v, -u ) neg x 3703 3704 } else if ( face == 4.0 ) { 3705 3706 direction = direction.xzy; 3707 direction.xy *= -1.0; // ( -u, -1, v ) neg y 3708 3709 } else if ( face == 5.0 ) { 3710 3711 direction.z *= -1.0; // ( u, v, -1 ) neg z 3712 3713 } 3714 3715 return direction; 3716 3717 } 3718 3719 void main() { 3720 3721 vOutputDirection = getDirection( uv, faceIndex ); 3722 gl_Position = vec4( position, 1.0 ); 3723 3724 } 3725 `}function SA(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const c=a.mapping,l=c===Td||c===bd,d=c===js||c===Ks;if(l||d){let h=e.get(a);const p=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==p)return t===null&&(t=new Hf(n)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const _=a.image;return l&&_&&_.height>0||d&&_&&r(_)?(t===null&&(t=new Hf(n)),h=l?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0;const l=6;for(let d=0;d<l;d++)a[d]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function AA(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&Jo("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function xA(n,e,t,i){const r={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const g in p.attributes)e.remove(p.attributes[g]);for(const g in p.morphAttributes){const S=p.morphAttributes[g];for(let m=0,f=S.length;m<f;m++)e.remove(S[m])}p.removeEventListener("dispose",o),delete r[p.id];const _=s.get(p);_&&(e.remove(_),s.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function a(h,p){return r[p.id]===!0||(p.addEventListener("dispose",o),r[p.id]=!0,t.memory.geometries++),p}function c(h){const p=h.attributes;for(const g in p)e.update(p[g],n.ARRAY_BUFFER);const _=h.morphAttributes;for(const g in _){const S=_[g];for(let m=0,f=S.length;m<f;m++)e.update(S[m],n.ARRAY_BUFFER)}}function l(h){const p=[],_=h.index,g=h.attributes.position;let S=0;if(_!==null){const M=_.array;S=_.version;for(let w=0,b=M.length;w<b;w+=3){const R=M[w+0],P=M[w+1],T=M[w+2];p.push(R,P,P,T,T,R)}}else if(g!==void 0){const M=g.array;S=g.version;for(let w=0,b=M.length/3-1;w<b;w+=3){const R=w+0,P=w+1,T=w+2;p.push(R,P,P,T,T,R)}}else return;const m=new(Sg(p)?Cg:Mg)(p,1);m.version=S;const f=s.get(h);f&&e.remove(f),s.set(h,m)}function d(h){const p=s.get(h);if(p){const _=h.index;_!==null&&p.version<_.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:d}}function wA(n,e,t){let i;function r(p){i=p}let s,o;function a(p){s=p.type,o=p.bytesPerElement}function c(p,_){n.drawElements(i,_,s,p*o),t.update(_,i,1)}function l(p,_,g){g!==0&&(n.drawElementsInstanced(i,_,s,p*o,g),t.update(_,i,g))}function d(p,_,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,_,0,s,p,0,g);let m=0;for(let f=0;f<g;f++)m+=_[f];t.update(m,i,1)}function h(p,_,g,S){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<p.length;f++)l(p[f]/o,_[f],S[f]);
vendor: 18,037 bytes, lines 3725-3760
3725else{m.multiDrawElementsInstancedWEBGL(i,_,0,s,p,0,S,0,g);let f=0;for(let M=0;M<g;M++)f+=_[M]*S[M];t.update(f,i,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function IA(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function MA(n,e,t){const i=new WeakMap,r=new Ot;function s(o,a,c){const l=o.morphTargetInfluences,d=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=d!==void 0?d.length:0;let p=i.get(a);if(p===void 0||p.count!==h){let E=function(){T.dispose(),i.delete(a),a.removeEventListener("dispose",E)};p!==void 0&&p.texture.dispose();const _=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,S=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],f=a.morphAttributes.normal||[],M=a.morphAttributes.color||[];let w=0;_===!0&&(w=1),g===!0&&(w=2),S===!0&&(w=3);let b=a.attributes.position.count*w,R=1;b>e.maxTextureSize&&(R=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);const P=new Float32Array(b*R*4*h),T=new xg(P,b,R,h);T.type=Bi,T.needsUpdate=!0;const A=w*4;for(let y=0;y<h;y++){const I=m[y],D=f[y],C=M[y],W=b*R*4*y;for(let Z=0;Z<I.count;Z++){const Y=Z*A;_===!0&&(r.fromBufferAttribute(I,Z),P[W+Y+0]=r.x,P[W+Y+1]=r.y,P[W+Y+2]=r.z,P[W+Y+3]=0),g===!0&&(r.fromBufferAttribute(D,Z),P[W+Y+4]=r.x,P[W+Y+5]=r.y,P[W+Y+6]=r.z,P[W+Y+7]=0),S===!0&&(r.fromBufferAttribute(C,Z),P[W+Y+8]=r.x,P[W+Y+9]=r.y,P[W+Y+10]=r.z,P[W+Y+11]=C.itemSize===4?r.w:1)}}p={count:h,texture:T,size:new xe(b,R)},i.set(a,p),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let _=0;for(let S=0;S<l.length;S++)_+=l[S];const g=a.morphTargetsRelative?1:1-_;c.getUniforms().setValue(n,"morphTargetBaseInfluence",g),c.getUniforms().setValue(n,"morphTargetInfluences",l)}c.getUniforms().setValue(n,"morphTargetsTexture",p.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",p.size)}return{update:s}}function CA(n,e,t,i){let r=new WeakMap;function s(c){const l=i.render.frame,d=c.geometry,h=e.get(c,d);if(r.get(h)!==l&&(e.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const p=c.skeleton;r.get(p)!==l&&(p.update(),r.set(p,l))}return h}function o(){r=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}class kg extends vn{constructor(e,t,i,r,s,o,a,c,l,d=Os){if(d!==Os&&d!==Qs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&d===Os&&(i=Kr),i===void 0&&d===Qs&&(i=Ys),super(null,r,s,o,a,c,d,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:ri,this.minFilter=c!==void 0?c:ri,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Ug=new vn,Xf=new kg(1,1),Og=new xg,Fg=new _T,Vg=new Lg,jf=[],Kf=[],Yf=new Float32Array(16),Qf=new Float32Array(9),Zf=new Float32Array(4);function fo(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=jf[r];if(s===void 0&&(s=new Float32Array(r),jf[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function qt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Xt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Bl(n,e){let t=Kf[e];t===void 0&&(t=new Int32Array(e),Kf[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function RA(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function PA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(qt(t,e))return;n.uniform2fv(this.addr,e),Xt(t,e)}}function LA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(qt(t,e))return;n.uniform3fv(this.addr,e),Xt(t,e)}}function DA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(qt(t,e))return;n.uniform4fv(this.addr,e),Xt(t,e)}}function NA(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(qt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Xt(t,e)}else{if(qt(t,i))return;Zf.set(i),n.uniformMatrix2fv(this.addr,!1,Zf),Xt(t,i)}}function kA(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(qt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Xt(t,e)}else{if(qt(t,i))return;Qf.set(i),n.uniformMatrix3fv(this.addr,!1,Qf),Xt(t,i)}}function UA(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(qt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Xt(t,e)}else{if(qt(t,i))return;Yf.set(i),n.uniformMatrix4fv(this.addr,!1,Yf),Xt(t,i)}}function OA(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function FA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(qt(t,e))return;n.uniform2iv(this.addr,e),Xt(t,e)}}function VA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(qt(t,e))return;n.uniform3iv(this.addr,e),Xt(t,e)}}function BA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(qt(t,e))return;n.uniform4iv(this.addr,e),Xt(t,e)}}function zA(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function HA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(qt(t,e))return;n.uniform2uiv(this.addr,e),Xt(t,e)}}function GA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(qt(t,e))return;n.uniform3uiv(this.addr,e),Xt(t,e)}}function WA(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(qt(t,e))return;n.uniform4uiv(this.addr,e),Xt(t,e)}}function qA(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Xf.compareFunction=bg,s=Xf):s=Ug,t.setTexture2D(e||s,r)}function XA(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Fg,r)}function jA(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Vg,r)}function KA(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Og,r)}function YA(n){switch(n){case 5126:return RA;case 35664:return PA;case 35665:return LA;case 35666:return DA;case 35674:return NA;case 35675:return kA;case 35676:return UA;case 5124:case 35670:return OA;case 35667:case 35671:return FA;case 35668:case 35672:return VA;case 35669:case 35673:return BA;case 5125:return zA;case 36294:return HA;case 36295:return GA;case 36296:return WA;case 35678:case 36198:case 36298:case 36306:case 35682:return qA;case 35679:case 36299:case 36307:return XA;case 35680:case 36300:case 36308:case 36293:return jA;case 36289:case 36303:case 36311:case 36292:return KA}}function QA(n,e){n.uniform1fv(this.addr,e)}function ZA(n,e){const t=fo(e,this.size,2);n.uniform2fv(this.addr,t)}function JA(n,e){const t=fo(e,this.size,3);n.uniform3fv(this.addr,t)}function $A(n,e){const t=fo(e,this.size,4);n.uniform4fv(this.addr,t)}function e1(n,e){const t=fo(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function t1(n,e){const t=fo(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function n1(n,e){const t=fo(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function i1(n,e){n.uniform1iv(this.addr,e)}function r1(n,e){n.uniform2iv(this.addr,e)}function s1(n,e){n.uniform3iv(this.addr,e)}function o1(n,e){n.uniform4iv(this.addr,e)}function a1(n,e){n.uniform1uiv(this.addr,e)}function c1(n,e){n.uniform2uiv(this.addr,e)}function l1(n,e){n.uniform3uiv(this.addr,e)}function u1(n,e){n.uniform4uiv(this.addr,e)}function d1(n,e,t){const i=this.cache,r=e.length,s=Bl(t,r);qt(i,s)||(n.uniform1iv(this.addr,s),Xt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||Ug,s[o])}function h1(n,e,t){const i=this.cache,r=e.length,s=Bl(t,r);qt(i,s)||(n.uniform1iv(this.addr,s),Xt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||Fg,s[o])}function p1(n,e,t){const i=this.cache,r=e.length,s=Bl(t,r);qt(i,s)||(n.uniform1iv(this.addr,s),Xt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||Vg,s[o])}function f1(n,e,t){const i=this.cache,r=e.length,s=Bl(t,r);qt(i,s)||(n.uniform1iv(this.addr,s),Xt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||Og,s[o])}function _1(n){switch(n){case 5126:return QA;case 35664:return ZA;case 35665:return JA;case 35666:return $A;case 35674:return e1;case 35675:return t1;case 35676:return n1;case 5124:case 35670:return i1;case 35667:case 35671:return r1;case 35668:case 35672:return s1;case 35669:case 35673:return o1;case 5125:return a1;case 36294:return c1;case 36295:return l1;case 36296:return u1;case 35678:case 36198:case 36298:case 36306:case 35682:return d1;case 35679:case 36299:case 36307:return h1;case 35680:case 36300:case 36308:case 36293:return p1;case 36289:case 36303:case 36311:case 36292:return f1}}class m1{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=YA(t.type)}}class g1{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=_1(t.type)}}class v1{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(e,t[a.id],i)}}}const zu=/(\w+)(\])?(\[|\.)?/g;function Jf(n,e){n.seq.push(e),n.map[e.id]=e}function y1(n,e,t){const i=n.name,r=i.length;for(zu.lastIndex=0;;){const s=zu.exec(i),o=zu.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){Jf(t,l===void 0?new m1(a,n,e):new g1(a,n,e));break}else{let h=t.map[a];h===void 0&&(h=new v1(a),Jf(t,h)),t=h}}}class Qc{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);y1(s,o,this)}}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){const a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&i.push(o)}return i}}function $f(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const E1=37297;let T1=0;function b1(n,e){const t=n.split(` 3726`),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(` 3727`)}const e_=new it;function S1(n){ft._getMatrix(e_,ft.workingColorSpace,n);const e=`mat3( ${e_.elements.map(t=>t.toFixed(4))} )`;switch(ft.getTransfer(n)){case Ul:return[e,"LinearTransferOETF"];case St:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function t_(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` 3728 3729`+r+` 3730 3731`+b1(n.getShaderSource(e),o)}else return r}function A1(n,e){const t=S1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` 3732`)}function x1(n,e){let t;switch(e){case IE:t="Linear";break;case ME:t="Reinhard";break;case CE:t="Cineon";break;case RE:t="ACESFilmic";break;case LE:t="AgX";break;case DE:t="Neutral";break;case PE:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Mc=new O;function w1(){ft.getLuminanceCoefficients(Mc);const n=Mc.x.toFixed(4),e=Mc.y.toFixed(4),t=Mc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` 3733`)}function I1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter($o).join(` 3734`)}function M1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` 3735`)}function C1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),o=s.name;let a=1;s.type===n.FLOAT_MAT2&&(a=2),s.type===n.FLOAT_MAT3&&(a=3),s.type===n.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function $o(n){return n!==""}function n_(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function i_(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const R1=/^[ \t]*#include +<([\w\d./]+)>/gm;function Jd(n){return n.replace(R1,L1)}const P1=new Map;function L1(n,e){let t=st[e];if(t===void 0){const i=P1.get(e);if(i!==void 0)t=st[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Jd(t)}const D1=/#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 r_(n){return n.replace(D1,N1)}function N1(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function s_(n){let e=`precision ${n.precision} float; 3736 precision ${n.precision} int; 3737 precision ${n.precision} sampler2D; 3738 precision ${n.precision} samplerCube; 3739 precision ${n.precision} sampler3D; 3740 precision ${n.precision} sampler2DArray; 3741 precision ${n.precision} sampler2DShadow; 3742 precision ${n.precision} samplerCubeShadow; 3743 precision ${n.precision} sampler2DArrayShadow; 3744 precision ${n.precision} isampler2D; 3745 precision ${n.precision} isampler3D; 3746 precision ${n.precision} isamplerCube; 3747 precision ${n.precision} isampler2DArray; 3748 precision ${n.precision} usampler2D; 3749 precision ${n.precision} usampler3D; 3750 precision ${n.precision} usamplerCube; 3751 precision ${n.precision} usampler2DArray; 3752 `;return n.precision==="highp"?e+=` 3753#define HIGH_PRECISION`:n.precision==="mediump"?e+=` 3754#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=` 3755#define LOW_PRECISION`),e}function k1(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===lg?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===oE?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Ui&&(e="SHADOWMAP_TYPE_VSM"),e}function U1(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case js:case Ks:e="ENVMAP_TYPE_CUBE";break;case kl:e="ENVMAP_TYPE_CUBE_UV";break}return e}function O1(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Ks:e="ENVMAP_MODE_REFRACTION";break}return e}function F1(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case kh:e="ENVMAP_BLENDING_MULTIPLY";break;case xE:e="ENVMAP_BLENDING_MIX";break;case wE:e="ENVMAP_BLENDING_ADD";break}return e}function V1(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function B1(n,e,t,i){const r=n.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=k1(t),l=U1(t),d=O1(t),h=F1(t),p=V1(t),_=I1(t),g=M1(s),S=r.createProgram();let m,f,M=t.glslVersion?"#version "+t.glslVersion+` 3756`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter($o).join(` 3757`),m.length>0&&(m+=` 3758`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter($o).join(` 3759`),f.length>0&&(f+=` 3760`)):(m=[s_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionCl
vendor: 6,454 bytes, lines 3760-3762
3760ipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` 3761`].filter($o).join(` 3762`),f=[s_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IR
3762IDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==yr?"#define TONE_MAPPING":"",t.toneMapping!==yr?st.tonemapping_pars_fragment:"",t.toneMapping!==yr?x1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,A1("linearToOutputTexel",t.outputColorSpace),w1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` 3763`].filter($o).join(` 3764`)),o=Jd(o),o=n_(o,t),o=i_(o,t),a=Jd(a),a=n_(a,t),a=i_(a,t),o=r_(o),a=r_(a),t.isRawShaderMaterial!==!0&&(M=`#version 300 es 3765`,m=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` 3766`)+` 3767`+m,f=["#define varying in",t.glslVersion===gf?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===gf?"":"#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(` 3768`)+` 3769`+f);const w=M+m+o,b=M+f+a,R=$f(r,r.VERTEX_SHADER,w),P=$f(r,r.FRAGMENT_SHADER,b);r.attachShader(S,R),r.attachShader(S,P),t.index0AttributeName!==void 0?r.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S);function T(I){if(n.debug.checkShaderErrors){const D=r.getProgramInfoLog(S).trim(),C=r.getShaderInfoLog(R).trim(),W=r.getShaderInfoLog(P).trim();let Z=!0,Y=!0;if(r.getProgramParameter(S,r.LINK_STATUS)===!1)if(Z=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,S,R,P);else{const ce=t_(r,R,"vertex"),K=t_(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,r.VALIDATE_STATUS)+` 3770 3771Material Name: `+I.name+` 3772Material Type: `+I.type+` 3773 3774Program Info Log: `+D+` 3775`+ce+` 3776`+K)}else D!==""?console.warn("THREE.WebGLProgram: Program Info Log:",D):(C===""||W==="")&&(Y=!1);Y&&(I.diagnostics={runnable:Z,programLog:D,vertexShader:{log:C,prefix:m},fragmentShader:{log:W,prefix:f}})}r.deleteShader(R),r.deleteShader(P),A=new Qc(r,S),E=C1(r,S)}let A;this.getUniforms=function(){return A===void 0&&T(this),A};let E;this.getAttributes=function(){return E===void 0&&T(this),E};let y=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return y===!1&&(y=r.getProgramParameter(S,E1)),y},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=T1++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=R,this.fragmentShader=P,this}let z1=0;class H1{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new G1(e),t.set(e,i)),i}}class G1{constructor(e){this.id=z1++,this.code=e,this.usedTimes=0}}function W1(n,e,t,i,r,s,o){const a=new Wh,c=new H1,l=new Set,d=[],h=r.logarithmicDepthBuffer,p=r.vertexTextures;let _=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function S(E){return l.add(E),E===0?"uv":`uv${E}`}function m(E,y,I,D,C){const W=D.fog,Z=C.geometry,Y=E.isMeshStandardMaterial?D.environment:null,ce=(E.isMeshStandardMaterial?t:e).get(E.envMap||Y),K=ce&&ce.mapping===kl?ce.image.height:null,ue=g[E.type];E.precision!==null&&(_=r.getMaxPrecision(E.precision),_!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",_,"instead."));const ve=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ye=ve!==void 0?ve.length:0;let Oe=0;Z.morphAttributes.position!==void 0&&(Oe=1),Z.morphAttributes.normal!==void 0&&(Oe=2),Z.morphAttributes.color!==void 0&&(Oe=3);let Ve,J,re,De;if(ue){const _t=li[ue];Ve=_t.vertexShader,J=_t.fragmentShader}else Ve=E.vertexShader,J=E.fragmentShader,c.update(E),re=c.getVertexShaderID(E),De=c.getFragmentShaderID(E);const pe=n.getRenderTarget(),ze=n.state.buffers.depth.getReversed(),se=C.isInstancedMesh===!0,Ee=C.isBatchedMesh===!0,He=!!E.map,Ke=!!E.matcap,dt=!!ce,V=!!E.aoMap,Pt=!!E.lightMap,Ge=!!E.bumpMap,Ie=!!E.normalMap,Ce=!!E.displacementMap,ot=!!E.emissiveMap,Re=!!E.metalnessMap,U=!!E.roughnessMap,L=E.anisotropy>0,G=E.clearcoat>0,ee=E.dispersion>0,ie=E.iridescence>0,$=E.sheen>0,_e=E.transmission>0,ne=L&&!!E.anisotropyMap,fe=G&&!!E.clearcoatMap,tt=G&&!!E.clearcoatNormalMap,ae=G&&!!E.clearcoatRoughnessMap,we=ie&&!!E.iridescenceMap,Ue=ie&&!!E.iridescenceThicknessMap,Xe=$&&!!E.sheenColorMap,Ae=$&&!!E.sheenRoughnessMap,rt=!!E.specularMap,nt=!!E.specularColorMap,yt=!!E.specularIntensityMap,F=_e&&!!E.transmissionMap,me=_e&&!!E.thicknessMap,Q=!!E.gradientMap,te=!!E.alphaMap,be=E.alphaTest>0,Te=!!E.alphaHash,je=!!E.extensions;let Mt=yr;E.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(Mt=n.toneMapping);const Vt={shaderID:ue,shaderType:E.type,shaderName:E.name,vertexShader:Ve,fragmentShader:J,defines:E.defines,customVertexShaderID:re,customFragmentShaderID:De,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:_,batching:Ee,batchingColor:Ee&&C._colorsTexture!==null,instancing:se,instancingColor:se&&C.instanceColor!==null,instancingMorph:se&&C.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:pe===null?n.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:ho,alphaToCoverage:!!E.alphaToCoverage,map:He,matcap:Ke,envMap:dt,envMapMode:dt&&ce.mapping,envMapCubeUVHeight:K,aoMap:V,lightMap:Pt,bumpMap:Ge,normalMap:Ie,displacementMap:p&&Ce,emissiveMap:ot,normalMapObjectSpace:Ie&&E.normalMapType===OE,normalMapTangentSpace:Ie&&E.normalMapType===Tg,metalnessMap:Re,roughnessMap:U,anisotropy:L,anisotropyMap:ne,clearcoat:G,clearcoatMap:fe,clearcoatNormalMap:tt,clearcoatRoughnessMap:ae,dispersion:ee,iridescence:ie,iridescenceMap:we,iridescenceThicknessMap:Ue,sheen:$,sheenColorMap:Xe,sheenRoughnessMap:Ae,specularMap:rt,specularColorMap:nt,specularIntensityMap:yt,transmission:_e,transmissionMap:F,thicknessMap:me,gradientMap:Q,opaque:E.transparent===!1&&E.blending===Us&&E.alphaToCoverage===!1,alphaMap:te,alphaTest:be,alphaHash:Te,combine:E.combine,mapUv:He&&S(E.map.channel),aoMapUv:V&&S(E.aoMap.channel),lightMapUv:Pt&&S(E.lightMap.channel),bumpMapUv:Ge&&S(E.bumpMap.channel),normalMapUv:Ie&&S(E.normalMap.channel),displacementMapUv:Ce&&S(E.displacementMap.channel),emissiveMapUv:ot&&S(E.emissiveMap.channel),metalnessMapUv:Re&&S(E.metalnessMap.channel),roughnessMapUv:U&&S(E.roughnessMap.channel),anisotropyMapUv:ne&&S(E.anisotropyMap.channel),clearcoatMapUv:fe&&S(E.clearcoatMap.channel),clearcoatNormalMapUv:tt&&S(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&S(E.clearcoatRoughnessMap.channel),iridescenceMapUv:we&&S(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&S(E.iridescenceThicknessMap.channel),sheenColorMapUv:Xe&&S(E.sheenColorMap.channel),sheenRoughnessMapUv:Ae&&S(E.sheenRoughnessMap.channel),specularMapUv:rt&&S(E.specularMap.channel),specularColorMapUv:nt&&S(E.specularColorMap.channel),specularIntensityMapUv:yt&&S(E.specularIntensityMap.channel),transmissionMapUv:F&&S(E.transmissionMap.channel),thicknessMapUv:me&&S(E.thicknessMap.channel),alphaMapUv:te&&S(E.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(Ie||L),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:C.isPoints===!0&&!!Z.attributes.uv&&(He||te),fog:!!W,useFog:E.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ze,skinning:C.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:ye,morphTextureStride:Oe,numDirLights:y.directional.length,numPointLights:y.point.length,numSpotLights:y.spot.length,numSpotLightMaps:y.spotLightMap.length,numRectAreaLights:y.rectArea.length,numHemiLights:y.hemi.length,numDirLightShadows:y.directionalShadowMap.length,numPointLightShadows:y.pointShadowMap.length,numSpotLightShadows:y.spotShadowMap.length,numSpotLightShadowsWithMaps:y.numSpotLightShadowsWithMaps,numLightProbes:y.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:Mt,decodeVideoTexture:He&&E.map.isVideoTexture===!0&&ft.getTransfer(E.map.colorSpace)===St,decodeVideoTextureEmissive:ot&&E.emissiveMap.isVideoTexture===!0&&ft.getTransfer(E.emissiveMap.colorSpace)===St,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Oi,flipSided:E.side===bn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionCl
vendor: 24,892 bytes, lines 3776-3804
3776ipCullDistance:je&&E.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(je&&E.extensions.multiDraw===!0||Ee)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Vt.vertexUv1s=l.has(1),Vt.vertexUv2s=l.has(2),Vt.vertexUv3s=l.has(3),l.clear(),Vt}function f(E){const y=[];if(E.shaderID?y.push(E.shaderID):(y.push(E.customVertexShaderID),y.push(E.customFragmentShaderID)),E.defines!==void 0)for(const I in E.defines)y.push(I),y.push(E.defines[I]);return E.isRawShaderMaterial===!1&&(M(y,E),w(y,E),y.push(n.outputColorSpace)),y.push(E.customProgramCacheKey),y.join()}function M(E,y){E.push(y.precision),E.push(y.outputColorSpace),E.push(y.envMapMode),E.push(y.envMapCubeUVHeight),E.push(y.mapUv),E.push(y.alphaMapUv),E.push(y.lightMapUv),E.push(y.aoMapUv),E.push(y.bumpMapUv),E.push(y.normalMapUv),E.push(y.displacementMapUv),E.push(y.emissiveMapUv),E.push(y.metalnessMapUv),E.push(y.roughnessMapUv),E.push(y.anisotropyMapUv),E.push(y.clearcoatMapUv),E.push(y.clearcoatNormalMapUv),E.push(y.clearcoatRoughnessMapUv),E.push(y.iridescenceMapUv),E.push(y.iridescenceThicknessMapUv),E.push(y.sheenColorMapUv),E.push(y.sheenRoughnessMapUv),E.push(y.specularMapUv),E.push(y.specularColorMapUv),E.push(y.specularIntensityMapUv),E.push(y.transmissionMapUv),E.push(y.thicknessMapUv),E.push(y.combine),E.push(y.fogExp2),E.push(y.sizeAttenuation),E.push(y.morphTargetsCount),E.push(y.morphAttributeCount),E.push(y.numDirLights),E.push(y.numPointLights),E.push(y.numSpotLights),E.push(y.numSpotLightMaps),E.push(y.numHemiLights),E.push(y.numRectAreaLights),E.push(y.numDirLightShadows),E.push(y.numPointLightShadows),E.push(y.numSpotLightShadows),E.push(y.numSpotLightShadowsWithMaps),E.push(y.numLightProbes),E.push(y.shadowMapType),E.push(y.toneMapping),E.push(y.numClippingPlanes),E.push(y.numClipIntersection),E.push(y.depthPacking)}function w(E,y){a.disableAll(),y.supportsVertexTextures&&a.enable(0),y.instancing&&a.enable(1),y.instancingColor&&a.enable(2),y.instancingMorph&&a.enable(3),y.matcap&&a.enable(4),y.envMap&&a.enable(5),y.normalMapObjectSpace&&a.enable(6),y.normalMapTangentSpace&&a.enable(7),y.clearcoat&&a.enable(8),y.iridescence&&a.enable(9),y.alphaTest&&a.enable(10),y.vertexColors&&a.enable(11),y.vertexAlphas&&a.enable(12),y.vertexUv1s&&a.enable(13),y.vertexUv2s&&a.enable(14),y.vertexUv3s&&a.enable(15),y.vertexTangents&&a.enable(16),y.anisotropy&&a.enable(17),y.alphaHash&&a.enable(18),y.batching&&a.enable(19),y.dispersion&&a.enable(20),y.batchingColor&&a.enable(21),E.push(a.mask),a.disableAll(),y.fog&&a.enable(0),y.useFog&&a.enable(1),y.flatShading&&a.enable(2),y.logarithmicDepthBuffer&&a.enable(3),y.reverseDepthBuffer&&a.enable(4),y.skinning&&a.enable(5),y.morphTargets&&a.enable(6),y.morphNormals&&a.enable(7),y.morphColors&&a.enable(8),y.premultipliedAlpha&&a.enable(9),y.shadowMapEnabled&&a.enable(10),y.doubleSided&&a.enable(11),y.flipSided&&a.enable(12),y.useDepthPacking&&a.enable(13),y.dithering&&a.enable(14),y.transmission&&a.enable(15),y.sheen&&a.enable(16),y.opaque&&a.enable(17),y.pointsUvs&&a.enable(18),y.decodeVideoTexture&&a.enable(19),y.decodeVideoTextureEmissive&&a.enable(20),y.alphaToCoverage&&a.enable(21),E.push(a.mask)}function b(E){const y=g[E.type];let I;if(y){const D=li[y];I=IT.clone(D.uniforms)}else I=E.uniforms;return I}function R(E,y){let I;for(let D=0,C=d.length;D<C;D++){const W=d[D];if(W.cacheKey===y){I=W,++I.usedTimes;break}}return I===void 0&&(I=new B1(n,y,E,s),d.push(I)),I}function P(E){if(--E.usedTimes===0){const y=d.indexOf(E);d[y]=d[d.length-1],d.pop(),E.destroy()}}function T(E){c.remove(E)}function A(){c.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:b,acquireProgram:R,releaseProgram:P,releaseShaderCache:T,programs:d,dispose:A}}function q1(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function r(o,a,c){n.get(o)[a]=c}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function X1(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function o_(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function a_(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(h,p,_,g,S,m){let f=n[e];return f===void 0?(f={id:h.id,object:h,geometry:p,material:_,groupOrder:g,renderOrder:h.renderOrder,z:S,group:m},n[e]=f):(f.id=h.id,f.object=h,f.geometry=p,f.material=_,f.groupOrder=g,f.renderOrder=h.renderOrder,f.z=S,f.group=m),e++,f}function a(h,p,_,g,S,m){const f=o(h,p,_,g,S,m);_.transmission>0?i.push(f):_.transparent===!0?r.push(f):t.push(f)}function c(h,p,_,g,S,m){const f=o(h,p,_,g,S,m);_.transmission>0?i.unshift(f):_.transparent===!0?r.unshift(f):t.unshift(f)}function l(h,p){t.length>1&&t.sort(h||X1),i.length>1&&i.sort(p||o_),r.length>1&&r.sort(p||o_)}function d(){for(let h=e,p=n.length;h<p;h++){const _=n[h];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:d,sort:l}}function j1(){let n=new WeakMap;function e(i,r){const s=n.get(i);let o;return s===void 0?(o=new a_,n.set(i,[o])):r>=s.length?(o=new a_,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function K1(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new O,color:new ut};break;case"SpotLight":t={position:new O,direction:new O,color:new ut,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new ut,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new ut,groundColor:new ut};break;case"RectAreaLight":t={color:new ut,position:new O,halfWidth:new O,halfHeight:new O};break}return n[e.id]=t,t}}}function Y1(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Q1=0;function Z1(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function J1(n){const e=new K1,t=Y1(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new O);const r=new O,s=new wt,o=new wt;function a(l){let d=0,h=0,p=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let _=0,g=0,S=0,m=0,f=0,M=0,w=0,b=0,R=0,P=0,T=0;l.sort(Z1);for(let E=0,y=l.length;E<y;E++){const I=l[E],D=I.color,C=I.intensity,W=I.distance,Z=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=D.r*C,h+=D.g*C,p+=D.b*C;else if(I.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(I.sh.coefficients[Y],C);T++}else if(I.isDirectionalLight){const Y=e.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const ce=I.shadow,K=t.get(I);K.shadowIntensity=ce.intensity,K.shadowBias=ce.bias,K.shadowNormalBias=ce.normalBias,K.shadowRadius=ce.radius,K.shadowMapSize=ce.mapSize,i.directionalShadow[_]=K,i.directionalShadowMap[_]=Z,i.directionalShadowMatrix[_]=I.shadow.matrix,M++}i.directional[_]=Y,_++}else if(I.isSpotLight){const Y=e.get(I);Y.position.setFromMatrixPosition(I.matrixWorld),Y.color.copy(D).multiplyScalar(C),Y.distance=W,Y.coneCos=Math.cos(I.angle),Y.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),Y.decay=I.decay,i.spot[S]=Y;const ce=I.shadow;if(I.map&&(i.spotLightMap[R]=I.map,R++,ce.updateMatrices(I),I.castShadow&&P++),i.spotLightMatrix[S]=ce.matrix,I.castShadow){const K=t.get(I);K.shadowIntensity=ce.intensity,K.shadowBias=ce.bias,K.shadowNormalBias=ce.normalBias,K.shadowRadius=ce.radius,K.shadowMapSize=ce.mapSize,i.spotShadow[S]=K,i.spotShadowMap[S]=Z,b++}S++}else if(I.isRectAreaLight){const Y=e.get(I);Y.color.copy(D).multiplyScalar(C),Y.halfWidth.set(I.width*.5,0,0),Y.halfHeight.set(0,I.height*.5,0),i.rectArea[m]=Y,m++}else if(I.isPointLight){const Y=e.get(I);if(Y.color.copy(I.color).multiplyScalar(I.intensity),Y.distance=I.distance,Y.decay=I.decay,I.castShadow){const ce=I.shadow,K=t.get(I);K.shadowIntensity=ce.intensity,K.shadowBias=ce.bias,K.shadowNormalBias=ce.normalBias,K.shadowRadius=ce.radius,K.shadowMapSize=ce.mapSize,K.shadowCameraNear=ce.camera.near,K.shadowCameraFar=ce.camera.far,i.pointShadow[g]=K,i.pointShadowMap[g]=Z,i.pointShadowMatrix[g]=I.shadow.matrix,w++}i.point[g]=Y,g++}else if(I.isHemisphereLight){const Y=e.get(I);Y.skyColor.copy(I.color).multiplyScalar(C),Y.groundColor.copy(I.groundColor).multiplyScalar(C),i.hemi[f]=Y,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ge.LTC_FLOAT_1,i.rectAreaLTC2=ge.LTC_FLOAT_2):(i.rectAreaLTC1=ge.LTC_HALF_1,i.rectAreaLTC2=ge.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=p;const A=i.hash;(A.directionalLength!==_||A.pointLength!==g||A.spotLength!==S||A.rectAreaLength!==m||A.hemiLength!==f||A.numDirectionalShadows!==M||A.numPointShadows!==w||A.numSpotShadows!==b||A.numSpotMaps!==R||A.numLightProbes!==T)&&(i.directional.length=_,i.spot.length=S,i.rectArea.length=m,i.point.length=g,i.hemi.length=f,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=M,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=b+R-P,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=T,A.directionalLength=_,A.pointLength=g,A.spotLength=S,A.rectAreaLength=m,A.hemiLength=f,A.numDirectionalShadows=M,A.numPointShadows=w,A.numSpotShadows=b,A.numSpotMaps=R,A.numLightProbes=T,i.version=Q1++)}function c(l,d){let h=0,p=0,_=0,g=0,S=0;const m=d.matrixWorldInverse;for(let f=0,M=l.length;f<M;f++){const w=l[f];if(w.isDirectionalLight){const b=i.directional[h];b.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),h++}else if(w.isSpotLight){const b=i.spot[_];b.position.setFromMatrixPosition(w.matrixWorld),b.position.applyMatrix4(m),b.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),_++}else if(w.isRectAreaLight){const b=i.rectArea[g];b.position.setFromMatrixPosition(w.matrixWorld),b.position.applyMatrix4(m),o.identity(),s.copy(w.matrixWorld),s.premultiply(m),o.extractRotation(s),b.halfWidth.set(w.width*.5,0,0),b.halfHeight.set(0,w.height*.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),g++}else if(w.isPointLight){const b=i.point[p];b.position.setFromMatrixPosition(w.matrixWorld),b.position.applyMatrix4(m),p++}else if(w.isHemisphereLight){const b=i.hemi[S];b.direction.setFromMatrixPosition(w.matrixWorld),b.direction.transformDirection(m),S++}}}return{setup:a,setupView:c,state:i}}function c_(n){const e=new J1(n),t=[],i=[];function r(d){l.camera=d,t.length=0,i.length=0}function s(d){t.push(d)}function o(d){i.push(d)}function a(){e.setup(t)}function c(d){e.setupView(t,d)}const l={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function $1(n){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let a;return o===void 0?(a=new c_(n),e.set(r,[a])):s>=o.length?(a=new c_(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}class ex extends ns{static get type(){return"MeshDepthMaterial"}constructor(e){super(),this.isMeshDepthMaterial=!0,this.depthPacking=kE,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class tx extends ns{static get type(){return"MeshDistanceMaterial"}constructor(e){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const nx=`void main() { 3777 gl_Position = vec4( position, 1.0 ); 3778}`,ix=`uniform sampler2D shadow_pass; 3779uniform vec2 resolution; 3780uniform float radius; 3781#include <packing> 3782void main() { 3783 const float samples = float( VSM_SAMPLES ); 3784 float mean = 0.0; 3785 float squared_mean = 0.0; 3786 float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); 3787 float uvStart = samples <= 1.0 ? 0.0 : - 1.0; 3788 for ( float i = 0.0; i < samples; i ++ ) { 3789 float uvOffset = uvStart + i * uvStride; 3790 #ifdef HORIZONTAL_PASS 3791 vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); 3792 mean += distribution.x; 3793 squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; 3794 #else 3795 float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); 3796 mean += depth; 3797 squared_mean += depth * depth; 3798 #endif 3799 } 3800 mean = mean / samples; 3801 squared_mean = squared_mean / samples; 3802 float std_dev = sqrt( squared_mean - mean * mean ); 3803 gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); 3804}`;function rx(n,e,t){let i=new Fl;const r=new xe,s=new xe,o=new Ot,a=new ex({depthPacking:UE}),c=new tx,l={},d=t.maxTextureSize,h={[Er]:bn,[bn]:Er,[Oi]:Oi},p=new Tr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xe},radius:{value:4}},vertexShader:nx,fragmentShader:ix}),_=p.clone();_.defines.HORIZONTAL_PASS=1;const g=new An;g.setAttribute("position",new Gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Hi(g,p),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lg;let f=this.type;this.render=function(P,T,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||P.length===0)return;const E=n.getRenderTarget(),y=n.getActiveCubeFace(),I=n.getActiveMipmapLevel(),D=n.state;D.setBlending(vr),D.buffers.color.setClear(1,1,1,1),D.buffers.depth.setTest(!0),D.setScissorTest(!1);const C=f!==Ui&&this.type===Ui,W=f===Ui&&this.type!==Ui;for(let Z=0,Y=P.length;Z<Y;Z++){const ce=P[Z],K=ce.shadow;if(K===void 0){console.warn("THREE.WebGLShadowMap:",ce,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;r.copy(K.mapSize);const ue=K.getFrameExtents();if(r.multiply(ue),s.copy(K.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(s.x=Math.floor(d/ue.x),r.x=s.x*ue.x,K.mapSize.x=s.x),r.y>d&&(s.y=Math.floor(d/ue.y),r.y=s.y*ue.y,K.mapSize.y=s.y)),K.map===null||C===!0||W===!0){const ye=this.type!==Ui?{minFilter:ri,magFilter:ri}:{};K.map!==null&&K.map.dispose(),K.map=new Yr(r.x,r.y,ye),K.map.texture.name=ce.name+".shadowMap",K.camera.updateProjectionMatrix()}n.setRenderTarget(K.map),n.clear();const ve=K.getViewportCount();for(let ye=0;ye<ve;ye++){const Oe=K.getViewport(ye);o.set(s.x*Oe.x,s.y*Oe.y,s.x*Oe.z,s.y*Oe.w),D.viewport(o),K.updateMatrices(ce,ye),i=K.getFrustum(),b(T,A,K.camera,ce,this.type)}K.isPointLightShadow!==!0&&this.type===Ui&&M(K,A),K.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(E,y,I)};function M(P,T){const A=e.update(S);p.defines.VSM_SAMPLES!==P.blurSamples&&(p.defines.VSM_SAMPLES=P.blurSamples,_.defines.VSM_SAMPLES=P.blurSamples,p.needsUpdate=!0,_.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Yr(r.x,r.y)),p.uniforms.shadow_pass.value=P.map.texture,p.uniforms.resolution.value=P.mapSize,p.uniforms.radius.value=P.radius,n.setRenderTarget(P.mapPass),n.clear(),n.renderBufferDirect(T,null,A,p,S,null),_.uniforms.shadow_pass.value=P.mapPass.texture,_.uniforms.resolution.value=P.mapSize,_.uniforms.radius.value=P.radius,n.setRenderTarget(P.map),n.clear(),n.renderBufferDirect(T,null,A,_,S,null)}function w(P,T,A,E){let y=null;const I=A.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(I!==void 0)y=I;else if(y=A.isPointLight===!0?c:a,n.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){const D=y.uuid,C=T.uuid;let W=l[D];W===void 0&&(W={},l[D]=W);let Z=W[C];Z===void 0&&(Z=y.clone(),W[C]=Z,T.addEventListener("dispose",R)),y=Z}if(y.visible=T.visible,y.wireframe=T.wireframe,E===Ui?y.side=T.shadowSide!==null?T.shadowSide:T.side:y.side=T.shadowSide!==null?T.shadowSide:h[T.side],y.alphaMap=T.alphaMap,y.alphaTest=T.alphaTest,y.map=T.map,y.clipShadows=T.clipShadows,y.clippingPlanes=T.clippingPlanes,y.clipIntersection=T.clipIntersection,y.displacementMap=T.displacementMap,y.displacementScale=T.displacementScale,y.displacementBias=T.displacementBias,y.wireframeLinewidth=T.wireframeLinewidth,y.linewidth=T.linewidth,A.isPointLight===!0&&y.isMeshDistanceMaterial===!0){const D=n.properties.get(y);D.light=A}return y}function b(P,T,A,E,y){if(P.visible===!1)return;if(P.layers.test(T.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&y===Ui)&&(!P.frustumCulled||i.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,P.matrixWorld);const C=e.update(P),W=P.material;if(Array.isArray(W)){const Z=C.groups;for(let Y=0,ce=Z.length;Y<ce;Y++){const K=Z[Y],ue=W[K.materialIndex];if(ue&&ue.visible){const ve=w(P,ue,E,y);P.onBeforeShadow(n,P,T,A,C,ve,K),n.renderBufferDirect(A,null,C,ve,P,K),P.onAfterShadow(n,P,T,A,C,ve,K)}}}else if(W.visible){const Z=w(P,W,E,y);P.onBeforeShadow(n,P,T,A,C,Z,null),n.renderBufferDirect(A,null,C,Z,P,null),P.onAfterShadow(n,P,T,A,C,Z,null)}}const D=P.children;for(let C=0,W=D.length;C<W;C++)b(D[C],T,A,E,y)}function R(P){P.target.removeEventListener("dispose",R);for(const A in l){const E=l[A],y=P.target.uuid;y in E&&(E[y].dispose(),delete E[y])}}}const sx={[fd]:_d,[md]:yd,[gd]:Ed,[Xs]:vd,[_d]:fd,[yd]:md,[Ed]:gd,[vd]:Xs};function ox(n,e){function t(){let F=!1;const me=new Ot;let Q=null;const te=new Ot(0,0,0,0);return{setMask:function(be){Q!==be&&!F&&(n.colorMask(be,be,be,be),Q=be)},setLocked:function(be){F=be},setClear:function(be,Te,je,Mt,Vt){Vt===!0&&(be*=Mt,Te*=Mt,je*=Mt),me.set(be,Te,je,Mt),te.equals(me)===!1&&(n.clearColor(be,Te,je,Mt),te.copy(me))},reset:function(){F=!1,Q=null,te.set(-1,0,0,0)}}}function i(){let F=!1,me=!1,Q=null,te=null,be=null;return{setReversed:function(Te){if(me!==Te){const je=e.get("EXT_clip_control");me?je.clipControlEXT(je.LOWER_LEFT_EXT,je.ZERO_TO_ONE_EXT):je.clipControlEXT(je.LOWER_LEFT_EXT,je.NEGATIVE_ONE_TO_ONE_EXT);const Mt=be;be=null,this.setClear(Mt)}me=Te},getReversed:function(){return me},setTest:function(Te){Te?pe(n.DEPTH_TEST):ze(n.DEPTH_TEST)},setMask:function(Te){Q!==Te&&!F&&(n.depthMask(Te),Q=Te)},setFunc:function(Te){if(me&&(Te=sx[Te]),te!==Te){switch(Te){case fd:n.depthFunc(n.NEVER);break;case _d:n.depthFunc(n.ALWAYS);break;case md:n.depthFunc(n.LESS);break;case Xs:n.depthFunc(n.LEQUAL);break;case gd:n.depthFunc(n.EQUAL);break;case vd:n.depthFunc(n.GEQUAL);break;case yd:n.depthFunc(n.GREATER);break;case Ed:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}te=Te}},setLocked:function(Te){F=Te},setClear:function(Te){be!==Te&&(me&&(Te=1-Te),n.clearDepth(Te),be=Te)},reset:function(){F=!1,Q=null,te=null,be=null,me=!1}}}function r(){let F=!1,me=null,Q=null,te=null,be=null,Te=null,je=null,Mt=null,Vt=null;return{setTest:function(_t){F||(_t?pe(n.STENCIL_TEST):ze(n.STENCIL_TEST))},setMask:function(_t){me!==_t&&!F&&(n.stencilMask(_t),me=_t)},setFunc:function(_t,Jt,Un){(Q!==_t||te!==Jt||be!==Un)&&(n.stencilFunc(_t,Jt,Un),Q=_t,te=Jt,be=Un)},setOp:function(_t,Jt,Un){(Te!==_t||je!==Jt||Mt!==Un)&&(n.stencilOp(_t,Jt,Un),Te=_t,je=Jt,Mt=Un)},setLocked:function(_t){F=_t},setClear:function(_t){Vt!==_t&&(n.clearStencil(_t),Vt=_t)},reset:function(){F=!1,me=null,Q=null,te=null,be=null,Te=null,je=null,Mt=null,Vt=null}}}const s=new t,o=new i,a=new r,c=new WeakMap,l=new WeakMap;let d={},h={},p=new WeakMap,_=[],g=null,S=!1,m=null,f=null,M=null,w=null,b=null,R=null,P=null,T=new ut(0,0,0),A=0,E=!1,y=null,I=null,D=null,C=null,W=null;const Z=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,ce=0;const K=n.getParameter(n.VERSION);K.indexOf("WebGL")!==-1?(ce=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=ce>=1):K.indexOf("OpenGL ES")!==-1&&(ce=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=ce>=2);let ue=null,ve={};const ye=n.getParameter(n.SCISSOR_BOX),Oe=n.getParameter(n.VIEWPORT),Ve=new Ot().fromArray(ye),J=new Ot().fromArray(Oe);function re(F,me,Q,te){const be=new Uint8Array(4),Te=n.createTexture();n.bindTexture(F,Te),n.texParameteri(F,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(F,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let je=0;je<Q;je++)F===n.TEXTURE_3D||F===n.TEXTURE_2D_ARRAY?n.texImage3D(me,0,n.RGBA,1,1,te,0,n.RGBA,n.UNSIGNED_BYTE,be):n.texImage2D(me+je,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,be);return Te}const De={};De[n.TEXTURE_2D]=re(n.TEXTURE_2D,n.TEXTURE_2D,1),De[n.TEXTURE_CUBE_MAP]=re(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),De[n.TEXTURE_2D_ARRAY]=re(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),De[n.TEXTURE_3D]=re(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),pe(n.DEPTH_TEST),o.setFunc(Xs),Ge(!1),Ie(hf),pe(n.CULL_FACE),V(vr);function pe(F){d[F]!==!0&&(n.enable(F),d[F]=!0)}function ze(F){d[F]!==!1&&(n.disable(F),d[F]=!1)}function se(F,me){return h[F]!==me?(n.bindFramebuffer(F,me),h[F]=me,F===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=me),F===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=me),!0):!1}function Ee(F,me){let Q=_,te=!1;if(F){Q=p.get(me),Q===void 0&&(Q=[],p.set(me,Q));const be=F.textures;if(Q.length!==be.length||Q[0]!==n.COLOR_ATTACHMENT0){for(let Te=0,je=be.length;Te<je;Te++)Q[Te]=n.COLOR_ATTACHMENT0+Te;Q.length=be.length,te=!0}}else Q[0]!==n.BACK&&(Q[0]=n.BACK,te=!0);te&&n.drawBuffers(Q)}function He(F){return g!==F?(n.useProgram(F),g=F,!0):!1}const Ke={[Fr]:n.FUNC_ADD,[cE]:n.FUNC_SUBTRACT,[lE]:n.FUNC_REVERSE_SUBTRACT};Ke[uE]=n.MIN,Ke[dE]=n.MAX;const dt={[hE]:n.ZERO,[pE]:n.ONE,[fE]:n.SRC_COLOR,[hd]:n.SRC_ALPHA,[EE]:n.SRC_ALPHA_SATURATE,[vE]:n.DST_COLOR,[mE]:n.DST_ALPHA,[_E]:n.ONE_MINUS_SRC_COLOR,[pd]:n.ONE_MINUS_SRC_ALPHA,[yE]:n.ONE_MINUS_DST_COLOR,[gE]:n.ONE_MINUS_DST_ALPHA,[TE]:n.CONSTANT_COLOR,[bE]:n.ONE_MINUS_CONSTANT_COLOR,[SE]:n.CONSTANT_ALPHA,[AE]:n.ONE_MINUS_CONSTANT_ALPHA};function V(F,me,Q,te,be,Te,je,Mt,Vt,_t){if(F===vr){S===!0&&(ze(n.BLEND),S=!1);return}if(S===!1&&(pe(n.BLEND),S=!0),F!==aE){if(F!==m||_t!==E){if((f!==Fr||b!==Fr)&&(n.blendEquation(n.FUNC_ADD),f=Fr,b=Fr),_t)switch(F){case Us:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.ONE,n.ONE);break;case ff:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case _f:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}else switch(F){case Us:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case pf:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case ff:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case _f:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}M=null,w=null,R=null,P=null,T.set(0,0,0),A=0,m=F,E=_t}return}be=be||me,Te=Te||Q,je=je||te,(me!==f||be!==b)&&(n.blendEquationSeparate(Ke[me],Ke[be]),f=me,b=be),(Q!==M||te!==w||Te!==R||je!==P)&&(n.blendFuncSeparate(dt[Q],dt[te],dt[Te],dt[je]),M=Q,w=te,R=Te,P=je),(Mt.equals(T)===!1||Vt!==A)&&(n.blendColor
vendor: 3,424 bytes, line 3804
3804(Mt.r,Mt.g,Mt.b,Vt),T.copy(Mt),A=Vt),m=F,E=!1}function Pt(F,me){F.side===Oi?ze(n.CULL_FACE):pe(n.CULL_FACE);let Q=F.side===bn;me&&(Q=!Q),Ge(Q),F.blending===Us&&F.transparent===!1?V(vr):V(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);const te=F.stencilWrite;a.setTest(te),te&&(a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass)),ot(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?pe(n.SAMPLE_ALPHA_TO_COVERAGE):ze(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ge(F){y!==F&&(F?n.frontFace(n.CW):n.frontFace(n.CCW),y=F)}function Ie(F){F!==rE?(pe(n.CULL_FACE),F!==I&&(F===hf?n.cullFace(n.BACK):F===sE?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ze(n.CULL_FACE),I=F}function Ce(F){F!==D&&(Y&&n.lineWidth(F),D=F)}function ot(F,me,Q){F?(pe(n.POLYGON_OFFSET_FILL),(C!==me||W!==Q)&&(n.polygonOffset(me,Q),C=me,W=Q)):ze(n.POLYGON_OFFSET_FILL)}function Re(F){F?pe(n.SCISSOR_TEST):ze(n.SCISSOR_TEST)}function U(F){F===void 0&&(F=n.TEXTURE0+Z-1),ue!==F&&(n.activeTexture(F),ue=F)}function L(F,me,Q){Q===void 0&&(ue===null?Q=n.TEXTURE0+Z-1:Q=ue);let te=ve[Q];te===void 0&&(te={type:void 0,texture:void 0},ve[Q]=te),(te.type!==F||te.texture!==me)&&(ue!==Q&&(n.activeTexture(Q),ue=Q),n.bindTexture(F,me||De[F]),te.type=F,te.texture=me)}function G(){const F=ve[ue];F!==void 0&&F.type!==void 0&&(n.bindTexture(F.type,null),F.type=void 0,F.texture=void 0)}function ee(){try{n.compressedTexImage2D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function ie(){try{n.compressedTexImage3D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function $(){try{n.texSubImage2D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function _e(){try{n.texSubImage3D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function ne(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function fe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function tt(){try{n.texStorage2D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function ae(){try{n.texStorage3D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function we(){try{n.texImage2D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Ue(){try{n.texImage3D.apply(n,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Xe(F){Ve.equals(F)===!1&&(n.scissor(F.x,F.y,F.z,F.w),Ve.copy(F))}function Ae(F){J.equals(F)===!1&&(n.viewport(F.x,F.y,F.z,F.w),J.copy(F))}function rt(F,me){let Q=l.get(me);Q===void 0&&(Q=new WeakMap,l.set(me,Q));let te=Q.get(F);te===void 0&&(te=n.getUniformBlockIndex(me,F.name),Q.set(F,te))}function nt(F,me){const te=l.get(me).get(F);c.get(me)!==te&&(n.uniformBlockBinding(me,te,F.__bindingPointIndex),c.set(me,te))}function yt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor
vendor: 41,388 bytes, lines 3804-3828
3804(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},ue=null,ve={},h={},p=new WeakMap,_=[],g=null,S=!1,m=null,f=null,M=null,w=null,b=null,R=null,P=null,T=new ut(0,0,0),A=0,E=!1,y=null,I=null,D=null,C=null,W=null,Ve.set(0,0,n.canvas.width,n.canvas.height),J.set(0,0,n.canvas.width,n.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:pe,disable:ze,bindFramebuffer:se,drawBuffers:Ee,useProgram:He,setBlending:V,setMaterial:Pt,setFlipSided:Ge,setCullFace:Ie,setLineWidth:Ce,setPolygonOffset:ot,setScissorTest:Re,activeTexture:U,bindTexture:L,unbindTexture:G,compressedTexImage2D:ee,compressedTexImage3D:ie,texImage2D:we,texImage3D:Ue,updateUBOMapping:rt,uniformBlockBinding:nt,texStorage2D:tt,texStorage3D:ae,texSubImage2D:$,texSubImage3D:_e,compressedTexSubImage2D:ne,compressedTexSubImage3D:fe,scissor:Xe,viewport:Ae,reset:yt}}function l_(n,e,t,i){const r=ax(i);switch(t){case fg:return n*e;case mg:return n*e;case gg:return n*e*2;case vg:return n*e/r.components*r.byteLength;case Vh:return n*e/r.components*r.byteLength;case yg:return n*e*2/r.components*r.byteLength;case Bh:return n*e*2/r.components*r.byteLength;case _g:return n*e*3/r.components*r.byteLength;case ei:return n*e*4/r.components*r.byteLength;case zh:return n*e*4/r.components*r.byteLength;case qc:case Xc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case jc:case Kc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case wd:case Md:return Math.max(n,16)*Math.max(e,8)/4;case xd:case Id:return Math.max(n,8)*Math.max(e,8)/2;case Cd:case Rd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Pd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ld:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Dd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Nd:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case kd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Ud:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Od:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Fd:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Vd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Bd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case zd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Hd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Gd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Wd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case qd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Yc:case Xd:case jd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Eg:case Kd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Yd:case Qd:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ax(n){switch(n){case Yi:case dg:return{byteLength:1,components:1};case ya:case hg:case Ba:return{byteLength:2,components:1};case Oh:case Fh:return{byteLength:2,components:4};case Kr:case Uh:case Bi:return{byteLength:4,components:1};case pg:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}function cx(n,e,t,i,r,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xe,d=new WeakMap;let h;const p=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(U,L){return _?new OffscreenCanvas(U,L):Ta("canvas")}function S(U,L,G){let ee=1;const ie=Re(U);if((ie.width>G||ie.height>G)&&(ee=G/Math.max(ie.width,ie.height)),ee<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const $=Math.floor(ee*ie.width),_e=Math.floor(ee*ie.height);h===void 0&&(h=g($,_e));const ne=L?g($,_e):h;return ne.width=$,ne.height=_e,ne.getContext("2d").drawImage(U,0,0,$,_e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+$+"x"+_e+")."),ne}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+")."),U;return U}function m(U){return U.generateMipmaps}function f(U){n.generateMipmap(U)}function M(U){return U.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?n.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function w(U,L,G,ee,ie=!1){if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let $=L;if(L===n.RED&&(G===n.FLOAT&&($=n.R32F),G===n.HALF_FLOAT&&($=n.R16F),G===n.UNSIGNED_BYTE&&($=n.R8)),L===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&($=n.R8UI),G===n.UNSIGNED_SHORT&&($=n.R16UI),G===n.UNSIGNED_INT&&($=n.R32UI),G===n.BYTE&&($=n.R8I),G===n.SHORT&&($=n.R16I),G===n.INT&&($=n.R32I)),L===n.RG&&(G===n.FLOAT&&($=n.RG32F),G===n.HALF_FLOAT&&($=n.RG16F),G===n.UNSIGNED_BYTE&&($=n.RG8)),L===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&($=n.RG8UI),G===n.UNSIGNED_SHORT&&($=n.RG16UI),G===n.UNSIGNED_INT&&($=n.RG32UI),G===n.BYTE&&($=n.RG8I),G===n.SHORT&&($=n.RG16I),G===n.INT&&($=n.RG32I)),L===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&($=n.RGB8UI),G===n.UNSIGNED_SHORT&&($=n.RGB16UI),G===n.UNSIGNED_INT&&($=n.RGB32UI),G===n.BYTE&&($=n.RGB8I),G===n.SHORT&&($=n.RGB16I),G===n.INT&&($=n.RGB32I)),L===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&($=n.RGBA8UI),G===n.UNSIGNED_SHORT&&($=n.RGBA16UI),G===n.UNSIGNED_INT&&($=n.RGBA32UI),G===n.BYTE&&($=n.RGBA8I),G===n.SHORT&&($=n.RGBA16I),G===n.INT&&($=n.RGBA32I)),L===n.RGB&&G===n.UNSIGNED_INT_5_9_9_9_REV&&($=n.RGB9_E5),L===n.RGBA){const _e=ie?Ul:ft.getTransfer(ee);G===n.FLOAT&&($=n.RGBA32F),G===n.HALF_FLOAT&&($=n.RGBA16F),G===n.UNSIGNED_BYTE&&($=_e===St?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT_4_4_4_4&&($=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&($=n.RGB5_A1)}return($===n.R16F||$===n.R32F||$===n.RG16F||$===n.RG32F||$===n.RGBA16F||$===n.RGBA32F)&&e.get("EXT_color_buffer_float"),$}function b(U,L){let G;return U?L===null||L===Kr||L===Ys?G=n.DEPTH24_STENCIL8:L===Bi?G=n.DEPTH32F_STENCIL8:L===ya&&(G=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Kr||L===Ys?G=n.DEPTH_COMPONENT24:L===Bi?G=n.DEPTH_COMPONENT32F:L===ya&&(G=n.DEPTH_COMPONENT16),G}function R(U,L){return m(U)===!0||U.isFramebufferTexture&&U.minFilter!==ri&&U.minFilter!==di?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function P(U){const L=U.target;L.removeEventListener("dispose",P),A(L),L.isVideoTexture&&d.delete(L)}function T(U){const L=U.target;L.removeEventListener("dispose",T),y(L)}function A(U){const L=i.get(U);if(L.__webglInit===void 0)return;const G=U.source,ee=p.get(G);if(ee){const ie=ee[L.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&E(U),Object.keys(ee).length===0&&p.delete(G)}i.remove(U)}function E(U){const L=i.get(U);n.deleteTexture(L.__webglTexture);const G=U.source,ee=p.get(G);delete ee[L.__cacheKey],o.memory.textures--}function y(U){const L=i.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),i.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(L.__webglFramebuffer[ee]))for(let ie=0;ie<L.__webglFramebuffer[ee].length;ie++)n.deleteFramebuffer(L.__webglFramebuffer[ee][ie]);else n.deleteFramebuffer(L.__webglFramebuffer[ee]);L.__webglDepthbuffer&&n.deleteRenderbuffer(L.__webglDepthbuffer[ee])}else{if(Array.isArray(L.__webglFramebuffer))for(let ee=0;ee<L.__webglFramebuffer.length;ee++)n.deleteFramebuffer(L.__webglFramebuffer[ee]);else n.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&n.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&n.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ee=0;ee<L.__webglColorRenderbuffer.length;ee++)L.__webglColorRenderbuffer[ee]&&n.deleteRenderbuffer(L.__webglColorRenderbuffer[ee]);L.__webglDepthRenderbuffer&&n.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const G=U.textures;for(let ee=0,ie=G.length;ee<ie;ee++){const $=i.get(G[ee]);$.__webglTexture&&(n.deleteTexture($.__webglTexture),o.memory.textures--),i.remove(G[ee])}i.remove(U)}let I=0;function D(){I=0}function C(){const U=I;return U>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+r.maxTextures),I+=1,U}function W(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function Z(U,L){const G=i.get(U);if(U.isVideoTexture&&Ce(U),U.isRenderTargetTexture===!1&&U.version>0&&G.__version!==U.version){const ee=U.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{J(G,U,L);return}}t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+L)}function Y(U,L){const G=i.get(U);if(U.version>0&&G.__version!==U.version){J(G,U,L);return}t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+L)}function ce(U,L){const G=i.get(U);if(U.version>0&&G.__version!==U.version){J(G,U,L);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+L)}function K(U,L){const G=i.get(U);if(U.version>0&&G.__version!==U.version){re(G,U,L);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+L)}const ue={[Sd]:n.REPEAT,[Br]:n.CLAMP_TO_EDGE,[Ad]:n.MIRRORED_REPEAT},ve={[ri]:n.NEAREST,[NE]:n.NEAREST_MIPMAP_NEAREST,[cc]:n.NEAREST_MIPMAP_LINEAR,[di]:n.LINEAR,[_u]:n.LINEAR_MIPMAP_NEAREST,[zr]:n.LINEAR_MIPMAP_LINEAR},ye={[FE]:n.NEVER,[WE]:n.ALWAYS,[VE]:n.LESS,[bg]:n.LEQUAL,[BE]:n.EQUAL,[GE]:n.GEQUAL,[zE]:n.GREATER,[HE]:n.NOTEQUAL};function Oe(U,L){if(L.type===Bi&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===di||L.magFilter===_u||L.magFilter===cc||L.magFilter===zr||L.minFilter===di||L.minFilter===_u||L.minFilter===cc||L.minFilter===zr)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(U,n.TEXTURE_WRAP_S,ue[L.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,ue[L.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,ue[L.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,ve[L.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,ve[L.minFilter]),L.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,ye[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ri||L.minFilter!==cc&&L.minFilter!==zr||L.type===Bi&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||i.get(L).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(U,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,r.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy}}}function Ve(U,L){let G=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",P));const ee=L.source;let ie=p.get(ee);ie===void 0&&(ie={},p.set(ee,ie));const $=W(L);if($!==U.__cacheKey){ie[$]===void 0&&(ie[$]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,G=!0),ie[$].usedTimes++;const _e=ie[U.__cacheKey];_e!==void 0&&(ie[U.__cacheKey].usedTimes--,_e.usedTimes===0&&E(L)),U.__cacheKey=$,U.__webglTexture=ie[$].texture}return G}function J(U,L,G){let ee=n.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ee=n.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ee=n.TEXTURE_3D);const ie=Ve(U,L),$=L.source;t.bindTexture(ee,U.__webglTexture,n.TEXTURE0+G);const _e=i.get($);if($.version!==_e.__version||ie===!0){t.activeTexture(n.TEXTURE0+G);const ne=ft.getPrimaries(ft.workingColorSpace),fe=L.colorSpace===pr?null:ft.getPrimaries(L.colorSpace),tt=L.colorSpace===pr||ne===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,L.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,L.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,tt);let ae=S(L.image,!1,r.maxTextureSize);ae=ot(L,ae);const we=s.convert(L.format,L.colorSpace),Ue=s.convert(L.type);let Xe=w(L.internalFormat,we,Ue,L.colorSpace,L.isVideoTexture);Oe(ee,L);let Ae;const rt=L.mipmaps,nt=L.isVideoTexture!==!0,yt=_e.__version===void 0||ie===!0,F=$.dataReady,me=R(L,ae);if(L.isDepthTexture)Xe=b(L.format===Qs,L.type),yt&&(nt?t.texStorage2D(n.TEXTURE_2D,1,Xe,ae.width,ae.height):t.texImage2D(n.TEXTURE_2D,0,Xe,ae.width,ae.height,0,we,Ue,null));else if(L.isDataTexture)if(rt.length>0){nt&&yt&&t.texStorage2D(n.TEXTURE_2D,me,Xe,rt[0].width,rt[0].height);for(let Q=0,te=rt.length;Q<te;Q++)Ae=rt[Q],nt?F&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,Ae.width,Ae.height,we,Ue,Ae.data):t.texImage2D(n.TEXTURE_2D,Q,Xe,Ae.width,Ae.height,0,we,Ue,Ae.data);L.generateMipmaps=!1}else nt?(yt&&t.texStorage2D(n.TEXTURE_2D,me,Xe,ae.width,ae.height),F&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ae.width,ae.height,we,Ue,ae.data)):t.texImage2D(n.TEXTURE_2D,0,Xe,ae.width,ae.height,0,we,Ue,ae.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){nt&&yt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Xe,rt[0].width,rt[0].height,ae.depth);for(let Q=0,te=rt.length;Q<te;Q++)if(Ae=rt[Q],L.format!==ei)if(we!==null)if(nt){if(F)if(L.layerUpdates.size>0){const be=l_(Ae.width,Ae.height,L.format,L.type);for(const Te of L.layerUpdates){const je=Ae.data.subarray(Te*be/Ae.data.BYTES_PER_ELEMENT,(Te+1)*be/Ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,Te,Ae.width,Ae.height,1,we,je)}L.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,Ae.width,Ae.height,ae.depth,we,Ae.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Q,Xe,Ae.width,Ae.height,ae.depth,0,Ae.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else nt?F&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,Ae.width,Ae.height,ae.depth,we,Ue,Ae.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Q,Xe,Ae.width,Ae.height,ae.depth,0,we,Ue,Ae.data)}else{nt&&yt&&t.texStorage2D(n.TEXTURE_2D,me,Xe,rt[0].width,rt[0].height);for(let Q=0,te=rt.length;Q<te;Q++)Ae=rt[Q],L.format!==ei?we!==null?nt?F&&t.compressedTexSubImage2D(n.TEXTURE_2D,Q,0,0,Ae.width,Ae.height,we,Ae.data):t.compressedTexImage2D(n.TEXTURE_2D,Q,Xe,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?F&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,Ae.width,Ae.height,we,Ue,Ae.data):t.texImage2D(n.TEXTURE_2D,Q,Xe,Ae.width,Ae.height,0,we,Ue,Ae.data)}else if(L.isDataArrayTexture)if(nt){if(yt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Xe,ae.width,ae.height,ae.depth),F)if(L.layerUpdates.size>0){const Q=l_(ae.width,ae.height,L.format,L.type);for(const te of L.layerUpdates){const be=ae.data.subarray(te*Q/ae.data.BYTES_PER_ELEMENT,(te+1)*Q/ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,te,ae.width,ae.height,1,we,Ue,be)}L.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,we,Ue,ae.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Xe,ae.width,ae.height,ae.depth,0,we,Ue,ae.data);else if(L.isData3DTexture)nt?(yt&&t.texStorage3D(n.TEXTURE_3D,me,Xe,ae.width,ae.height,ae.depth),F&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,we,Ue,ae.data)):t.texImage3D(n.TEXTURE_3D,0,Xe,ae.width,ae.height,ae.depth,0,we,Ue,ae.data);else if(L.isFramebufferTexture){if(yt)if(nt)t.texStorage2D(n.TEXTURE_2D,me,Xe,ae.width,ae.height);else{let Q=ae.width,te=ae.height;for(let be=0;be<me;be++)t.texImage2D(n.TEXTURE_2D,be,Xe,Q,te,0,we,Ue,null),Q>>=1,te>>=1}}else if(rt.length>0){if(nt&&yt){const Q=Re(rt[0]);t.texStorage2D(n.TEXTURE_2D,me,Xe,Q.width,Q.height)}for(let Q=0,te=rt.length;Q<te;Q++)Ae=rt[Q],nt?F&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,we,Ue,Ae):t.texImage2D(n.TEXTURE_2D,Q,Xe,we,Ue,Ae);L.generateMipmaps=!1}else if(nt){if(yt){const Q=Re(ae);t.texStorage2D(n.TEXTURE_2D,me,Xe,Q.width,Q.height)}F&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,we,Ue,ae)}else t.texImage2D(n.TEXTURE_2D,0,Xe,we,Ue,ae);m(L)&&f(ee),_e.__version=$.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function re(U,L,G){if(L.image.length!==6)return;const ee=Ve(U,L),ie=L.source;t.bindTexture(n.TEXTURE_CUBE_MAP,U.__webglTexture,n.TEXTURE0+G);const $=i.get(ie);if(ie.version!==$.__version||ee===!0){t.activeTexture(n.TEXTURE0+G);const _e=ft.getPrimaries(ft.workingColorSpace),ne=L.colorSpace===pr?null:ft.getPrimaries(L.colorSpace),fe=L.colorSpace===pr||_e===ne?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,L.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,L.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,fe);const tt=L.isCompressedTexture||L.image[0].isCompressedTexture,ae=L.image[0]&&L.image[0].isDataTexture,we=[];for(let te=0;te<6;te++)!tt&&!ae?we[te]=S(L.image[te],!0,r.maxCubemapSize):we[te]=ae?L.image[te].image:L.image[te],we[te]=ot(L,we[te]);const Ue=we[0],Xe=s.convert(L.format,L.colorSpace),Ae=s.convert(L.type),rt=w(L.internalFormat,Xe,Ae,L.colorSpace),nt=L.isVideoTexture!==!0,yt=$.__version===void 0||ee===!0,F=ie.dataReady;let me=R(L,Ue);Oe(n.TEXTURE_CUBE_MAP,L);let Q;if(tt){nt&&yt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,me,rt,Ue.width,Ue.height);for(let te=0;te<6;te++){Q=we[te].mipmaps;for(let be=0;be<Q.length;be++){const Te=Q[be];L.format!==ei?Xe!==null?nt?F&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be,0,0,Te.width,Te.height,Xe,Te.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be,rt,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?F&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be,0,0,Te.width,Te.height,Xe,Ae,Te.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be,rt,Te.width,Te.height,0,Xe,Ae,Te.data)}}}else{if(Q=L.mipmaps,nt&&yt){Q.length>0&&me++;const te=Re(we[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,me,rt,te.width,te.height)}for(let te=0;te<6;te++)if(ae){nt?F&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,we[te].width,we[te].height,Xe,Ae,we[te].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,rt,we[te].width,we[te].height,0,Xe,Ae,we[te].data);for(let be=0;be<Q.length;be++){const je=Q[be].image[te].image;nt?F&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be+1,0,0,je.width,je.height,Xe,Ae,je.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be+1,rt,je.width,je.height,0,Xe,Ae,je.data)}}else{nt?F&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Xe,Ae,we[te]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,rt,Xe,Ae,we[te]);for(let be=0;be<Q.length;be++){const Te=Q[be];nt?F&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be+1,0,0,Xe,Ae,Te.image[te]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+te,be+1,rt,Xe,Ae,Te.image[te])}}}m(L)&&f(n.TEXTURE_CUBE_MAP),$.__version=ie.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function De(U,L,G,ee,ie,$){const _e=s.convert(G.format,G.colorSpace),ne=s.convert(G.type),fe=w(G.internalFormat,_e,ne,G.colorSpace),tt=i.get(L),ae=i.get(G);if(ae.__renderTarget=L,!tt.__hasExternalTextures){const we=Math.max(1,L.width>>$),Ue=Math.max(1,L.height>>$);ie===n.TEXTURE_3D||ie===n.TEXTURE_2D_ARRAY?t.texImage3D(ie,$,fe,we,Ue,L.depth,0,_e,ne,null):t.texImage2D(ie,$,fe,we,Ue,0,_e,ne,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),Ie(L)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ee,ie,ae.__webglTexture,0,Ge(L)):(ie===n.TEXTURE_2D||ie>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ee,ie,ae.__webglTexture,$),t.bindFramebuffer(n.FRAMEBUFFER,null)}function pe(U,L,G){if(n.bindRenderbuffer(n.RENDERBUFFER,U),L.depthBuffer){const ee=L.depthTexture,ie=ee&&ee.isDepthTexture?ee.type:null,$=b(L.stencilBuffer,ie),_e=L.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ne=Ge(L);Ie(L)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ne,$,L.width,L.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ne,$,L.width,L.height):n.renderbufferStorage(n.RENDERBUFFER,$,L.width,L.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,_e,n.RENDERBUFFER,U)}else{const ee=L.textures;for(let ie=0;ie<ee.length;ie++){const $=ee[ie],_e=s.convert($.format,$.colorSpace),ne=s.convert($.type),fe=w($.internalFormat,_e,ne,$.colorSpace),tt=Ge(L);G&&Ie(L)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,tt,fe,L.width,L.height):Ie(L)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,tt,fe,L.width,L.height):n.renderbufferStorage(n.RENDERBUFFER,fe,L.width,L.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ze(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ee=i.get(L.depthTexture);ee.__renderTarget=L,(!ee.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),Z(L.depthTexture,0);const ie=ee.__webglTexture,$=Ge(L);if(L.depthTexture.format===Os)Ie(L)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ie,0,$):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ie,0);else if(L.depthTexture.format===Qs)Ie(L)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ie,0,$):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ie,0);else throw new Error("Unknown depthTexture format")}function se(U){const L=i.get(U),G=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const ee=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ee){const ie=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ee.removeEventListener("dispose",ie)};ee.addEventListener("dispose",ie),L.__depthDisposeCallback=ie}L.__boundDepthTexture=ee}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");ze(L.__webglFramebuffer,U)}else if(G){L.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)if(t.bindFramebuffer(n.FRAMEBUFFER,L.__webglFramebuffer[ee]),L.__webglDepthbuffer[ee]===void 0)L.__webglDepthbuffer[ee]=n.createRenderbuffer(),pe(L.__webglDepthbuffer[ee],U,!1);else{const ie=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,$=L.__webglDepthbuffer[ee];n.bindRenderbuffer(n.RENDERBUFFER,$),n.framebufferRenderbuffer(n.FRAMEBUFFER,ie,n.RENDERBUFFER,$)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=n.createRenderbuffer(),pe(L.__webglDepthbuffer,U,!1);else{const ee=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ie=L.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,ie),n.framebufferRenderbuffer(n.FRAMEBUFFER,ee,n.RENDERBUFFER,ie)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ee(U,L,G){const ee=i.get(U);L!==void 0&&De(ee.__webglFramebuffer,U,U.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&se(U)}function He(U){const L=U.texture,G=i.get(U),ee=i.get(L);U.addEventListener("dispose",T);const ie=U.textures,$=U.isWebGLCubeRenderTarget===!0,_e=ie.length>1;if(_e||(ee.__webglTexture===void 0&&(ee.__webglTexture=n.createTexture()),ee.__version=L.version,o.memory.textures++),$){G.__webglFramebuffer=[];for(let ne=0;ne<6;ne++)if(L.mipmaps&&L.mipmaps.length>0){G.__webglFramebuffer[ne]=[];for(let fe=0;fe<L.mipmaps.length;fe++)G.__webglFramebuffer[ne][fe]=n.createFramebuffer()}else G.__webglFramebuffer[ne]=n.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){G.__webglFramebuffer=[];for(let ne=0;ne<L.mipmaps.length;ne++)G.__webglFramebuffer[ne]=n.createFramebuffer()}else G.__webglFramebuffer=n.createFramebuffer();if(_e)for(let ne=0,fe=ie.length;ne<fe;ne++){const tt=i.get(ie[ne]);tt.__webglTexture===void 0&&(tt.__webglTexture=n.createTexture(),o.memory.textures++)}if(U.samples>0&&Ie(U)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let ne=0;ne<ie.length;ne++){const fe=ie[ne];G.__webglColorRenderbuffer[ne]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[ne]);const tt=s.convert(fe.format,fe.colorSpace),ae=s.convert(fe.type),we=w(fe.internalFormat,tt,ae,fe.colorSpace,U.isXRRenderTarget===!0),Ue=Ge(U);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ue,we,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ne,n.RENDERBUFFER,G.__webglColorRenderbuffer[ne])}n.bindRenderbuffer(n.RENDERBUFFER,null),U.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),pe(G.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if($){t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture),Oe(n.TEXTURE_CUBE_MAP,L);for(let ne=0;ne<6;ne++)if(L.mipmaps&&L.mipmaps.length>0)for(let fe=0;fe<L.mipmaps.length;fe++)De(G.__webglFramebuffer[ne][fe],U,L,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,fe);else De(G.__webglFramebuffer[ne],U,L,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0);m(L)&&f(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let ne=0,fe=ie.length;ne<fe;ne++){const tt=ie[ne],ae=i.get(tt);t.bindTexture(n.TEXTURE_2D,ae.__webglTexture),Oe(n.TEXTURE_2D,tt),De(G.__webglFramebuffer,U,tt,n.COLOR_ATTACHMENT0+ne,n.TEXTURE_2D,0),m(tt)&&f(n.TEXTURE_2D)}t.unbindTexture()}else{let ne=n.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ne=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ne,ee.__webglTexture),Oe(ne,L),L.mipmaps&&L.mipmaps.length>0)for(let fe=0;fe<L.mipmaps.length;fe++)De(G.__webglFramebuffer[fe],U,L,n.COLOR_ATTACHMENT0,ne,fe);else De(G.__webglFramebuffer,U,L,n.COLOR_ATTACHMENT0,ne,0);m(L)&&f(ne),t.unbindTexture()}U.depthBuffer&&se(U)}function Ke(U){const L=U.textures;for(let G=0,ee=L.length;G<ee;G++){const ie=L[G];if(m(ie)){const $=M(U),_e=i.get(ie).__webglTexture;t.bindTexture($,_e),f($),t.unbindTexture()}}}const dt=[],V=[];function Pt(U){if(U.samples>0){if(Ie(U)===!1){const L=U.textures,G=U.width,ee=U.height;let ie=n.COLOR_BUFFER_BIT;const $=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=i.get(U),ne=L.length>1;if(ne)for(let fe=0;fe<L.length;fe++)t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let fe=0;fe<L.length;fe++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ie|=n.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ie|=n.STENCIL_BUFFER_BIT)),ne){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,_e.__webglColorRenderbuffer[fe]);const tt=i.get(L[fe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,tt,0)}n.blitFramebuffer(0,0,G,ee,0,0,G,ee,ie,n.NEAREST),c===!0&&(dt.length=0,V.length=0,dt.push(n.COLOR_ATTACHMENT0+fe),U.depthBuffer&&U.resolveDepthBuffer===!1&&(dt.push($),V.push($),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,V)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,dt))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ne)for(let fe=0;fe<L.length;fe++){t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,_e.__webglColorRenderbuffer[fe]);const tt=i.get(L[fe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,tt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){const L=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[L])}}}function Ge(U){return Math.min(r.maxSamples,U.samples)}function Ie(U){const L=i.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ce(U){const L=o.render.frame;d.get(U)!==L&&(d.set(U,L),U.update())}function ot(U,L){const G=U.colorSpace,ee=U.format,ie=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||G!==ho&&G!==pr&&(ft.getTransfer(G)===St?(ee!==ei||ie!==Yi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),L}function Re(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(l.width=U.naturalWidth||U.width,l.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(l.width=U.displayWidth,l.height=U.displayHeight):(l.width=U.width,l.height=U.height),l}this.allocateTextureUnit=C,this.resetTextureUnits=D,this.setTexture2D=Z,this.setTexture2DArray=Y,this.setTexture3D=ce,this.setTextureCube=K,this.rebindTextures=Ee,this.setupRenderTarget=He,this.updateRenderTargetMipmap=Ke,this.updateMultisampleRenderTarget=Pt,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=De,this.useMultisampledRTT=Ie}function lx(n,e){function t(i,r=pr){let s;const o=ft.getTransfer(r);if(i===Yi)return n.UNSIGNED_BYTE;if(i===Oh)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Fh)return n.UNSIGNED_SHORT_5_5_5_1;if(i===pg)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===dg)return n.BYTE;if(i===hg)return n.SHORT;if(i===ya)return n.UNSIGNED_SHORT;if(i===Uh)return n.INT;if(i===Kr)return n.UNSIGNED_INT;if(i===Bi)return n.FLOAT;if(i===Ba)return n.HALF_FLOAT;if(i===fg)return n.ALPHA;if(i===_g)return n.RGB;if(i===ei)return n.RGBA;if(i===mg)return n.LUMINANCE;if(i===gg)return n.LUMINANCE_ALPHA;if(i===Os)return n.DEPTH_COMPONENT;if(i===Qs)return n.DEPTH_STENCIL;if(i===vg)return n.RED;if(i===Vh)return n.RED_INTEGER;if(i===yg)return n.RG;if(i===Bh)return n.RG_INTEGER;if(i===zh)return n.RGBA_INTEGER;if(i===qc||i===Xc||i===jc||i===Kc)if(o===St)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===qc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Xc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===jc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Kc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===qc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Xc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===jc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Kc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===xd||i===wd||i===Id||i===Md)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===xd)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===wd)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Id)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Md)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Cd||i===Rd||i===Pd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Cd||i===Rd)return o===St?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Pd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Ld||i===Dd||i===Nd||i===kd||i===Ud||i===Od||i===Fd||i===Vd||i===Bd||i===zd||i===Hd||i===Gd||i===Wd||i===qd)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Ld)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Dd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Nd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===kd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ud)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Od)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Fd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Vd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Bd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===zd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Gd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Wd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===qd)return o===St?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Yc||i===Xd||i===jd)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Yc)return o===St?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Xd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===jd)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Eg||i===Kd||i===Yd||i===Qd)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Yc)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Kd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Yd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Qd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ys?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}class ux extends Jn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}let Cc=class extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}};const dx={type:"move"};class Hu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Cc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Cc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Cc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const S of e.hand.values()){const m=t.getJointPose(S,i),f=this._getHandJoint(l,S);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const d=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],p=d.position.distanceTo(h.position),_=.02,g=.005;l.inputState.pinching&&p>_+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&p<=_-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(dx)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Cc;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const hx=` 3805void main() { 3806 3807 gl_Position = vec4( position, 1.0 ); 3808 3809}`,px=` 3810uniform sampler2DArray depthColor; 3811uniform float depthWidth; 3812uniform float depthHeight; 3813 3814void main() { 3815 3816 vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); 3817 3818 if ( coord.x >= 1.0 ) { 3819 3820 gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; 3821 3822 } else { 3823 3824 gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; 3825 3826 } 3827 3828}`;class fx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new vn,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Tr({vertexShader:hx,fragmentShader:px,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Hi(new Vl(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class _x extends ts{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",c=1,l=null,d=null,h=null,p=null,_=null,g=null;const S=new fx,m=t.getContextAttributes();let f=null,M=null;const w=[],b=[],R=new xe;let P=null;const T=new Jn;T.viewport=new Ot;const A=new Jn;A.viewport=new Ot;const E=[T,A],y=new ux;let I=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let re=w[J];return re===void 0&&(re=new Hu,w[J]=re),re.getTargetRaySpace()},this.getControllerGrip=function(J){let re=w[J];return re===void 0&&(re=new Hu,w[J]=re),re.getGripSpace()},this.getHand=function(J){let re=w[J];return re===void 0&&(re=new Hu,w[J]=re),re.getHandSpace()};function C(J){const re=b.indexOf(J.inputSource);if(re===-1)return;const De=w[re];De!==void 0&&(De.update(J.inputSource,J.frame,l||o),De.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){r.removeEventListener("select",C),r.removeEventListener("selectstart",C),r.removeEventListener("selectend",C),r.removeEventListener("squeeze",C),r.removeEventListener("squeezestart",C),r.removeEventListener("squeezeend",C),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",Z);for(let J=0;J<w.length;J++){const re=b[J];re!==null&&(b[J]=null,w[J].disconnect(re))}I=null,D=null,S.reset(),e.setRenderTarget(f),_=null,p=null,h=null,r=null,M=null,Ve.stop(),i.isPresenting=!1,e.setPixelRatio(P),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){a=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(J){l=J},this.getBaseLayer=function(){return p!==null?p:_},this.getBinding=function(){return h},this.getFrame=function(){return g}
vendor: 5,878 bytes, line 3828
3828,this.getSession=function(){return r},this.setSession=async function(J){if(r=J,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",W),r.addEventListener("inputsourceschange",Z),m.xrCompatible!==!0&&await t.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(R),r.renderState.layers===void 0){const re={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};_=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:_}),e.setPixelRatio(1),e.setSize(_.framebufferWidth,_.framebufferHeight,!1),M=new Yr(_.framebufferWidth,_.framebufferHeight,{format:ei,type:Yi,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let re=null,De=null,pe=null;m.depth&&(pe=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=m.stencil?Qs:Os,De=m.stencil?Ys:Kr);const ze={colorFormat:t.RGBA8,depthFormat:pe,scaleFactor:s};h=new XRWebGLBinding(r,t),p=h.createProjectionLayer(ze),r.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),M=new Yr(p.textureWidth,p.textureHeight,{format:ei,type:Yi,depthTexture:new kg(p.textureWidth,p.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),Ve.setContext(r),Ve.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return S.getDepthTexture()};function Z(J){for(let re=0;re<J.removed.length;re++){const De=J.removed[re],pe=b.indexOf(De);pe>=0&&(b[pe]=null,w[pe].disconnect(De))}for(let re=0;re<J.added.length;re++){const De=J.added[re];let pe=b.indexOf(De);if(pe===-1){for(let se=0;se<w.length;se++)if(se>=b.length){b.push(De),pe=se;break}else if(b[se]===null){b[se]=De,pe=se;break}if(pe===-1)break}const ze=w[pe];ze&&ze.connect(De)}}const Y=new O,ce=new O;function K(J,re,De){Y.setFromMatrixPosition(re.matrixWorld),ce.setFromMatrixPosition(De.matrixWorld);const pe=Y.distanceTo(ce),ze=re.projectionMatrix.elements,se=De.projectionMatrix.elements,Ee=ze[14]/(ze[10]-1),He=ze[14]/(ze[10]+1),Ke=(ze[9]+1)/ze[5],dt=(ze[9]-1)/ze[5],V=(ze[8]-1)/ze[0],Pt=(se[8]+1)/se[0],Ge=Ee*V,Ie=Ee*Pt,Ce=pe/(-V+Pt),ot=Ce*-V;if(re.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(ot),J.translateZ(Ce),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ze[10]===-1)J.projectionMatrix.copy(re.projectionMatrix),J.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Re=Ee+Ce,U=He+Ce,L=Ge-ot,G=Ie+(pe-ot),ee=Ke*He/U*Re,ie=dt*He/U*Re;J.projectionMatrix.makePerspective(L,G,ee,ie,Re,U),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function ue(J,re){re===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(re.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;let re=J.near,De=J.far;S.texture!==null&&(S.depthNear>0&&(re=S.depthNear),S.depthFar>0&&(De=S.depthFar)),y.near=A.near=T.near=re,y.far=A.far=T.far=De,(I!==y.near||D!==y.far)&&(r.updateRenderState({depthNear:y.near,depthFar:y.far}),I=y.near,D=y.far),T.layers.mask=J.layers.mask|2,A.layers.mask=J.layers.mask|4,y.layers.mask=T.layers.mask|A.layers.mask;const pe=J.parent,ze=y.cameras;ue(y,pe);for(let se=0;se<ze.length;se++)ue(ze[se],pe);ze.length===2?K(y,T,A):y.projectionMatrix.copy(T.projectionMatrix),ve(J,y,pe)};function ve(J,re,De){De===null?J.matrix.copy(re.matrixWorld):(J.matrix.copy(De.matrixWorld),J.matrix.invert(),J.matrix.multiply(re.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(re.projectionMatrix),J.projectionMatrixInverse.copy(re.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=Ea*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return y},this.getFoveation=function(){if(!(p===null&&_===null))return c},this.setFoveation=function(J){c=J,p!==null&&(p.fixedFoveation=J),_!==null&&_.fixedFoveation!==void 0&&(_.fixedFoveation=J)},this.hasDepthSensing=function(){return S.texture!==null},this.getDepthSensingMesh=function(){return S.getMesh(y)};let ye=null;function Oe(J,re){if(d=re.getViewerPose(l||o),g=re,d!==null){const De=d.views;_!==null&&(e.setRenderTargetFramebuffer(M,_.framebuffer),e.setRenderTarget(M));let pe=!1;De.length!==y.cameras.length&&(y.cameras.length=0,pe=!0);for(let se=0;se<De.length;se++){const Ee=De[se];let He=null;if(_!==null)He=_.getViewport(Ee);else{const dt=h.getViewSubImage(p,Ee);He=dt.viewport,se===0&&(e.setRenderTargetTextures(M,dt.colorTexture,p.ignoreDepthValues?void 0:dt.depthStencilTexture),e.setRenderTarget(M))}let Ke=E[se];Ke===void 0&&(Ke=new Jn,Ke.layers.enable(se),Ke.viewport=new Ot,E[se]=Ke),Ke.matrix.fromArray(Ee.transform.matrix),Ke.matrix.decompose(Ke.position,Ke.quaternion,Ke.scale),Ke.projectionMatrix.fromArray(Ee.projectionMatrix),Ke.projectionMatrixInverse.copy(Ke.projectionMatrix).invert(),Ke.viewport.set(He.x,He.y,He.width,He.height),se===0&&(y.matrix.copy(Ke.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale)),pe===!0&&y.cameras.push(Ke)}const ze=r.enabledFeatures;if(ze&&ze.includes("depth-sensing")){const se=h.getDepthInformation(De[0]);se&&se.isValid&&se.texture&&S.init(e,se,r.renderState)}}for(let De=0;De<w.length;De++){const pe=b[De],ze=w[De];pe!==null&&ze!==void 0&&ze.update(pe,re,l||o)}ye&&ye(J,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),g=null}const Ve=new Dg;
vendor: 40,847 bytes, line 3828
3828Ve.setAnimationLoop(Oe),this.setAnimationLoop=function(J){ye=J},this.dispose=function(){}}}const Nr=new vi,mx=new wt;function gx(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function i(m,f){f.color.getRGB(m.fogColor.value,Rg(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,M,w,b){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),h(m,f)):f.isMeshPhongMaterial?(s(m,f),d(m,f)):f.isMeshStandardMaterial?(s(m,f),p(m,f),f.isMeshPhysicalMaterial&&_(m,f,b)):f.isMeshMatcapMaterial?(s(m,f),g(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),S(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(o(m,f),f.isLineDashedMaterial&&a(m,f)):f.isPointsMaterial?c(m,f,M,w):f.isSpriteMaterial?l(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===bn&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===bn&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const M=e.get(f),w=M.envMap,b=M.envMapRotation;w&&(m.envMap.value=w,Nr.copy(b),Nr.x*=-1,Nr.y*=-1,Nr.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Nr.y*=-1,Nr.z*=-1),m.envMapRotation.value.setFromMatrix4(mx.makeRotationFromEuler(Nr)),m.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function o(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function a(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function c(m,f,M,w){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*M,m.scale.value=w*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function l(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function d(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function p(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function _(m,f,M){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===bn&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=M.texture,m.transmissionSamplerSize.value.set(M.width,M.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function S(m,f){const M=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(M.matrixWorld),m.nearDistance.value=M.shadow.camera.near,m.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function vx(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,w){const b=w.program;i.uniformBlockBinding(M,b)}function l(M,w){let b=r[M.id];b===void 0&&(g(M),b=d(M),r[M.id]=b,M.addEventListener("dispose",m));const R=w.program;i.updateUBOMapping(M,R);const P=e.render.frame;s[M.id]!==P&&(p(M),s[M.id]=P)}function d(M){const w=h();M.__bindingPointIndex=w;const b=n.createBuffer(),R=M.__size,P=M.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,R,P),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,w,b),b}function h(){for(let M=0;M<a;M++)if(o.indexOf(M)===-1)return o.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(M){const w=r[M.id],b=M.uniforms,R=M.__cache;n.bindBuffer(n.UNIFORM_BUFFER,w);for(let P=0,T=b.length;P<T;P++){const A=Array.isArray(b[P])?b[P]:[b[P]];for(let E=0,y=A.length;E<y;E++){const I=A[E];if(_(I,P,E,R)===!0){const D=I.__offset,C=Array.isArray(I.value)?I.value:[I.value];let W=0;for(let Z=0;Z<C.length;Z++){const Y=C[Z],ce=S(Y);typeof Y=="number"||typeof Y=="boolean"?(I.__data[0]=Y,n.bufferSubData(n.UNIFORM_BUFFER,D+W,I.__data)):Y.isMatrix3?(I.__data[0]=Y.elements[0],I.__data[1]=Y.elements[1],I.__data[2]=Y.elements[2],I.__data[3]=0,I.__data[4]=Y.elements[3],I.__data[5]=Y.elements[4],I.__data[6]=Y.elements[5],I.__data[7]=0,I.__data[8]=Y.elements[6],I.__data[9]=Y.elements[7],I.__data[10]=Y.elements[8],I.__data[11]=0):(Y.toArray(I.__data,W),W+=ce.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,D,I.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function _(M,w,b,R){const P=M.value,T=w+"_"+b;if(R[T]===void 0)return typeof P=="number"||typeof P=="boolean"?R[T]=P:R[T]=P.clone(),!0;{const A=R[T];if(typeof P=="number"||typeof P=="boolean"){if(A!==P)return R[T]=P,!0}else if(A.equals(P)===!1)return A.copy(P),!0}return!1}function g(M){const w=M.uniforms;let b=0;const R=16;for(let T=0,A=w.length;T<A;T++){const E=Array.isArray(w[T])?w[T]:[w[T]];for(let y=0,I=E.length;y<I;y++){const D=E[y],C=Array.isArray(D.value)?D.value:[D.value];for(let W=0,Z=C.length;W<Z;W++){const Y=C[W],ce=S(Y),K=b%R,ue=K%ce.boundary,ve=K+ue;b+=ue,ve!==0&&R-ve<ce.storage&&(b+=R-ve),D.__data=new Float32Array(ce.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=b,b+=ce.storage}}}const P=b%R;return P>0&&(b+=R-P),M.__size=b,M.__cache={},this}function S(M){const w={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),w}function m(M){const w=M.target;w.removeEventListener("dispose",m);const b=o.indexOf(w.__bindingPointIndex);o.splice(b,1),n.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function f(){for(const M in r)n.deleteBuffer(r[M]);o=[],r={},s={}}return{bind:c,update:l,dispose:f}}class rk{constructor(e={}){const{canvas:t=aT(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let _;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=i.getContextAttributes().alpha}else _=o;const g=new Uint32Array(4),S=new Int32Array(4);let m=null,f=null;const M=[],w=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Vn,this.toneMapping=yr,this.toneMappingExposure=1;const b=this;let R=!1,P=0,T=0,A=null,E=-1,y=null;const I=new Ot,D=new Ot;let C=null;const W=new ut(0);let Z=0,Y=t.width,ce=t.height,K=1,ue=null,ve=null;const ye=new Ot(0,0,Y,ce),Oe=new Ot(0,0,Y,ce);let Ve=!1;const J=new Fl;let re=!1,De=!1;const pe=new wt,ze=new wt,se=new O,Ee=new Ot,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function dt(){return A===null?K:1}let V=i;function Pt(k,B){return t.getContext(k,B)}try{const k={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Nh}`),t.addEventListener("webglcontextlost",te,!1),t.addEventListener("webglcontextrestored",be,!1),t.addEventListener("webglcontextcreationerror",Te,!1),V===null){const B="webgl2";if(V=Pt(B,k),V===null)throw Pt(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let Ge,Ie,Ce,ot,Re,U,L,G,ee,ie,$,_e,ne,fe,tt,ae,we,Ue,Xe,Ae,rt,nt,yt,F;function me(){Ge=new AA(V),Ge.init(),nt=new lx(V,Ge),Ie=new vA(V,Ge,e,nt),Ce=new ox(V,Ge),Ie.reverseDepthBuffer&&p&&Ce.buffers.depth.setReversed(!0),ot=new IA(V),Re=new q1,U=new cx(V,Ge,Ce,Re,Ie,nt,ot),L=new EA(b),G=new SA(b),ee=new NT(V),yt=new mA(V,ee),ie=new xA(V,ee,ot,yt),$=new CA(V,ie,ee,ot),Xe=new MA(V,Ie,U),ae=new yA(Re),_e=new W1(b,L,G,Ge,Ie,yt,ae),ne=new gx(b,Re),fe=new j1,tt=new $1(Ge),Ue=new _A(b,L,G,Ce,$,_,c),we=new rx(b,$,Ie),F=new vx(V,ot,Ie,Ce),Ae=new gA(V,Ge,ot),rt=new wA(V,Ge,ot),ot.programs=_e.programs,b.capabilities=Ie,b.extensions=Ge,b.properties=Re,b.renderLists=fe,b.shadowMap=we,b.state=Ce,b.info=ot}me();const Q=new _x(b,V);this.xr=Q,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const k=Ge.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=Ge.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(k){k!==void 0&&(K=k,this.setSize(Y,ce,!1))},this.getSize=function(k){return k.set(Y,ce)},this.setSize=function(k,B,q=!0){if(Q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=k,ce=B,t.width=Math.floor(k*K),t.height=Math.floor(B*K),q===!0&&(t.style.width=k+"px",t.style.height=B+"px"),this.setViewport(0,0,k,B)},this.getDrawingBufferSize=function(k){return k.set(Y*K,ce*K).floor()},this.setDrawingBufferSize=function(k,B,q){Y=k,ce=B,K=q,t.width=Math.floor(k*q),t.height=Math.floor(B*q),this.setViewport(0,0,k,B)},this.getCurrentViewport=function(k){return k.copy(I)},this.getViewport=function(k){return k.copy(ye)},this.setViewport=function(k,B,q,X){k.isVector4?ye.set(k.x,k.y,k.z,k.w):ye.set(k,B,q,X),Ce.viewport(I.copy(ye).multiplyScalar(K).round())},this.getScissor=function(k){return k.copy(Oe)},this.setScissor=function(k,B,q,X){k.isVector4?Oe.set(k.x,k.y,k.z,k.w):Oe.set(k,B,q,X),Ce.scissor(D.copy(Oe).multiplyScalar(K).round())},this.getScissorTest=function(){return Ve},this.setScissorTest=function(k){Ce.setScissorTest(Ve=k)},this.setOpaqueSort=function(k){ue=k},this.setTransparentSort=function(k){ve=k},this.getClearColor=function(k){return k.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor.apply(Ue,arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha.apply(Ue,arguments)},this.clear=function(k=!0,B=!0,q=!0){let X=0;if(k){let z=!1;if(A!==null){const de=A.texture.format;z=de===zh||de===Bh||de===Vh}if(z){const de=A.texture.type,Se=de===Yi||de===Kr||de===ya||de===Ys||de===Oh||de===Fh,Pe=Ue.getClearColor(),Ne=Ue.getClearAlpha(),Ye=Pe.r,Ze=Pe.g,Me=Pe.b;Se?(g[0]=Ye,g[1]=Ze,g[2]=Me,g[3]=Ne,V.clearBufferuiv(V.COLOR,0,g)):(S[0]=Ye,S[1]=Ze,S[2]=Me,S[3]=Ne,V.clearBufferiv(V.COLOR,0,S))}else X|=V.COLOR_BUFFER_BIT}B&&(X|=V.DEPTH_BUFFER_BIT),q&&(X|=V.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",te,!1),t.removeEventListener("webglcontextrestored",be,!1),t.removeEventListener("webglcontextcreationerror",Te,!1),fe.dispose(),tt.dispose(),Re.dispose(),L.dispose(),G.dispose(),$.dispose(),yt.dispose(),F.dispose(),_e.dispose(),Q.dispose(),Q.removeEventListener("sessionstart",jt),Q.removeEventListener("sessionend",bo),wn.stop()};function te(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),R=!0}function be(){console.log("THREE.WebGLRenderer: Context Restored."),R=!1;const k=ot.autoReset,B=we.enabled,q=we.autoUpdate,X=we.needsUpdate,z=we.type;me(),ot.autoReset=k,we.enabled=B,we.autoUpdate=q,we.needsUpdate=X,we.type=z}function Te(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function je(k){const B=k.target;B.removeEventListener("dispose",je),Mt(B)}function Mt(k){Vt(k),Re.remove(k)}function Vt(k){const B=Re.get(k).programs;B!==void 0&&(B.forEach(function(q){_e.releaseProgram(q)}),k.isShaderMaterial&&_e.releaseShaderCache(k))}this.renderBufferDirect=function(k,B,q,X,z,de){B===null&&(B=He);const Se=z.isMesh&&z.matrixWorld.determinant()<0,Pe=Ao(k,B,q,X,z);Ce.setMaterial(X,Se);let Ne=q.index,Ye=1;if(X.wireframe===!0){if(Ne=ie.getWireframeAttribute(q),Ne===void 0)return;Ye=2}const Ze=q.drawRange,Me=q.attributes.position;let at=Ze.start*Ye,Et=(Ze.start+Ze.count)*Ye;de!==null&&(at=Math.max(at,de.start*Ye),Et=Math.min(Et,(de.start+de.count)*Ye)),Ne!==null?(at=Math.max(at,0),Et=Math.min(Et,Ne.count)):Me!=null&&(at=Math.max(at,0),Et=Math.min(Et,Me.count));const Tt=Et-at;if(Tt<0||Tt===1/0)return;yt.setup(z,X,Pe,q,Ne);let $t,ht=Ae;if(Ne!==null&&($t=ee.get(Ne),ht=rt,ht.setIndex($t)),z.isMesh)X.wireframe===!0?(Ce.setLineWidth(X.wireframeLinewidth*dt()),ht.setMode(V.LINES)):ht.setMode(V.TRIANGLES);else if(z.isLine){let ke=X.linewidth;ke===void 0&&(ke=1),Ce.setLineWidth(ke*dt()),z.isLineSegments?ht.setMode(V.LINES):z.isLineLoop?ht.setMode(V.LINE_LOOP):ht.setMode(V.LINE_STRIP)}else z.isPoints?ht.setMode(V.POINTS):z.isSprite&&ht.setMode(V.TRIANGLES);if(z.isBatchedMesh)if(z._multiDrawInstances!==null)ht.renderMultiDrawInstances(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount,z._multiDrawInstances);else if(Ge.get("WEBGL_multi_draw"))ht.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const ke=z._multiDrawStarts,In=z._multiDrawCounts,pt=z._multiDrawCount,Tn=Ne?ee.get(Ne).bytesPerElement:1,er=Re.get(X).currentProgram.getUniforms();for(let fn=0;fn<pt;fn++)er.setValue(V,"_gl_DrawID",fn),ht.render(ke[fn]/Tn,In[fn])}else if(z.isInstancedMesh)ht.renderInstances(at,Tt,z.count);else if(q.isInstancedBufferGeometry){const ke=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,In=Math.min(q.instanceCount,ke);ht.renderInstances(at,Tt,In)}else ht.render(at,Tt)};function _t(k,B,q){k.transparent===!0&&k.side===Oi&&k.forceSinglePass===!1?(k.side=bn,k.needsUpdate=!0,ss(k,B,q),k.side=Er,k.needsUpdate=!0,ss(k,B,q),k.side=Oi):ss(k,B,q)}this.compile=function(k,B,q=null){q===null&&(q=k),f=tt.get(q),f.init(B),w.push(f),q.traverseVisible(function(z){z.isLight&&z.layers.test(B.layers)&&(f.pushLight(z),z.castShadow&&f.pushShadow(z))}),k!==q&&k.traverseVisible(function(z){z.isLight&&z.layers.test(B.layers)&&(f.pushLight(z),z.castShadow&&f.pushShadow(z))}),f.setupLights();const X=new Set;return k.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const de=z.material;if(de)if(Array.isArray(de))for(let Se=0;Se<de.length;Se++){const Pe=de[Se];_t(Pe,q,z),X.add(Pe)}else _t(de,q,z),X.add(de)}),w.pop(),f=null,X},this.compileAsync=function(k,B,q=null){const X=this.compile(k,B,q);return new Promise(z=>{function de(){if(X.forEach(function(Se){Re.get(Se).currentProgram.isReady()&&X.delete(Se)}),X.size===0){z(k);return}setTimeout(de,10)}Ge.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Jt=null;function Un(k){Jt&&Jt(k)}function jt(){wn.stop()}function bo(){wn.start()}const wn=new Dg;wn.setAnimationLoop(Un),typeof self<"u"&&wn.setContext(self),this.setAnimationLoop=function(k){Jt=k,Q.setAnimationLoop(k),k===null?wn.stop():wn.start()},Q.addEventListener("sessionstart",jt),Q.addEventListener("sessionend",bo),this.render=function(k,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;if(k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),Q.enabled===!0&&Q.isPresenting===!0&&(Q.cameraAutoUpdate===!0&&Q.updateCamera(B),B=Q.getCamera()),k.isScene===!0&&k.onBeforeRender(b,k,B,A),f=tt.get(k,w.length),f.init(B),w.push(f),ze.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),J.setFromProjectionMatrix(ze),De=this.localClippingEnabled,re=ae.init(this.clippingPlanes,De),m=fe.get(k,M.length),m.init(),M.push(m),Q.enabled===!0&&Q.isPresenting===!0){const de=b.xr.getDepthSensingMesh();de!==null&&Ai(de,B,-1/0,b.sortObjects)}Ai(k,B,0,b.sortObjects),m.finish(),b.sortObjects===!0&&m.sort(ue,ve),Ke=Q.enabled===!1||Q.isPresenting===!1||Q.hasDepthSensing()===!1,Ke&&Ue.addToRenderList(m,k),this.info.render.frame++,re===!0&&ae.beginShadows();const q=f.state.shadowsArray;we.render(q,k,B),re===!0&&ae.endShadows(),this.info.autoReset===!0&&this.info.reset();const X=m.opaque,z=m.transmissive;if(f.setupLights(),B.isArrayCamera){const de=B.cameras;if(z.length>0)for(let Se=0,Pe=de.length;Se<Pe;Se++){const Ne=de[Se];Ja(X,z,k,Ne)}Ke&&Ue.render(k);for(let Se=0,Pe=de.length;Se<Pe;Se++){const Ne=de[Se];Za(m,k,Ne,Ne.viewport)}}else z.length>0&&Ja(X,z,k,B),Ke&&Ue.render(k),Za(m,k,B);A!==null&&(U.updateMultisampleRenderTarget(A),U.updateRenderTargetMipmap(A)),k.isScene===!0&&k.onAfterRender(b,k,B),yt.resetDefaultState(),E=-1,y=null,w.pop(),w.length>0?(f=w[w.length-1],re===!0&&ae.setGlobalState(b.clippingPlanes,f.state.camera)):f=null,M.pop(),M.length>0?m=M[M.length-1]:m=null};function Ai(k,B,q,X){if(k.visible===!1)return;if(k.layers.test(B.layers)){if(k.isGroup)q=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(B);else if(k.isLight)f.pushLight(k),k.castShadow&&f.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||J.intersectsSprite(k)){X&&Ee.setFromMatrixPosition(k.matrixWorld).applyMatrix4(ze);const Se=$.update(k),Pe=k.material;Pe.visible&&m.push(k,Se,Pe,q,Ee.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||J.intersectsObject(k))){const Se=$.update(k),Pe=k.material;if(X&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Ee.copy(k.boundingSphere.center)):(Se.boundingSphere===null&&Se.computeBoundingSphere(),Ee.copy(Se.boundingSphere.center)),Ee.applyMatrix4(k.matrixWorld).applyMatrix4(ze)),Array.isArray(Pe)){const Ne=Se.groups;for(let Ye=0,Ze=Ne.length;Ye<Ze;Ye++){const Me=Ne[Ye],at=Pe[Me.materialIndex];at&&at.visible&&m.push(k,Se,at,q,Ee.z,Me)}}else Pe.visible&&m.push(k,Se,Pe,q,Ee.z,null)}}const de=k.children;for(let Se=0,Pe=de.length;Se<Pe;Se++)Ai(de[Se],B,q,X)}function Za(k,B,q,X){const z=k.opaque,de=k.transmissive,Se=k.transparent;f.setupLightsView(q),re===!0&&ae.setGlobalState(b.clippingPlanes,q),X&&Ce.viewport(I.copy(X)),z.length>0&&qn(z,B,q),de.length>0&&qn(de,B,q),Se.length>0&&qn(Se,B,q),Ce.buffers.depth.setTest(!0),Ce.buffers.depth.setMask(!0),Ce.buffers.color.setMask(!0),Ce.setPolygonOffset(!1)}function Ja(k,B,q,X){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[X.id]===void 0&&(f.state.transmissionRenderTarget[X.id]=new Yr(1,1,{generateMipmaps:!0,type:Ge.has("EXT_color_buffer_half_float")||Ge.has("EXT_color_buffer_float")?Ba:Yi,minFilter:zr,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ft.workingColorSpace}));const de=f.state.transmissionRenderTarget[X.id],Se=X.viewport||I;de.setSize(Se.z,Se.w);const Pe=b.getRenderTarget();b.setRenderTarget(de),b.getClearColor(W),Z=b.getClearAlpha(),Z<1&&b.setClearColor(16777215,.5),b.clear(),Ke&&Ue.render(q);const Ne=b.toneMapping;b.toneMapping=yr;const Ye=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),f.setupLightsView(X),re===!0&&ae.setGlobalState(b.clippingPlanes,X),qn(k,q,X),U.updateMultisampleRenderTarget(de),U.updateRenderTargetMipmap(de),Ge.has("WEBGL_multisampled_render_to_texture")===!1){let Ze=!1;for(let Me=0,at=B.length;Me<at;Me++){const Et=B[Me],Tt=Et.object,$t=Et.geometry,ht=Et.material,ke=Et.group;if(ht.side===Oi&&Tt.layers.test(X.layers)){const In=ht.side;ht.side=bn,ht.needsUpdate=!0,$a(Tt,q,X,$t,ht,ke),ht.side=In,ht.needsUpdate=!0,Ze=!0}}Ze===!0&&(U.updateMultisampleRenderTarget(de),U.updateRenderTargetMipmap(de))}b.setRenderTarget(Pe),b.setClearColor(W,Z),Ye!==void 0&&(X.viewport=Ye),b.toneMapping=Ne}function qn(k,B,q){const X=B.isScene===!0?B.overrideMaterial:null;for(let z=0,de=k.length;z<de;z++){const Se=k[z],Pe=Se.object,Ne=Se.geometry,Ye=X===null?Se.material:X,Ze=Se.group;Pe.layers.test(q.layers)&&$a(Pe,B,q,Ne,Ye,Ze)}}function $a(k,B,q,X,z,de){k.onBeforeRender(b,B,q,X,z,de),k.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),z.onBeforeRender(b,B,q,X,k,de),z.transparent===!0&&z.side===Oi&&z.forceSinglePass===!1?(z.side=bn,z.needsUpdate=!0,b.renderBufferDirect(q,B,X,z,k,de),z.side=Er,z.needsUpdate=!0,b.renderBufferDirect(q,B,X,z,k,de),z.side=Oi):b.renderBufferDirect(q,B,X,z,k,de),k.onAfterRender(b,B,q,X,z,de)}function ss(k,B,q){B.isScene!==!0&&(B=He);const X=Re.get(k),z=f.state.lights,de=f.state.shadowsArray,Se=z.state.version,Pe=_e.getParameters(k,z.state,de,B,q),Ne=_e.getProgramCacheKey(Pe);let Ye=X.programs;X.environment=k.isMeshStandardMaterial?B.environment:null,X.fog=B.fog,X.envMap=(k.isMeshStandardMaterial?G:L).get(k.envMap||X.environment),X.envMapRotation=X.environment!==null&&k.envMap===null?B.environmentRotation:k.envMapRotation,Ye===void 0&&(k.addEventListener("dispose",je),Ye=new Map,X.programs=Ye);let Ze=Ye.get(Ne);if(Ze!==void 0){if(X.currentProgram===Ze&&X.lightsStateVersion===Se)return So(k,Pe),Ze}else Pe.uniforms=_e.getUniforms(k),k.onBeforeCompile(Pe,b),Ze=_e.acquireProgram(Pe,Ne),Ye.set(Ne,Ze),X.uniforms=Pe.uniforms;const Me=X.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Me.clippingPlanes=ae.uniform),So(k,Pe),X.needsLights=ai(k),X.lightsStateVersion=Se,X.needsLights&&(Me.ambientLightColor.value=z.state.ambient,Me.lightProbe.value=z.state.probe,Me.directionalLights.value=z.state.directional,Me.directionalLightShadows.value=z.state.directionalShadow,Me.spotLights.value=z.state.spot,Me.spotLightShadows.value=z.state.spotShadow,Me.rectAreaLights.value=z.state.rectArea,Me.ltc_1.value=z.state.rectAreaLTC1,Me.ltc_2.value=z.state.rectAreaLTC2,Me.pointLights.value=z.state.point,Me.pointLightShadows.value=z.state.pointShadow,Me.hemisphereLights.value=z.state.hemi,Me.directionalShadowMap.value=z.state.directionalShadowMap,Me.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Me.spotShadowMap.value=z.state.spotShadowMap,Me.spotLightMatrix.value=z.state.spotLightMatrix,Me.spotLightMap.value=z.state.spotLightMap,Me.pointShadowMap.value=z.state.pointShadowMap,Me.pointShadowMatrix.value=z.state.pointShadowMatrix),X.currentProgram=Ze,X.uniformsList=null,Ze}function Ir(k){if(k.uniformsList===null){const B=k.currentProgram.getUniforms();k.uniformsList=Qc.seqWithValue(B.seq,k.uniforms)}return k.uniformsList}function So(k,B){const q=Re.get(k);q.outputColorSpace=B.outputColorSpace,q.batching=B.batching,q.batchingColor=B.batchingColor,q.instancing=B.instancing,q.instancingColor=B.instancingColor,q.instancingMorph=B.instancingMorph,q.skinning=B.skinning,q.morphTargets=B.morphTargets,q.morphNormals=B.morphNormals,q.morphColors=B.morphColors,q.morphTargetsCount=B.morphTargetsCount,q.numClippingPlanes=B.numClippingPlanes,q.numIntersection=B.numClipIntersection,q.vertexAlphas=B.vertexAlphas,q.vertexTangents=B.vertexTangents,q.toneMapping=B.toneMapping}function Ao(k,B,q,X,z){B.isScene!==!0&&(B=He),U.resetTextureUnits();const de=B.fog,Se=X.isMeshStandardMaterial?B.environment:null,Pe=A===null?b.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:ho,Ne=(X.isMeshStandardMaterial?G:L).get(X.envMap||Se),Ye=X.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Ze=!!q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Me=!!q.morphAttributes.position,at=!!q.morphAttributes.normal,Et=!!q.morphAttributes.color;let Tt=yr;X.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Tt=b.toneMapping);const $t=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,ht=$t!==void 0?$t.length:0,ke=Re.get(X),In=f.state.lights;if(re===!0&&(De===!0||k!==y)){const Nt=k===y&&X.id===E;ae.setState(X,k,Nt)}let pt=!1;X.version===ke.__version?(ke.needsLights&&ke.lightsStateVersion!==In.state.version||ke.outputColorSpace!==Pe||z.isBatchedMesh&&ke.batching===!1||!z.isBatchedMesh&&ke.batching===!0||z.isBatchedMesh&&ke.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&ke.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&ke.instancing===!1||!z.isInstancedMesh&&ke.instancing===!0||z.isSkinnedMesh&&ke.skinning===!1||!z.isSkinnedMesh&&ke.skinning===!0||z.isInstancedMesh&&ke.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&ke.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&ke.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&ke.instancingMorph===!1&&z.morphTexture!==null||ke.envMap!==Ne||X.fog===!0&&ke.fog!==de||ke.numClippingPlanes!==void 0&&(ke.numClippingPlanes!==ae.numPlanes||ke.numIntersection!==ae.numIntersection)||ke.vertexAlphas!==Ye||ke.vertexTangents!==Ze||ke.morphTargets!==Me||ke.morphNormals!==at||ke.morphColors!==Et||ke.toneMapping!==Tt||ke.morphTargetsCount!==ht)&&(pt=!0):(pt=!0,ke.__version=X.version);let Tn=ke.currentProgram;pt===!0&&(Tn=ss(X,B,z));let er=!1,fn=!1,tr=!1;const bt=Tn.getUniforms(),On=ke.uniforms;if(Ce.useProgram(Tn.program)&&(er=!0,fn=!0,tr=!0),X.id!==E&&(E=X.id,fn=!0),er||y!==k){Ce.buffers.depth.getReversed()?(pe.copy(k.projectionMatrix),lT(pe),uT(pe),bt.setValue(V,"projectionMatrix",pe)):bt.setValue(V,"projectionMatrix",k.projectionMatrix),bt.setValue(V,"viewMatrix",k.matrixWorldInverse);const Cn=bt.map.cameraPosition;Cn!==void 0&&Cn.setValue(V,se.setFromMatrixPosition(k.matrixWorld)),Ie.logarithmicDepthBuffer&&bt.setValue(V,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&bt.setValue(V,"isOrthographic",k.isOrthographicCamera===!0),y!==k&&(y=k,fn=!0,tr=!0)}if(z.isSkinnedMesh){bt.setOptional(V,z,"bindMatrix"),bt.setOptional(V,z,"bindMatrixInverse");const Nt=z.skeleton;Nt&&(Nt.boneTexture===null&&Nt.computeBoneTexture(),bt.setValue(V,"boneTexture",Nt.boneTexture,U))}z.isBatchedMesh&&(bt.setOptional(V,z,"batchingTexture"),bt.setValue(V,"batchingTexture",z._matricesTexture,U),bt.setOptional(V,z,"batchingIdTexture"),bt.setValue(V,"batchingIdTexture",z._indirectTexture,U),bt.setOptional(V,z,"batchingColorTexture"),z._colorsTexture!==null&&bt.setValue(V,"batchingColorTexture",z._colorsTexture,U));const Mn=q.morphAttributes;if((Mn.position!==void 0||Mn.normal!==void 0||Mn.color!==void 0)&&Xe.update(z,q,Tn),(fn||ke.receiveShadow!==z.receiveShadow)&&(ke.receiveShadow=z.receiveShadow,bt.setValue(V,"receiveShadow",z.receiveShadow)),X.isMeshGouraudMaterial&&X.envMap!==null&&(On.envMap.value=Ne,On.flipEnvMap.value=Ne.isCubeTexture&&Ne.isRenderTargetTexture===!1?-1:1),X.isMeshStandardMaterial&&X.envMap===null&&B.environment!==null&&(On.envMapIntensity.value=B.environmentIntensity),fn&&(bt.setValue(V,"toneMappingExposure",b.toneMappingExposure),ke.needsLights&&os(On,tr),de&&X.fog===!0&&ne.refreshFogUniforms(On,de),ne.refreshMaterialUniforms(On,X,K,ce,f.state.transmissionRenderTarget[k.id]),Qc.upload(V,Ir(ke),On,U)),X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(Qc.upload(V,Ir(ke),On,U),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&bt.setValue(V,"center",z.center),bt.setValue(V,"modelViewMatrix",z.modelViewMatrix),bt.setValue(V,"normalMatrix",z.normalMatrix),bt.setValue(V,"modelMatrix",z.matrixWorld),X.isShaderMaterial||X.isRawShaderMaterial){const Nt=X.uniformsGroups;for(let Cn=0,Rn=Nt.length;Cn<Rn;Cn++){const xo=Nt[Cn];F.update(xo,Tn),F.bind(xo,Tn)}}return Tn}function os(k,B){k.ambientLightColor.needsUpdate=B,k.lightProbe.needsUpdate=B,k.directionalLights.needsUpdate=B,k.directionalLightShadows.needsUpdate=B,k.pointLights.needsUpdate=B,k.pointLightShadows.needsUpdate=B,k.spotLights.needsUpdate=B,k.spotLightShadows.needsUpdate=B,k.rectAreaLights.needsUpdate=B,k.hemisphereLights.needsUpdate=B}function ai(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(k,B,q){Re.get(k.texture).__webglTexture=B,Re.get(k.depthTexture).__webglTexture=q;const X=Re.get(k);X.__hasExternalTextures=!0,X.__autoAllocateDepthBuffer=q===void 0,X.__autoAllocateDepthBuffer||Ge.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),X.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(k,B){const q=Re.get(k);q.__webglFramebuffer=B,q.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(k,B=0,q=0){A=k,P=B,T=q;let X=!0,z=null,de=!1,Se=!1;if(k){const Ne=Re.get(k);if(Ne.__useDefaultFramebuffer!==void 0)Ce.bindFramebuffer(V.FRAMEBUFFER,null),X=!1;else if(Ne.__webglFramebuffer===void 0)U.setupRenderTarget(k);else if(Ne.__hasExternalTextures)U.rebindTextures(k,Re.get(k.texture).__webglTexture,Re.get(k.depthTexture).__webglTexture);else if(k.depthBuffer){const Me=k.depthTexture;if(Ne.__boundDepthTexture!==Me){if(Me!==null&&Re.has(Me)&&(k.width!==Me.image.width||k.height!==Me.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");U.setupDepthRenderbuffer(k)}}const Ye=k.texture;(Ye.isData3DTexture||Ye.isDataArrayTexture||Ye.isCompressedArrayTexture)&&(Se=!0);const Ze=Re.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(Ze[B])?z=Ze[B][q]:z=Ze[B],de=!0):k.samples>0&&U.useMultisampledRTT(k)===!1?z=Re.get(k).__webglMultisampledFramebuffer:Array.isArray(Ze)?z=Ze[q]:z=Ze,I.copy(k.viewport),D.copy(k.scissor),C=k.scissorTest}else I.copy(ye).multiplyScalar(K).floor(),D.copy(Oe).multiplyScalar(K).floor(),C=Ve;if(Ce.bindFramebuffer(V.FRAMEBUFFER,z)&&X&&Ce.drawBuffers(k,z),Ce.viewport(I),Ce.scissor(D),Ce.setScissorTest(C),de){const Ne=Re.get(k.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+B,Ne.__webglTexture,q)}else if(Se){const Ne=Re.get(k.texture),Ye=B||0;V.framebufferTextureLayer(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,Ne.__webglTexture,q||0,Ye)}E=-1},this.readRenderTargetPixels=function(k,B,q,X,z,de,Se){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=Re.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe){Ce.bindFramebuffer(V.FRAMEBUFFER,Pe);try{const Ne=k.texture,Ye=Ne.format,Ze=Ne.type;if(!Ie.textureFormatReadable(Ye)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ie.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=k.width-X&&q>=0&&q<=k.height-z&&V.readPixels(B,q,X,z,nt.convert(Ye),nt.convert(Ze),de)}finally{const Ne=A!==null?Re.get(A).__webglFramebuffer:null;Ce.bindFramebuffer(V.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(k,B,q,X,z,de,Se){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=Re.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe){const Ne=k.texture,Ye=Ne.format,Ze=Ne.type;if(!Ie.textureFormatReadable(Ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ie.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=k.width-X&&q>=0&&q<=k.height-z){Ce.bindFramebuffer(V.FRAMEBUFFER,Pe);const Me=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,Me),V.bufferData(V.PIXEL_PACK_BUFFER,de.byteLength,V.STREAM_READ),V.readPixels(B,q,X,z,nt.convert(Ye),nt.convert(Ze),0);const at=A!==null?Re.get(A).__webglFramebuffer:null;Ce.bindFramebuffer(V.FRAMEBUFFER,at);const Et=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await cT(V,Et,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,Me),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,de),V.deleteBuffer(Me),V.deleteSync(Et),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(k,B=null,q=0){k.isTexture!==!0&&(Jo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,k=arguments[1]);const X=Math.pow(2,-q),z=Math.floor(k.image.width*X),de=Math.floor(k.image.height*X),Se=B!==null?B.x:0,Pe=B!==null?B.y:0;U.setTexture2D(k,0),V.copyTexSubImage2D(V.TEXTURE_2D,q,0,0,Se,Pe,z,de),Ce.unbindTexture()},this.copyTextureToTexture=function(k,B,q=null,X=null,z=0){k.isTexture!==!0&&(Jo("WebGLRenderer: copyTextureToTexture function signature has changed."),X=arguments[0]||null,k=arguments[1],B=arguments[2],z=arguments[3]||0,q=null);let de,Se,Pe,Ne,Ye,Ze,Me,at,Et;const Tt=k.isCompressedTexture?k.mipmaps[z]:k.image;q!==null?(de=q.max.x-q.min.x,Se=q.max.y-q.min.y,Pe=q.isBox3?q.max.z-q.min.z:1,Ne=q.min.x,Ye=q.min.y,Ze=q.isBox3?q.min.z:0):(de=Tt.width,Se=Tt.height,Pe=Tt.depth||1,Ne=0,Ye=0,Ze=0),X!==null?(Me=X.x,at=X.y,Et=X.z):(Me=0,at=0,Et=0);const $t=nt.convert(B.format),ht=nt.convert(B.type);let ke;B.isData3DTexture?(U.setTexture3D(B,0),ke=V.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(U.setTexture2DArray(B,0),ke=V.TEXTURE_2D_ARRAY):(U.setTexture2D(B,0),ke=V.TEXTURE_2D),V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,B.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,B.unpackAlignment);const In=V.getParameter(V.UNPACK_ROW_LENGTH),pt=V.getParameter(V.UNPACK_IMAGE_HEIGHT),Tn=V.getParameter(V.UNPACK_SKIP_PIXELS),er=V.getParameter(V.UNPACK_SKIP_ROWS),fn=V.getParameter(V.UNPACK_SKIP_IMAGES);V.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),V.pixelStorei(V.UNPACK_SKIP_PIXELS,Ne),V.pixelStorei(V.UNPACK_SKIP_ROWS,Ye),V.pixelStorei(V.UNPACK_SKIP_IMAGES,Ze);const tr=k.isDataArrayTexture||k.isData3DTexture,bt=B.isDataArrayTexture||B.isData3DTexture;if(k.isRenderTargetTexture||k.isDepthTexture){const On=Re.get(k),Mn=Re.get(B),Nt=Re.get(On.__renderTarget),Cn=Re.get(Mn.__renderTarget);Ce.bindFramebuffer(V.READ_FRAMEBUFFER,Nt.__webglFramebuffer),Ce.bindFramebuffer(V.DRAW_FRAMEBUFFER,Cn.__webglFramebuffer);for(let Rn=0;Rn<Pe;Rn++)tr&&V.framebufferTextureLayer(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Re.get(k).__webglTexture,z,Ze+Rn),k.isDepthTexture?(bt&&V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Re.get(B).__webglTexture,z,Et+Rn),V.blitFramebuffer(Ne,Ye,de,Se,Me,at,de,Se,V.DEPTH_BUFFER_BIT,V.NEAREST)):bt?V.copyTexSubImage3D(ke,z,Me,at,Et+Rn,Ne,Ye,de,Se):V.copyTexSubImage2D(ke,z,Me,at,Et+Rn,Ne,Ye,de,Se);Ce.bindFramebuffer(V.READ_FRAMEBUFFER,null),Ce.bindFramebuffer(V.DRAW_FRAMEBUFFER,null)}else bt?k.isDataTexture||k.isData3DTexture?V.texSubImage3D(ke,z,Me,at,Et,de,Se,Pe,$t,ht,Tt.data):B.isCompressedArrayTexture?V.compressedTexSubImage3D(ke,z,Me,at,Et,de,Se,Pe,$t,Tt.data):V.texSubImage3D(ke,z,Me,at,Et,de,Se,Pe,$t,ht,Tt):k.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,z,Me,at,de,Se,$t,ht,Tt.data):k.isCompressedTexture?V.compressedTexSubImage2D(V.TEXTURE_2D,z,Me,at,Tt.width,Tt.height,$t,Tt.data):V.texSubImage2D(V.TEXTURE_2D,z,Me,at,de,Se,$t,ht,Tt);V.pixelStorei(V.UNPACK_ROW_LENGTH,In),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,pt),V.pixelStorei(V.UNPACK_SKIP_PIXELS,Tn),V.pixelStorei(V.UNPACK_SKIP_ROWS,er),V.pixelStorei(V.UNPACK_SKIP_IMAGES,fn),z===0&&B.generateMipmaps&&V.generateMipmap(ke),Ce.unbindTexture()},this.copyTextureToTexture3D=function(k,B,q=null,X=null,z=0){return k.isTexture!==!0&&(Jo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),q=arguments[0]||null,X=arguments[1]||null,k=arguments[2],B=arguments[3],z=arguments[4]||0),Jo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(k,B,q,X,z)},this.initRenderTarget=function(k){Re.get(k).__webglFramebuffer===void 0&&U.setupRenderTarget(k)},this.initTexture=function(k){k.isCubeTexture?U.setTextureCube(k,0):k.isData3DTexture?U.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?U.setTexture2DArray(k,0):U.setTexture2D(k,0),Ce.unbindTexture()},this.resetState=function(){P=0,T=0,A=null,Ce.reset(),yt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return zi}get outputColorSpace(){return this._outputColorSpace}
vendor: 9,070 bytes, line 3828
3828set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=ft._getDrawingBufferColorSpace(e),t.unpackColorSpace=ft._getUnpackColorSpace()}}class sk extends Zt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new vi,this.environmentIntensity=1,this.environmentRotation=new vi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class yx{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Zd,this.updateRanges=[],this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=pi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=pi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const _n=new O;class ul{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix4(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)_n.fromBufferAttribute(this,t),_n.applyNormalMatrix(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)_n.fromBufferAttribute(this,t),_n.transformDirection(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=$n(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=$n(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=$n(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=$n(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=$n(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),r=vt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),r=vt(r,this.array),s=vt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Gn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ul(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ex extends ns{static get type(){return"SpriteMaterial"}constructor(e){super(),this.isSpriteMaterial=!0,this.color=new ut(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let As;const Fo=new O,xs=new O,ws=new O,Is=new xe,Vo=new xe,Bg=new wt,Rc=new O,Bo=new O,Pc=new O,u_=new xe,Gu=new xe,d_=new xe;class ok extends Zt{constructor(e=new Ex){if(super(),this.isSprite=!0,this.type="Sprite",As===void 0){As=new An;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new yx(t,5);As.setIndex([0,1,2,0,2,3]),As.setAttribute("position",new ul(i,3,0,!1)),As.setAttribute("uv",new ul(i,2,3,!1))}this.geometry=As,this.material=e,this.center=new xe(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xs.setFromMatrixScale(this.matrixWorld),Bg.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ws.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xs.multiplyScalar(-ws.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const o=this.center;Lc(Rc.set(-.5,-.5,0),ws,o,xs,r,s),Lc(Bo.set(.5,-.5,0),ws,o,xs,r,s),Lc(Pc.set(.5,.5,0),ws,o,xs,r,s),u_.set(0,0),Gu.set(1,0),d_.set(1,1);let a=e.ray.intersectTriangle(Rc,Bo,Pc,!1,Fo);if(a===null&&(Lc(Bo.set(-.5,.5,0),ws,o,xs,r,s),Gu.set(0,1),a=e.ray.intersectTriangle(Rc,Pc,Bo,!1,Fo),a===null))return;const c=e.ray.origin.distanceTo(Fo);c<e.near||c>e.far||t.push({distance:c,point:Fo.clone(),uv:zn.getInterpolation(Fo,Rc,Bo,Pc,u_,Gu,d_,new xe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Lc(n,e,t,i,r,s){Is.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Vo.x=s*Is.x-r*Is.y,Vo.y=r*Is.x+s*Is.y):Vo.c
vendor: 4,284 bytes, line 3828
3828opy(Is),n.copy(e),n.x+=Vo.x,n.y+=Vo.y,n.applyMatrix4(Bg)}class zg extends ns{static get type(){return"LineBasicMaterial"}constructor(e){super(),this.isLineBasicMaterial=!0,this.color=new ut(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const dl=new O,hl=new O,h_=new wt,zo=new Gh,Dc=new Ol,Wu=new O,p_=new O;class Tx extends Zt{constructor(e=new An,t=new zg){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)dl.fromBufferAttribute(t,r-1),hl.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=dl.distanceTo(hl);e.setAttribute("lineDistance",new Ft(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dc.copy(i.boundingSphere),Dc.applyMatrix4(r),Dc.radius+=s,e.ray.intersectsSphere(Dc)===!1)return;h_.copy(r).invert(),zo.copy(e.ray).applyMatrix4(h_);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,d=i.index,p=i.attributes.position;if(d!==null){const _=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let S=_,m=g-1;S<m;S+=l){const f=d.getX(S),M=d.getX(S+1),w=Nc(this,e,zo,c,f,M);w&&t.push(w)}if(this.isLineLoop){const S=d.getX(g-1),m=d.getX(_),f=Nc(this,e,zo,c,S,m);f&&t.push(f)}}else{const _=Math.max(0,o.start),g=Math.min(p.count,o.start+o.count);for(let S=_,m=g-1;S<m;S+=l){const f=Nc(this,e,zo,c,S,S+1);f&&t.push(f)}if(this.isLineLoop){const S=Nc(this,e,zo,c,g-1,_);S&&t.push(S)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Nc(n,e,t,i,r,s){const o=n.geometry.attributes.position;if(dl.fromBufferAttribute(o,r),hl.fromBufferAttribute(o,s),t.distanceSqToSegment(dl,hl,Wu,p_)>i)return;Wu.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Wu);if(!(c<e.near||c>e.far))return{distance:c,point:p_.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const f_=new O,__=new O;class bx extends Tx{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)f_.fromBufferAttribute(t,r),__.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+f_.distanceTo(__);e.setAttribute("lineDistance",new Ft(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Si{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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 i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;
vendor: 7,594 bytes, line 3828
3828)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);const d=i[r],p=i[r+1]-d,_=(o-d)/p;return(r+_)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new xe:new O);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new O,r=[],s=[],o=[],a=new O,c=new wt;for(let _=0;_<=e;_++){const g=_/e;r[_]=this.getTangentAt(g,new O)}s[0]=new O,o[0]=new O;let l=Number.MAX_VALUE;const d=Math.abs(r[0].x),h=Math.abs(r[0].y),p=Math.abs(r[0].z);d<=l&&(l=d,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),p<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let _=1;_<=e;_++){if(s[_]=s[_-1].clone(),o[_]=o[_-1].clone(),a.crossVectors(r[_-1],r[_]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(Qt(r[_-1].dot(r[_]),-1,1));s[_].applyMatrix4(c.makeRotationAxis(a,g))}o[_].crossVectors(r[_],s[_])}if(t===!0){let _=Math.acos(Qt(s[0].dot(s[e]),-1,1));_/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(_=-_);for(let g=1;g<=e;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],_*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xh extends Si{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new xe){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const d=Math.cos(this.aRotation),h=Math.sin(this.aRotation),p=c-this.aX,_=l-this.aY;c=p*d-_*h+this.aX,l=p*h+_*d+this.aY}return i.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Sx extends Xh{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function jh(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,d,h){let p=(o-s)/l-(a-s)/(l+d)+(a-o)/d,_=(a-o)/d-(c-o)/(d+h)+(c-a)/h;p*=d,_*=d,r(o,a,p,_)},calc:function(s){const o=s*s,a=o*s;return n+e*s+t*o+i*a}}}const kc=new O,qu=new jh,Xu=new jh,ju=new jh;class Ax extends Si{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new O){const i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,d;this.closed||a>0?l=r[(a-1)%s]:(kc.subVectors(r[0],r[1]).add(r[0]),l=kc);const h=r[a%s],p=r[(a+1)%s];if(this.closed||a+2<s?d=r[(a+2)%s]:(kc.subVectors(r[s-1],r[s-2]).add(r[s-1]),d=kc),this.curveType==="centripetal"||this.curveType==="chordal"){const _=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(h),_),S=Math.pow(h.distanceToSquared(p),_),m=Math.pow(p.distanceToSquared(d),_);S<1e-4&&(S=1),g<1e-4&&(g=S),m<1e-4&&(m=S),qu.initNonuniformCatmullRom(l.x,h.x,p.x,d.x,g,S,m),Xu.initNonuniformCatmullRom(l.y,h.y,p.y,d.y,g,S,m),ju.initNonuniformCatmullRom(l.z,h.z,p.z,d.z,g,S,m)}else this.curveType==="catmullrom"&&(qu.initCatmullRom(l.x,h.x,p.x,d.x,this.tension),Xu.initCatmullRom(l.y,h.y,p.y,d.y,this.tension),ju.initCatmullRom(l.z,h.z,p.z,d.z,this.tension));return i.set(qu.calc(c),Xu.calc(c),ju.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new O().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function m_(n,e,t,i,r){const s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function xx(n,e){const t=1-n;return t*t*e}function wx(n,e){return 2*(1-n)*n*e}function Ix(n,e){return n*n*e}function da(n,e,t,i){return xx(n,e)+wx(n,t)+Ix(n,i)}function Mx(n,e){const t=1-n;return t*t*t*e}function Cx(n,e){const t=1-n;return 3*t*t*n*e}function Rx(n,e){return 3*(1-n)*n*n*e}function Px(n,e){return n*n*n*e}function ha(n,e,t,i,r){return Mx(n,e)+Cx(n,t)+Rx(n,i)+Px(n,r)}class Hg extends Si{constructor(e=new xe,t=new xe,i=new xe,r=new xe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new xe){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ha(e,r.x,s.x,o.x,a.x),ha(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Lx extends Si{constructor(e=new O,t=new O,i=new O,r=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new O){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ha(e,r.x,s.x,o.x,a.x),ha(e,r.y,s.y,o.y,a.y),ha(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Gg extends Si{constructor(e=new xe,t=new xe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new xe){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}
vendor: 8,563 bytes, line 3828
3828getTangent(e,t=new xe){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Dx extends Si{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new O){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Wg extends Si{constructor(e=new xe,t=new xe,i=new xe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new xe){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(da(e,r.x,s.x,o.x),da(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class qg extends Si{constructor(e=new O,t=new O,i=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new O){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(da(e,r.x,s.x,o.x),da(e,r.y,s.y,o.y),da(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Xg extends Si{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new xe){const i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],d=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set(m_(a,c.x,l.x,d.x,h.x),m_(a,c.y,l.y,d.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new xe().fromArray(r))}return this}}var $d=Object.freeze({__proto__:null,ArcCurve:Sx,CatmullRomCurve3:Ax,CubicBezierCurve:Hg,CubicBezierCurve3:Lx,EllipseCurve:Xh,LineCurve:Gg,LineCurve3:Dx,QuadraticBezierCurve:Wg,QuadraticBezierCurve3:qg,SplineCurve:Xg});class Nx extends Si{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new $d[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const d=c[l];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new $d[r.type]().fromJSON(r))}return this}}class eh extends Nx{constructor(e){super(),this.type="Path",this.currentPoint=new xe,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new Gg(this.currentPoint.clone(),new xe(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new Wg(this.currentPoint.clone(),new xe(e,t),new xe(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){const a=new Hg(this.currentPoint.clone(),new xe(e,t),new xe(i,r),new xe(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Xg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){const l=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+l,t+d,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){const l=new Xh(e,t,i,r,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const d=l.getPoint(1);return this.currentPoint.copy(d),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 Kh extends An{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const d=[],h=[],p=[],_=[];let g=0;const S=[],m=i/2;let f=0;M(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(d),this.setAttribute("position",new Ft(h,3)),this.setAttribute("normal",new Ft(p,3)),this.setAttribute("uv",new Ft(_,2));function M(){const b=new O,R=new O;let P=0;const T=(t-e)/i;for(let A=0;A<=s;A++){const E=[],y=A/s,I=y*(t-e)+e;for(let D=0;D<=r;D++){const C=D/r,W=C*c+a,Z=Math.sin(W),Y=Math.cos(W);R.x=I*Z,R.y=-y*i+m,R.z=I*Y,h.push(R.x,R.y,R.z),b.set(Z,T,Y).normalize(),p.push(b.x,b.y,b.z),_.push(C,1-y),E.push(g++)}S.push(E)}for(let A=0;A<r;A++)for(let E=0;E<s;E++){const y=S[E][A],I=S[E+1][A],D=S[E+1][A+1],C=S[E][A+1];(e>0||E!==0)&&(d.push(y,I,C),P+=3),(t>0||E!==s-1)&&(d.push(I,D,C),P+=3)}l.addGroup(f,P,0),f+=P}function w(b){const R=g,P=new xe,T=new O;let A=0;const E=b===!0?e:t,y=b===!0?1:-1;for(let D=1;D<=r;D++)h.push(0,m*y,0),p.push(0,y,0),_.push(.5,.5),g++;const I=g;for(let D=0;D<=r;D++){const W=D/r*c+a,Z=Math.cos(W),Y=Math.sin(W);T.x=E*Y,T.y=m*y,T.z=E*Z,h.push(T.x,T.y,T.z),p.push(0,y,0),P.x=Z*.5+.5,P.y=Y*.5*y+.5,_.push(P.x,P.y),g++}for(let D=0;D<r;D++){const C=R+D,W=I+D;b===!0?d.push(W,W+1,C):d.push(W+1,W,C),A+=3}l.addGroup(f,A,b===!0?1:2),f+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class jg extends Kh{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="C
3828oneGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new jg(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Zc extends eh{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new eh().fromJSON(r))}return this}}const kx={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Kg(n,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l,d,h,p,_;if(i&&(s=Bx(n,e,s,t)),n.length>80*t){a=l=n[0],c=d=n[1];for(let g=t;g<r;g+=t)h=n[g],p=n[g+1],h<a&&(a=h),p<c&&(c=p),h>l&&(l=h),p>d&&(d=p);_=Math.max(l-a,d-c),_=_!==0?32767/_:0}return ba(s,o,t,a,c,_,0),o}};function Kg(n,e,t,i,r){let s,o;if(r===Zx(n,e,t,i)>0)for(s=e;s<t;s+=i)o=g_(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=g_(s,n[s],n[s+1],o);return o&&zl(o,o.next)&&(Aa(o),o=o.next),o}function Qr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(zl(t,t.next)||Lt(t.prev,t,t.next)===0)){if(Aa(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ba(n,e,t,i,r,s,o){if(!n)return;!o&&s&&qx(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?Ox(n,i,r,s):Ux(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Aa(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=Fx(Qr(n),e,t),ba(n,e,t,i,r,s,2)):o===2&&Vx(n,e,t,i,r,s):ba(Qr(n),e,t,i,r,s,1);break}}}function Ux(n){const e=n.prev,t=n,i=n.next;if(Lt(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,d=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,p=r>s?r>o?r:o:s>o?s:o,_=a>c?a>l?a:l:c>l?c:l;let g=i.next;for(;g!==e;){if(g.x>=d&&g.x<=p&&g.y>=h&&g.y<=_&&Ns(r,a,s,c,o,l,g.x,g.y)&&Lt(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Ox(n,e,t,i){const r=n.prev,s=n,o=n.next;if(Lt(r,s,o)>=0)return!1;const a=r.x,c=s.x,l=o.x,d=r.y,h=s.y,p=o.y,_=a<c?a<l?a:l:c<l?c:l,g=d<h?d<p?d:p:h<
vendor: 12,440 bytes, line 3828
3828p?h:p,S=a>c?a>l?a:l:c>l?c:l,m=d>h?d>p?d:p:h>p?h:p,f=th(_,g,e,t,i),M=th(S,m,e,t,i);let w=n.prevZ,b=n.nextZ;for(;w&&w.z>=f&&b&&b.z<=M;){if(w.x>=_&&w.x<=S&&w.y>=g&&w.y<=m&&w!==r&&w!==o&&Ns(a,d,c,h,l,p,w.x,w.y)&&Lt(w.prev,w,w.next)>=0||(w=w.prevZ,b.x>=_&&b.x<=S&&b.y>=g&&b.y<=m&&b!==r&&b!==o&&Ns(a,d,c,h,l,p,b.x,b.y)&&Lt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;w&&w.z>=f;){if(w.x>=_&&w.x<=S&&w.y>=g&&w.y<=m&&w!==r&&w!==o&&Ns(a,d,c,h,l,p,w.x,w.y)&&Lt(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;b&&b.z<=M;){if(b.x>=_&&b.x<=S&&b.y>=g&&b.y<=m&&b!==r&&b!==o&&Ns(a,d,c,h,l,p,b.x,b.y)&&Lt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Fx(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!zl(r,s)&&Yg(r,i,i.next,s)&&Sa(r,s)&&Sa(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Aa(i),Aa(i.next),i=n=s),i=i.next}while(i!==n);return Qr(i)}function Vx(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Kx(o,a)){let c=Qg(o,a);o=Qr(o,o.next),c=Qr(c,c.next),ba(o,e,t,i,r,s,0),ba(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function Bx(n,e,t,i){const r=[];let s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=Kg(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(jx(l));for(r.sort(zx),s=0;s<r.length;s++)t=Hx(r[s],t);return t}function zx(n,e){return n.x-e.x}function Hx(n,e){const t=Gx(n,e);if(!t)return e;const i=Qg(t,n);return Qr(i,i.next),Qr(t,t.next)}function Gx(n,e){let t=e,i=-1/0,r;const s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const p=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(p<=s&&p>i&&(i=p,r=t.x<t.next.x?t:t.next,p===s))return r}t=t.next}while(t!==e);if(!r)return null;const a=r,c=r.x,l=r.y;let d=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Ns(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Sa(t,n)&&(h<d||h===d&&(t.x>r.x||t.x===r.x&&Wx(r,t)))&&(r=t,d=h)),t=t.next;while(t!==a);return r}function Wx(n,e){return Lt(n.prev,n,e.prev)<0&&Lt(e.next,n,n.next)<0}function qx(n,e,t,i){let r=n;do r.z===0&&(r.z=th(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,Xx(r)}function Xx(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function th(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function jx(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Ns(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function Kx(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Yx(n,e)&&(Sa(n,e)&&Sa(e,n)&&Qx(n,e)&&(Lt(n.prev,n,e.prev)||Lt(n,e.prev,e))||zl(n,e)&&Lt(n.prev,n,n.next)>0&&Lt(e.prev,e,e.next)>0)}function Lt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function zl(n,e){return n.x===e.x&&n.y===e.y}function Yg(n,e,t,i){const r=Oc(Lt(n,e,t)),s=Oc(Lt(n,e,i)),o=Oc(Lt(t,i,n)),a=Oc(Lt(t,i,e));return!!(r!==s&&o!==a||r===0&&Uc(n,t,e)||s===0&&Uc(n,i,e)||o===0&&Uc(t,n,i)||a===0&&Uc(t,e,i))}function Uc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Oc(n){return n>0?1:n<0?-1:0}function Yx(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Yg(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sa(n,e){return Lt(n.prev,n,n.next)<0?Lt(n,e,n.next)>=0&&Lt(n,n.prev,e)>=0:Lt(n,e,n.prev)<0||Lt(n,n.next,e)<0}function Qx(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Qg(n,e){const t=new nh(n.i,n.x,n.y),i=new nh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function g_(n,e,t,i){const r=new nh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Aa(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function nh(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Zx(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}class Vs{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return Vs.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];v_(e),y_(i,e);let o=e.length;t.forEach(v_);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,y_(i,t[c]);const a=kx.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function v_(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function y_(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Zg extends An{constructor(e=new Zc([new xe(0,.5),new xe(-.5,-.5),new xe(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let d=0;d<e.length;d++)l(e[d]),this.addGroup(a,c,d),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new Ft(r,3)),this.setAttribute("normal",new Ft(s,3)),this.setAttribute("uv",new Ft(o,2));function l(d){const h=r.length/3,p=d.extractPoints(t);let _=p.shape;const g=p.holes;Vs.isClockWise(_)===!1&&(_=_.reverse());for(let m=0,f=g.length;m<f;m++){const M=g[m];Vs.isClockWise(M)===!0&&(g[m]=M.reverse())}const S=Vs.triangulateShape(_,g);for(let m=0,f=g.length;m<f;m++){const M=g[m];_=_.concat(M)}for(let m=0,f=_.length;m<f;m++){const M=_[m];r.push(M.x,M.y,0),s.push(0,0,1),o.push(M.x,M.y)}for(let m=0,f=S.length;m<f;m++){const M=S[m],w=M[0]+h,b=M[1]+h,R=M[2]+h;i.push(w,b,R),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Jx(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}return new Zg(i,e.curveSegments)}}function Jx(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Jg extends An{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(o+a,Math.PI);let l=0;const d=[],h=new O,p=new O,_=[],g=[],S=[],m=[];for(let f=0;f<=i;f++){const M=[],w=f/i;let b=0;f===0&&o===0?b=.5/t:f===i&&c===Math.PI&&(b=-.5/t);for(let R=0;R<=t;R++){const P=R/t;h.x=-e*Math.cos(r+P*s)*Math.sin(o+w*a),h.y=e*Math.cos(o+w*a),h.z=e*Math.sin(r+P*s)*Math.sin(o+w*a),g.push(h.x,h.y,h.z),p.copy(h).normalize(),S.push(p.x,p.y,p.z),m.push(P+b,1-w),M.push(l++)}d.push(M)}for(let f=0;f<i;f++)for(let M=0;M<t;M++){const w=d[f][M+1],b=d[f][M],R=d[f+1][M],P=d[f+1][M+1];(f!==0||o>0)&&_.push(w,b,P),(f!==i-1||c<Math.PI)&&_.push(b,R,P)}this.setIndex(_),this.setAttribute("position",new Ft(g,3)),this.setAttribute("normal",new Ft(S,3)),this.setAttribute("uv",new Ft(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class $g extends An{constructor(e=new qg(new O(-1,-1,0),new O(-1,1,0),new O(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new O,c=new O,l=new xe;let d=new O;const h=[],p=[],_=[],g=[];S(),this.setIndex(g),this.setAttribute("position",new Ft(h,3)),this.setAttribute("normal",new Ft(p,3)),this.setAttribute("uv",new Ft(_,2));function S(){for(let w=0;w<t;w++)m(w);m(s===!1?t:0),M(),f()}function m(w){d=e.getPointAt(w/t,d);const b=o.normals[w],R=o.binormals[w];for(let P=0;P<=r;P++){const T=P/r*Math.PI*2,A=Math.sin(T),E=-Math.cos(T);c.x=E*b.x+A*R.x,c.y=E*b.y+A*R.y,c.z=E*b.z+A*R.z,c.normalize(),p.push(c.x,c.y,c.z),a.x=d.x+i*c.x,a.y=d.y+i*c.y,a.z=d.z+i*c.z,h.push(a.x,a.y,a.z)}}function f(){for(let w=1;w<=t;w++)for(let b=1;b<=r;b++){const R=(r+1)*(w-1)+(b-1),P=(r+1)*w+(b-1),T=(r+1)*w+b,A=(r+1)*(w-1)+b;g.push(R,P,A),g.push(P,T,A)}}function M(){for(let w=0;w<=t;w++)for(let b=0;b<=r;b++)l.x=w/t,l.y=b/r,_.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new $g(new $d[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class ak extends ns{static get type(){return"MeshLambertMaterial"}constructor(e){super(),this.isMeshLambertMaterial=!0,this.color=new ut(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Tg,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new vi,this.combine=kh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.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.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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}const pl={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class $x{constructor(e,t,i){const r=this;let s=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(d){a++,s===!1&&r.onStart!==void 0&&r.onStart(d,o,a),s=!0},this.itemEnd=function(d){o++,r.onProgress!==void 0&&r.onProgress(d,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,h){return l.push(d,h),this},this.removeHandler=function(d){const h=l.indexOf(d);return h!==-1&&l.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=l.length;h<p;h+=2){const _=l[h],g=l[h+1];if(_.global&&(_.lastIndex=0),_.test(d))return g}return null}}}const ew=new $x;class Hl{constructor(e){this.manager=e!==void 0?e:ew,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Hl.DEFAULT_MATERIAL_NAME="__DEFAULT";const Pi={};
vendor: 5,221 bytes, line 3828
3828class tw extends Error{constructor(e,t){super(e),this.response=t}}class ck extends Hl{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=pl.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Pi[e]!==void 0){Pi[e].push({onLoad:t,onProgress:i,onError:r});return}Pi[e]=[],Pi[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const d=Pi[e],h=l.body.getReader(),p=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),_=p?parseInt(p):0,g=_!==0;let S=0;const m=new ReadableStream({start(f){M();function M(){h.read().then(({done:w,value:b})=>{if(w)f.close();else{S+=b.byteLength;const R=new ProgressEvent("progress",{lengthComputable:g,loaded:S,total:_});for(let P=0,T=d.length;P<T;P++){const A=d[P];A.onProgress&&A.onProgress(R)}f.enqueue(b),M()}},w=>{f.error(w)})}}});return new Response(m)}else throw new tw(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(d=>new DOMParser().parseFromString(d,a));case"json":return l.json();default:if(a===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),p=h&&h[1]?h[1].toLowerCase():void 0,_=new TextDecoder(p);return l.arrayBuffer().then(g=>_.decode(g))}}}).then(l=>{pl.add(e,l);const d=Pi[e];delete Pi[e];for(let h=0,p=d.length;h<p;h++){const _=d[h];_.onLoad&&_.onLoad(l)}}).catch(l=>{const d=Pi[e];if(d===void 0)throw this.manager.itemError(e),l;delete Pi[e];for(let h=0,p=d.length;h<p;h++){const _=d[h];_.onError&&_.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class nw extends Hl{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=pl.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Ta("img");function c(){d(),pl.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){d(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class lk extends Hl{constructor(e){super(e)}load(e,t,i,r){const s=new vn,o=new nw(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ev extends Zt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ut(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Ku=new wt,E_=new O,T_=new O;class iw{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xe(512,512),this.map=null,this.mapPass=null,this.matrix=new wt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Fl,this._frameExtents=new xe(1,1),this._viewportCount=1,this._viewports=[new Ot(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;E_.setFromMatrixPosition(e.matrixWorld),t.position.copy(E_),T_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(T_),t.updateMatrixWorld(),Ku.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ku),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ku)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radiu
vendor: 6,380 bytes, line 3828
3828s=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class rw extends iw{constructor(){super(new Ng(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class uk extends ev{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.target=new Zt,this.shadow=new rw}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class dk extends ev{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class hk{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=b_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=b_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function b_(){return performance.now()}const S_=new wt;class pk{constructor(e,t,i=0,r=1/0){this.ray=new Gh(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Wh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return S_.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(S_),this}intersectObject(e,t=!0,i=[]){return ih(e,this,i,t),i.sort(A_),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)ih(e[r],this,i,t);return i.sort(A_),i}}function A_(n,e){return n.distance-e.distance}function ih(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)ih(s[o],e,t,!0)}}class fk{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Qt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const x_=new xe;class _k{constructor(e=new xe(1/0,1/0),t=new xe(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=x_.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.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.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,x_).distanceTo(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}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)}}class mk extends bx{constructor(e,t=16776960){const i=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]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new An;s.setIndex(new Gn(i,1)),s.setAttribute("position",new Ft(r,3)),super(s,new zg({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))}dispose(){this.geometry.dispose(),this.material.dispose()}}class gk{constructor(){this.type="ShapePath",this.color=new ut,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new eh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const M=[];for(let w=0,b=f.length;w<b;w++){const R=f[w],P=new Zc;P.curves=R.curves,M.push(P)}return M}function i(f,M){const w=M.length;let b=!1;for(let R=w-1,P=0;P<w;R=P++){let T=M[R],A=M[P],E=A.x-T.x,y=A.y-T.y;if(Math.abs(y)>Number.EPSILON){if(y<0&&(T=M[P],E=-E,A=M[R],y=-y),f.y<T.y||f.y>A.y)continue;if(f.y===T.y){if(f.x===T.x)return!0}else{const I=y*(f.x-T.x)-E*(f.y-T.y);if(I===0)return!0;
3828if(I<0)continue;b=!b}}else{if(f.y!==T.y)continue;if(A.x<=f.x&&f.x<=T.x||T.x<=f.x&&f.x<=A.x)return!0}}return b}const r=Vs.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c;const l=[];if(s.length===1)return a=s[0],c=new Zc,c.curves=a.curves,l.push(c),l;let d=!r(s[0].getPoints());d=e?!d:d;const h=[],p=[];let _=[],g=0,S;p[g]=void 0,_[g]=[];for(let f=0,M=s.length;f<M;f++)a=s[f],S=a.getPoints(),o=r(S),o=e?!o:o,o?(!d&&p[g]&&g++,p[g]={s:new Zc,p:S},p[g].s.curves=a.curves,d&&g++,_[g]=[]):_[g].push({h:a,p:S[0]});if(!p[0])return t(s);if(p.length>1){let f=!1,M=0;for(let w=0,b=p.length;w<b;w++)h[w]=[];for(let w=0,b=p.length;w<b;w++){const R=_[w];for(let P=0;P<R.length;P++){const T=R[P];let A=!0;for(let E=0;E<p.length;E++)i(T.p,p[E].p)&&(w!==E&&M++,A?(A=!1,h[E].push(T)):f=!0);A&&h[w].push(T)}}M>0&&f===!1&&(_=h)}let m;for(let f=0,M=p.length;f<M;f++){c=p[f].s,l.push(c),m=_[f];for(let w=0,b=m.length;w<b;w++)c.holes.push(m[w].h)}return l}}class vk extends ts{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Nh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Nh);function yk(n,e,t){var i,r=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function s(){var o,a=i.length,c,l=0,d=0,h=0;for(o=0;o<a;++o)c=i[o],l+=c.x||0,d+=c.y||0,h+=c.z||0;for(l=(l/a-n)*r,d=(d/a-e)*r,h=(h/a-t)*r,o=0;o<a;++o)c=i[o],l&&(c.x-=l),d&&(c.y-=d),h&&(c.z-=h)}return s.initialize=function(o){i=o},s.x=function(o){return arguments.length?(n=+o,s):n},s.y=function(o){return arguments.length?(e=+o,s):e},s.z=function(o){return arguments.length?(t=+o,s):t},s.strength=function(o){return arguments.length?(r=+o,s):r},s}function sw(n){const e=+this._x.call(null,n);return tv(this.cover(e),e,n)}function tv(n,e,t){if(isNaN(e))return n;var i,r=n._root,s={data:t},o=n._x0,a=n._x1,c,l,d,h,p;if(!r)return n._root=s,n;for(;r.length;)if((d=e>=(c=(o+a)/2))?o=c:a=c,i=r,!(r=r[h=+d]))return i[h]=s,n;if(l=+n._x.call(null,r.data),e===l)return s.next=r,i?i[h]=s:n._root=s,n;do i=i?i[h]=new Array(2):n._root=new Array(2),(d=e>=(c=(o+a)/2))?o=c:a=c;while((h=+d)==(p=+(l>=c)));return i[p]=r,i[h]=s,n}function ow(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);let i=1/0,r=-1/0;for(let s=0,o;s<e;++s)isNaN(o=+this._x.call(null,n[s]))||(t[s]=o,o<i&&(i=o),o>r&&(r=o));if(i>r)return this;this.cover(i).cover(r);for(let s=0;s<e;++s)tv(this,t[s],n[s]);return this}function aw(n){if(isNaN(n=+n))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(n))+1;else{for(var i=t-e||1,r=this._root,s,o;e>n||n>=t;)switch(o=+(n<e),s=new Array(2),s[o]=r,r=s,i*=2,o){case 0:t=e+i;break;case 1:e=t-i;break}this._root&&this._root.length&&(this._root=r)}return this._x0=e,this._x1=t,this}function cw(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function lw(n){return arguments.length?this.cover(+n[0][0]).cover(+n[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function ji(n,e,t){this.node=n,this.x0=e,this.x1=t}function uw(n,e){var t,i=this._x0,r,s,o=this._x1,a=[],c=this._root,l,d;for(c&&a.push(new ji(c,i,o)),e==null?e=1/0:(i=n-e,o=n+e);l=a.pop();)if(!(!(c=l.node)||(r=l.x0)>o||(s=l.x1)<i))if(c.length){var h=(r+s)/2;a.push(new ji(c[1],h,s),new ji(c[0],r,h)),(d=+(n>=h))&&(l=a[a.length-1],a[a.length-1]=a[a.length-1-d],a[a.length-1-d]=l)}else{var p=Math.abs(n-+this._x.call(null,c.data));p<e&&(e=p,i=n-p,o=n+p,t=c.data)}return t}function dw(n){if(isNaN(c=+this._x.call(null,n)))return this;var e,t=this._root,i,r,s,o=this._x0,a=this._x1,c,l,d,h,p;if(!t)return this;if(t.length)for(;;){if((d=c>=(l=(o+a)/2))?o=l:a=l,e=t,!(t=t[h=+d]))return this;if(!t.length)break;e[h+1&1]&&(i=e,p=h)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[h]=s:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(i?i[p]=t:this._root=t),this):(this._root=s,this)}function hw(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function pw(){return this._root}function fw(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function _w(n){var e=[],t,i=this._root,r,s,o;for(i&&e.push(new ji(i,this._x0,this._x1));t=e.pop();)if(!n(i=t.node,s=t.x0,o=t.x1)&&i.length){var a=(s+o)/2;(r=i[1])&&e.push(new ji(r,a,o)),(r=i[0])&&e.push(new ji(r,s,a))}return this}function mw(n){var e=[],t=[],i;for(this._root&&e.push(new ji(this._root,this._x0,this._x1));i=e.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.x1,c=(o+a)/2;(s=r[0])&&e.push(new ji(s,o,c)),(s=r[1])&&e.push(new ji(s,c,a))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.x1);return this}function gw(n){return n[0]}function vw(n){return arguments.length?(this._x=n,this):this._x}function Yh(n,e){var t=new Qh(e??gw,NaN,NaN);return n==null?t:t.addAll(n)}function Qh(n,e,t){this._x=n,this._x0=e,this._x1=t,this._root=void 0}function w_(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var xn=Yh.prototype=Qh.prototype;xn.copy=function(){var n=new Qh(this._x,this._x0,this._x1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=w_(e),n;for(t=[{source:e,target:n._root=new Array(2)}];e=t.pop();)for(var r=0;r<2;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(2)}):e.target[r]=w_(i));return n};xn.add=sw;xn.addAll=ow;xn.cover=aw;xn.data=cw;xn.extent=lw;xn.find=uw;xn.remove=dw;xn.removeAll=hw;xn.root=pw;xn.size=fw;xn.visit=_w;xn.visitAfter=mw;xn.x=vw;function yw(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return nv(this.cover(e,t),e,t,n)}function nv(n,e,t,i){if(isNaN(e)||isNaN(t))return n;var r,s=n._root,o={data:i},a=n._x0,c=n._y0,l=n._x1,d=n._y1,h,p,_,g,S,m,f,M;if(!s)return n._root=o,n;for(;s.length;)if((S=e>=(h=(a+l)/2))?a=h:l=h,(m=t>=(p=(c+d)/2))?c=p:d=p,r=s,!(s=s[f=m<<1|S]))return r[f]=o,n;if(_=+n._x.call(null,s.data),g=+n._y.call(null,s.data),e===_&&t===g)return o.next=s,r?r[f]=o:n._root=o,n;do r=r?r[f]=new Array(4):n._root=new Array(4),(S=e>=(h=(a+l)/2))?a=h:l=h,(m=t>=(p=(c+d)/2))?c=p:d=p;while((f=m<<1|S)===(M=(g>=p)<<1|_>=h));return r[M]=s,r[f]=o,n}function Ew(n){var e,t,i=n.length,r,s,o=new Array(i),a=new Array(i),c=1/0,l=1/0,d=-1/0,h=-1/0;for(t=0;t<i;++t)isNaN(r=+this._x.call(null,e=n[t]))||isNaN(s=+this._y.call(null,e))||(o[t]=r,a[t]=s,r<c&&(c=r),r>d&&(d=r),s<l&&(l=s),s>h&&(h=s));if(c>d||l>h)return this;for(this.cover(c,l).cover(d,h),t=0;t<i;++t)nv(this,o[t],a[t],n[t]);return this}function Tw(n,e){if(isNaN(n=+n)||isNaN(e=+e))return this;var t=this._x0,i=this._y0,r=this._x1,s=this._y1;if(isNaN(t))r=(t=Math.floor(n))+1,s=(i=Math.floor(e))+1;else{for(var o=r-t||1,a=this._root,c,l;t>n||n>=r||i>e||e>=s;)switch(l=(e<i)<<1|n<t,c=new Array(4),c[l]=a,a=c,o*=2,l){case 0:r=t+o,s=i+o;break;case 1:t=r-o,s=i+o;break;case 2:r=t+o,i=s-o;break;case 3:t=r-o,i=s-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=t,this._y0=i,this._x1=r,this._y1=s,this}function bw(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}
vendor: 4,555 bytes, line 3828
3828function Sw(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function gn(n,e,t,i,r){this.node=n,this.x0=e,this.y0=t,this.x1=i,this.y1=r}function Aw(n,e,t){var i,r=this._x0,s=this._y0,o,a,c,l,d=this._x1,h=this._y1,p=[],_=this._root,g,S;for(_&&p.push(new gn(_,r,s,d,h)),t==null?t=1/0:(r=n-t,s=e-t,d=n+t,h=e+t,t*=t);g=p.pop();)if(!(!(_=g.node)||(o=g.x0)>d||(a=g.y0)>h||(c=g.x1)<r||(l=g.y1)<s))if(_.length){var m=(o+c)/2,f=(a+l)/2;p.push(new gn(_[3],m,f,c,l),new gn(_[2],o,f,m,l),new gn(_[1],m,a,c,f),new gn(_[0],o,a,m,f)),(S=(e>=f)<<1|n>=m)&&(g=p[p.length-1],p[p.length-1]=p[p.length-1-S],p[p.length-1-S]=g)}else{var M=n-+this._x.call(null,_.data),w=e-+this._y.call(null,_.data),b=M*M+w*w;if(b<t){var R=Math.sqrt(t=b);r=n-R,s=e-R,d=n+R,h=e+R,i=_.data}}return i}function xw(n){if(isNaN(d=+this._x.call(null,n))||isNaN(h=+this._y.call(null,n)))return this;var e,t=this._root,i,r,s,o=this._x0,a=this._y0,c=this._x1,l=this._y1,d,h,p,_,g,S,m,f;if(!t)return this;if(t.length)for(;;){if((g=d>=(p=(o+c)/2))?o=p:c=p,(S=h>=(_=(a+l)/2))?a=_:l=_,e=t,!(t=t[m=S<<1|g]))return this;if(!t.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(i=e,f=m)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[m]=s:delete e[m],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(i?i[f]=t:this._root=t),this):(this._root=s,this)}function ww(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function Iw(){return this._root}function Mw(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function Cw(n){var e=[],t,i=this._root,r,s,o,a,c;for(i&&e.push(new gn(i,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!n(i=t.node,s=t.x0,o=t.y0,a=t.x1,c=t.y1)&&i.length){var l=(s+a)/2,d=(o+c)/2;(r=i[3])&&e.push(new gn(r,l,d,a,c)),(r=i[2])&&e.push(new gn(r,s,d,l,c)),(r=i[1])&&e.push(new gn(r,l,o,a,d)),(r=i[0])&&e.push(new gn(r,s,o,l,d))}return this}function Rw(n){var e=[],t=[],i;for(this._root&&e.push(new gn(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.y0,c=i.x1,l=i.y1,d=(o+c)/2,h=(a+l)/2;(s=r[0])&&e.push(new gn(s,o,a,d,h)),(s=r[1])&&e.push(new gn(s,d,a,c,h)),(s=r[2])&&e.push(new gn(s,o,h,d,l)),(s=r[3])&&e.push(new gn(s,d,h,c,l))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Pw(n){return n[0]}function Lw(n){return arguments.length?(this._x=n,this):this._x}function Dw(n){return n[1]}function Nw(n){return arguments.length?(this._y=n,this):this._y}function Zh(n,e,t){var i=new Jh(e??Pw,t??Dw,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function Jh(n,e,t,i,r,s){this._x=n,this._y=e,this._x0=t,this._y0=i,this._x1=r,this._y1=s,this._root=void 0}function I_(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var En=Zh.prototype=Jh.prototype;En.copy=function(){var n=new Jh(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=I_(e),n;for(t=[{source:e,target:n._root=new Array(4)}];e=t.pop();)for(var r=0;r<4;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(4)}):e.target[r]=I_(i));return n};En.add=yw;En.addAll=Ew;En.cover=Tw;En.data=bw;En.extent=Sw;En.find=Aw;En.remove=xw;En.removeAll=ww;En.root=Iw;En.size=Mw;En.visit=Cw;En.visitAfter=Rw;En.x=Lw;En.y=Nw;function kw(n){const e=+this._x.call(null,n),t=+this._y.call(null,n),i=+this._z.call(null,n);return iv(this.cover(e,t,i),e,t,i,n)}function iv(n,e,t,i,r){if(isNaN(e)||isNaN(t)||isNaN(i))return n;var s,o=n._root,a={data:r},c=n._x0,l=n._y0,d=n._z0,h=n._x1,p=n._y1,_=n._z1,g,S,m,f,M,w,b,R,P,T,A;if(!o)return n._root=a,n;for(;o.length;)if((b=e>=(g=(c+h)/2))?c=g:h=g,(R=t>=(S=(l+p)/2))?l=S:p=S,(P=i>=(m=(d+_)/2))?d=m:_=m,s=o,!(o=o[T=P<<2|R<<1|b]))return s[T]=a,n;if(f=+n._x.call(null,o.data),M=+n._y.call(null,o.data),w=+n._z.call(null,o.data),e===f&&t===M&&i===w)return a.next=o,s?s[T]=a:n._root=a,n;do s=s?s[T]=new Array(8):n._root=new Array(8),(b=e>=(g=(c+h)/2))?c=g:h=g,(R=t>=(S=(l+p)/2))?l=S:p=S,(P=i>=(m=(d+_)/2))?d=m:_=m;while((T=P<<2|R<<1|b)===(A=(w>=m)<<2|(M>=S)<<1|f>=g));return s[A]=o,s[T]=a,n}function Uw(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),i=new Float64Array(e),r=new Float64Array(e);let s=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,d=-1/0;for(let h=0,p,_,g,S;h<e;++h)isNaN(_=+this._x.call(null,p=n[h]))||isNaN(g=+this._y.call(null,p))||isNaN(S=+this._z.call(null,p))||
3828(t[h]=_,i[h]=g,r[h]=S,_<s&&(s=_),_>c&&(c=_),g<o&&(o=g),g>l&&(l=g),S<a&&(a=S),S>d&&(d=S));if(s>c||o>l||a>d)return this;this.cover(s,o,a).cover(c,l,d);for(let h=0;h<e;++h)iv(this,t[h],i[h],r[h],n[h]);return this}function Ow(n,e,t){if(isNaN(n=+n)||isNaN(e=+e)||isNaN(t=+t))return this;var i=this._x0,r=this._y0,s=this._z0,o=this._x1,a=this._y1,c=this._z1;if(isNaN(i))o=(i=Math.floor(n))+1,a=(r=Math.floor(e))+1,c=(s=Math.floor(t))+1;else{for(var l=o-i||1,d=this._root,h,p;i>n||n>=o||r>e||e>=a||s>t||t>=c;)switch(p=(t<s)<<2|(e<r)<<1|n<i,h=new Array(8),h[p]=d,d=h,l*=2,p){case 0:o=i+l,a=r+l,c=s+l;break;case 1:i=o-l,a=r+l,c=s+l;break;case 2:o=i+l,r=a-l,c=s+l;break;case 3:i=o-l,r=a-l,c=s+l;break;case 4:o=i+l,a=r+l,s=c-l;break;case 5:i=o-l,a=r+l,s=c-l;break;case 6:o=i+l,r=a-l,s=c-l;break;case 7:i=o-l,r=a-l,s=c-l;break}this._root&&this._root.length&&(this._root=d)}return this._x0=i,this._y0=r,this._z0=s,this._x1=o,this._y1=a,this._z1=c,this}function Fw(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function Vw(n){return arguments.length?this.cover(+n[0][0],+n[0][1],+n[0][2]).cover(+n[1][0],+n[1][1],+n[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function xt(n,e,t,i,r,s,o){this.node=n,this.x0=e,this.y0=t,this.z0=i,this.x1=r,this.y1=s,this.z1=o}function Bw(n,e,t,i){var r,s=this._x0,o=this._y0,a=this._z0,c,l,d,h,p,_,g=this._x1,S=this._y1,m=this._z1,f=[],M=this._root,w,b;for(M&&f.push(new xt(M,s,o,a,g,S,m)),i==null?i=1/0:(s=n-i,o=e-i,a=t-i,g=n+i,S=e+i,m=t+i,i*=i);w=f.pop();)if(!(!(M=w.node)||(c=w.x0)>g||(l=w.y0)>S||(d=w.z0)>m||(h=w.x1)<s||(p=w.y1)<o||(_=w.z1)<a))if(M.length){var R=(c+h)/2,P=(l+p)/2,T=(d+_)/2;f.push(new xt(M[7],R,P,T,h,p,_),new xt(M[6],c,P,T,R,p,_),new xt(M[5],R,l,T,h,P,_),new xt(M[4],c,l,T,R,P,_),new xt(M[3],R,P,d,h,p,T),new xt(M[2],c,P,d,R,p,T),new xt(M[1],R,l,d,h,P,T),new xt(M[0],c,l,d,R,P,T)),(b=(t>=T)<<2|(e>=P)<<1|n>=R)&&(w=f[f.length-1],f[f.length-1]=f[f.length-1-b],f[f.length-1-b]=w)}else{var A=n-+this._x.call(null,M.data),E=e-+this._y.call(null,M.data),y=t-+this._z.call(null,M.data),I=A*A+E*E+y*y;if(I<i){var D=Math.sqrt(i=I);s=n-D,o=e-D,a=t-D,g=n+D,S=e+D,m=t+D,r=M.data}}return r}function zw(n){if(isNaN(p=+this._x.call(null,n))||isNaN(_=+this._y.call(null,n))||isNaN(g=+this._z.call(null,n)))return this;var e,t=this._root,i,r,s,o=this._x0,a=this._y0,c=this._z0,l=this._x1,d=this._y1,h=this._z1,p,_,g,S,m,f,M,w,b,R,P;if(!t)return this;if(t.length)for(;;){if((M=p>=(S=(o+l)/2))?o=S:l=S,(w=_>=(m=(a+d)/2))?a=m:d=m,(b=g>=(f=(c+h)/2))?c=f:h=f,e=t,!(t=t[R=b<<2|w<<1|M]))return this;if(!t.length)break;(e[R+1&7]||e[R+2&7]||e[R+3&7]||e[R+4&7]||e[R+5&7]||e[R+6&7]||e[R+7&7])&&(i=e,P=R)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[R]=s:delete e[R],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(i?i[P]=t:this._root=t),this):(this._root=s,this)}function Hw(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function Gw(){return this._root}function Ww(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function qw(n){var e=[],t,i=this._root,r,s,o,a,c,l,d;for(i&&e.push(new xt(i,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!n(i=t.node,s=t.x0,o=t.y0,a=t.z0,c=t.x1,l=t.y1,d=t.z1)&&i.length){var h=(s+c)/2,p=(o+l)/2,_=(a+d)/2;(r=i[7])&&e.push(new xt(r,h,p,_,c,l,d)),(r=i[6])&&e.push(new xt(r,s,p,_,h,l,d)),(r=i[5])&&e.push(new xt(r,h,o,_,c,p,d)),(r=i[4])&&e.push(new xt(r,s,o,_,h,p,d)),(r=i[3])&&e.push(new xt(r,h,p,a,c,l,_)),(r=i[2])&&e.push(new xt(r,s,p,a,h,l,_)),(r=i[1])&&e.push(new xt(r,h,o,a,c,p,_)),(r=i[0])&&e.push(new xt(r,s,o,a,h,p,_))}return this}function Xw(n){var e=[],t=[],i;for(this._root&&e.push(new xt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=e.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.y0,c=i.z0,l=i.x1,d=i.y1,h=i.z1,p=(o+l)/2,_=(a+d)/2,g=(c+h)/2;(s=r[0])&&e.push(new xt(s,o,a,c,p,_,g)),(s=r[1])&&e.push(new xt(s,p,a,c,l,_,g)),(s=r[2])&&e.push(new xt(s,o,_,c,p,d,g)),(s=r[3])&&e.push(new xt(s,p,_,c,l,d,g)),(s=r[4])&&e.push(new xt(s,o,a,g,p,_,h)),(s=r[5])&&e.push(new xt(s,p,a,g,l,_,h)),(s=r[6])&&e.push(new xt(s,o,_,g,p,d,h)),(s=r[7])&&e.push(new xt(s,p,_,g,l,d,h))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.y0,i.z0,i.x1,i.y1,i.z1);return this}function jw(n){return n[0]}function Kw(n){return arguments.length?(this._x=n,this):this._x}function Yw(n){return n[1]}function Qw(n){return arguments.length?(this._y=n,this):this._y}function Zw(n){return n[2]}function Jw(n){return arguments.length?(this._z=n,this):this._z}function $h(n,e,t,i){var r=new ep(e??jw,t??Yw,i??Zw,NaN,NaN,NaN,NaN,NaN,NaN);return n==null?r:r.addAll(n)}function ep(n,e,t,i,r,s,o,a,c){this._x=n,this._y=e,this._z=t,this._x0=i,this._y0=r,this._z0=s,this._x1=o,this._y1=a,this._z1=c,this._root=void 0}function M_(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var pn=$h.prototype=ep.prototype;pn.copy=function(){var n=new ep(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=M_(e),n;for(t=[{source:e,target:n._root=new Array(8)}];e=t.pop();)for(var r=0;r<8;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(8)}):e.target[r]=M_(i));return n};pn.add=kw;pn.addAll=Uw;pn.cover=Ow;pn.data=Fw;pn.extent=Vw;pn.find=Bw;pn.remove=zw;pn.removeAll=Hw;pn.root=Gw;pn.size=Ww;pn.visit=qw;pn.visitAfter=Xw;pn.x=Kw;pn.y=Qw;pn.z=Jw;function ti(n){return function(){return n}}function Bn(n){return(n()-.5)*1e-6}function Yu(n){return n.x+n.vx}function C_(n){return n.y+n.vy}function $w(n){return n.z+n.vz}function Ek(n){var e,t,i,r,s=1,o=1;typeof n!="function"&&(n=ti(n==null?1:+n));function a(){for(var d,h=e.length,p,_,g,S,m,f,M,w=0;w<o;++w)for(p=(t===1?Yh(e,Yu):t===2?Zh(e,Yu,C_):t===3?$h(e,Yu,C_,$w):null).visitAfter(c),d=0;d<h;++d)_=e[d],f=i[_.index],M=f*f,g=_.x+_.vx,t>1&&(S=_.y+_.vy),t>2&&(m=_.z+_.vz),p.visit(b);function b(R,P,T,A,E,y,I){var D=[P,T,A,E,y,I],C=D[0],W=D[1],Z=D[2],Y=D[t],ce=D[t+1],K=D[t+2],ue=R.data,ve=R.r,ye=f+ve;if(ue){if(ue.index>_.index){var Oe=g-ue.x-ue.vx,Ve=t>1?S-ue.y-ue.vy:0,J=t>2?m-ue.z-ue.vz:0,re=Oe*Oe+Ve*Ve+J*J;re<ye*ye&&(Oe===0&&(Oe=Bn(r),re+=Oe*Oe),t>1&&Ve===0&&(Ve=Bn(r),re+=Ve*Ve),t>2&&J===0&&(J=Bn(r),re+=J*J),re=(ye-(re=Math.sqrt(re)))/re*s,_.vx+=(Oe*=re)*(ye=(ve*=ve)/(M+ve)),t>1&&(_.vy+=(Ve*=re)*ye),t>2&&(_.vz+=(J*=re)*ye),ue.vx-=Oe*(ye=1-ye),t>1&&(ue.vy-=Ve*ye),t>2&&(ue.vz-=J*ye))}return}return C>g+ye||Y<g-ye||t>1&&(W>S+ye||ce<S-ye)||t>2&&(Z>m+ye||K<m-ye)}}function c(d){if(d.data)return d.r=i[d.data.index];for(var h=d.r=0;h<Math.pow(2,t);++h)d[h]&&d[h].r>d.r&&(d.r=d[h].r)}function l(){if(e){var d,h=e.length,p;for(i=new Array(h),d=0;d<h;++d)p=e[d],i[p.index]=+n(p,d,e)}}return a.initialize=function(d,...h){e=d,r=h.find(p=>typeof p=="function")||Math.random,t=h.find(p=>[1,2,3].includes(p))||2,l()},a.iterations=function(d){return arguments.length?(o=+d,a):o},a.strength=function(d){return arguments.length?(s=+d,a):s},a.radius=function(d){return arguments.length?(n=typeof d=="function"?d:ti(+d),l(),a):n},a}function eI(n){return n.index}function R_(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function Tk(n){var e=eI,t=p,i,r=ti(30),s,o,a,c,l,d,h=1;n==null&&(n=[]);function p(f){return 1/Math.min(c[f.source.index],c[f.target.index])}function _(f){for(var M=0,w=n.length;M<h;++M)for(var b=0,R,P,T,A=0,E=0,y=0,I,D;b<w;++b)R=n[b],P=R.source,T=R.target,A=T.x+T.vx-P.x-P.vx||Bn(d),a>1&&(E=T.y+T.vy-P.y-P.vy||Bn(d)),a>2&&(y=T.z+T.vz-P.z-P.vz||Bn(d)),I=Math.sqrt(A*A+E*E+y*y),I=(I-s[b])/I*f*i[b],A*=I,E*=I,y*=I,T.vx-=A*(D=l[b]),a>1&&(T.vy-=E*D),a>2&&(T.vz-=y*D),P.vx+=A*(D=1-D),a>1&&(P.vy+=E*D),a>2&&(P.vz+=y*D)}function g(){if(o){var f,M=o.length,w=n.length,b=new Map(o.map((P,T)=>[e(P,T,o),P])),R;for(f=0,c=new Array(M);f<w;++f)R=n[f],R.index=f,typeof R.source!="object"&&(R.source=R_(b,R.source)),typeof R.target!="object"&&(R.target=R_(b,R.target)),c[R.source.index]=(c[R.source.index]||0)+1,c[R.target.index]=(c[R.target.index]||0)+1;for(f=0,l=new Array(w);f<w;++f)R=n[f],l[f]=c[R.source.index]/(c[R.source.index]+c[R.target.index]);i=new Array(w),S(),s=new Array(w),m()}}function S(){if(o)for(var f=0,M=n.length;
3828f<M;++f)i[f]=+t(n[f],f,n)}function m(){if(o)for(var f=0,M=n.length;f<M;++f)s[f]=+r(n[f],f,n)}return _.initialize=function(f,...M){o=f,d=M.find(w=>typeof w=="function")||Math.random,a=M.find(w=>[1,2,3].includes(w))||2,g()},_.links=function(f){return arguments.length?(n=f,g(),_):n},_.id=function(f){return arguments.length?(e=f,_):e},_.iterations=function(f){return arguments.length?(h=+f,_):h},_.strength=function(f){return arguments.length?(t=typeof f=="function"?f:ti(+f),S(),_):t},_.distance=function(f){return arguments.length?(r=typeof f=="function"?f:ti(+f),m(),_):r},_}var tI={value:()=>{}};function rv(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new Jc(t)}function Jc(n){this._=n}function nI(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}Jc.prototype=rv.prototype={constructor:Jc,on:function(n,e){var t=this._,i=nI(n+"",t),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(n=i[s]).type)&&(r=iI(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(n=i[s]).type)t[r]=P_(t[r],n.name,e);else if(e==null)for(r in t)t[r]=P_(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new Jc(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function iI(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function P_(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=tI,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var Js=0,ea=0,Ho=0,sv=1e3,fl,ta,_l=0,Zr=0,Gl=0,xa=typeof performance=="object"&&performance.now?performance:Date,ov=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function av(){return Zr||(ov(rI),Zr=xa.now()+Gl)}function rI(){Zr=0}function rh(){this._call=this._time=this._next=null}rh.prototype=cv.prototype={constructor:rh,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?av():+t)+(e==null?0:+e),!this._next&&ta!==this&&(ta?ta._next=this:fl=this,ta=this),this._call=n,this._time=t,sh()},stop:function(){this._call&&(this._call=null,this._time=1/0,sh())}};function cv(n,e,t){var i=new rh;return i.restart(n,e,t),i}function sI(){av(),++Js;for(var n=fl,e;n;)(e=Zr-n._time)>=0&&n._call.call(void 0,e),n=n._next;--Js}function L_(){Zr=(_l=xa.now())+Gl,Js=ea=0;try{sI()}finally{Js=0,aI(),Zr=0}}function oI(){var n=xa.now(),e=n-_l;e>sv&&(Gl-=e,_l=n)}function aI(){for(var n,e=fl,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:fl=t);ta=n,sh(i)}function sh(n){if(!Js){ea&&(ea=clearTimeout(ea));var e=n-Zr;e>24?(n<1/0&&(ea=setTimeout(L_,n-xa.now()-Gl)),Ho&&(Ho=clearInterval(Ho))):(Ho||(_l=xa.now(),Ho=setInterval(oI,sv)),Js=1,ov(L_))}}const cI=1664525,lI=1013904223,D_=4294967296;function uI(){let n=1;return()=>(n=(cI*n+lI)%D_)/D_}var N_=3;function Qu(n){return n.x}function k_(n){return n.y}function dI(n){return n.z}var hI=10,pI=Math.PI*(3-Math.sqrt(5)),fI=Math.PI*20/(9+Math.sqrt(221));function bk(n,e){e=e||2;var t=Math.min(N_,Math.max(1,Math.round(e))),i,r=1,s=.001,o=1-Math.pow(s,1/300),a=0,c=.6,l=new Map,d=cv(_),h=rv("tick","end"),p=uI();n==null&&(n=[]);function _(){g(),h.call("tick",i),r<s&&(d.stop(),h.call("end",i))}function g(f){var M,w=n.length,b;f===void 0&&(f=1);for(var R=0;R<f;++R)for(r+=(a-r)*o,l.forEach(function(P){P(r)}),M=0;M<w;++M)b=n[M],b.fx==null?b.x+=b.vx*=c:(b.x=b.fx,b.vx=0),t>1&&(b.fy==null?b.y+=b.vy*=c:(b.y=b.fy,b.vy=0)),t>2&&(b.fz==null?b.z+=b.vz*=c:(b.z=b.fz,b.vz=0));return i}function S(){for(var f=0,M=n.length,w;f<M;++f){if(w=n[f],w.index=f,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),w.fz!=null&&(w.z=w.fz),isNaN(w.x)||t>1&&isNaN(w.y)||t>2&&isNaN(w.z)){var b=hI*(t>2?Math.cbrt(.5+f):t>1?Math.sqrt(.5+f):f),R=f*pI,P=f*fI;t===1?w.x=b:t===2?(w.x=b*Math.cos(R),w.y=b*Math.sin(R)):(w.x=b*Math.sin(R)*Math.cos(P),w.y=b*Math.cos(R),w.z=b*Math.sin(R)*Math.sin(P))}(isNaN(w.vx)||t>1&&isNaN(w.vy)||t>2&&isNaN(w.vz))&&(w.vx=0,t>1&&(w.vy=0),t>2&&(w.vz=0))}}function m(f){return f.initialize&&f.initialize(n,p,t),f}return S(),i={tick:g,restart:function(){return d.restart(_),i},stop:function(){return d.stop(),i},numDimensions:function(f){return arguments.length?(t=Math.min(N_,Math.max(1,Math.round(f))),l.forEach(m),i):t},nodes:function(f){return arguments.length?(n=f,S(),l.forEach(m),i):n},alpha:function(f){return arguments.length?(r=+f,i):r},alphaMin:function(f){return arguments.length?(s=+f,i):s},alphaDecay:function(f){return arguments.length?(o=+f,i):+o},alphaTarget:function(f){return arguments.length?(a=+f,i):a},velocityDecay:function(f){return arguments.length?(c=1-f,i):1-c},randomSource:function(f){return arguments.length?(p=f,l.forEach(m),i):p},force:function(f,M){return arguments.length>1?(M==null?l.delete(f):l.set(f,m(M)),i):l.get(f)},find:function(){var f=Array.prototype.slice.call(arguments),M=f.shift()||0,w=(t>1?f.shift():null)||0,b=(t>2?f.shift():null)||0,R=f.shift()||1/0,P=0,T=n.length,A,E,y,I,D,C;for(R*=R,P=0;P<T;++P)D=n[P],A=M-D.x,E=w-(D.y||0),y=b-(D.z||0),I=A*A+E*E+y*y,I<R&&(C=D,R=I);return C},on:function(f,M){return arguments.length>1?(h.on(f,M),i):h.on(f)}}}function Sk(){var n,e,t,i,r,s=ti(-30),o,a=1,c=1/0,l=.81;
3828function d(g){var S,m=n.length,f=(e===1?Yh(n,Qu):e===2?Zh(n,Qu,k_):e===3?$h(n,Qu,k_,dI):null).visitAfter(p);for(r=g,S=0;S<m;++S)t=n[S],f.visit(_)}function h(){if(n){var g,S=n.length,m;for(o=new Array(S),g=0;g<S;++g)m=n[g],o[m.index]=+s(m,g,n)}}function p(g){var S=0,m,f,M=0,w,b,R,P,T=g.length;if(T){for(w=b=R=P=0;P<T;++P)(m=g[P])&&(f=Math.abs(m.value))&&(S+=m.value,M+=f,w+=f*(m.x||0),b+=f*(m.y||0),R+=f*(m.z||0));S*=Math.sqrt(4/T),g.x=w/M,e>1&&(g.y=b/M),e>2&&(g.z=R/M)}else{m=g,m.x=m.data.x,e>1&&(m.y=m.data.y),e>2&&(m.z=m.data.z);do S+=o[m.data.index];while(m=m.next)}g.value=S}function _(g,S,m,f,M){if(!g.value)return!0;var w=[m,f,M][e-1],b=g.x-t.x,R=e>1?g.y-t.y:0,P=e>2?g.z-t.z:0,T=w-S,A=b*b+R*R+P*P;if(T*T/l<A)return A<c&&(b===0&&(b=Bn(i),A+=b*b),e>1&&R===0&&(R=Bn(i),A+=R*R),e>2&&P===0&&(P=Bn(i),A+=P*P),A<a&&(A=Math.sqrt(a*A)),t.vx+=b*g.value*r/A,e>1&&(t.vy+=R*g.value*r/A),e>2&&(t.vz+=P*g.value*r/A)),!0;if(g.length||A>=c)return;(g.data!==t||g.next)&&(b===0&&(b=Bn(i),A+=b*b),e>1&&R===0&&(R=Bn(i),A+=R*R),e>2&&P===0&&(P=Bn(i),A+=P*P),A<a&&(A=Math.sqrt(a*A)));do g.data!==t&&(T=o[g.data.index]*r/A,t.vx+=b*T,e>1&&(t.vy+=R*T),e>2&&(t.vz+=P*T));while(g=g.next)}return d.initialize=function(g,...S){n=g,i=S.find(m=>typeof m=="function")||Math.random,e=S.find(m=>[1,2,3].includes(m))||2,h()},d.strength=function(g){return arguments.length?(s=typeof g=="function"?g:ti(+g),h(),d):s},d.distanceMin=function(g){return arguments.length?(a=g*g,d):Math.sqrt(a)},d.distanceMax=function(g){return arguments.length?(c=g*g,d):Math.sqrt(c)},d.theta=function(g){return arguments.length?(l=g*g,d):Math.sqrt(l)},d}function Ak(n,e,t,i){var r,s,o=ti(.1),a,c;typeof n!="function"&&(n=ti(+n)),e==null&&(e=0),t==null&&(t=0),i==null&&(i=0);function l(h){for(var p=0,_=r.length;p<_;++p){var g=r[p],S=g.x-e||1e-6,m=(g.y||0)-t||1e-6,f=(g.z||0)-i||1e-6,M=Math.sqrt(S*S+m*m+f*f),w=(c[p]-M)*a[p]*h/M;g.vx+=S*w,s>1&&(g.vy+=m*w),s>2&&(g.vz+=f*w)}}function d(){if(r){var h,p=r.length;for(a=new Array(p),c=new Array(p),h=0;h<p;++h)c[h]=+n(r[h],h,r),a[h]=isNaN(c[h])?0:+o(r[h],h,r)}}return l.initialize=function(h,...p){r=h,s=p.find(_=>[1,2,3].includes(_))||2,d()},l.strength=function(h){return arguments.length?(o=typeof h=="function"?h:ti(+h),d(),l):o},l.radius=function(h){return arguments.length?(n=typeof h=="function"?h:ti(+h),d(),l):n},l.x=function(h){return arguments.length?(e=+h,l):e},l.y=function(h){return arguments.length?(t=+h,l):t},l.z=function(h){return arguments.length?(i=+h,l):i},l}var xk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _I(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function oh(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var mI=typeof global=="object"&&global&&global.Object===Object&&global;const gI=mI;var vI=typeof self=="object"&&self&&self.Object===Object&&self,yI=gI||vI||Function("return this")();const lv=yI;var EI=function(){return lv.Date.now()};const Zu=EI;var TI=/\s/;function bI(n){for(var e=n.length;e--&&TI.test(n.charAt(e)););return e}var SI=/^\s+/;function AI(n){return n&&n.slice(0,bI(n)+1).replace(SI,"")}var xI=lv.Symbol;const ml=xI;var uv=Object.prototype,wI=uv.hasOwnProperty,II=uv.toString,Go=ml?ml.toStringTag:void 0;function MI(n){var e=wI.call(n,Go),t=n[Go];try{n[Go]=void 0;var i=!0}catch{}var r=II.call(n);return i&&(e?n[Go]=t:delete n[Go]),r}var CI=Object.prototype,RI=CI.toString;function PI(n){return RI.call(n)}var LI="[object Null]",DI="[object Undefined]",U_=ml?ml.toStringTag:void 0;function NI(n){return n==null?n===void 0?DI:LI:U_&&U_ in Object(n)?MI(n):PI(n)}function kI(n){return n!=null&&typeof n=="object"}var UI="[object Symbol]";function OI(n){return typeof n=="symbol"||kI(n)&&NI(n)==UI}var O_=0/0,FI=/^[-+]0x[0-9a-f]+$/i,VI=/^0b[01]+$/i,BI=/^0o[0-7]+$/i,zI=parseInt;function F_(n){if(typeof n=="number")return n;if(OI(n))return O_;if(oh(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=oh(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=AI(n);var t=VI.test(n);return t||BI.test(n)?zI(n.slice(2),t?2:8):FI.test(n)?O_:+n}var HI="Expected a function",GI=Math.max,WI=Math.min;function qI(n,e,t){var i,r,s,o,a,c,l=0,d=!1,h=!1,p=!0;if(typeof n!="function")throw new TypeError(HI);e=F_(e)||0,oh(t)&&(d=!!t.leading,h="maxWait"in t,s=h?GI(F_(t.maxWait)||0,e):s,p="trailing"in t?!!t.trailing:p);function _(P){var T=i,A=r;return i=r=void 0,l=P,o=n.apply(A,T),o}function g(P){return l=P,a=setTimeout(f,e),d?_(P):o}function S(P){var T=P-c,A=P-l,E=e-T;return h?WI(E,s-A):E}function m(P){var T=P-c,A=P-l;return c===void 0||T>=e||T<0||h&&A>=s}function f(){var P=Zu();if(m(P))return M(P);a=setTimeout(f,S(P))}function M(P){return a=void 0,p&&i?_(P):(i=r=void 0,o)}function w(){a!==void 0&&clearTimeout(a),l=0,i=c=r=a=void 0}function b(){return a===void 0?o:M(Zu())}function R(){var P=Zu(),T=m(P);if(i=arguments,r=this,c=P,T){if(a===void 0)return g(c);if(h)return clearTimeout(a),a=setTimeout(f,e),_(c)}return a===void 0&&(a=setTimeout(f,e)),o}return R.cancel=w,R.flush=b,R}function XI(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,s,o,a=[],c=!0,l=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(i=s.call(t)).done)&&(a.push(i.value),a.length!==e);c=!0);}catch(d){l=!0,r=d}
3828finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw r}}return a}}function jI(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function V_(n,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,eM(i.key),i)}}function KI(n,e,t){return e&&V_(n.prototype,e),t&&V_(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function YI(n,e){return QI(n)||XI(n,e)||ZI(n,e)||JI()}function QI(n){if(Array.isArray(n))return n}function ZI(n,e){if(n){if(typeof n=="string")return B_(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return B_(n,e)}}function B_(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function JI(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 3829In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $I(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function eM(n){var e=$I(n,"string");return typeof e=="symbol"?e:String(e)}var tM=KI(function n(e,t){var i=t.default,r=i===void 0?null:i,s=t.triggerUpdate,o=s===void 0?!0:s,a=t.onChange,c=a===void 0?function(l,d){}:a;jI(this,n),this.name=e,this.defaultVal=r,this.triggerUpdate=o,this.onChange=c});function wk(n){var e=n.stateInit,t=e===void 0?function(){return{}}:e,i=n.props,r=i===void 0?{}:i,s=n.methods,o=s===void 0?{}:s,a=n.aliases,c=a===void 0?{}:a,l=n.init,d=l===void 0?function(){}:l,h=n.update,p=h===void 0?function(){}:h,_=Object.keys(r).map(function(g){return new tM(g,r[g])});return function(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=Object.assign({},t instanceof Function?t(g):t,{initialised:!1}),m={};function f(b){return M(b,g),w(),f}var M=function(R,P){d.call(f,R,S,P),S.initialised=!0},w=qI(function(){S.initialised&&(p.call(f,S,m),m={})},1);return _.forEach(function(b){f[b.name]=R(b);function R(P){var T=P.name,A=P.triggerUpdate,E=A===void 0?!1:A,y=P.onChange,I=y===void 0?function(W,Z){}:y,D=P.defaultVal,C=D===void 0?null:D;return function(W){var Z=S[T];if(!arguments.length)return Z;var Y=W===void 0?C:W;return S[T]=Y,I.call(f,Y,S,Z),!m.hasOwnProperty(T)&&(m[T]=Z),E&&w(),f}}}),Object.keys(o).forEach(function(b){f[b]=function(){for(var R,P=arguments.length,T=new Array(P),A=0;A<P;A++)T[A]=arguments[A];return(R=o[b]).call.apply(R,[f,S].concat(T))}}),Object.entries(c).forEach(function(b){var R=YI(b,2),P=R[0],T=R[1];return f[P]=f[T]}),f.resetProps=function(){return _.forEach(function(b){f[b.name](b.defaultVal)}),f},f.resetProps(),S._rerender=w,f}}var Ik=function(n){return typeof n=="function"?n:typeof n=="string"?function(e){return e[n]}:function(e){return n}};class z_ extends Map{constructor(e,t=rM){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[i,r]of e)this.set(i,r)}get(e){return super.get(H_(this,e))}has(e){return super.has(H_(this,e))}set(e,t){return super.set(nM(this,e),t)}delete(e){return super.delete(iM(this,e))}}function H_({_intern:n,_key:e},t){const i=e(t);return n.has(i)?n.get(i):t}function nM({_intern:n,_key:e},t){const i=e(t);return n.has(i)?n.get(i):(n.set(i,t),t)}function iM({_intern:n,_key:e},t){const i=e(t);return n.has(i)&&(t=n.get(i),n.delete(i)),t}function rM(n){return n!==null&&typeof n=="object"?n.valueOf():n}function Mk(n,e){let t;if(e===void 0)for(const i of n)i!=null&&(t<i||t===void 0&&i>=i)&&(t=i);else{let i=-1;for(let r of n)(r=e(r,++i,n))!=null&&(t<r||t===void 0&&r>=r)&&(t=r)}return t}function Ck(n,e){let t;if(e===void 0)for(const i of n)i!=null&&(t>i||t===void 0&&i>=i)&&(t=i);else{let i=-1;for(let r of n)(r=e(r,++i,n))!=null&&(t>r||t===void 0&&r>=r)&&(t=r)}return t}function ah(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function sM(n){if(Array.isArray(n))return n}function oM(n){if(Array.isArray(n))return ah(n)}function aM(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function cM(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,s,o,a=[],c=!0,l=!1;try{if(s=(t=t.call(n)).next,e!==0)for(;!(c=(i=s.call(t)).done)&&(a.push(i.value),a.length!==e);c=!0);}catch(d){l=!0,r=d}
3829finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw r}}return a}}function lM(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 3830In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uM(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 3831In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dM(n,e){if(n==null)return{};var t,i,r=hM(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)t=s[i],e.includes(t)||{}.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function hM(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.includes(i))continue;t[i]=n[i]}return t}function pM(n,e){return sM(n)||cM(n,e)||dv(n,e)||lM()}function fM(n){return oM(n)||aM(n)||dv(n)||uM()}function _M(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function mM(n){var e=_M(n,"string");return typeof e=="symbol"?e:e+""}function dv(n,e){if(n){if(typeof n=="string")return ah(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ah(n,e):void 0}}var Rk=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(a){return{keyAccessor:a,isProp:!(a instanceof Function)}}),s=n.reduce(function(a,c){var l=a,d=c;return r.forEach(function(h,p){var _=h.keyAccessor,g=h.isProp,S;if(g){var m=d,f=m[_],M=dM(m,[_].map(mM));S=f,d=M}else S=_(d,p);p+1<r.length?(l.hasOwnProperty(S)||(l[S]={}),l=l[S]):t?(l.hasOwnProperty(S)||(l[S]=[]),l[S].push(d)):l[S]=d}),a},{});t instanceof Function&&function a(c){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;l===r.length?Object.keys(c).forEach(function(d){return c[d]=t(c[d])}):Object.values(c).forEach(function(d){return a(d,l+1)})}(s);var o=s;return i&&(o=[],function a(c){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];l.length===r.length?o.push({keys:l,vals:c}):Object.entries(c).forEach(function(d){var h=pM(d,2),p=h[0],_=h[1];return a(_,[].concat(fM(l),[p]))})}(s),e instanceof Array&&e.length===0&&o.length===1&&(o[0].keys=[])),o};function gM(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}const G_=Symbol("implicit");function vM(){var n=new z_,e=[],t=[],i=G_;function r(s){let o=n.get(s);if(o===void 0){if(i!==G_)return i;n.set(s,o=e.push(s)-1)}return t[o%t.length]}return r.domain=function(s){if(!arguments.length)return e.slice();e=[],n=new z_;for(const o of s)n.has(o)||n.set(o,e.push(o)-1);return r},r.range=function(s){return arguments.length?(t=Array.from(s),r):t.slice()},r.unknown=function(s){return arguments.length?(i=s,r):i},r.copy=function(){return vM(e,t).unknown(i)},gM.apply(r,arguments),r}function yM(n){for(var e=n.length/6|0,t=new Array(e),i=0;i<e;)t[i]="#"+n.slice(i*6,++i*6);return t}const Pk=yM("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function gl(n){"@babel/helpers - typeof";return gl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gl(n)}var EM=/^\s+/,TM=/\s+$/;function Be(n,e){if(n=n||"",e=e||{},n instanceof Be)return n;if(!(this instanceof Be))return new Be(n,e);var t=bM(n);this._originalInput=n,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Be.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,i,r,s,o,a;return t=e.r/255,i=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),i<=.03928?o=i/12.92:o=Math.pow((i+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*o+.0722*a},setAlpha:function(e){return this._a=hv(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=q_(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=q_(this._r,this._g,this._b),t=Math.round(e.h*360),i=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=W_(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=W_(this._r,this._g,this._b),t=Math.round(e.h*360),i=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return X_(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return wM(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Rt(this._r,255)*100)+"%",g:Math.round(Rt(this._g,255)*100)+"%",b:Math.round(Rt(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Rt(this._r,255)*100)+"%, "+Math.round(Rt(this._g,255)*100)+"%, "+Math.round(Rt(this._b,255)*100)+"%)":"rgba("+Math.round(Rt(this._r,255)*100)+"%, "+Math.round(Rt(this._g,255)*100)+"%, "+Math.round(Rt(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:FM[X_(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+j_(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Be(e);i="#"+j_(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(i=this.toRgbString()),e==="prgb"&&(i=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(i=this.toHexString()),e==="hex3"&&(i=this.toHexString(!0)),e==="hex4"&&(i=this.toHex8String(!0)),e==="hex8"&&(i=this.toHex8String()),e==="name"&&(i=this.toName()),e==="hsl"&&(i=this.toHslString()),e==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return Be(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(RM,arguments)},brighten:function(){return this._applyModification(PM,arguments)},darken:function(){return this._applyModification(LM,arguments)},desaturate:function(){return this._applyModification(IM,arguments)},saturate:function(){return this._applyModification(MM,arguments)},greyscale:function(){return this._applyModification(CM,arguments)},spin:function(){return this._applyModification(DM,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(UM,arguments)},complement:function(){return this._applyCombination(NM,arguments)},monochromatic:function(){return this._applyCombination(OM,arguments)},splitcomplement:function(){return this._applyCombination(kM,arguments)},triad:function(){return this._applyCombination(K_,[3])},tetrad:function(){return this._applyCombination(K_,[4])}};Be.fromRatio=function(n,e){if(gl(n)=="object"){var t={};for(var i in n)n.hasOwnProperty(i)&&(i==="a"?t[i]=n[i]:t[i]=na(n[i]));n=t}return Be(n,e)};function bM(n){var e={r:0,g:0,b:0},t=1,i=null,r=null,s=null,o=!1,a=!1;return typeof n=="string"&&(n=HM(n)),gl(n)=="object"&&(Li(n.r)&&Li(n.g)&&Li(n.b)?(e=SM(n.r,n.g,n.b),o=!0,a=String(n.r).substr(-1)==="%"?"prgb":"rgb"):Li(n.h)&&Li(n.s)&&Li(n.v)?(i=na(n.s),r=na(n.v),e=xM(n.h,i,r),o=!0,a="hsv"):Li(n.h)&&Li(n.s)&&Li(n.l)&&(i=na(n.s),s=na(n.l),e=AM(n.h,i,s),o=!0,a="hsl"),n.hasOwnProperty("a")&&(t=n.a)),t=hv(t),{ok:o,format:n.format||a,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function SM(n,e,t){return{r:Rt(n,255)*255,g:Rt(e,255)*255,b:Rt(t,255)*255}}function W_(n,e,t){n=Rt(n,255),e=Rt(e,255),t=Rt(t,255);var i=Math.max(n,e,t),r=Math.min(n,e,t),s,o,a=(i+r)/2;if(i==r)s=o=0;else{var c=i-r;switch(o=a>.5?c/(2-i-r):c/(i+r),i){case n:s=(e-t)/c+(e<t?6:0);break;case e:s=(t-n)/c+2;break;case t:s=(n-e)/c+4;break}s/=6}return{h:s,s:o,l:a}}function AM(n,e,t){var i,r,s;n=Rt(n,360),e=Rt(e,100),t=Rt(t,100);function o(l,d,h){return h<0&&(h+=1),h>1&&(h-=1),h<1/6?l+(d-l)*6*h:h<1/2?d:h<2/3?l+(d-l)*(2/3-h)*6:l}if(e===0)i=r=s=t;else{var a=t<.5?t*(1+e):t+e-t*e,c=2*t-a;i=o(c,a,n+1/3),r=o(c,a,n),s=o(c,a,n-1/3)}return{r:i*255,g:r*255,b:s*255}}function q_(n,e,t){n=Rt(n,255),e=Rt(e,255),t=Rt(t,255);var i=Math.max(n,e,t),r=Math.min(n,e,t),s,o,a=i,c=i-r;if(o=i===0?0:c/i,i==r)s=0;else{switch(i){case n:s=(e-t)/c+(e<t?6:0);break;case e:s=(t-n)/c+2;break;case t:s=(n-e)/c+4;break}s/=6}return{h:s,s:o,v:a}}function xM(n,e,t){n=Rt(n,360)*6,e=Rt(e,100),t=Rt(t,100);var i=Math.floor(n),r=n-i,s=t*(1-e),o=t*(1-r*e),a=t*(1-(1-r)*e),c=i%6,l=[t,o,s,s,a,t][c],d=[a,t,t,o,s,s][c],h=[s,s,a,t,t,o][c];
vendor: 3,009 bytes, line 3831
3831return{r:l*255,g:d*255,b:h*255}}function X_(n,e,t,i){var r=[ni(Math.round(n).toString(16)),ni(Math.round(e).toString(16)),ni(Math.round(t).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function wM(n,e,t,i,r){var s=[ni(Math.round(n).toString(16)),ni(Math.round(e).toString(16)),ni(Math.round(t).toString(16)),ni(pv(i))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)&&s[3].charAt(0)==s[3].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}function j_(n,e,t,i){var r=[ni(pv(i)),ni(Math.round(n).toString(16)),ni(Math.round(e).toString(16)),ni(Math.round(t).toString(16))];return r.join("")}Be.equals=function(n,e){return!n||!e?!1:Be(n).toRgbString()==Be(e).toRgbString()};Be.random=function(){return Be.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function IM(n,e){e=e===0?0:e||10;var t=Be(n).toHsl();return t.s-=e/100,t.s=Wl(t.s),Be(t)}function MM(n,e){e=e===0?0:e||10;var t=Be(n).toHsl();return t.s+=e/100,t.s=Wl(t.s),Be(t)}function CM(n){return Be(n).desaturate(100)}function RM(n,e){e=e===0?0:e||10;var t=Be(n).toHsl();return t.l+=e/100,t.l=Wl(t.l),Be(t)}function PM(n,e){e=e===0?0:e||10;var t=Be(n).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(255*-(e/100)))),t.g=Math.max(0,Math.min(255,t.g-Math.round(255*-(e/100)))),t.b=Math.max(0,Math.min(255,t.b-Math.round(255*-(e/100)))),Be(t)}function LM(n,e){e=e===0?0:e||10;var t=Be(n).toHsl();return t.l-=e/100,t.l=Wl(t.l),Be(t)}function DM(n,e){var t=Be(n).toHsl(),i=(t.h+e)%360;return t.h=i<0?360+i:i,Be(t)}function NM(n){var e=Be(n).toHsl();return e.h=(e.h+180)%360,Be(e)}function K_(n,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=Be(n).toHsl(),i=[Be(n)],r=360/e,s=1;s<e;s++)i.push(Be({h:(t.h+s*r)%360,s:t.s,l:t.l}));return i}function kM(n){var e=Be(n).toHsl(),t=e.h;return[Be(n),Be({h:(t+72)%360,s:e.s,l:e.l}),Be({h:(t+216)%360,s:e.s,l:e.l})]}function UM(n,e,t){e=e||6,t=t||30;var i=Be(n).toHsl(),r=360/t,s=[Be(n)];for(i.h=(i.h-(r*e>>1)+720)%360;--e;)i.h=(i.h+r)%360,s.push(Be(i));return s}function OM(n,e){e=e||6;for(var t=Be(n).toHsv(),i=t.h,r=t.s,s=t.v,o=[],a=1/e;e--;)o.push(Be({h:i,s:r,v:s})),s=(s+a)%1;return o}Be.mix=function(n,e,t){t=t===0?0:t||50;var i=Be(n).toRgb(),r=Be(e).toRgb(),s=t/100,o={r:(r.r-i.r)*s+i.r,g:(r.g-i.g)*s+i.g,b:(r.b-i.b)*s+i.b,a:(r.a-i.a)*s+i.a};return Be(o)};Be.readability=function(n,e){var t=Be(n),i=Be(e);return(Math.max(t.getLuminance(),i.getLuminance())+.05)/(Math.min(t.getLuminance(),i.getLuminance())+.05)};Be.isReadable=function(n,e,t){var i=Be.readability(n,e),r,s;switch(s=!1,r=GM(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=i>=4.5;break;case"AAlarge":s=i>=3;break;case"AAAsmall":s=i>=7;break}return s};Be.mostReadable=function(n,e,t){var i=null,r=0,s,o,a,c;t=t||{},o=t.includeFallbackColors,a=t.level,c=t.size;
3831for(var l=0;l<e.length;l++)s=Be.readability(n,e[l]),s>r&&(r=s,i=Be(e[l]));return Be.isReadable(n,i,{level:a,size:c})||!o?i:(t.includeFallbackColors=!1,Be.mostReadable(n,["#fff","#000"],t))};var ch=Be.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee9
38310",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},FM=Be.hexNames=VM(ch);function VM(n){var e={};for(var t in n)n.hasOwnProperty(t)&&(e[n[t]]=t);return e}function hv(n){return n=parseFloat(n),(isNaN(n)||n<0||n>1)&&(n=1),n}function Rt(n,e){BM(n)&&(n="100%");var t=zM(n);return n=Math.min(e,Math.max(0,parseFloat(n))),t&&(n=parseInt(n*e,10)/100),Math.abs(n-e)<1e-6?1:n%e/parseFloat(e)}function Wl(n){return Math.min(1,Math.max(0,n))}function Nn(n){return parseInt(n,16)}function BM(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}function zM(n){return typeof n=="string"&&n.indexOf("%")!=-1}function ni(n){return n.length==1?"0"+n:""+n}function na(n){return n<=1&&(n=n*100+"%"),n}function pv(n){return Math.round(parseFloat(n)*255).toString(16)}function Y_(n){return Nn(n)/255}var Zn=function(){var n="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+n+")",i="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+i),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"
3831+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Li(n){return!!Zn.CSS_UNIT.exec(n)}function HM(n){n=n.replace(EM,"").replace(TM,"").toLowerCase();var e=!1;if(ch[n])n=ch[n],e=!0;else if(n=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Zn.rgb.exec(n))?{r:t[1],g:t[2],b:t[3]}:(t=Zn.rgba.exec(n))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Zn.hsl.exec(n))?{h:t[1],s:t[2],l:t[3]}:(t=Zn.hsla.exec(n))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Zn.hsv.exec(n))?{h:t[1],s:t[2],v:t[3]}:(t=Zn.hsva.exec(n))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Zn.hex8.exec(n))?{r:Nn(t[1]),g:Nn(t[2]),b:Nn(t[3]),a:Y_(t[4]),format:e?"name":"hex8"}:(t=Zn.hex6.exec(n))?{r:Nn(t[1]),g:Nn(t[2]),b:Nn(t[3]),format:e?"name":"hex"}:(t=Zn.hex4.exec(n))?{r:Nn(t[1]+""+t[1]),g:Nn(t[2]+""+t[2]),b:Nn(t[3]+""+t[3]),a:Y_(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Zn.hex3.exec(n))?{r:Nn(t[1]+""+t[1]),g:Nn(t[2]+""+t[2]),b:Nn(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function GM(n){var e,t;return n=n||{level:"AA",size:"small"},e=(n.level||"AA").toUpperCase(),t=(n.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Sn(){return Sn=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},Sn.apply(null,arguments)}function WM(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function wa(n,e){return wa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},wa(n,e)}function qM(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,wa(n,e)}function lh(n){return lh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},lh(n)}function XM(n){try{return Function.toString.call(n).indexOf("[native code]")!==-1}catch{return typeof n=="function"}}function fv(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fv=function(){return!!n})()}function jM(n,e,t){if(fv())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var r=new(n.bind.apply(n,i));return t&&wa(r,t.prototype),r}function uh(n){var e=typeof Map=="function"?new Map:void 0;return uh=function(i){if(i===null||!XM(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(i))return e.get(i);e.set(i,r)}function r(){return jM(i,arguments,lh(this).constructor)}return r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),wa(r,i)},uh(n)}var hi=function(n){qM(e,n);function e(t){var i;return i=n.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this,WM(i)}return e}(uh(Error));function Ju(n){return Math.round(n*255)}function KM(n,e,t){return Ju(n)+","+Ju(e)+","+Ju(t)}function Ia(n,e,t,i){if(i===void 0&&(i=KM),e===0)return i(t,t,t);var r=(n%360+360)%360/60,s=(1-Math.abs(2*t-1))*e,o=s*(1-Math.abs(r%2-1)),a=0,c=0,l=0;r>=0&&r<1?(a=s,c=o):r>=1&&r<2?(a=o,c=s):r>=2&&r<3?(c=s,l=o):r>=3&&r<4?(c=o,l=s):r>=4&&r<5?(a=o,l=s):r>=5&&r<6&&(a=s,l=o);var d=t-s/2,h=a+d,p=c+d,_=l+d;return i(h,p,_)}var Q_={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee9
38310",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function YM(n){if(typeof n!="string")return n;var e=n.toLowerCase();return Q_[e]?"#"+Q_[e]:n}var QM=/^#[a-fA-F0-9]{6}$/,ZM=/^#[a-fA-F0-9]{8}$/,JM=/^#[a-fA-F0-9]{3}$/,$M=/^#[a-fA-F0-9]{4}$/,$u=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,eC=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,tC=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,nC=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function $s(n){if(typeof n!="string")throw new hi(3);var e=YM(n);if(e.match(QM))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(ZM)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alph
3831a:t}}if(e.match(JM))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match($M)){var i=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:i}}var r=$u.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=eC.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var o=tC.exec(e);if(o){var a=parseInt(""+o[1],10),c=parseInt(""+o[2],10)/100,l=parseInt(""+o[3],10)/100,d="rgb("+Ia(a,c,l)+")",h=$u.exec(d);if(!h)throw new hi(4,e,d);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10)}}var p=nC.exec(e.substring(0,50));if(p){var _=parseInt(""+p[1],10),g=parseInt(""+p[2],10)/100,S=parseInt(""+p[3],10)/100,m="rgb("+Ia(_,g,S)+")",f=$u.exec(m);if(!f)throw new hi(4,e,m);return{red:parseInt(""+f[1],10),green:parseInt(""+f[2],10),blue:parseInt(""+f[3],10),alpha:parseFloat(""+p[4])>1?parseFloat(""+p[4])/100:parseFloat(""+p[4])}}throw new hi(5)}
3831function iC(n){var e=n.red/255,t=n.green/255,i=n.blue/255,r=Math.max(e,t,i),s=Math.min(e,t,i),o=(r+s)/2;if(r===s)return n.alpha!==void 0?{hue:0,saturation:0,lightness:o,alpha:n.alpha}:{hue:0,saturation:0,lightness:o};var a,c=r-s,l=o>.5?c/(2-r-s):c/(r+s);switch(r){case e:a=(t-i)/c+(t<i?6:0);break;case t:a=(i-e)/c+2;break;default:a=(e-t)/c+4;break}return a*=60,n.alpha!==void 0?{hue:a,saturation:l,lightness:o,alpha:n.alpha}:{hue:a,saturation:l,lightness:o}}function xr(n){return iC($s(n))}var rC=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},dh=rC;function Or(n){var e=n.toString(16);return e.length===1?"0"+e:e}function ed(n){return Or(Math.round(n*255))}function sC(n,e,t){return dh("#"+ed(n)+ed(e)+ed(t))}function vl(n,e,t){return Ia(n,e,t,sC)}function oC(n,e,t){if(typeof n=="number"&&typeof e=="number"&&typeof t=="number")return vl(n,e,t);if(typeof n=="object"&&e===void 0&&t===void 0)return vl(n.hue,n.saturation,n.lightness);throw new hi(1)}function aC(n,e,t,i){if(typeof n=="number"&&typeof e=="number"&&typeof t=="number"&&typeof i=="number")return i>=1?vl(n,e,t):"rgba("+Ia(n,e,t)+","+i+")";if(typeof n=="object"&&e===void 0&&t===void 0&&i===void 0)return n.alpha>=1?vl(n.hue,n.saturation,n.lightness):"rgba("+Ia(n.hue,n.saturation,n.lightness)+","+n.alpha+")";throw new hi(2)}function hh(n,e,t){if(typeof n=="number"&&typeof e=="number"&&typeof t=="number")return dh("#"+Or(n)+Or(e)+Or(t));if(typeof n=="object"&&e===void 0&&t===void 0)return dh("#"+Or(n.red)+Or(n.green)+Or(n.blue));throw new hi(6)}function ql(n,e,t,i){if(typeof n=="string"&&typeof e=="number"){var r=$s(n);return"rgba("+r.red+","+r.green+","+r.blue+","+e+")"}else{if(typeof n=="number"&&typeof e=="number"&&typeof t=="number"&&typeof i=="number")return i>=1?hh(n,e,t):"rgba("+n+","+e+","+t+","+i+")";if(typeof n=="object"&&e===void 0&&t===void 0&&i===void 0)return n.alpha>=1?hh(n.red,n.green,n.blue):"rgba("+n.red+","+n.green+","+n.blue+","+n.alpha+")"}throw new hi(7)}var cC=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},lC=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},uC=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},dC=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function wr(n){if(typeof n!="object")throw new hi(8);if(lC(n))return ql(n);if(cC(n))return hh(n);if(dC(n))return aC(n);if(uC(n))return oC(n);throw new hi(8)}function _v(n,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?n.apply(this,r):_v(n,e,r)}}function kn(n){return _v(n,n.length,[])}function hC(n,e){if(e==="transparent")return e;var t=xr(e);return wr(Sn({},t,{hue:t.hue+parseFloat(n)}))}kn(hC);function _o(n,e,t){return Math.max(n,Math.min(e,t))}function pC(n,e){if(e==="transparent")return e;var t=xr(e);return wr(Sn({},t,{lightness:_o(0,1,t.lightness-parseFloat(n))}))}kn(pC);function fC(n,e){if(e==="transparent")return e;var t=xr(e);return wr(Sn({},t,{saturation:_o(0,1,t.saturation-parseFloat(n))}))}kn(fC);function _C(n,e){if(e==="transparent")return e;var t=xr(e);return wr(Sn({},t,{lightness:_o(0,1,t.lightness+parseFloat(n))}))}kn(_C);function mC(n,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(n===0)return t;var i=$s(e),r=Sn({},i,{alpha:typeof i.alpha=="number"?i.alpha:1}),s=$s(t),o=Sn({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),a=r.alpha-o.alpha,c=parseFloat(n)*2-1,l=c*a===-1?c:c+a,d=1+c*a,h=(l/d+1)/2,p=1-h,_={red:Math.floor(r.red*h+o.red*p),green:Math.floor(r.green*h+o.green*p),blue:Math.floor(r.blue*h+o.blue*p),alpha:r.alpha*parseFloat(n)+o.alpha*(1-parseFloat(n))};return ql(_)}var gC=kn(mC),mv=gC;function vC(n,e){if(e==="transparent")return e;var t=$s(e),i=typeof t.alpha=="number"?t.alpha:1,r=Sn({},t,{alpha:_o(0,1,(i*100+parseFloat(n)*100)/100)});return ql(r)}var yC=kn(vC),Lk=yC;function EC(n,e){if(e==="transparent")return e;var t=xr(e);return wr(Sn({},t,{saturation:_o(0,1,t.saturation+parseFloat(n))}))}kn(EC);function TC(n,e){return e==="transparent"?e:wr(Sn({},xr(e),{hue:parseFloat(n)}))}kn(TC);function bC(n,e){return e==="transparent"?e:wr(Sn({},xr(e),{lightness:parseFloat(n)}))}kn(bC);function SC(n,e){return e==="transparent"?e:wr(Sn({},xr(e),{saturation:parseFloat(n)}))}kn(SC);function AC(n,e){return e==="transparent"?e:mv(parseFloat(n),"rgb(0, 0, 0)",e)}kn(AC);function xC(n,e){return e==="transparent"?e:mv(parseFloat(n),"rgb(255, 255, 255)",e)}kn(xC);function wC(n,e){if(e==="transparent")return e;var t=$s(e),i=typeof t.alpha=="number"?t.alpha:1,r=Sn({},t,{alpha:_o(0,1,+(i*100-parseFloat(n)*100).toFixed(2)/100)});return ql(r)}kn(wC);var pa=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-pa.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?pa.Bounce.In(n*2)*.5:pa.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,
3831n))/2+.5}}}}),ia=function(){return performance.now()},IC=function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=ia()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var s=this._tweens[i[r]],o=!t;s&&s.update(e,o)===!1&&!t&&delete this._tweens[i[r]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n}(),ks={Linear:function(n,e){var t=n.length-1,i=t*e,r=Math.floor(i),s=ks.Utils.Linear;return e<0?s(n[0],n[1],i):e>1?s(n[t],n[t-1],t-i):s(n[r],n[r+1>t?t:r+1],i-r)},Bezier:function(n,e){for(var t=0,i=n.length-1,r=Math.pow,s=ks.Utils.Bernstein,o=0;o<=i;o++)t+=r(1-e,i-o)*r(e,o)*n[o]*s(i,o);return t},CatmullRom:function(n,e){var t=n.length-1,i=t*e,r=Math.floor(i),s=ks.Utils.CatmullRom;return n[0]===n[t]?(e<0&&(r=Math.floor(i=t*(1+e))),s(n[(r-1+t)%t],n[r],n[(r+1)%t],n[(r+2)%t],i-r)):e<0?n[0]-(s(n[0],n[0],n[1],n[1],-i)-n[0]):e>1?n[t]-(s(n[t],n[t],n[t-1],n[t-1],i-t)-n[t]):s(n[r?r-1:0],n[r],n[t<r+1?t:r+1],n[t<r+2?t:r+2],i-r)},Utils:{Linear:function(n,e,t){return(e-n)*t+n},Bernstein:function(n,e){var t=ks.Utils.Factorial;return t(n)/t(e)/t(n-e)},Factorial:function(){var n=[1];return function(e){var t=1;if(n[e])return n[e];for(var i=e;i>1;i--)t*=i;return n[e]=t,t}}(),CatmullRom:function(n,e,t,i,r){var s=(t-n)*.5,o=(i-e)*.5,a=r*r,c=r*a;return(2*e-2*t+s+o)*c+(-3*e+3*t-2*s-o)*a+s*r+e}}},MC=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),ph=new IC,Dk=function(){function n(e,t){t===void 0&&(t=ph),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=pa.Linear.None,this._interpolationFunction=ks.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=MC.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=ia()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,r,s){for(var o in i){var a=e[o],c=Array.isArray(a),l=c?"array":typeof a,d=!c&&Array.isArray(i[o]);if(!(l==="undefined"||l==="function")){if(d){var h=i[o];if(h.length===0)continue;for(var p=[a],_=0,g=h.length;_<g;_+=1){var S=this._handleRelativeValue(a,h[_]);if(isNaN(S)){d=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(S)}d&&(i[o]=p)}if((l==="object"||c)&&a&&!d){t[o]=c?[]:{};var m=a;for(var f in m)t[o][f]=m[f];r[o]=c?[]:{};var h=i[o];if(!this._isDynamic){var M={};for(var f in h)M[f]=h[f];i[o]=h=M}this._setupProperties(m,t[o],h,r[o],s)}else(typeof t[o]>"u"||s)&&(t[o]=a),c||(t[o]*=1),d?r[o]=i[o].slice().reverse():r[o]=t[o]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=ia()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=ia()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},n.prototype.group=function(e){return e===void 0&&(e=ph),this._group=e,this},n.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},n.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},n.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},n.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},n.prototype.easing=function(e){return e===void 0&&(e=pa.Linear.None),this._easingFunction=e,this},n.prototype.interpolation=function(e){return e===void 0&&(e=ks.Linear),this._interpolationFunction=e,this},n.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},n.prototype.onStart=function(e){return this._onStartCallback=e,this},n.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},n.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},n.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},n.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},n.prototype.onStop=function(e){return this._onStopCallback=e,this},n.prototype.update=function(e,t){var i=this,r;if(e===void 0&&(e=ia()),t===void 0&&(t=!0),this._isPaused)return!0;var s,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,c=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),l=this._duration+this._repeat*c,d=function(){if(i._duration===0||a>l)return 1;var m=Math.trunc(a/c),f=a-m*c,M=Math.min(f/i._duration,1);return M===0&&a===i._duration?1:M},h=d(),p=this._easingFunction(h);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),this._duration===0||a>=this._duration)if(this._repeat>0){var _=Math.min(Math.trunc((a-this._duration)/c)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=_);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])
3831),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=c*_,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,S=this._chainedTweens.length;g<S;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(e,t,i,r){for(var s in i)if(t[s]!==void 0){var o=t[s]||0,a=i[s],c=Array.isArray(e[s]),l=Array.isArray(a),d=!c&&l;d?e[s]=this._interpolationFunction(a,r):typeof a=="object"&&a?this._updateProperties(e[s],o,a,r):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[s]=o+(a-o)*r))}},n.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},n.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},n}(),yi=ph;yi.getAll.bind(yi);var Nk=yi.removeAll.bind(yi);yi.add.bind(yi);yi.remove.bind(yi);var kk=yi.update.bind(yi),gv={exports:{}},CC=gv.exports={};CC.forEach=function(n,e){for(var t=0;t<n.length;t++){var i=e(n[t]);if(i)return i}};var vv=gv.exports,RC=function(n){var e=n.stateHandler.getState;function t(o){var a=e(o);return a&&!!a.isDetectable}function i(o){e(o).isDetectable=!0}function r(o){return!!e(o).busy}function s(o,a){e(o).busy=!!a}return{isDetectable:t,markAsDetectable:i,isBusy:r,markBusy:s}},PC=function(n){var e={};function t(o){var a=n.get(o);return a===void 0?[]:e[a]||[]}function i(o,a){var c=n.get(o);e[c]||(e[c]=[]),e[c].push(a)}function r(o,a){for(var c=t(o),l=0,d=c.length;l<d;++l)if(c[l]===a){c.splice(l,1);break}}function s(o){var a=t(o);a&&(a.length=0)}return{get:t,add:i,removeListener:r,removeAllListeners:s}},LC=function(){var n=1;function e(){return n++}return{generate:e}},DC=function(n){var e=n.idGenerator,t=n.stateHandler.getState;function i(s){var o=t(s);return o&&o.id!==void 0?o.id:null}function r(s){var o=t(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=e.generate();return o.id=a,a}return{get:i,set:r}},NC=function(n){function e(){}var t={log:e,warn:e,error:e};if(!n&&window.console){var i=function(r,s){r[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var c=0;c<arguments.length;c++)a(arguments[c])}};i(t,"log"),i(t,"warn"),i(t,"error")}return t},yv={exports:{}},Ev=yv.exports={};Ev.isIE=function(n){function e(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!e())return!1;if(!n)return!0;var t=function(){var i,r=3,s=document.createElement("div"),o=s.getElementsByTagName("i");do s.innerHTML="<!--[if gt IE "+ ++r+"]><i></i><![endif]-->";while(o[0]);return r>4?r:i}();return n===t};Ev.isLegacyOpera=function(){return!!window.opera};var Tv=yv.exports,bv={exports:{}},kC=bv.exports={};kC.getOption=UC;function UC(n,e,t){var i=n[e];return i==null&&t!==void 0?t:i}var OC=bv.exports,Z_=OC,FC=function(e){e=e||{};var t=e.reporter,i=Z_.getOption(e,"async",!0),r=Z_.getOption(e,"auto",!0);r&&!i&&(t&&t.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),i=!0);var s=J_(),o,a=!1;function c(g,S){!a&&r&&i&&s.size()===0&&h(),s.add(g,S)}function l(){for(a=!0;s.size();){var g=s;s=J_(),g.process()}a=!1}function d(g){a||(g===void 0&&(g=i),o&&(p(o),o=null),g?h():l())}function h(){o=_(l)}function p(g){var S=clearTimeout;return S(g)}function _(g){var S=function(m){return setTimeout(m,0)};return S(g)}return{add:c,force:d}};function J_(){var n={},e=0,t=0,i=0;function r(a,c){c||(c=a,a=0),a>t?t=a:a<i&&(i=a),n[a]||(n[a]=[]),n[a].push(c),e++}function s(){for(var a=i;a<=t;a++)for(var c=n[a],l=0;l<c.length;l++){var d=c[l];d()}}function o(){return e}return{add:r,process:s,size:o}}var tp="_erd";function VC(n){return n[tp]={},Sv(n)}function Sv(n){return n[tp]}function BC(n){delete n[tp]}
3831var zC={initState:VC,getState:Sv,cleanState:BC},Wo=Tv,HC=function(n){n=n||{};var e=n.reporter,t=n.batchProcessor,i=n.stateHandler.getState;if(!e)throw new Error("Missing required dependency: reporter.");function r(l,d){function h(){d(l)}if(Wo.isIE(8))i(l).object={proxy:h},l.attachEvent("onresize",h);else{var p=a(l);if(!p)throw new Error("Element is not detectable by this strategy.");p.contentDocument.defaultView.addEventListener("resize",h)}}function s(l){var d=n.important?" !important; ":"; ";return(l.join(d)+d).trim()}function o(l,d,h){h||(h=d,d=l,l=null),l=l||{},l.debug;function p(_,g){var S=s(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),m=!1,f=window.getComputedStyle(_),M=_.offsetWidth,w=_.offsetHeight;i(_).startSize={width:M,height:w};function b(){function R(){if(f.position==="static"){_.style.setProperty("position","relative",l.important?"important":"");var A=function(E,y,I,D){function C(Z){return Z.replace(/[^-\d\.]/g,"")}var W=I[D];W!=="auto"&&C(W)!=="0"&&(E.warn("An element that is positioned static has style."+D+"="+W+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+D+" will be set to 0. Element: ",y),y.style.setProperty(D,"0",l.important?"important":""))};A(e,_,f,"top"),A(e,_,f,"right"),A(e,_,f,"bottom"),A(e,_,f,"left")}}function P(){m||R();function A(y,I){if(!y.contentDocument){var D=i(y);D.checkForObjectDocumentTimeoutId&&window.clearTimeout(D.checkForObjectDocumentTimeoutId),D.checkForObjectDocumentTimeoutId=setTimeout(function(){D.checkForObjectDocumentTimeoutId=0,A(y,I)},100);return}I(y.contentDocument)}var E=this;A(E,function(I){g(_)})}f.position!==""&&(R(),m=!0);var T=document.createElement("object");T.style.cssText=S,T.tabIndex=-1,T.type="text/html",T.setAttribute("aria-hidden","true"),T.onload=P,Wo.isIE()||(T.data="about:blank"),i(_)&&(_.appendChild(T),i(_).object=T,Wo.isIE()&&(T.data="about:blank"))}t?t.add(b):b()}Wo.isIE(8)?h(d):p(d,h)}function a(l){return i(l).object}function c(l){if(i(l)){var d=a(l);d&&(Wo.isIE(8)?l.detachEvent("onresize",d.proxy):l.removeChild(d),i(l).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(l).checkForObjectDocumentTimeoutId),delete i(l).object)}}return{makeDetectable:o,addListener:r,uninstall:c}},GC=vv.forEach,WC=function(n){n=n||{};var e=n.reporter,t=n.batchProcessor,i=n.stateHandler.getState;n.stateHandler.hasState;var r=n.idHandler;if(!t)throw new Error("Missing required dependency: batchProcessor");if(!e)throw new Error("Missing required dependency: reporter.");var s=d(),o="erd_scroll_detection_scrollbar_style",a="erd_scroll_detection_container";function c(b){h(b,o,a)}c(window.document);function l(b){var R=n.important?" !important; ":"; ";return(b.join(R)+R).trim()}function d(){var b=500,R=500,P=document.createElement("div");P.style.cssText=l(["position: absolute","width: "+b*2+"px","height: "+R*2+"px","visibility: hidden","margin: 0","padding: 0"]);var T=document.createElement("div");T.style.cssText=l(["position: absolute","width: "+b+"px","height: "+R+"px","overflow: scroll","visibility: none","top: "+-b*3+"px","left: "+-R*3+"px","visibility: hidden","margin: 0","padding: 0"]),T.appendChild(P),document.body.insertBefore(T,document.body.firstChild);var A=b-T.clientWidth,E=R-T.clientHeight;return document.body.removeChild(T),{width:A,height:E}}function h(b,R,P){function T(I,D){D=D||function(W){b.head.appendChild(W)};var C=b.createElement("style");return C.innerHTML=I,C.id=R,D(C),C}if(!b.getElementById(R)){var A=P+"_animation",E=P+"_animation_active",y=`/* Created by the element-resize-detector library. */ 3832`;y+="."+P+" > div::-webkit-scrollbar { "+l(["display: none"])+` } 3833 3834`,y+="."+E+" { "+l(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+A,"animation-name: "+A])+` } 3835`,y+="@-webkit-keyframes "+A+` { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } } 3836`,y+="@keyframes "+A+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",T(y)}}function p(b){b.className+=" "+a+"_animation_active"}function _(b,R,P){if(b.addEventListener)b.addEventListener(R,P);else if(b.attachEvent)b.attachEvent("on"+R,P);else return e.error("[scroll] Don't know how to add event listeners.")}function g(b,R,P){if(b.removeEventListener)b.removeEventListener(R,P);else if(b.detachEvent)b.detachEvent("on"+R,P);else return e.error("[scroll] Don't know how to remove event listeners.")}function S(b){return i(b).container.childNodes[0].childNodes[0].childNodes[0]}function m(b){return i(b).container.childNodes[0].childNodes[0].childNodes[1]}function f(b,R){var P=i(b).listeners;if(!P.push)throw new Error("Cannot add listener to an element that is not detectable.");i(b).listeners.push(R)}function M(b,R,P){P||(P=R,R=b,b=null),b=b||{};function T(){if(b.debug){var se=Array.prototype.slice.call(arguments);if(se.unshift(r.get(R),"Scroll: "),e.log.apply)e.log.apply(null,se);else for(var Ee=0;Ee<se.length;
3836Ee++)e.log(se[Ee])}}function A(se){function Ee(He){var Ke=He.getRootNode&&He.getRootNode().contains(He);return He===He.ownerDocument.body||He.ownerDocument.body.contains(He)||Ke}return!Ee(se)||window.getComputedStyle(se)===null}function E(se){var Ee=i(se).container.childNodes[0],He=window.getComputedStyle(Ee);return!He.width||He.width.indexOf("px")===-1}function y(){var se=window.getComputedStyle(R),Ee={};return Ee.position=se.position,Ee.width=R.offsetWidth,Ee.height=R.offsetHeight,Ee.top=se.top,Ee.right=se.right,Ee.bottom=se.bottom,Ee.left=se.left,Ee.widthCSS=se.width,Ee.heightCSS=se.height,Ee}function I(){var se=y();i(R).startSize={width:se.width,height:se.height},T("Element start size",i(R).startSize)}function D(){i(R).listeners=[]}function C(){if(T("storeStyle invoked."),!i(R)){T("Aborting because element has been uninstalled");return}var se=y();i(R).style=se}function W(se,Ee,He){i(se).lastWidth=Ee,i(se).lastHeight=He}function Z(se){return S(se).childNodes[0]}function Y(){return 2*s.width+1}function ce(){return 2*s.height+1}function K(se){return se+10+Y()}function ue(se){return se+10+ce()}function ve(se){return se*2+Y()}function ye(se){return se*2+ce()}function Oe(se,Ee,He){var Ke=S(se),dt=m(se),V=K(Ee),Pt=ue(He),Ge=ve(Ee),Ie=ye(He);Ke.scrollLeft=V,Ke.scrollTop=Pt,dt.scrollLeft=Ge,dt.scrollTop=Ie}function Ve(){var se=i(R).container;if(!se){se=document.createElement("div"),se.className=a,se.style.cssText=l(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(R).container=se,p(se),R.appendChild(se);var Ee=function(){i(R).onRendered&&i(R).onRendered()};_(se,"animationstart",Ee),i(R).onAnimationStart=Ee}return se}function J(){function se(){var ne=i(R).style;if(ne.position==="static"){R.style.setProperty("position","relative",b.important?"important":"");var fe=function(tt,ae,we,Ue){function Xe(rt){return rt.replace(/[^-\d\.]/g,"")}var Ae=we[Ue];Ae!=="auto"&&Xe(Ae)!=="0"&&(tt.warn("An element that is positioned static has style."+Ue+"="+Ae+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+Ue+" will be set to 0. Element: ",ae),ae.style[Ue]=0)};fe(e,R,ne,"top"),fe(e,R,ne,"right"),fe(e,R,ne,"bottom"),fe(e,R,ne,"left")}}function Ee(ne,fe,tt,ae){return ne=ne?ne+"px":"0",fe=fe?fe+"px":"0",tt=tt?tt+"px":"0",ae=ae?ae+"px":"0",["left: "+ne,"top: "+fe,"right: "+ae,"bottom: "+tt]}if(T("Injecting elements"),!i(R)){T("Aborting because element has been uninstalled");return}se();var He=i(R).container;He||(He=Ve());var Ke=s.width,dt=s.height,V=l(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),Pt=l(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(Ee(-(1+Ke),-(1+dt),-dt,-Ke))),Ge=l(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),Ie=l(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),Ce=l(["position: absolute","left: 0","top: 0"]),ot=l(["position: absolute","width: 200%","height: 200%"]),Re=document.createElement("div"),U=document.createElement("div"),L=document.createElement("div"),G=document.createElement("div"),ee=document.createElement("div"),ie=document.createElement("div");Re.dir="ltr",Re.style.cssText=V,Re.className=a,U.className=a,U.style.cssText=Pt,L.style.cssText=Ge,G.style.cssText=Ce,ee.style.cssText=Ie,ie.style.cssText=ot,L.appendChild(G),ee.appendChild(ie),U.appendChild(L),U.appendChild(ee),Re.appendChild(U),He.appendChild(Re);function $(){var ne=i(R);ne&&ne.onExpand?ne.onExpand():T("Aborting expand scroll handler: element has been uninstalled")}function _e(){var ne=i(R);ne&&ne.onShrink?ne.onShrink():T("Aborting shrink scroll handler: element has been uninstalled")}_(L,"scroll",$),_(ee,"scroll",_e),i(R).onExpandScroll=$,i(R).onShrinkScroll=_e}function re(){function se(Ge,Ie,Ce){var ot=Z(Ge),Re=K(Ie),U=ue(Ce);ot.style.setProperty("width",Re+"px",b.important?"important":""),ot.style.setProperty("height",U+"px",b.important?"important":"")}function Ee(Ge){var Ie=R.offsetWidth,Ce=R.offsetHeight,ot=Ie!==i(R).lastWidth||Ce!==i(R).lastHeight;T("Storing current size",Ie,Ce),W(R,Ie,Ce),t.add(0,function(){if(ot){if(!i(R)){T("Aborting because element has been uninstalled");return}if(!He()){T("Aborting because element container has not been initialized");return}if(b.debug){var U=R.offsetWidth,L=R.offsetHeight;(U!==Ie||L!==Ce)&&e.warn(r.get(R),"Scroll: Size changed before updating detector elements.")}se(R,Ie,Ce)}}),t.add(1,function(){if(!i(R)){T("Aborting because element has been uninstalled");return}if(!He()){T("Aborting because element container has not been initialized");return}Oe(R,Ie,Ce)}),ot&&Ge&&t.add(2,function(){if(!i(R)){T("Aborting because element has been uninstalled");return}if(!He()){T("Aborting because element container has not been initialized");return}Ge()})}function He(){return!!i(R).container}function Ke(){function Ge(){return i(R).lastNotifiedWidth===void 0}T("notifyListenersIfNeeded invoked");var Ie=i(R);if(Ge()&&Ie.lastWidth===Ie.startSize.width&&Ie.lastHeight===Ie.startSize.height)return T("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(Ie.lastWidth===Ie.lastNotifiedWidth&&Ie.lastHeight===Ie.lastNotifiedHeight)return T("Not notifying: Size already notified");T("Current size not notified, notifying..."),Ie.lastNotifiedWidth=Ie.lastWidth,Ie.lastNotifiedHeight=Ie.lastHeight,GC(i(R).listeners,function(Ce){Ce(R)})}function dt(){if(T("startanimation triggered."),E(R)){T("Ignoring since element is still unrendered...");return}T("Element rendered.");var Ge=S(R),Ie=m(R);(Ge.scrollLeft===0||Ge.scrollTop===0||Ie.scrollLeft===0||Ie.scrollTop===0)&&(T("Scrollbars out of sync. Updating detector elements..."),Ee(Ke))}function V(){if(T("Scroll detected."),E(R)){T("Scroll event fired while unrendered. Ignoring...");return}Ee(Ke)}if(T("registerListenersAndPositionElements invoked."),!i(R)){T("Aborting because element has been uninstalled");return}i(R).onRendered=dt,i(R).onExpand=V,i(R).onShrink=V;var Pt=i(R).style;se(R,Pt.width,Pt.height)}function De(){if(T("finalizeDomMutation invoked."),!i(R)){T("Aborting because element has been uninstalled");return}var se=i(R).style;W(R,se.width,se.height),Oe(R,se.width,se.height)}function pe(){P(R)}function ze(){T("Installing..."),D(),I(),t.add(0,C),t.add(1,J),t.add(2,re),t.add(3,De),t.add(4,pe)}T("Making detectable..."),A(R)?(T("Element is detached"),Ve(),T("Waiting until element is attached..."),i(R).onRendered=function(){T("Element is now attached"),ze()}):ze()}function w(b){var R=i(b);R&&(R.onExpandScroll&&g(S(b),"scroll",R.onExpandScroll),R.onShrinkScroll&&g(m(b),"scroll",R.onShrinkScroll),R.onAnimationStart&&g(R.container,"animationstart",R.onAnimationStart),R.container&&b.removeChild(R.container))}return{makeDetectable:M,addListener:f,uninstall:w,initDocument:c}},ra=vv.forEach,qC=RC,XC=PC,jC=LC,KC=DC,YC=NC,$_=Tv,QC=FC,ur=zC,ZC=HC,JC=WC;function em(n){return Array.isArray(n)||n.length!==void 0}function tm(n){if(Array.isArray(n))return n;var e=[];return ra(n,function(t){e.push(t)}),e}function nm(n){return n&&n.nodeType===1}var $C=function(n){n=n||{};var e;if(n.idHandler)e={get:function(M){return n.idHandler.get(M,!0)},set:n.idHandler.set};else{var t=jC(),i=KC({idGenerator:t,stateHandler:ur});e=i}var r=n.reporter;if(!r){var s=r===!1;r=YC(s)}var o=dr(n,"batchProcessor",QC({reporter:r})),a={};a.callOnAdd=!!dr(n,"callOnAdd",!0),a.debug=!!dr(n,"debug",!1);var c=XC(e),l=qC({stateHandler:ur}),d,h=dr(n,"strategy","object"),p=dr(n,"important",!1),_={reporter:r,batchProcessor:o,stateHandler:ur,idHandler:e,important:p};if(h==="scroll"&&($_.isLegacyOpera()?(r.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),h="object"):$_.
3836isIE(9)&&(r.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),h="object")),h==="scroll")d=JC(_);else if(h==="object")d=ZC(_);else throw new Error("Invalid strategy name: "+h);var g={};function S(M,w,b){function R(I){var D=c.get(I);ra(D,function(W){W(I)})}function P(I,D,C){c.add(D,C),I&&C(D)}if(b||(b=w,w=M,M={}),!w)throw new Error("At least one element required.");if(!b)throw new Error("Listener required.");if(nm(w))w=[w];else if(em(w))w=tm(w);else return r.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var T=0,A=dr(M,"callOnAdd",a.callOnAdd),E=dr(M,"onReady",function(){}),y=dr(M,"debug",a.debug);ra(w,function(D){ur.getState(D)||(ur.initState(D),e.set(D));var C=e.get(D);if(y&&r.log("Attaching listener to element",C,D),!l.isDetectable(D)){if(y&&r.log(C,"Not detectable."),l.isBusy(D)){y&&r.log(C,"System busy making it detectable"),P(A,D,b),g[C]=g[C]||[],g[C].push(function(){T++,T===w.length&&E()});return}return y&&r.log(C,"Making detectable..."),l.markBusy(D,!0),d.makeDetectable({debug:y,important:p},D,function(Z){if(y&&r.log(C,"onElementDetectable"),ur.getState(Z)){l.markAsDetectable(Z),l.markBusy(Z,!1),d.addListener(Z,R),P(A,Z,b);var Y=ur.getState(Z);if(Y&&Y.startSize){var ce=Z.offsetWidth,K=Z.offsetHeight;(Y.startSize.width!==ce||Y.startSize.height!==K)&&R(Z)}g[C]&&ra(g[C],function(ue){ue()})}else y&&r.log(C,"Element uninstalled before being detectable.");delete g[C],T++,T===w.length&&E()})}y&&r.log(C,"Already detecable, adding listener."),P(A,D,b),T++}),T===w.length&&E()}function m(M){if(!M)return r.error("At least one element is required.");if(nm(M))M=[M];else if(em(M))M=tm(M);else return r.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");ra(M,function(w){c.removeAllListeners(w),d.uninstall(w),ur.cleanState(w)})}function f(M){d.initDocument&&d.initDocument(M)}return{listenTo:S,removeListener:c.removeListener,removeAllListeners:c.removeAllListeners,uninstall:m,initDocument:f}};function dr(n,e,t){var i=n[e];return i==null&&t!==void 0?t:i}const Uk=_I($C);/** 3837 * lil-gui 3838 * https://lil-gui.georgealways.com 3839 * @version 0.17.0 3840 * @author George Michael Brower 3841 * @license MIT 3842 */class fi{constructor(e,t,i,r,s="div"){this.parent=e,this.object=t,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(r),this.$name=document.createElement("div"),this.$name.classList.add("name"),fi.nextNameID=fi.nextNameID||0,this.$name.id="lil-gui-name-"+ ++fi.nextNameID,this.$widget=document.createElement(s),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(e){return this._name=e,this.$name.innerHTML=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled||(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e)),this}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.object[this.property]=e,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class eR extends fi{constructor(e,t,i){super(e,t,i,"boolean","label"),this.$input
vendor: 12,325 bytes, line 3842
3842=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function fh(n){let e,t;return(e=n.match(/(#|0x)?([a-f0-9]{6})/i))?t=e[2]:(e=n.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?t=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=n.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(t=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),!!t&&"#"+t}const tR={isPrimitive:!0,match:n=>typeof n=="string",fromHexString:fh,toHexString:fh},Ma={isPrimitive:!0,match:n=>typeof n=="number",fromHexString:n=>parseInt(n.substring(1),16),toHexString:n=>"#"+n.toString(16).padStart(6,0)},nR={isPrimitive:!1,match:Array.isArray,fromHexString(n,e,t=1){const i=Ma.fromHexString(n);e[0]=(i>>16&255)/255*t,e[1]=(i>>8&255)/255*t,e[2]=(255&i)/255*t},toHexString:([n,e,t],i=1)=>Ma.toHexString(n*(i=255/i)<<16^e*i<<8^t*i<<0)},iR={isPrimitive:!1,match:n=>Object(n)===n,fromHexString(n,e,t=1){const i=Ma.fromHexString(n);e.r=(i>>16&255)/255*t,e.g=(i>>8&255)/255*t,e.b=(255&i)/255*t},toHexString:({r:n,g:e,b:t},i=1)=>Ma.toHexString(n*(i=255/i)<<16^e*i<<8^t*i<<0)},rR=[tR,Ma,nR,iR];class sR extends fi{constructor(e,t,i,r){var s;super(e,t,i,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(s=this.initialValue,rR.find(o=>o.match(s))),this._rgbScale=r,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const o=fh(this.$text.value);o&&this._setValueFromHexString(o)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class td extends fi{constructor(e,t,i){super(e,t,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",r=>{r.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class oR extends fi{constructor(e,t,i,r,s,o){super(e,t,i,"number"),this._initInput(),this.min(r),this.max(s);const a=o!==void 0;this.step(a?o:this._getImplicitStep(),a),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=100*t+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const e=d=>{const h=parseFloat(this.$input.value);isNaN(h)||(this._snapClampSetValue(h+d),this.$input.value=this.getValue())};let t,i,r,s,o,a=!1;const c=d=>{if(a){const h=d.clientX-t,p=d.clientY-i;Math.abs(p)>5?(d.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(h)>5&&l()}if(!a){const h=d.clientY-r;o-=h*this._step*this._arrowKeyMultiplier(d),s+o>this._max?o=this._max-s:s+o<this._min&&(o=this._min-s),this._snapClampSetValue(s+o)}r=d.clientY},l=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",l)};this.$input.addEventListener("input",()=>{let d=parseFloat(this.$input.value);isNaN(d)||(this._stepExplicit&&(d=this._snap(d)),this.setValue(this._clamp(d)))}),this.$input.addEventListener("keydown",d=>{d.code==="Enter"&&this.$input.blur(),d.code==="ArrowUp"&&(d.preventDefault(),e(this._step*this._arrowKeyMultiplier(d))),d.code==="ArrowDown"&&(d.preventDefault(),e(this._step*this._arrowKeyMultiplier(d)*-1))}),this.$input.addEventListener("wheel",d=>{this._inputFocused&&(d.preventDefault(),e(this._step*this._normalizeMouseWheel(d)))},{passive:!1}),this.$input.addEventListener("mousedown",d=>{t=d.clientX,i=r=d.clientY,a=!0,s=this.getValue(),o=0,window.addEventListener("mousemove",c),window.addEventListener("mouseup",l)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=p=>{const _=this.$slider.getBoundingClientRect();let g=(S=p,m=_.left,f=_.right,M=this._min,w=this._max,(S-m)/(f-m)*(w-M)+M);var S,m,f,M,w;this._snapClampSetValue(g)},t=p=>{e(p.clientX)},i=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",i)};let r,s,o=!1;const a=p=>{p.preventDefault(),this._setDraggingStyle(!0),e(p.touches[0].clientX),o=!1},c=p=>{if(o){const _=p.touches[0].clientX-r,g=p.touches[0].clientY-s;Math.abs(_)>Math.abs(g)?a(p):(window.removeEventListener("touchmove",c),window.removeEventListener("touchend",l))}else p.preventDefault(),e(p.touches[0].clientX)},l=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",c),window.removeEventListener("touchend",l)},d=this._callOnFinishChange.bind(this);let h;this.$slider.addEventListener("mousedown",p=>{this._setDraggingStyle(!0),e(p.clientX),window.addEventListener("mousemove",t),window.addEventListener("mouseup",i)}),this.$slider.addEventListener("touchstart",p=>{p.touches.length>1||(this._hasScrollBar?(r=p.touches[0].clientX,s=p.touches[0].clientY,o=!0):a(p),window.addEventListener("touchmove",c,{passive:!1}),window.addEventListener("touchend",l))},{passive:!1}),this.$slider.addEventListener("wheel",p=>{if(Math.abs(p.deltaX)<Math.abs(p.deltaY)&&this._hasScrollBar)return;p.preventDefault();const _=this._normalizeMouseWheel(p)*this._step;this._snapClampSetValue(this.getValue()+_),this.$input.value=this.getValue(),clearTimeout(h),h=setTimeout(d,400)},{passive:!1})}_setDraggingStyle(e,t="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle("lil-gui-"+t,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:t,deltaY:i}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(t=0,i=-e.wheelDelta/120,i*=this._stepExplicit?1:10),t+-i}_arrowKeyMultiplier(e){let t=this._stepExplicit?1:10;return e.shiftKey?t*=10:e.altKey&&(t/=10),t}_snap(e){const t=Math.round(e/this._step)*this._step;return parseFloat(t.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class aR extends fi{constructor(e,t,i,r){super(e,t,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(r)?r:Object.values(r),this._names=Array.isArray(r)?r:Object.keys(r),this._names.forEach(s=>{const o=document.createElement("option");o.innerHTML=s,this.$select.appendChild(o)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.innerHTML=t===-1?e:this._names[t],this}}class cR extends fi{constructor(e,t,i){super(e,t,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",r=>{r.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let im=!1;class Av{constructor({parent:e,autoPlace:t=e===void 0,container:i,width:r,title:s="Controls",injectStyles:o=!0,touchStyles:a=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{c.code!=="Enter"&&c.code!=="Space"||(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),a&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!im&&o&&(function(c){const l=document.createElement("style");l.innerHTML=c;const d=document.querySelector("head link[rel=stylesheet], head style");d?document.head.insertBefore(l,d):document.head.appendChild(l)}
vendor: 10,710 bytes, line 3842
3842('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),
vendor: 2,418 bytes, lines 3842-3845
3842im=!0),i?i.appendChild(this.domElement):t&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),r&&this.domElement.style.setProperty("--width",r+"px"),this.domElement.addEventListener("keydown",c=>c.stopPropagation()),this.domElement.addEventListener("keyup",c=>c.stopPropagation())}add(e,t,i,r,s){if(Object(i)===i)return new aR(this,e,t,i);const o=e[t];switch(typeof o){case"number":return new oR(this,e,t,i,r,s);case"boolean":return new eR(this,e,t);case"string":return new cR(this,e,t);case"function":return new td(this,e,t)}console.error(`gui.add failed 3843 property:`,t,` 3844 object:`,e,` 3845 value:`,o)}addColor(e,t,i=1){return new sR(this,e,t,i)}addFolder(e){return new Av({parent:this,title:e})}load(e,t=!0){return e.controllers&&this.controllers.forEach(i=>{i instanceof td||i._name in e.controllers&&i.load(e.controllers[i._name])}),t&&e.folders&&this.folders.forEach(i=>{i._title in e.folders&&i.load(e.folders[i._title])}),this}save(e=!0){const t={controllers:{},folders:{}};return this.controllers.forEach(i=>{if(!(i instanceof td)){if(i._name in t.controllers)throw new Error(`Cannot save GUI with duplicate property "${i._name}"`);t.controllers[i._name]=i.save()}}),e&&this.folders.forEach(i=>{if(i._title in t.folders)throw new Error(`Cannot save GUI with duplicate folder "${i._title}"`);t.folders[i._title]=i.save()}),t}open(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const t=this.$children.clientHeight;this.$children.style.height=t+"px",this.domElement.classList.add("transition");const i=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",i))};this.$children.addEventListener("transitionend",i);const r=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=r+"px"})}),this}title(e){return this._title=e,this.$title.innerHTML=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEac
3845h(t=>t.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}}const nd=new Fl,Ms=new O,Cs=new O,Qn=new O,Di=new O,ci=new O,Ni=new O,ki=new O,qo=new O,Xo=new O,jo=new O,Fc=new O,Ko=new O,Yo=new O,Qo=new O,rm=new wt,lR=new po,uR=new O;class Ok{constructor(e,t,i=Number.MAX_VALUE){this.camera=e,this.scene=t,this.startPoint=new O,this.endPoint=new O,this.collection=[],this.instances={},this.deep=i}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(nd,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Cs.copy(e),Cs.x=Math.min(e.x,t.x),Cs.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),Qn.setFromMatrixPosition(this.camera.matrixWorld),Di.copy(Cs),ci.set(t.x,Cs.y,0),Ni.copy(t),ki.set(Cs.x,t.y,0),Di.unproject(this.camera),ci.unproject(this.camera),Ni.unproject(this.camera),ki.unproject(this.camera),Ko.copy(Di).sub(Qn),Yo.copy(ci).sub(Qn),Qo.copy(Ni).sub(Qn),Ko.normalize(),Yo.normalize(),Qo.normalize(),Ko.multiplyScalar(this.deep),Yo.multiplyScalar(this.deep),Qo.multiplyScalar(this.deep),Ko.add(Qn),Yo.add(Qn),Qo.add(Qn);const i=nd.planes;i[0].setFromCoplanarPoints(Qn,Di,ci),i[1].setFromCoplanarPoints(Qn,ci,Ni),i[2].setFromCoplanarPoints(Ni,ki,Qn),i[3].setFromCoplanarPoints(ki,Di,Qn),i[4].setFromCoplanarPoints(ci,Ni,ki),i[5].setFromCoplanarPoints(Qo,Yo,Ko),i[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),r=Math.max(e.y,t.y),s=Math.max(e.x,t.x),o=Math.min(e.y,t.y);Di.set(i,r,-1),ci.set(s,r,-1),Ni.set(s,o,-1),ki.set(i,o,-1),qo.set(i,r,1),Xo.set(s,r,1),jo.set(s,o,1),Fc.set(i,o,1),Di.unproject(this.camera),ci.unproject(this.camera),Ni.unproject(this.camera),ki.unproject(this.camera),qo.unproject(this.camera),Xo.unproject(this.camera),jo.unproject(this.camera),Fc.unproject(this.camera);const a=nd.planes;a[0].setFromCoplanarPoints(Di,qo,Xo),a[1].setFromCoplanarPoints(ci,Xo,jo),a[2].setFromCoplanarPoints(jo,Fc,ki),a[3].setFromCoplanarPoints(Fc,qo,Di),a[4].setFromCoplanarPoints(ci,Ni,ki),a[5].setFromCoplanarPoints(jo,Xo,qo),a[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if(t.isMesh||t.isLine||t.isPoints)if(t.isInstancedMesh){this.instances[t.uuid]=[];for(let i=0;i<t.count;i++)t.getMatrixAt(i,rm),rm.decompose(Ms,lR,uR),Ms.applyMatrix4(t.matrixWorld),e.containsPoint(Ms)&&this.instances[t.uuid].push(i)}else t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),Ms.copy(t.geometry.boundingSphere.center),Ms.applyMatrix4(t.matrixWorld),e.containsPoint(Ms)&&this.collection.push(t);if(t.children.length>0)for(let i=0;i<t.children.length;i++)this.searchChildInFrustum(e,t.children[i])}}function Fk(n,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>{n(...i)},e)}}function Vk(n,e){n=n.replace("#","");const t=parseInt(n.substring(0,2),16),i=parseInt(n.substring(2,4),16),r=parseInt(n.substring(4,6),16);return`rgba(${t}, ${i}, ${r}, ${e})`}function np(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t}function xv(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const dR=xv,wv=new Dh("auth","Firebase",xv());/** 3846 * @license 3847 * Copyright 2020 Google LLC 3848 * 3849 * Licensed under the Apache License, Version 2.0 (the "License");
3850 * you may not use this file except in compliance with the License. 3851 * You may obtain a copy of the License at 3852 * 3853 * http://www.apache.org/licenses/LICENSE-2.0 3854 * 3855 * Unless required by applicable law or agreed to in writing, software 3856 * distributed under the License is distributed on an "AS IS" BASIS, 3857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3858 * See the License for the specific language governing permissions and 3859 * limitations under the License. 3860 */const yl=new cg("@firebase/auth");function hR(n,...e){yl.logLevel<=ui.WARN&&yl.warn(`Auth (${uo}): ${n}`,...e)}function $c(n,...e){yl.logLevel<=ui.ERROR&&yl.error(`Auth (${uo}): ${n}`,...e)}/** 3861 * @license 3862 * Copyright 2020 Google LLC 3863 * 3864 * Licensed under the Apache License, Version 2.0 (the "License"); 3865 * you may not use this file except in compliance with the License. 3866 * You may obtain a copy of the License at 3867 * 3868 * http://www.apache.org/licenses/LICENSE-2.0 3869 * 3870 * Unless required by applicable law or agreed to in writing, software 3871 * distributed under the License is distributed on an "AS IS" BASIS, 3872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3873 * See the License for the specific language governing permissions and 3874 * limitations under the License. 3875 */function Ei(n,...e){throw rp(n,...e)}function si(n,...e){return rp(n,...e)}function ip(n,e,t){const i=Object.assign(Object.assign({},dR()),{[e]:t});return new Dh("auth","Firebase",i).create(e,{appName:n.name})}function Wr(n){return ip(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function pR(n,e,t){const i=t;if(!(e instanceof i))throw i.name!==e.constructor.name&&Ei(n,"argument-error"),ip(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function rp(n,...e){if(typeof n!="string"){const t=e[0],i=[...e.slice(1)];return i[0]&&(i[0].appName=n.name),n._errorFactory.create(t,...i)}return wv.create(n,...e)}function Qe(n,e,...t){if(!n)throw rp(e,...t)}function Gi(n){const e="INTERNAL ASSERTION FAILED: "+n;throw $c(e),new Error(e)}function Qi(n,e){n||Gi(e)}/** 3876 * @license 3877 * Copyright 2020 Google LLC 3878 * 3879 * Licensed under the Apache License, Version 2.0 (the "License"); 3880 * you may not use this file except in compliance with the License. 3881 * You may obtain a copy of the License at 3882 * 3883 * http://www.apache.org/licenses/LICENSE-2.0 3884 * 3885 * Unless required by applicable law or agreed to in writing, software 3886 * distributed under the License is distributed on an "AS IS" BASIS, 3887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3888 * See the License for the specific language governing permissions and 3889 * limitations under the License. 3890 */function _h(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function fR(){return sm()==="http:"||sm()==="https:"}function sm(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/** 3891 * @license 3892 * Copyright 2020 Google LLC 3893 * 3894 * Licensed under the Apache License, Version 2.0 (the "License"); 3895 * you may not use this file except in compliance with the License. 3896 * You may obtain a copy of the License at 3897 * 3898 * http://www.apache.org/licenses/LICENSE-2.0 3899 * 3900 * Unless required by applicable law or agreed to in writing, software 3901 * distributed under the License is distributed on an "AS IS" BASIS, 3902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3903 * See the License for the specific language governing permissions and 3904 * limitations under the License. 3905 */function _R(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(fR()||Yy()||"connection"in navigator)?navigator.onLine:!0}function mR(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/** 3906 * @license 3907 * Copyright 2020 Google LLC 3908 * 3909 * Licensed under the Apache License, Version 2.0 (the "License");
3910 * you may not use this file except in compliance with the License. 3911 * You may obtain a copy of the License at 3912 * 3913 * http://www.apache.org/licenses/LICENSE-2.0 3914 * 3915 * Unless required by applicable law or agreed to in writing, software 3916 * distributed under the License is distributed on an "AS IS" BASIS, 3917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3918 * See the License for the specific language governing permissions and 3919 * limitations under the License. 3920 */class Ga{constructor(e,t){this.shortDelay=e,this.longDelay=t,Qi(t>e,"Short delay should be less than long delay!"),this.isMobile=Xy()||jy()}get(){return _R()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** 3921 * @license 3922 * Copyright 2020 Google LLC 3923 * 3924 * Licensed under the Apache License, Version 2.0 (the "License"); 3925 * you may not use this file except in compliance with the License. 3926 * You may obtain a copy of the License at 3927 * 3928 * http://www.apache.org/licenses/LICENSE-2.0 3929 * 3930 * Unless required by applicable law or agreed to in writing, software 3931 * distributed under the License is distributed on an "AS IS" BASIS, 3932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3933 * See the License for the specific language governing permissions and 3934 * limitations under the License. 3935 */function sp(n,e){Qi(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/** 3936 * @license 3937 * Copyright 2020 Google LLC 3938 * 3939 * Licensed under the Apache License, Version 2.0 (the "License"); 3940 * you may not use this file except in compliance with the License. 3941 * You may obtain a copy of the License at 3942 * 3943 * http://www.apache.org/licenses/LICENSE-2.0 3944 * 3945 * Unless required by applicable law or agreed to in writing, software 3946 * distributed under the License is distributed on an "AS IS" BASIS, 3947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3948 * See the License for the specific language governing permissions and 3949 * limitations under the License. 3950 */class Iv{static initialize(e,t,i){this.fetchImpl=e,t&&(this.headersImpl=t),i&&(this.responseImpl=i)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Gi("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Gi("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Gi("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** 3951 * @license 3952 * Copyright 2020 Google LLC 3953 * 3954 * Licensed under the Apache License, Version 2.0 (the "License"); 3955 * you may not use this file except in compliance with the License. 3956 * You may obtain a copy of the License at 3957 * 3958 * http://www.apache.org/licenses/LICENSE-2.0 3959 * 3960 * Unless required by applicable law or agreed to in writing, software 3961 * distributed under the License is distributed on an "AS IS" BASIS, 3962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3963 * See the License for the specific language governing permissions and 3964 * limitations under the License. 3965 */const gR={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-rec
3965aptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/** 3966 * @license 3967 * Copyright 2020 Google LLC 3968 * 3969 * Licensed under the Apache License, Version 2.0 (the "License"); 3970 * you may not use this file except in compliance with the License. 3971 * You may obtain a copy of the License at 3972 * 3973 * http://www.apache.org/licenses/LICENSE-2.0 3974 * 3975 * Unless required by applicable law or agreed to in writing, software 3976 * distributed under the License is distributed on an "AS IS" BASIS, 3977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3978 * See the License for the specific language governing permissions and 3979 * limitations under the License. 3980 */const vR=new Ga(3e4,6e4);function op(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function mo(n,e,t,i,r={}){return Mv(n,r,async()=>{let s={},o={};i&&(e==="GET"?o=i:s={body:JSON.stringify(i)});const a=Va(Object.assign({key:n.config.apiKey},o)).slice(1),c=await n._getAdditionalHeaders();return c["Content-Type"]="application/json",n.languageCode&&(c["X-Firebase-Locale"]=n.languageCode),Iv.fetch()(Cv(n,n.config.apiHost,t,a),Object.assign({method:e,headers:c,referrerPolicy:"no-referrer"},s))})}async function Mv(n,e,t){n._canInitEmulator=!1;const i=Object.assign(Object.assign({},gR),e);try{const r=new ER(n),s=await Promise.race([t(),r.promise]);r.clearNetworkTimeout();const o=await s.json();if("needConfirmation"in o)throw Vc(n,"account-exists-with-different-credential",o);if(s.ok&&!("errorMessage"in o))return o;{const a=s.ok?o.errorMessage:o.error.message,[c,l]=a.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw Vc(n,"credential-already-in-use",o);if(c==="EMAIL_EXISTS")throw Vc(n,"email-already-in-use",o);if(c==="USER_DISABLED")throw Vc(n,"user-disabled",o);const d=i[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(l)throw ip(n,d,l);Ei(n,d)}}catch(r){if(r instanceof Nl)throw r;Ei(n,"network-request-failed",{message:String(r)})}}async function yR(n,e,t,i,r={}){const s=await mo(n,e,t,i,r);return"mfaPendingCredential"in s&&Ei(n,"multi-factor-auth-required",{_serverResponse:s}),s}function Cv(n,e,t,i){const r=`${e}${t}?${i}`;return n.config.emulator?sp(n.config,r):`${n.config.apiScheme}://${r}`}class ER{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,i)=>{this.timer=setTimeout(()=>i(si(this.auth,"network-request-failed")),vR.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Vc(n,e,t){const i={appName:n.name};t.email&&(i.email=t.email),t.phoneNumber&&(i.phoneNumber=t.phoneNumber);const r=si(n,e,i);return r.customData._tokenResponse=t,r}/** 3981 * @license 3982 * Copyright 2020 Google LLC 3983 * 3984 * Licensed under the Apache License, Version 2.0 (the "License"); 3985 * you may not use this file except in compliance with the License. 3986 * You may obtain a copy of the License at 3987 * 3988 * http://www.apache.org/licenses/LICENSE-2.0 3989 * 3990 * Unless required by applicable law or agreed to in writing, software 3991 * distributed under the License is distributed on an "AS IS" BASIS, 3992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3993 * See the License for the specific language governing permissions and 3994 * limitations under the License. 3995 */async function TR(n,e){return mo(n,"POST","/v1/accounts:delete",e)}async function Rv(n,e){return mo(n,"POST","/v1/accounts:lookup",e)}/** 3996 * @license 3997 * Copyright 2020 Google LLC 3998 * 3999 * Licensed under the Apache License, Version 2.0 (the "License"); 4000 * you may not use this file except in compliance with the License. 4001 * You may obtain a copy of the License at 4002 * 4003 * http://www.apache.org/licenses/LICENSE-2.0 4004 * 4005 * Unless required by applicable law or agreed to in writing, software 4006 * distributed under the License is distributed on an "AS IS" BASIS, 4007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4008 * See the License for the specific language governing permissions and 4009 * limitations under the License. 4010 */function fa(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function bR(n,e=!1){const t=oi(n),i=await t.getIdToken(e),r=Xl(i);Qe(r&&r.exp&&r.auth_time&&r.iat,t.auth,"internal-error");const s=typeof r.firebase=="object"?r.firebase:void 0,o=s==null?void 0:s.sign_in_provider;return{claims:r,token:i,authTime:fa(id(r.auth_time)),issuedAtTime:fa(id(r.iat)),expirationTime:fa(id(r.exp)),signInProvider:o||null,signInSecondFactor:(s==null?void 0:s.sign_in_second_factor)||null}}function id(n){return Number(n)*1e3}function Xl(n){const[e,t,i]=n.split(".");if(e===void 0||t===void 0||i===void 0)return $c("JWT malformed, contained fewer than 3 sections"),null;try{const r=Jy(t);return r?JSON.parse(r):($c("Failed to decode base64 JWT payload"),null)}catch(r){return $c("Caught error parsing JWT payload as JSON",r==null?void 0:r.toString()),null}}function om(n){const e=Xl(n);return Qe(e,"internal-error"),Qe(typeof e.exp<"u","internal-error"),Qe(typeof e.iat
4010<"u","internal-error"),Number(e.exp)-Number(e.iat)}/** 4011 * @license 4012 * Copyright 2020 Google LLC 4013 * 4014 * Licensed under the Apache License, Version 2.0 (the "License"); 4015 * you may not use this file except in compliance with the License. 4016 * You may obtain a copy of the License at 4017 * 4018 * http://www.apache.org/licenses/LICENSE-2.0 4019 * 4020 * Unless required by applicable law or agreed to in writing, software 4021 * distributed under the License is distributed on an "AS IS" BASIS, 4022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4023 * See the License for the specific language governing permissions and 4024 * limitations under the License. 4025 */async function Ca(n,e,t=!1){if(t)return e;try{return await e}catch(i){throw i instanceof Nl&&SR(i)&&n.auth.currentUser===n&&await n.auth.signOut(),i}}function SR({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/** 4026 * @license 4027 * Copyright 2020 Google LLC 4028 * 4029 * Licensed under the Apache License, Version 2.0 (the "License"); 4030 * you may not use this file except in compliance with the License. 4031 * You may obtain a copy of the License at 4032 * 4033 * http://www.apache.org/licenses/LICENSE-2.0 4034 * 4035 * Unless required by applicable law or agreed to in writing, software 4036 * distributed under the License is distributed on an "AS IS" BASIS, 4037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4038 * See the License for the specific language governing permissions and 4039 * limitations under the License. 4040 */class AR{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const i=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),i}else{this.errorBackoff=3e4;const r=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** 4041 * @license 4042 * Copyright 2020 Google LLC 4043 * 4044 * Licensed under the Apache License, Version 2.0 (the "License"); 4045 * you may not use this file except in compliance with the License. 4046 * You may obtain a copy of the License at 4047 * 4048 * http://www.apache.org/licenses/LICENSE-2.0 4049 * 4050 * Unless required by applicable law or agreed to in writing, software 4051 * distributed under the License is distributed on an "AS IS" BASIS, 4052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4053 * See the License for the specific language governing permissions and 4054 * limitations under the License. 4055 */class mh{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=fa(this.lastLoginAt),this.creationTime=fa(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** 4056 * @license 4057 * Copyright 2019 Google LLC 4058 * 4059 * Licensed under the Apache License, Version 2.0 (the "License"); 4060 * you may not use this file except in compliance with the License. 4061 * You may obtain a copy of the License at 4062 * 4063 * http://www.apache.org/licenses/LICENSE-2.0 4064 * 4065 * Unless required by applicable law or agreed to in writing, software 4066 * distributed under the License is distributed on an "AS IS" BASIS, 4067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4068 * See the License for the specific language governing permissions and 4069 * limitations under the License. 4070 */async function El(n){var e;const t=n.auth,i=await n.getIdToken(),r=await Ca(n,Rv(t,{idToken:i}));Qe(r==null?void 0:r.users.length,t,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const o=!((e=s.providerUserInfo)===null||e===void 0)&&e.length?Pv(s.providerUserInfo):[],a=wR(n.providerData,o),c=n.isAnonymous,l=!(n.email&&s.passwordHash)&&!(a!=null&&a.length),d=c?l:!1,h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new mh(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(n,h)}async function xR(n){const e=oi(n);await El(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function wR(n,e){return[...n.filter(i=>
4070!e.some(r=>r.providerId===i.providerId)),...e]}function Pv(n){return n.map(e=>{var{providerId:t}=e,i=np(e,["providerId"]);return{providerId:t,uid:i.rawId||"",displayName:i.displayName||null,email:i.email||null,phoneNumber:i.phoneNumber||null,photoURL:i.photoUrl||null}})}/** 4071 * @license 4072 * Copyright 2020 Google LLC 4073 * 4074 * Licensed under the Apache License, Version 2.0 (the "License"); 4075 * you may not use this file except in compliance with the License. 4076 * You may obtain a copy of the License at 4077 * 4078 * http://www.apache.org/licenses/LICENSE-2.0 4079 * 4080 * Unless required by applicable law or agreed to in writing, software 4081 * distributed under the License is distributed on an "AS IS" BASIS, 4082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4083 * See the License for the specific language governing permissions and 4084 * limitations under the License. 4085 */async function IR(n,e){const t=await Mv(n,{},async()=>{const i=Va({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:r,apiKey:s}=n.config,o=Cv(n,r,"/v1/token",`key=${s}`),a=await n._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",Iv.fetch()(o,{method:"POST",headers:a,body:i})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function MR(n,e){return mo(n,"POST","/v2/accounts:revokeToken",op(n,e))}/** 4086 * @license 4087 * Copyright 2020 Google LLC 4088 * 4089 * Licensed under the Apache License, Version 2.0 (the "License"); 4090 * you may not use this file except in compliance with the License. 4091 * You may obtain a copy of the License at 4092 * 4093 * http://www.apache.org/licenses/LICENSE-2.0 4094 * 4095 * Unless required by applicable law or agreed to in writing, software 4096 * distributed under the License is distributed on an "AS IS" BASIS, 4097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4098 * See the License for the specific language governing permissions and 4099 * limitations under the License. 4100 */class Bs{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Qe(e.idToken,"internal-error"),Qe(typeof e.idToken<"u","internal-error"),Qe(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):om(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){Qe(e.length!==0,"internal-error");const t=om(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(Qe(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:i,refreshToken:r,expiresIn:s}=await IR(e,t);this.updateTokensAndExpiration(i,r,Number(s))}updateTokensAndExpiration(e,t,i){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+i*1e3}static fromJSON(e,t){const{refreshToken:i,accessToken:r,expirationTime:s}=t,o=new Bs;return i&&(Qe(typeof i=="string","internal-error",{appName:e}),o.refreshToken=i),r&&(Qe(typeof r=="string","internal-error",{appName:e}),o.accessToken=r),s&&(Qe(typeof s=="number","internal-error",{appName:e}),o.expirationTime=s),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Bs,this.toJSON())}_performRefresh(){return Gi("not implemented")}}/** 4101 * @license 4102 * Copyright 2020 Google LLC 4103 * 4104 * Licensed under the Apache License, Version 2.0 (the "License"); 4105 * you may not use this file except in compliance with the License. 4106 * You may obtain a copy of the License at 4107 * 4108 * http://www.apache.org/licenses/LICENSE-2.0 4109 * 4110 * Unless required by applicable law or agreed to in writing, software 4111 * distributed under the License is distributed on an "AS IS" BASIS, 4112 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4113 * See the License for the specific language governing permissions and 4114 * limitations under the License. 4115 */function hr(n,e){Qe(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Wi{constructor(e){var{uid:t,auth:i,stsTokenManager:r}=e,s=np(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new AR(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=i,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new mh(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Ca(this,this.stsTokenManager.getToken(this.auth,e));return Qe(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return bR(this,e)}reload(){return xR(this)}_assign(e){this!==e&&(Qe(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.ph
4115otoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Wi(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){Qe(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let i=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),i=!0),t&&await El(this),await this.auth._persistUserIfCurrent(this),i&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Vi(this.auth.app))return Promise.reject(Wr(this.auth));const e=await this.getIdToken();return await Ca(this,TR(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var i,r,s,o,a,c,l,d;const h=(i=t.displayName)!==null&&i!==void 0?i:void 0,p=(r=t.email)!==null&&r!==void 0?r:void 0,_=(s=t.phoneNumber)!==null&&s!==void 0?s:void 0,g=(o=t.photoURL)!==null&&o!==void 0?o:void 0,S=(a=t.tenantId)!==null&&a!==void 0?a:void 0,m=(c=t._redirectEventId)!==null&&c!==void 0?c:void 0,f=(l=t.createdAt)!==null&&l!==void 0?l:void 0,M=(d=t.lastLoginAt)!==null&&d!==void 0?d:void 0,{uid:w,emailVerified:b,isAnonymous:R,providerData:P,stsTokenManager:T}=t;Qe(w&&T,e,"internal-error");const A=Bs.fromJSON(this.name,T);Qe(typeof w=="string",e,"internal-error"),hr(h,e.name),hr(p,e.name),Qe(typeof b=="boolean",e,"internal-error"),Qe(typeof R=="boolean",e,"internal-error"),hr(_,e.name),hr(g,e.name),hr(S,e.name),hr(m,e.name),hr(f,e.name),hr(M,e.name);const E=new Wi({uid:w,auth:e,email:p,emailVerified:b,displayName:h,isAnonymous:R,photoURL:g,phoneNumber:_,tenantId:S,stsTokenManager:A,createdAt:f,lastLoginAt:M});return P&&Array.isArray(P)&&(E.providerData=P.map(y=>Object.assign({},y))),m&&(E._redirectEventId=m),E}static async _fromIdTokenResponse(e,t,i=!1){const r=new Bs;r.updateFromServerResponse(t);const s=new Wi({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:i});return await El(s),s}static async _fromGetAccountInfoResponse(e,t,i){const r=t.users[0];Qe(r.localId!==void 0,"internal-error");const s=r.providerUserInfo!==void 0?Pv(r.providerUserInfo):[],o=!(r.email&&r.passwordHash)&&!(s!=null&&s.length),a=new Bs;a.updateFromIdToken(i);const c=new Wi({uid:r.localId,auth:e,stsTokenManager:a,isAnonymous:o}),l={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:s,metadata:new mh(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash)&&!(s!=null&&s.length)};return Object.assign(c,l),c}}/** 4116 * @license 4117 * Copyright 2020 Google LLC 4118 * 4119 * Licensed under the Apache License, Version 2.0 (the "License"); 4120 * you may not use this file except in compliance with the License. 4121 * You may obtain a copy of the License at 4122 * 4123 * http://www.apache.org/licenses/LICENSE-2.0 4124 * 4125 * Unless required by applicable law or agreed to in writing, softw
4125are 4126 * distributed under the License is distributed on an "AS IS" BASIS, 4127 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4128 * See the License for the specific language governing permissions and 4129 * limitations under the License. 4130 */const am=new Map;function qi(n){Qi(n instanceof Function,"Expected a class definition");let e=am.get(n);return e?(Qi(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,am.set(n,e),e)}/** 4131 * @license 4132 * Copyright 2019 Google LLC 4133 * 4134 * Licensed under the Apache License, Version 2.0 (the "License"); 4135 * you may not use this file except in compliance with the License. 4136 * You may obtain a copy of the License at 4137 * 4138 * http://www.apache.org/licenses/LICENSE-2.0 4139 * 4140 * Unless required by applicable law or agreed to in writing, software 4141 * distributed under the License is distributed on an "AS IS" BASIS, 4142 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4143 * See the License for the specific language governing permissions and 4144 * limitations under the License. 4145 */class Lv{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Lv.type="NONE";const cm=Lv;/** 4146 * @license 4147 * Copyright 2019 Google LLC 4148 * 4149 * Licensed under the Apache License, Version 2.0 (the "License"); 4150 * you may not use this file except in compliance with the License. 4151 * You may obtain a copy of the License at 4152 * 4153 * http://www.apache.org/licenses/LICENSE-2.0 4154 * 4155 * Unless required by applicable law or agreed to in writing, software 4156 * distributed under the License is distributed on an "AS IS" BASIS, 4157 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4158 * See the License for the specific language governing permissions and 4159 * limitations under the License. 4160 */function el(n,e,t){return`firebase:${n}:${e}:${t}`}class zs{constructor(e,t,i){this.persistence=e,this.auth=t,this.userKey=i;const{config:r,name:s}=this.auth;this.fullUserKey=el(this.userKey,r.apiKey,s),this.fullPersistenceKey=el("persistence",r.apiKey,s),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?Wi._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,i="authUser"){if(!t.length)return new zs(qi(cm),e,i);const r=(await Promise.all(t.map(async l=>{if(await l._isAvailable())return l}))).filter(l=>l);let s=r[0]||qi(cm);const o=el(i,e.config.apiKey,e.name);let a=null;for(const l of t)try{const d=await l._get(o);if(d){const h=Wi._fromJSON(e,d);l!==s&&(a=h),s=l;break}}catch{}const c=r.filter(l=>l._shouldAllowMigration);return!s._shouldAllowMigration||!c.length?new zs(s,e,i):(s=c[0],a&&await s._set(o,a.toJSON()),await Promise.all(t.map(async l=>{if(l!==s)try{await l._remove(o)}catch{}})),new zs(s,e,i))}}/** 4161 * @license 4162 * Copyright 2020 Google LLC 4163 * 4164 * Licensed under the Apache License, Version 2.0 (the "License"); 4165 * you may not use this file except in compliance with the License. 4166 * You may obtain a copy of the License at 4167 * 4168 * http://www.apache.org/licenses/LICENSE-2.0 4169 * 4170 * Unless required by applicable law or agreed to in writing, software 4171 * distributed under the License is distributed on an "AS IS" BASIS, 4172 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4173 * See the License for the specific language governing permissions and 4174 * limitations under the License. 4175 */function lm(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(kv(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Dv(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Ov(e))return"Blackberry";if(Fv(e))return"Webos";if(ap(e))return"Safari";if((e.includes("chrome/")||Nv(e))&&!e.includes("edge/"))return"Chrome";if(Uv(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,i=n.match(t);if((i==null?void 0:i.length)===2)return i[1]}return"Other"}function Dv(n=yn()){return/firefox\//i.test(n)}function ap(n=yn()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Nv(n=yn()){return/crios\//i.test(n)}function kv(n=yn()){return/iemobile/i.test(n)}function Uv(n=yn()){return/android/i.test(n)}function Ov(n=yn()){return/blackberry/i.test(n)}function Fv(n=yn()){return/webos/i.test(n)}function jl(n=yn()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function CR(n=yn()){var e;return jl(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function RR(){return $y()&&document.documentMode===10}function Vv(n=yn()){return jl(n)||Uv(n)||Fv(n)||Ov(n)||/windows phone/i.test(n)||kv(n)}function PR(){try{return!!(window&&window!==window.top)}catch{return!1}}/** 4176 * @license 4177 * Copyright 2020 Google LLC 4178 * 4179 * Licensed under the Apache License, Version 2.0 (the "License");
4180 * you may not use this file except in compliance with the License. 4181 * You may obtain a copy of the License at 4182 * 4183 * http://www.apache.org/licenses/LICENSE-2.0 4184 * 4185 * Unless required by applicable law or agreed to in writing, software 4186 * distributed under the License is distributed on an "AS IS" BASIS, 4187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4188 * See the License for the specific language governing permissions and 4189 * limitations under the License. 4190 */function Bv(n,e=[]){let t;switch(n){case"Browser":t=lm(yn());break;case"Worker":t=`${lm(yn())}-${n}`;break;default:t=n}const i=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${uo}/${i}`}/** 4191 * @license 4192 * Copyright 2022 Google LLC 4193 * 4194 * Licensed under the Apache License, Version 2.0 (the "License"); 4195 * you may not use this file except in compliance with the License. 4196 * You may obtain a copy of the License at 4197 * 4198 * http://www.apache.org/licenses/LICENSE-2.0 4199 * 4200 * Unless required by applicable law or agreed to in writing, software 4201 * distributed under the License is distributed on an "AS IS" BASIS, 4202 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4203 * See the License for the specific language governing permissions and 4204 * limitations under the License. 4205 */class LR{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const i=s=>new Promise((o,a)=>{try{const c=e(s);o(c)}catch(c){a(c)}});i.onAbort=t,this.queue.push(i);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const i of this.queue)await i(e),i.onAbort&&t.push(i.onAbort)}catch(i){t.reverse();for(const r of t)try{r()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:i==null?void 0:i.message})}}}/** 4206 * @license 4207 * Copyright 2023 Google LLC 4208 * 4209 * Licensed under the Apache License, Version 2.0 (the "License"); 4210 * you may not use this file except in compliance with the License. 4211 * You may obtain a copy of the License at 4212 * 4213 * http://www.apache.org/licenses/LICENSE-2.0 4214 * 4215 * Unless required by applicable law or agreed to in writing, software 4216 * distributed under the License is distributed on an "AS IS" BASIS, 4217 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4218 * See the License for the specific language governing permissions and 4219 * limitations under the License. 4220 */async function DR(n,e={}){return mo(n,"GET","/v2/passwordPolicy",op(n,e))}/** 4221 * @license 4222 * Copyright 2023 Google LLC 4223 * 4224 * Licensed under the Apache License, Version 2.0 (the "License"); 4225 * you may not use this file except in compliance with the License. 4226 * You may obtain a copy of the License at 4227 * 4228 * http://www.apache.org/licenses/LICENSE-2.0 4229 * 4230 * Unless required by applicable law or agreed to in writing, software 4231 * distributed under the License is distributed on an "AS IS" BASIS, 4232 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4233 * See the License for the specific language governing permissions and 4234 * limitations under the License. 4235 */const NR=6;class kR{constructor(e){var t,i,r,s;const o=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=o.minPasswordLength)!==null&&t!==void 0?t:NR,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),o.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),o.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),o.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),o.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(r=(i=e.allowedNonAlphanumericCharacters)===null||i===void 0?void 0:i.join(""))!==null&&r!==void 0?r:"",this.forceUpgradeOnSignin=(s=e.forceUpgradeOnSignin)!==null&&s!==void 0?s:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,i,r,s,o,a;const c={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,c),this.validatePasswordCharacterOptions(e,c),c.isValid&&
4235(c.isValid=(t=c.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),c.isValid&&(c.isValid=(i=c.meetsMaxPasswordLength)!==null&&i!==void 0?i:!0),c.isValid&&(c.isValid=(r=c.containsLowercaseLetter)!==null&&r!==void 0?r:!0),c.isValid&&(c.isValid=(s=c.containsUppercaseLetter)!==null&&s!==void 0?s:!0),c.isValid&&(c.isValid=(o=c.containsNumericCharacter)!==null&&o!==void 0?o:!0),c.isValid&&(c.isValid=(a=c.containsNonAlphanumericCharacter)!==null&&a!==void 0?a:!0),c}validatePasswordLengthOptions(e,t){const i=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;i&&(t.meetsMinPasswordLength=e.length>=i),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let i;for(let r=0;r<e.length;r++)i=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,i>="a"&&i<="z",i>="A"&&i<="Z",i>="0"&&i<="9",this.allowedNonAlphanumericCharacters.includes(i))}updatePasswordCharacterOptionsStatuses(e,t,i,r,s){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=i)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=s))}}/** 4236 * @license 4237 * Copyright 2020 Google LLC 4238 * 4239 * Licensed under the Apache License, Version 2.0 (the "License"); 4240 * you may not use this file except in compliance with the License. 4241 * You may obtain a copy of the License at 4242 * 4243 * http://www.apache.org/licenses/LICENSE-2.0 4244 * 4245 * Unless required by applicable law or agreed to in writing, software 4246 * distributed under the License is distributed on an "AS IS" BASIS, 4247 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4248 * See the License for the specific language governing permissions and 4249 * limitations under the License. 4250 */class UR{constructor(e,t,i,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=i,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new um(this),this.idTokenSubscription=new um(this),this.beforeStateQueue=new LR(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=wv,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=qi(t)),this._initializationPromise=this.queue(async()=>{var i,r;if(!this._deleted&&(this.persistenceManager=await zs.create(this,e),!this._deleted)){if(!((i=this._popupRedirectResolver)===null||i===void 0)&&i._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((r=this.currentUser)===null||r===void 0?void 0:r.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await Rv(this,{idToken:e}),i=await Wi._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(i)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(Vi(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(a,a))}):this.directlySetCurrentUser(null)}const i=await this.assertedPersistence.getCurrentUser();let r=i,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,a=r==null?void 0:r._redirectEventId,c=await this.tryRedirectSignIn(e);(!o||o===a)&&(c!=null&&c.user)&&(r=c.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);
4250if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(o){r=i,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return Qe(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await El(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=mR()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Vi(this.app))return Promise.reject(Wr(this));const t=e?oi(e):null;return t&&Qe(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&Qe(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Vi(this.app)?Promise.reject(Wr(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Vi(this.app)?Promise.reject(Wr(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(qi(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await DR(this),t=new kR(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new Dh("auth","Firebase",e())}onAuthStateChanged(e,t,i){return this.registerStateListener(this.authStateSubscription,e,t,i)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,i){return this.registerStateListener(this.idTokenSubscription,e,t,i)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const i=this.onAuthStateChanged(()=>{i(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),i={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(i.tenantId=this.tenantId),await MR(this,i)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const i=await this.getOrInitRedirectPersistenceManager(t);return e===null?i.removeCurrentUser():i.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&qi(e)||this._popupRedirectResolver;Qe(t,this,"argument-error"),this.redirectPersistenceManager=await zs.create(this,[qi(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,i;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((i=this.redirectUser)===null||i===void 0?void 0:i._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const i=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==i&&(this.lastNotifiedUid=i,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,i,r){if(this._deleted)return()=>{};const s=typeof t=="function"?t:t.next.bind(t);let o=!1;const a=this._isInitialized?Promise.resolve():this._initializationPromise;if(Qe(a,this,"internal-error"),a.then(()=>{o||s(this.currentUser)}),typeof t=="function"){const c=e.addObserver(t,i,r);return()=>{o=!0,c()}}else{const c=e.addObserver(t);return()=>{o=!0,c()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return Qe(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Bv(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const i=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());i&&(t["X-Firebase-Client"]=i);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var e;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t!=null&&t.error&&hR(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function Kl(n){return oi(n)}class um{constructor(e){this.auth=e,this.observer=null,this.addObserver=Qy(t=>this.observer=t)}get next(){return Qe(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** 4251 * @license 4252 * Copyright 2020 Google LLC 4253 * 4254 * Licensed under the Apache License, Version 2.0 (the "License");
4255 * you may not use this file except in compliance with the License. 4256 * You may obtain a copy of the License at 4257 * 4258 * http://www.apache.org/licenses/LICENSE-2.0 4259 * 4260 * Unless required by applicable law or agreed to in writing, software 4261 * distributed under the License is distributed on an "AS IS" BASIS, 4262 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4263 * See the License for the specific language governing permissions and 4264 * limitations under the License. 4265 */let cp={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function OR(n){cp=n}function FR(n){return cp.loadJS(n)}function VR(){return cp.gapiScript}function BR(n){return`__${n}${Math.floor(Math.random()*1e6)}`}/** 4266 * @license 4267 * Copyright 2020 Google LLC 4268 * 4269 * Licensed under the Apache License, Version 2.0 (the "License"); 4270 * you may not use this file except in compliance with the License. 4271 * You may obtain a copy of the License at 4272 * 4273 * http://www.apache.org/licenses/LICENSE-2.0 4274 * 4275 * Unless required by applicable law or agreed to in writing, software 4276 * distributed under the License is distributed on an "AS IS" BASIS, 4277 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4278 * See the License for the specific language governing permissions and 4279 * limitations under the License. 4280 */function zR(n,e){const t=Lh(n,"auth");if(t.isInitialized()){const r=t.getImmediate(),s=t.getOptions();if(Zy(s,e??{}))return r;Ei(r,"already-initialized")}return t.initialize({options:e})}function HR(n,e){const t=(e==null?void 0:e.persistence)||[],i=(Array.isArray(t)?t:[t]).map(qi);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(i,e==null?void 0:e.popupRedirectResolver)}function GR(n,e,t){const i=Kl(n);Qe(i._canInitEmulator,i,"emulator-config-failed"),Qe(/^https?:\/\//.test(e),i,"invalid-emulator-scheme");const r=!!(t!=null&&t.disableWarnings),s=zv(e),{host:o,port:a}=WR(e),c=a===null?"":`:${a}`;i.config.emulator={url:`${s}//${o}${c}/`},i.settings.appVerificationDisabledForTesting=!0,i.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:r})}),r||qR()}function zv(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function WR(n){const e=zv(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const i=t[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(i);if(r){const s=r[1];return{host:s,port:dm(i.substr(s.length+1))}}else{const[s,o]=i.split(":");return{host:s,port:dm(o)}}}function dm(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function qR(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/** 4281 * @license 4282 * Copyright 2020 Google LLC 4283 * 4284 * Licensed under the Apache License, Version 2.0 (the "License"); 4285 * you may not use this file except in compliance with the License. 4286 * You may obtain a copy of the License at 4287 * 4288 * http://www.apache.org/licenses/LICENSE-2.0 4289 * 4290 * Unless required by applicable law or agreed to in writing, software 4291 * distributed under the License is distributed on an "AS IS" BASIS, 4292 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4293 * See the License for the specific language governing permissions and 4294 * limitations under the License. 4295 */class Hv{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Gi("not implemented")}_getIdTokenResponse(e){return Gi("not implemented")}_linkToIdToken(e,t){return Gi("not implemented")}_getReauthenticationResolver(e){return Gi("not implemented")}}/** 4296 * @license 4297 * Copyright 2020 Google LLC 4298 * 4299 * Licensed under the Apache License, Version 2.0 (the "License");
4300 * you may not use this file except in compliance with the License. 4301 * You may obtain a copy of the License at 4302 * 4303 * http://www.apache.org/licenses/LICENSE-2.0 4304 * 4305 * Unless required by applicable law or agreed to in writing, software 4306 * distributed under the License is distributed on an "AS IS" BASIS, 4307 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4308 * See the License for the specific language governing permissions and 4309 * limitations under the License. 4310 */async function Hs(n,e){return yR(n,"POST","/v1/accounts:signInWithIdp",op(n,e))}/** 4311 * @license 4312 * Copyright 2020 Google LLC 4313 * 4314 * Licensed under the Apache License, Version 2.0 (the "License"); 4315 * you may not use this file except in compliance with the License. 4316 * You may obtain a copy of the License at 4317 * 4318 * http://www.apache.org/licenses/LICENSE-2.0 4319 * 4320 * Unless required by applicable law or agreed to in writing, software 4321 * distributed under the License is distributed on an "AS IS" BASIS, 4322 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4323 * See the License for the specific language governing permissions and 4324 * limitations under the License. 4325 */const XR="http://localhost";class Zi extends Hv{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Zi(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Ei("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
4325once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:i,signInMethod:r}=t,s=np(t,["providerId","signInMethod"]);if(!i||!r)return null;const o=new Zi(i,r);return o.idToken=s.idToken||void 0,o.accessToken=s.accessToken||void 0,o.secret=s.secret,o.nonce=s.nonce,o.pendingToken=s.pendingToken||null,o}_getIdTokenResponse(e){const t=this.buildRequest();return Hs(e,t)}_linkToIdToken(e,t){const i=this.buildRequest();return i.idToken=t,Hs(e,i)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Hs(e,t)}buildRequest(){const e={requestUri:XR,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Va(t)}return e}}/** 4326 * @license 4327 * Copyright 2020 Google LLC 4328 * 4329 * Licensed under the Apache License, Version 2.0 (the "License"); 4330 * you may not use this file except in compliance with the License. 4331 * You may obtain a copy of the License at 4332 * 4333 * http://www.apache.org/licenses/LICENSE-2.0 4334 * 4335 * Unless required by applicable law or agreed to in writing, software 4336 * distributed under the License is distributed on an "AS IS" BASIS, 4337 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4338 * See the License for the specific language governing permissions and 4339 * limitations under the License. 4340 */class lp{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/** 4341 * @license 4342 * Copyright 2019 Google LLC 4343 * 4344 * Licensed under the Apache License, Version 2.0 (the "License"); 4345 * you may not use this file except in compliance with the License. 4346 * You may obtain a copy of the License at 4347 * 4348 * http://www.apache.org/licenses/LICENSE-2.0 4349 * 4350 * Unless required by applicable law or agreed to in writing, software 4351 * distributed under the License is distributed on an "AS IS" BASIS, 4352 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4353 * See the License for the specific language governing permissions and 4354 * limitations under the License. 4355 */class go extends lp{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class qr extends go{static credentialFromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;return Qe("providerId"in t&&"signInMethod"in t,"argument-error"),Zi._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return Qe(e.idToken||e.accessToken,"argument-error"),Zi._fromParams(Object.assign(Object.assign({}
4355,e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return qr.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return qr.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:i,oauthTokenSecret:r,pendingToken:s,nonce:o,providerId:a}=e;if(!i&&!r&&!t&&!s||!a)return null;try{return new qr(a)._credential({idToken:t,accessToken:i,nonce:o,pendingToken:s})}catch{return null}}}/** 4356 * @license 4357 * Copyright 2020 Google LLC 4358 * 4359 * Licensed under the Apache License, Version 2.0 (the "License"); 4360 * you may not use this file except in compliance with the License. 4361 * You may obtain a copy of the License at 4362 * 4363 * http://www.apache.org/licenses/LICENSE-2.0 4364 * 4365 * Unless required by applicable law or agreed to in writing, software 4366 * distributed under the License is distributed on an "AS IS" BASIS, 4367 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4368 * See the License for the specific language governing permissions and 4369 * limitations under the License. 4370 */class fr extends go{constructor(){super("facebook.com")}static credential(e){return Zi._fromParams({providerId:fr.PROVIDER_ID,signInMethod:fr.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return fr.credentialFromTaggedObject(e)}static credentialFromError(e){return fr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return fr.credential(e.oauthAccessToken)}catch{return null}}}fr.FACEBOOK_SIGN_IN_METHOD="facebook.com";fr.PROVIDER_ID="facebook.com";/** 4371 * @license 4372 * Copyright 2020 Google LLC 4373 * 4374 * Licensed under the Apache License, Version 2.0 (the "License"); 4375 * you may not use this file except in compliance with the License. 4376 * You may obtain a copy of the License at 4377 * 4378 * http://www.apache.org/licenses/LICENSE-2.0 4379 * 4380 * Unless required by applicable law or agreed to in writing, software 4381 * distributed under the License is distributed on an "AS IS" BASIS, 4382 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4383 * See the License for the specific language governing permissions and 4384 * limitations under the License. 4385 */class Fi extends go{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Zi._fromParams({providerId:Fi.PROVIDER_ID,signInMethod:Fi.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Fi.credentialFromTaggedObject(e)}static credentialFromError(e){return Fi.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:i}=e;if(!t&&!i)return null;try{return Fi.credential(t,i)}catch{return null}}}Fi.GOOGLE_SIGN_IN_METHOD="google.com";Fi.PROVIDER_ID="google.com";/** 4386 * @license 4387 * Copyright 2020 Google LLC 4388 * 4389 * Licensed under the Apache License, Version 2.0 (the "License"); 4390 * you may not use this file except in compliance with the License. 4391 * You may obtain a copy of the License at 4392 * 4393 * http://www.apache.org/licenses/LICENSE-2.0 4394 * 4395 * Unless required by applicable law or agreed to in writing, software 4396 * distributed under the License is distributed on an "AS IS" BASIS, 4397 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4398 * See the License for the specific language governing permissions and 4399 * limitations under the License. 4400 */class _r extends go{constructor(){super("github.com")}static credential(e){return Zi._fromParams({providerId:_r.PROVIDER_ID,signInMethod:_r.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return _r.credentialFromTaggedObject(e)}static credentialFromError(e){return _r.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return _r.credential(e.oauthAccessToken)}catch{return null}}}_r.GITHUB_SIGN_IN_METHOD="github.com";_r.PROVIDER_ID="github.com";/** 4401 * @license 4402 * Copyright 2020 Google LLC 4403 * 4404 * Licensed under the Apache License, Version 2.0 (the "License");
4405 * you may not use this file except in compliance with the License. 4406 * You may obtain a copy of the License at 4407 * 4408 * http://www.apache.org/licenses/LICENSE-2.0 4409 * 4410 * Unless required by applicable law or agreed to in writing, software 4411 * distributed under the License is distributed on an "AS IS" BASIS, 4412 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4413 * See the License for the specific language governing permissions and 4414 * limitations under the License. 4415 */class mr extends go{constructor(){super("twitter.com")}static credential(e,t){return Zi._fromParams({providerId:mr.PROVIDER_ID,signInMethod:mr.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return mr.credentialFromTaggedObject(e)}static credentialFromError(e){return mr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:i}=e;if(!t||!i)return null;try{return mr.credential(t,i)}catch{return null}}}mr.TWITTER_SIGN_IN_METHOD="twitter.com";mr.PROVIDER_ID="twitter.com";/** 4416 * @license 4417 * Copyright 2020 Google LLC 4418 * 4419 * Licensed under the Apache License, Version 2.0 (the "License"); 4420 * you may not use this file except in compliance with the License. 4421 * You may obtain a copy of the License at 4422 * 4423 * http://www.apache.org/licenses/LICENSE-2.0 4424 * 4425 * Unless required by applicable law or agreed to in writing, software 4426 * distributed under the License is distributed on an "AS IS" BASIS, 4427 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4428 * See the License for the specific language governing permissions and 4429 * limitations under the License. 4430 */class eo{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,i,r=!1){const s=await Wi._fromIdTokenResponse(e,i,r),o=hm(i);return new eo({user:s,providerId:o,_tokenResponse:i,operationType:t})}static async _forOperation(e,t,i){await e._updateTokensIfNecessary(i,!0);const r=hm(i);return new eo({user:e,providerId:r,_tokenResponse:i,operationType:t})}}function hm(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/** 4431 * @license 4432 * Copyright 2020 Google LLC 4433 * 4434 * Licensed under the Apache License, Version 2.0 (the "License"); 4435 * you may not use this file except in compliance with the License. 4436 * You may obtain a copy of the License at 4437 * 4438 * http://www.apache.org/licenses/LICENSE-2.0 4439 * 4440 * Unless required by applicable law or agreed to in writing, software 4441 * distributed under the License is distributed on an "AS IS" BASIS, 4442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4443 * See the License for the specific language governing permissions and 4444 * limitations under the License. 4445 */class Tl extends Nl{constructor(e,t,i,r){var s;super(t.code,t.message),this.operationType=i,this.user=r,Object.setPrototypeOf(this,Tl.prototype),this.customData={appName:e.name,tenantId:(s=e.tenantId)!==null&&s!==void 0?s:void 0,_serverResponse:t.customData._serverResponse,operationType:i}}static _fromErrorAndOperation(e,t,i,r){return new Tl(e,t,i,r)}}function Gv(n,e,t,i){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(s=>{throw s.code==="auth/multi-factor-auth-required"?Tl._fromErrorAndOperation(n,s,e,i):s})}async function jR(n,e,t=!1){const i=await Ca(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return eo._forOperation(n,"link",i)}/** 4446 * @license 4447 * Copyright 2019 Google LLC 4448 * 4449 * Licensed under the Apache License, Version 2.0 (the "License"); 4450 * you may not use this file except in compliance with the License. 4451 * You may obtain a copy of the License at 4452 * 4453 * http://www.apache.org/licenses/LICENSE-2.0 4454 * 4455 * Unless required by applicable law or agreed to in writing, software 4456 * distributed under the License is distributed on an "AS IS" BASIS, 4457 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4458 * See the License for the specific language governing permissions and 4459 * limitations under the License. 4460 */async function KR(n,e,t=!1){const{auth:i}=n;if(Vi(i.app))return Promise.reject(Wr(i));const r="reauthenticate";try{const s=await Ca(n,Gv(i,r,e,n),t);Qe(s.idToken,i,"internal-error");const o=Xl(s.idToken);Qe(o,i,"internal-error");const{sub:a}=o;return Qe(n.uid===a,i,"user-mismatch"),eo._forOperation(n,r,s)}catch(s){throw(s==null?void 0:s.code)==="auth/user-not-found"&&Ei(i,"user-mismatch"),s}}/** 4461 * @license 4462 * Copyright 2020 Google LLC 4463 * 4464 * Licensed under the Apache License, Version 2.0 (the "License");
4465 * you may not use this file except in compliance with the License. 4466 * You may obtain a copy of the License at 4467 * 4468 * http://www.apache.org/licenses/LICENSE-2.0 4469 * 4470 * Unless required by applicable law or agreed to in writing, software 4471 * distributed under the License is distributed on an "AS IS" BASIS, 4472 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4473 * See the License for the specific language governing permissions and 4474 * limitations under the License. 4475 */async function YR(n,e,t=!1){if(Vi(n.app))return Promise.reject(Wr(n));const i="signIn",r=await Gv(n,i,e),s=await eo._fromIdTokenResponse(n,i,r);return t||await n._updateCurrentUser(s.user),s}/** 4476 * @license 4477 * Copyright 2019 Google LLC 4478 * 4479 * Licensed under the Apache License, Version 2.0 (the "License"); 4480 * you may not use this file except in compliance with the License. 4481 * You may obtain a copy of the License at 4482 * 4483 * http://www.apache.org/licenses/LICENSE-2.0 4484 * 4485 * Unless required by applicable law or agreed to in writing, software 4486 * distributed under the License is distributed on an "AS IS" BASIS, 4487 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4488 * See the License for the specific language governing permissions and 4489 * limitations under the License. 4490 */function QR(n){var e,t;if(!n)return null;const{providerId:i}=n,r=n.rawUserInfo?JSON.parse(n.rawUserInfo):{},s=n.isNewUser||n.kind==="identitytoolkit#SignupNewUserResponse";if(!i&&(n!=null&&n.idToken)){const o=(t=(e=Xl(n.idToken))===null||e===void 0?void 0:e.firebase)===null||t===void 0?void 0:t.sign_in_provider;if(o){const a=o!=="anonymous"&&o!=="custom"?o:null;return new Gs(s,a)}}if(!i)return null;switch(i){case"facebook.com":return new ZR(s,r);case"github.com":return new JR(s,r);case"google.com":return new $R(s,r);case"twitter.com":return new e2(s,r,n.screenName||null);case"custom":case"anonymous":return new Gs(s,null);default:return new Gs(s,i,r)}}class Gs{constructor(e,t,i={}){this.isNewUser=e,this.providerId=t,this.profile=i}}class Wv extends Gs{constructor(e,t,i,r){super(e,t,i),this.username=r}}class ZR extends Gs{constructor(e,t){super(e,"facebook.com",t)}}class JR extends Wv{constructor(e,t){super(e,"github.com",t,typeof(t==null?void 0:t.login)=="string"?t==null?void 0:t.login:null)}}class $R extends Gs{constructor(e,t){super(e,"google.com",t)}}class e2 extends Wv{constructor(e,t,i){super(e,"twitter.com",t,i)}}function t2(n){const{user:e,_tokenResponse:t}=n;return e.isAnonymous&&!t?{providerId:null,isNewUser:!1,profile:null}:QR(t)}function n2(n,e,t,i){return oi(n).onIdTokenChanged(e,t,i)}function i2(n,e,t){return oi(n).beforeAuthStateChanged(e,t)}const bl="__sak";/** 4491 * @license 4492 * Copyright 2019 Google LLC 4493 * 4494 * Licensed under the Apache License, Version 2.0 (the "License"); 4495 * you may not use this file except in compliance with the License. 4496 * You may obtain a copy of the License at 4497 * 4498 * http://www.apache.org/licenses/LICENSE-2.0 4499 * 4500 * Unless required by applicable law or agreed to in writing, software 4501 * distributed under the License is distributed on an "AS IS" BASIS, 4502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4503 * See the License for the specific language governing permissions and 4504 * limitations under the License. 4505 */class qv{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(bl,"1"),this.storage.removeItem(bl),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/** 4506 * @license 4507 * Copyright 2020 Google LLC 4508 * 4509 * Licensed under the Apache License, Version 2.0 (the "License"); 4510 * you may not use this file except in compliance with the License. 4511 * You may obtain a copy of the License at 4512 * 4513 * http://www.apache.org/licenses/LICENSE-2.0 4514 * 4515 * Unless required by applicable law or agreed to in writing, softw
4515are 4516 * distributed under the License is distributed on an "AS IS" BASIS, 4517 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4518 * See the License for the specific language governing permissions and 4519 * limitations under the License. 4520 */function r2(){const n=yn();return ap(n)||jl(n)}const s2=1e3,o2=10;class Xv extends qv{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=r2()&&PR(),this.fallbackToPolling=Vv(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const i=this.storage.getItem(t),r=this.localCache[t];i!==r&&e(t,r,i)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((o,a,c)=>{this.notifyListeners(o,c)});return}const i=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const o=this.storage.getItem(i);if(e.newValue!==o)e.newValue!==null?this.storage.setItem(i,e.newValue):this.storage.removeItem(i);else if(this.localCache[i]===e.newValue&&!t)return}const r=()=>{const o=this.storage.getItem(i);!t&&this.localCache[i]===o||this.notifyListeners(i,o)},s=this.storage.getItem(i);RR()&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,o2):r()}notifyListeners(e,t){this.localCache[e]=t;const i=this.listeners[e];if(i)for(const r of Array.from(i))r(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,i)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:i}),!0)})},s2)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
4520ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Xv.type="LOCAL";const a2=Xv;/** 4521 * @license 4522 * Copyright 2020 Google LLC 4523 * 4524 * Licensed under the Apache License, Version 2.0 (the "License"); 4525 * you may not use this file except in compliance with the License. 4526 * You may obtain a copy of the License at 4527 * 4528 * http://www.apache.org/licenses/LICENSE-2.0 4529 * 4530 * Unless required by applicable law or agreed to in writing, software 4531 * distributed under the License is distributed on an "AS IS" BASIS, 4532 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4533 * See the License for the specific language governing permissions and 4534 * limitations under the License. 4535 */class jv extends qv{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}jv.type="SESSION";const Kv=jv;/** 4536 * @license 4537 * Copyright 2019 Google LLC 4538 * 4539 * Licensed under the Apache License, Version 2.0 (the "License"); 4540 * you may not use this file except in compliance with the License. 4541 * You may obtain a copy of the License at 4542 * 4543 * http://www.apache.org/licenses/LICENSE-2.0 4544 * 4545 * Unless required by applicable law or agreed to in writing, software 4546 * distributed under the License is distributed on an "AS IS" BASIS, 4547 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4548 * See the License for the specific language governing permissions and 4549 * limitations under the License. 4550 */function c2(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/** 4551 * @license 4552 * Copyright 2019 Google LLC 4553 * 4554 * Licensed under the Apache License, Version 2.0 (the "License"); 4555 * you may not use this file except in compliance with the License. 4556 * You may obtain a copy of the License at 4557 * 4558 * http://www.apache.org/licenses/LICENSE-2.0 4559 * 4560 * Unless required by applicable law or agreed to in writing, software 4561 * distributed under the License is distributed on an "AS IS" BASIS, 4562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4563 * See the License for the specific language governing permissions and 4564 * limitations under the License. 4565 */class Yl{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(r=>r.isListeningto(e));if(t)return t;const i=new Yl(e);return this.receivers.push(i),i}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:i,eventType:r,data:s}=t.data,o=this.handlersMap[r];if(!(o!=null&&o.size))return;t.ports[0].postMessage({status:"ack",eventId:i,eventType:r});const a=Array.from(o).map(async l=>l(t.origin,s)),c=await c2(a);t.ports[0].postMessage({status:"done",eventId:i,eventType:r,response:c})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Yl.receivers=[];/** 4566 * @license 4567 * Copyright 2020 Google LLC 4568 * 4569 * Licensed under the Apache License, Version 2.0 (the "License"); 4570 * you may not use this file except in compliance with the License. 4571 * You may obtain a copy of the License at 4572 * 4573 * http://www.apache.org/licenses/LICENSE-2.0 4574 * 4575 * Unless required by applicable law or agreed to in writing, software 4576 * distributed under the License is distributed on an "AS IS" BASIS, 4577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4578 * See the License for the specific language governing permissions and 4579 * limitations under the License. 4580 */function up(n="",e=10){let t="";for(let i=0;i<e;i++)t+=Math.floor(Math.random()*10);return n+t}/** 4581 * @license 4582 * Copyright 2019 Google LLC 4583 * 4584 * Licensed under the Apache License, Version 2.0 (the "License");
4585 * you may not use this file except in compliance with the License. 4586 * You may obtain a copy of the License at 4587 * 4588 * http://www.apache.org/licenses/LICENSE-2.0 4589 * 4590 * Unless required by applicable law or agreed to in writing, software 4591 * distributed under the License is distributed on an "AS IS" BASIS, 4592 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4593 * See the License for the specific language governing permissions and 4594 * limitations under the License. 4595 */class l2{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,i=50){const r=typeof MessageChannel<"u"?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let s,o;return new Promise((a,c)=>{const l=up("",20);r.port1.start();const d=setTimeout(()=>{c(new Error("unsupported_event"))},i);o={messageChannel:r,onMessage(h){const p=h;if(p.data.eventId===l)switch(p.data.status){case"ack":clearTimeout(d),s=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(s),a(p.data.response);break;default:clearTimeout(d),clearTimeout(s),c(new Error("invalid_response"));break}}},this.handlers.add(o),r.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[r.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/** 4596 * @license 4597 * Copyright 2020 Google LLC 4598 * 4599 * Licensed under the Apache License, Version 2.0 (the "License"); 4600 * you may not use this file except in compliance with the License. 4601 * You may obtain a copy of the License at 4602 * 4603 * http://www.apache.org/licenses/LICENSE-2.0 4604 * 4605 * Unless required by applicable law or agreed to in writing, software 4606 * distributed under the License is distributed on an "AS IS" BASIS, 4607 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4608 * See the License for the specific language governing permissions and 4609 * limitations under the License. 4610 */function _i(){return window}function u2(n){_i().location.href=n}/** 4611 * @license 4612 * Copyright 2020 Google LLC. 4613 * 4614 * Licensed under the Apache License, Version 2.0 (the "License"); 4615 * you may not use this file except in compliance with the License. 4616 * You may obtain a copy of the License at 4617 * 4618 * http://www.apache.org/licenses/LICENSE-2.0 4619 * 4620 * Unless required by applicable law or agreed to in writing, software 4621 * distributed under the License is distributed on an "AS IS" BASIS, 4622 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4623 * See the License for the specific language governing permissions and 4624 * limitations under the License. 4625 */function Yv(){return typeof _i().WorkerGlobalScope<"u"&&typeof _i().importScripts=="function"}async function d2(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function h2(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function p2(){return Yv()?self:null}/** 4626 * @license 4627 * Copyright 2019 Google LLC 4628 * 4629 * Licensed under the Apache License, Version 2.0 (the "License"); 4630 * you may not use this file except in compliance with the License. 4631 * You may obtain a copy of the License at 4632 * 4633 * http://www.apache.org/licenses/LICENSE-2.0 4634 * 4635 * Unless required by applicable law or agreed to in writing, software 4636 * distributed under the License is distributed on an "AS IS" BASIS, 4637 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4638 * See the License for the specific language governing permissions and 4639 * limitations under the License. 4640 */const Qv="firebaseLocalStorageDb",f2=1,Sl="firebaseLocalStorage",Zv="fbase_key";class Wa{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function Ql(n,e){return n.transaction([Sl],e?"readwrite":"readonly").objectStore(Sl)}function _2(){const n=indexedDB.deleteDatabase(Qv);return new Wa(n).toPromise()}function gh(){const n=indexedDB.open(Qv,f2);return new Promise((e,t)=>
4640{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const i=n.result;try{i.createObjectStore(Sl,{keyPath:Zv})}catch(r){t(r)}}),n.addEventListener("success",async()=>{const i=n.result;i.objectStoreNames.contains(Sl)?e(i):(i.close(),await _2(),e(await gh()))})})}async function pm(n,e,t){const i=Ql(n,!0).put({[Zv]:e,value:t});return new Wa(i).toPromise()}async function m2(n,e){const t=Ql(n,!1).get(e),i=await new Wa(t).toPromise();return i===void 0?null:i.value}function fm(n,e){const t=Ql(n,!0).delete(e);return new Wa(t).toPromise()}const g2=800,v2=3;class Jv{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await gh(),this.db)}async _withRetries(e){let t=0;for(;;)try{const i=await this._openDb();return await e(i)}catch(i){if(t++>v2)throw i;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Yv()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Yl._getInstance(p2()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await d2(),!this.activeServiceWorker)return;this.sender=new l2(this.activeServiceWorker);const i=await this.sender._send("ping",{},800);i&&!((e=i[0])===null||e===void 0)&&e.fulfilled&&!((t=i[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||h2()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await gh();return await pm(e,bl,"1"),await fm(e,bl),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(i=>pm(i,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(i=>m2(i,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>fm(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(r=>{const s=Ql(r,!1).getAll();return new Wa(s).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],i=new Set;if(e.length!==0)for(const{fbase_key:r,value:s}of e)i.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(s)&&(this.notifyListeners(r,s),t.push(r));for(const r of Object.keys(this.localCache))this.localCache[r]&&!i.has(r)&&(this.notifyListeners(r,null),t.push(r));return t}notifyListeners(e,t){this.localCache[e]=t;const i=this.listeners[e];if(i)for(const r of Array.from(i))r(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),g2)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
4640ject.keys(this.listeners).length===0&&this.stopPolling()}}Jv.type="LOCAL";const y2=Jv;new Ga(3e4,6e4);/** 4641 * @license 4642 * Copyright 2021 Google LLC 4643 * 4644 * Licensed under the Apache License, Version 2.0 (the "License"); 4645 * you may not use this file except in compliance with the License. 4646 * You may obtain a copy of the License at 4647 * 4648 * http://www.apache.org/licenses/LICENSE-2.0 4649 * 4650 * Unless required by applicable law or agreed to in writing, software 4651 * distributed under the License is distributed on an "AS IS" BASIS, 4652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4653 * See the License for the specific language governing permissions and 4654 * limitations under the License. 4655 */function $v(n,e){return e?qi(e):(Qe(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/** 4656 * @license 4657 * Copyright 2019 Google LLC 4658 * 4659 * Licensed under the Apache License, Version 2.0 (the "License"); 4660 * you may not use this file except in compliance with the License. 4661 * You may obtain a copy of the License at 4662 * 4663 * http://www.apache.org/licenses/LICENSE-2.0 4664 * 4665 * Unless required by applicable law or agreed to in writing, software 4666 * distributed under the License is distributed on an "AS IS" BASIS, 4667 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4668 * See the License for the specific language governing permissions and 4669 * limitations under the License. 4670 */class dp extends Hv{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Hs(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Hs(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Hs(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function E2(n){return YR(n.auth,new dp(n),n.bypassAuthState)}function T2(n){const{auth:e,user:t}=n;return Qe(t,e,"internal-error"),KR(t,new dp(n),n.bypassAuthState)}async function b2(n){const{auth:e,user:t}=n;return Qe(t,e,"internal-error"),jR(t,new dp(n),n.bypassAuthState)}/** 4671 * @license 4672 * Copyright 2020 Google LLC 4673 * 4674 * Licensed under the Apache License, Version 2.0 (the "License"); 4675 * you may not use this file except in compliance with the License. 4676 * You may obtain a copy of the License at 4677 * 4678 * http://www.apache.org/licenses/LICENSE-2.0 4679 * 4680 * Unless required by applicable law or agreed to in writing, software 4681 * distributed under the License is distributed on an "AS IS" BASIS, 4682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4683 * See the License for the specific language governing permissions and 4684 * limitations under the License. 4685 */class e0{constructor(e,t,i,r,s=!1){this.auth=e,this.resolver=i,this.user=r,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(i){this.reject(i)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:i,postBody:r,tenantId:s,error:o,type:a}=e;if(o){this.reject(o);return}const c={auth:this.auth,requestUri:t,sessionId:i,tenantId:s||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(a)(c))}catch(l){this.reject(l)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return E2;case"linkViaPopup":case"linkViaRedirect":return b2;case"reauthViaPopup":case"reauthViaRedirect":return T2;default:Ei(this.auth,"internal-error")}}resolve(e){Qi(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Qi(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** 4686 * @license 4687 * Copyright 2020 Google LLC 4688 * 4689 * Licensed under the Apache License, Version 2.0 (the "License");
4690 * you may not use this file except in compliance with the License. 4691 * You may obtain a copy of the License at 4692 * 4693 * http://www.apache.org/licenses/LICENSE-2.0 4694 * 4695 * Unless required by applicable law or agreed to in writing, software 4696 * distributed under the License is distributed on an "AS IS" BASIS, 4697 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4698 * See the License for the specific language governing permissions and 4699 * limitations under the License. 4700 */const S2=new Ga(2e3,1e4);async function t0(n,e,t){if(Vi(n.app))return Promise.reject(si(n,"operation-not-supported-in-this-environment"));const i=Kl(n);pR(n,e,lp);const r=$v(i,t);return new Hr(i,"signInViaPopup",e,r).executeNotNull()}class Hr extends e0{constructor(e,t,i,r,s){super(e,t,r,s),this.provider=i,this.authWindow=null,this.pollId=null,Hr.currentPopupAction&&Hr.currentPopupAction.cancel(),Hr.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Qe(e,this.auth,"internal-error"),e}async onExecution(){Qi(this.filter.length===1,"Popup operations only handle one event");const e=up();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(si(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(si(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Hr.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,i;if(!((i=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||i===void 0)&&i.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(si(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,S2.get())};e()}}Hr.currentPopupAction=null;/** 4701 * @license 4702 * Copyright 2020 Google LLC 4703 * 4704 * Licensed under the Apache License, Version 2.0 (the "License"); 4705 * you may not use this file except in compliance with the License. 4706 * You may obtain a copy of the License at 4707 * 4708 * http://www.apache.org/licenses/LICENSE-2.0 4709 * 4710 * Unless required by applicable law or agreed to in writing, software 4711 * distributed under the License is distributed on an "AS IS" BASIS, 4712 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4713 * See the License for the specific language governing permissions and 4714 * limitations under the License. 4715 */const A2="pendingRedirect",tl=new Map;class x2 extends e0{constructor(e,t,i=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,i),this.eventId=null}async execute(){let e=tl.get(this.auth._key());if(!e){try{const i=await w2(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(i)}catch(t){e=()=>Promise.reject(t)}tl.set(this.auth._key(),e)}return this.bypassAuthState||tl.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function w2(n,e){const t=C2(e),i=M2(n);if(!await i._isAvailable())return!1;const r=await i._get(t)==="true";return await i._remove(t),r}function I2(n,e){tl.set(n._key(),e)}function M2(n){return qi(n._redirectPersistence)}function C2(n){return el(A2,n.config.apiKey,n.name)}async function R2(n,e,t=!1){if(Vi(n.app))return Promise.reject(Wr(n));const i=Kl(n),r=$v(i,e),o=await new x2(i,r,t).execute();return o&&!t&&(delete o.user._redirectEventId,await i._persistUserIfCurrent(o.user),await i._setRedirectUser(null,e)),o}/** 4716 * @license 4717 * Copyright 2020 Google LLC 4718 * 4719 * Licensed under the Apache License, Version 2.0 (the "License");
4720 * you may not use this file except in compliance with the License. 4721 * You may obtain a copy of the License at 4722 * 4723 * http://www.apache.org/licenses/LICENSE-2.0 4724 * 4725 * Unless required by applicable law or agreed to in writing, software 4726 * distributed under the License is distributed on an "AS IS" BASIS, 4727 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4728 * See the License for the specific language governing permissions and 4729 * limitations under the License. 4730 */const P2=10*60*1e3;class L2{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(i=>{this.isEventForConsumer(e,i)&&(t=!0,this.sendToConsumer(e,i),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!D2(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var i;if(e.error&&!n0(e)){const r=((i=e.error.code)===null||i===void 0?void 0:i.split("auth/")[1])||"internal-error";t.onError(si(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const i=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&i}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=P2&&this.cachedEventUids.clear(),this.cachedEventUids.has(_m(e))}saveEventToCache(e){this.cachedEventUids.add(_m(e)),this.lastProcessedEventTime=Date.now()}}function _m(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function n0({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function D2(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return n0(n);default:return!1}}/** 4731 * @license 4732 * Copyright 2020 Google LLC 4733 * 4734 * Licensed under the Apache License, Version 2.0 (the "License"); 4735 * you may not use this file except in compliance with the License. 4736 * You may obtain a copy of the License at 4737 * 4738 * http://www.apache.org/licenses/LICENSE-2.0 4739 * 4740 * Unless required by applicable law or agreed to in writing, software 4741 * distributed under the License is distributed on an "AS IS" BASIS, 4742 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4743 * See the License for the specific language governing permissions and 4744 * limitations under the License. 4745 */async function N2(n,e={}){return mo(n,"GET","/v1/projects",e)}/** 4746 * @license 4747 * Copyright 2020 Google LLC 4748 * 4749 * Licensed under the Apache License, Version 2.0 (the "License"); 4750 * you may not use this file except in compliance with the License. 4751 * You may obtain a copy of the License at 4752 * 4753 * http://www.apache.org/licenses/LICENSE-2.0 4754 * 4755 * Unless required by applicable law or agreed to in writing, software 4756 * distributed under the License is distributed on an "AS IS" BASIS, 4757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4758 * See the License for the specific language governing permissions and 4759 * limitations under the License. 4760 */const k2=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,U2=/^https?/;async function O2(n){if(n.config.emulator)return;const{authorizedDomains:e}=await N2(n);for(const t of e)try{if(F2(t))return}catch{}Ei(n,"unauthorized-domain")}function F2(n){const e=_h(),{protocol:t,hostname:i}=new URL(e);if(n.startsWith("chrome-extension://")){const o=new URL(n);return o.hostname===""&&i===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===i}if(!U2.test(t))return!1;if(k2.test(n))return i===n;const r=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(i)}/** 4761 * @license 4762 * Copyright 2020 Google LLC. 4763 * 4764 * Licensed under the Apache License, Version 2.0 (the "License");
4765 * you may not use this file except in compliance with the License. 4766 * You may obtain a copy of the License at 4767 * 4768 * http://www.apache.org/licenses/LICENSE-2.0 4769 * 4770 * Unless required by applicable law or agreed to in writing, software 4771 * distributed under the License is distributed on an "AS IS" BASIS, 4772 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4773 * See the License for the specific language governing permissions and 4774 * limitations under the License. 4775 */const V2=new Ga(3e4,6e4);function mm(){const n=_i().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function B2(n){return new Promise((e,t)=>{var i,r,s;function o(){mm(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{mm(),t(si(n,"network-request-failed"))},timeout:V2.get()})}if(!((r=(i=_i().gapi)===null||i===void 0?void 0:i.iframes)===null||r===void 0)&&r.Iframe)e(gapi.iframes.getContext());else if(!((s=_i().gapi)===null||s===void 0)&&s.load)o();else{const a=BR("iframefcb");return _i()[a]=()=>{gapi.load?o():t(si(n,"network-request-failed"))},FR(`${VR()}?onload=${a}`).catch(c=>t(c))}}).catch(e=>{throw nl=null,e})}let nl=null;function z2(n){return nl=nl||B2(n),nl}/** 4776 * @license 4777 * Copyright 2020 Google LLC. 4778 * 4779 * Licensed under the Apache License, Version 2.0 (the "License"); 4780 * you may not use this file except in compliance with the License. 4781 * You may obtain a copy of the License at 4782 * 4783 * http://www.apache.org/licenses/LICENSE-2.0 4784 * 4785 * Unless required by applicable law or agreed to in writing, software 4786 * distributed under the License is distributed on an "AS IS" BASIS, 4787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4788 * See the License for the specific language governing permissions and 4789 * limitations under the License. 4790 */const H2=new Ga(5e3,15e3),G2="__/auth/iframe",W2="emulator/auth/iframe",q2={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},X2=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function j2(n){const e=n.config;Qe(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?sp(e,W2):`https://${n.config.authDomain}/${G2}`,i={apiKey:e.apiKey,appName:n.name,v:uo},r=X2.get(n.config.apiHost);r&&(i.eid=r);const s=n._getFrameworks();return s.length&&(i.fw=s.join(",")),`${t}?${Va(i).slice(1)}`}async function K2(n){const e=await z2(n),t=_i().gapi;return Qe(t,n,"internal-error"),e.open({where:document.body,url:j2(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:q2,dontclear:!0},i=>new Promise(async(r,s)=>{await i.restyle({setHideOnLeave:!1});const o=si(n,"network-request-failed"),a=_i().setTimeout(()=>{s(o)},H2.get());function c(){_i().clearTimeout(a),r(i)}i.ping(c).then(c,()=>{s(o)})}))}/** 4791 * @license 4792 * Copyright 2020 Google LLC. 4793 * 4794 * Licensed under the Apache License, Version 2.0 (the "License"); 4795 * you may not use this file except in compliance with the License. 4796 * You may obtain a copy of the License at 4797 * 4798 * http://www.apache.org/licenses/LICENSE-2.0 4799 * 4800 * Unless required by applicable law or agreed to in writing, software 4801 * distributed under the License is distributed on an "AS IS" BASIS, 4802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4803 * See the License for the specific language governing permissions and 4804 * limitations under the License. 4805 */const Y2={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Q2=500,Z2=600,J2="_blank",$2="http://localhost";class gm{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function eP(n,e,t,i=Q2,r=Z2){const s=Math.max((window.screen.availHeight-r)/2,0).toString(),o=Math.max((window.screen.availWidth-i)/2,0).toString();let a="";const c=Object.assign(Object.assign({},Y2),{width:i.toString(),height:r.toString(),top:s,left:o}),l=yn().toLowerCase();t&&(a=Nv(l)?J2:t),Dv(l)&&(e=e||$2,c.scrollbars="yes");const d=Object.entries(c).reduce((p,[_,g])=>`${p}${_}=${g},`,"");if(CR(l)&&a!=="_self")return tP(e||"",a),new gm(null);const h=window.open(e||"",a,d);Qe(h,n,"popup-blocked");try{h.focus()}catch{}return new gm(h)}function tP(n,e){const t=document.createElement("a");t.href=n,t.target=e;const i=document.createEvent("MouseEvent");
4805i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(i)}/** 4806 * @license 4807 * Copyright 2021 Google LLC 4808 * 4809 * Licensed under the Apache License, Version 2.0 (the "License"); 4810 * you may not use this file except in compliance with the License. 4811 * You may obtain a copy of the License at 4812 * 4813 * http://www.apache.org/licenses/LICENSE-2.0 4814 * 4815 * Unless required by applicable law or agreed to in writing, software 4816 * distributed under the License is distributed on an "AS IS" BASIS, 4817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4818 * See the License for the specific language governing permissions and 4819 * limitations under the License. 4820 */const nP="__/auth/handler",iP="emulator/auth/handler",rP=encodeURIComponent("fac");async function vm(n,e,t,i,r,s){Qe(n.config.authDomain,n,"auth-domain-config-required"),Qe(n.config.apiKey,n,"invalid-api-key");const o={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:i,v:uo,eventId:r};if(e instanceof lp){e.setDefaultLanguage(n.languageCode),o.providerId=e.providerId||"",eE(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[d,h]of Object.entries(s||{}))o[d]=h}if(e instanceof go){const d=e.getScopes().filter(h=>h!=="");d.length>0&&(o.scopes=d.join(","))}n.tenantId&&(o.tid=n.tenantId);const a=o;for(const d of Object.keys(a))a[d]===void 0&&delete a[d];const c=await n._getAppCheckToken(),l=c?`#${rP}=${encodeURIComponent(c)}`:"";return`${sP(n)}?${Va(a).slice(1)}${l}`}function sP({config:n}){return n.emulator?sp(n,iP):`https://${n.authDomain}/${nP}`}/** 4821 * @license 4822 * Copyright 2020 Google LLC 4823 * 4824 * Licensed under the Apache License, Version 2.0 (the "License"); 4825 * you may not use this file except in compliance with the License. 4826 * You may obtain a copy of the License at 4827 * 4828 * http://www.apache.org/licenses/LICENSE-2.0 4829 * 4830 * Unless required by applicable law or agreed to in writing, software 4831 * distributed under the License is distributed on an "AS IS" BASIS, 4832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4833 * See the License for the specific language governing permissions and 4834 * limitations under the License. 4835 */const rd="webStorageSupport";class oP{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Kv,this._completeRedirectFn=R2,this._overrideRedirectResult=I2}async _openPopup(e,t,i,r){var s;Qi((s=this.eventManagers[e._key()])===null||s===void 0?void 0:s.manager,"_initialize() not called before _openPopup()");const o=await vm(e,t,i,_h(),r);return eP(e,o,up())}async _openRedirect(e,t,i,r){await this._originValidation(e);const s=await vm(e,t,i,_h(),r);return u2(s),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:r,promise:s}=this.eventManagers[t];return r?Promise.resolve(r):(Qi(s,"If manager is not set, promise should be"),s)}const i=this.initAndGetManager(e);return this.eventManagers[t]={promise:i},i.catch(()=>{delete this.eventManagers[t]}),i}async initAndGetManager(e){const t=await K2(e),i=new L2(e);return t.register("authEvent",r=>(Qe(r==null?void 0:r.authEvent,e,"invalid-auth-event"),{status:i.onEvent(r.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:i},this.iframes[e._key()]=t,i}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(rd,{type:rd},r=>{var s;const o=(s=r==null?void 0:r[0])===null||s===void 0?void 0:s[rd];o!==void 0&&t(!!o),Ei(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=O2(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Vv()||ap()||jl()}}const aP=oP;var ym="@firebase/auth",Em="1.7.6";/** 4836 * @license 4837 * Copyright 2020 Google LLC 4838 * 4839 * Licensed under the Apache License, Version 2.0 (the "License"); 4840 * you may not use this file except in compliance with the License. 4841 * You may obtain a copy of the License at 4842 * 4843 * http://www.apache.org/licenses/LICENSE-2.0 4844 * 4845 * Unless required by applicable law or agreed to in writing, softw
4845are 4846 * distributed under the License is distributed on an "AS IS" BASIS, 4847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4848 * See the License for the specific language governing permissions and 4849 * limitations under the License. 4850 */class cP{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(i=>{e((i==null?void 0:i.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){Qe(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** 4851 * @license 4852 * Copyright 2020 Google LLC 4853 * 4854 * Licensed under the Apache License, Version 2.0 (the "License"); 4855 * you may not use this file except in compliance with the License. 4856 * You may obtain a copy of the License at 4857 * 4858 * http://www.apache.org/licenses/LICENSE-2.0 4859 * 4860 * Unless required by applicable law or agreed to in writing, software 4861 * distributed under the License is distributed on an "AS IS" BASIS, 4862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4863 * See the License for the specific language governing permissions and 4864 * limitations under the License. 4865 */function lP(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function uP(n){ud(new dd("auth",(e,{options:t})=>{const i=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),s=e.getProvider("app-check-internal"),{apiKey:o,authDomain:a}=i.options;Qe(o&&!o.includes(":"),"invalid-api-key",{appName:i.name});const c={apiKey:o,authDomain:a,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Bv(n)},l=new UR(i,r,s,c);return HR(l,t),l},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,i)=>{e.getProvider("auth-internal").initialize()})),ud(new dd("auth-internal",e=>{const t=Kl(e.getProvider("auth").getImmediate());return(i=>new cP(i))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),cl(ym,Em,lP(n)),cl(ym,Em,"esm2017")}/** 4866 * @license 4867 * Copyright 2021 Google LLC 4868 * 4869 * Licensed under the Apache License, Version 2.0 (the "License"); 4870 * you may not use this file except in compliance with the License. 4871 * You may obtain a copy of the License at 4872 * 4873 * http://www.apache.org/licenses/LICENSE-2.0 4874 * 4875 * Unless required by applicable law or agreed to in writing, software 4876 * distributed under the License is distributed on an "AS IS" BASIS, 4877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4878 * See the License for the specific language governing permissions and 4879 * limitations under the License. 4880 */const dP=5*60,hP=og("authIdTokenMaxAge")||dP;let Tm=null;const pP=n=>async e=>{const t=e&&await e.getIdTokenResult(),i=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(i&&i>hP)return;const r=t==null?void 0:t.token;Tm!==r&&(Tm=r,await fetch(n,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))};function fP(n=ag()){const e=Lh(n,"auth");if(e.isInitialized())return e.getImmediate();const t=zR(n,{popupRedirectResolver:aP,persistence:[y2,a2,Kv]}),i=og("authTokenSyncURL");if(i&&typeof isSecureContext=="boolean"&&isSecureContext){const s=new URL(i,location.origin);if(location.origin===s.origin){const o=pP(s.toString());i2(t,o,()=>o(t.currentUser)),n2(t,a=>o(a))}}const r=Ky("auth");return r&&GR(t,`http://${r}`),t}function _P(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}OR({loadJS(n){return new Promise((e,t)=>
vendor: 13,242 bytes, lines 4880-4894
4880{const i=document.createElement("script");i.setAttribute("src",n),i.onload=e,i.onerror=r=>{const s=si("internal-error");s.customData=r,t(s)},i.type="text/javascript",i.charset="UTF-8",_P().appendChild(i)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});uP("Browser");var bm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 4881Copyright The Closure Library Authors. 4882SPDX-License-Identifier: Apache-2.0 4883*/var Xr,i0;(function(){var n;/** @license 4884 4885 Copyright The Closure Library Authors. 4886 SPDX-License-Identifier: Apache-2.0 4887*/function e(T,A){function E(){}E.prototype=A.prototype,T.D=A.prototype,T.prototype=new E,T.prototype.constructor=T,T.C=function(y,I,D){for(var C=Array(arguments.length-2),W=2;W<arguments.length;W++)C[W-2]=arguments[W];return A.prototype[I].apply(y,C)}}function t(){this.blockSize=-1}function i(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(i,t),i.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function r(T,A,E){E||(E=0);var y=Array(16);if(typeof A=="string")for(var I=0;16>I;++I)y[I]=A.charCodeAt(E++)|A.charCodeAt(E++)<<8|A.charCodeAt(E++)<<16|A.charCodeAt(E++)<<24;else for(I=0;16>I;++I)y[I]=A[E++]|A[E++]<<8|A[E++]<<16|A[E++]<<24;A=T.g[0],E=T.g[1],I=T.g[2];var D=T.g[3],C=A+(D^E&(I^D))+y[0]+3614090360&4294967295;A=E+(C<<7&4294967295|C>>>25),C=D+(I^A&(E^I))+y[1]+3905402710&4294967295,D=A+(C<<12&4294967295|C>>>20),C=I+(E^D&(A^E))+y[2]+606105819&4294967295,I=D+(C<<17&4294967295|C>>>15),C=E+(A^I&(D^A))+y[3]+3250441966&4294967295,E=I+(C<<22&4294967295|C>>>10),C=A+(D^E&(I^D))+y[4]+4118548399&4294967295,A=E+(C<<7&4294967295|C>>>25),C=D+(I^A&(E^I))+y[5]+1200080426&4294967295,D=A+(C<<12&4294967295|C>>>20),C=I+(E^D&(A^E))+y[6]+2821735955&4294967295,I=D+(C<<17&4294967295|C>>>15),C=E+(A^I&(D^A))+y[7]+4249261313&4294967295,E=I+(C<<22&4294967295|C>>>10),C=A+(D^E&(I^D))+y[8]+1770035416&4294967295,A=E+(C<<7&4294967295|C>>>25),C=D+(I^A&(E^I))+y[9]+2336552879&4294967295,D=A+(C<<12&4294967295|C>>>20),C=I+(E^D&(A^E))+y[10]+4294925233&4294967295,I=D+(C<<17&4294967295|C>>>15),C=E+(A^I&(D^A))+y[11]+2304563134&4294967295,E=I+(C<<22&4294967295|C>>>10),C=A+(D^E&(I^D))+y[12]+1804603682&4294967295,A=E+(C<<7&4294967295|C>>>25),C=D+(I^A&(E^I))+y[13]+4254626195&4294967295,D=A+(C<<12&4294967295|C>>>20),C=I+(E^D&(A^E))+y[14]+2792965006&4294967295,I=D+(C<<17&4294967295|C>>>15),C=E+(A^I&(D^A))+y[15]+1236535329&4294967295,E=I+(C<<22&4294967295|C>>>10),C=A+(I^D&(E^I))+y[1]+4129170786&4294967295,A=E+(C<<5&4294967295|C>>>27),C=D+(E^I&(A^E))+y[6]+3225465664&4294967295,D=A+(C<<9&4294967295|C>>>23),C=I+(A^E&(D^A))+y[11]+643717713&4294967295,I=D+(C<<14&4294967295|C>>>18),C=E+(D^A&(I^D))+y[0]+3921069994&4294967295,E=I+(C<<20&4294967295|C>>>12),C=A+(I^D&(E^I))+y[5]+3593408605&4294967295,A=E+(C<<5&4294967295|C>>>27),C=D+(E^I&(A^E))+y[10]+38016083&4294967295,D=A+(C<<9&4294967295|C>>>23),C=I+(A^E&(D^A))+y[15]+3634488961&4294967295,I=D+(C<<14&4294967295|C>>>18),C=E+(D^A&(I^D))+y[4]+3889429448&4294967295,E=I+(C<<20&4294967295|C>>>12),C=A+(I^D&(E^I))+y[9]+568446438&4294967295,A=E+(C<<5&4294967295|C>>>27),C=D+(E^I&(A^E))+y[14]+3275163606&4294967295,D=A+(C<<9&4294967295|C>>>23),C=I+(A^E&(D^A))+y[3]+4107603335&4294967295,I=D+(C<<14&4294967295|C>>>18),C=E+(D^A&(I^D))+y[8]+1163531501&4294967295,E=I+(C<<20&4294967295|C>>>12),C=A+(I^D&(E^I))+y[13]+2850285829&4294967295,A=E+(C<<5&4294967295|C>>>27),C=D+(E^I&(A^E))+y[2]+4243563512&4294967295,D=A+(C<<9&4294967295|C>>>23),C=I+(A^E&(D^A))+y[7]+1735328473&4294967295,I=D+(C<<14&4294967295|C>>>18),C=E+(D^A&(I^D))+y[12]+2368359562&4294967295,E=I+(C<<20&4294967295|C>>>12),C=A+(E^I^D)+y[5]+4294588738&4294967295,A=E+(C<<4&4294967295|C>>>28),C=D+(A^E^I)+y[8]+2272392833&4294967295,D=A+(C<<11&4294967295|C>>>21),C=I+(D^A^E)+y[11]+1839030562&4294967295,I=D+(C<<16&4294967295|C>>>16),C=E+(I^D^A)+y[14]+4259657740&4294967295,E=I+(C<<23&4294967295|C>>>9),C=A+(E^I^D)+y[1]+2763975236&4294967295,A=E+(C<<4&4294967295|C>>>28),C=D+(A^E^I)+y[4]+1272893353&4294967295,D=A+(C<<11&4294967295|C>>>21),C=I+(D^A^E)+y[7]+4139469664&4294967295,I=D+(C<<16&4294967295|C>>>16),C=E+(I^D^A)+y[10]+3200236656&4294967295,E=I+(C<<23&4294967295|C>>>9),C=A+(E^I^D)+y[13]+681279174&4294967295,A=E+(C<<4&4294967295|C>>>28),C=D+(A^E^I)+y[0]+3936430074&4294967295,D=A+(C<<11&4294967295|C>>>21),C=I+(D^A^E)+y[3]+3572445317&4294967295,I=D+(C<<16&4294967295|C>>>16),C=E+(I^D^A)+y[6]+76029189&4294967295,E=I+(C<<23&4294967295|C>>>9),C=A+(E^I^D)+y[9]+3654602809&4294967295,A=E+(C<<4&4294967295|C>>>28),C=D+(A^E^I)+y[12]+3873151461&4294967295,D=A+(C<<11&4294967295|C>>>21),C=I+(D^A^E)+y[15]+530742520&4294967295,I=D+(C<<16&4294967295|C>>>16),C=E+(I^D^A)+y[2]+3299628645&4294967295,E=I+(C<<23&4294967295|C>>>9),C=A+(I^(E|~D))+y[0]+4096336452&4294967295,A=E+(C<<6&4294967295|C>>>26),C=D+(E^(A|~I))+y[7]+1126891415&4294967295,D=A+(C<<10&4294967295|C>>>22),C=I+(A^(D|~E))+y[14]+2878612391&4294967295,I=D+(C<<15&4294967295|C>>>17),C=E+(D^(I|~A))+y[5]+4237533241&4294967295,E=I+(C<<21&4294967295|C>>>11),C=A+(I^(E|~D))+y[12]+1700485571&4294967295,A=E+(C<<6&4294967295|C>>>26),C=D+(E^(A|~I))+y[3]+2399980690&4294967295,D=A+(C<<10&4294967295|C>>>22),C=I+(A^(D|~E))+y[10]+4293915773&4294967295,I=D+(C<<15&4294967295|C>>>17),C=E+(D^(I|~A))+y[1]+2240044497&4294967295,E=I+(C<<21&4294967295|C>>>11),C=A+(I^(E|~D))+y[8]+1873313359&4294967295,A=E+(C<<6&4294967295|C>>>26),C=D+(E^(A|~I))+y[15]+4264355552&4294967295,D=A+(C<<10&4294967295|C>>>22),C=I+(A^(D|~E))+y[6]+2734768916&4294967295,I=D+(C<<15&4294967295|C>>>17),C=E+(D^(I|~A))+y[13]+1309151649&4294967295,E=I+(C<<21&4294967295|C>>>11),C=A+(I^(E|~D))+y[4]+4149444226&4294967295,A=E+(C<<6&4294967295|C>>>26),C=D+(E^(A|~I))+y[11]+3174756917&4294967295,D=A+(C<<10&4294967295|C>>>22),C=I+(A^(D|~E))+y[2]+718787259&4294967295,I=D+(C<<15&4294967295|C>>>17),C=E+(D^(I|~A))+y[9]+3951481745&4294967295,T.g[0]=T.g[0]+A&4294967295,T.g[1]=T.g[1]+(I+(C<<21&4294967295|C>>>11))&4294967295,T.g[2]=T.g[2]+I&4294967295,T.g[3]=T.g[3]+D&4294967295}i.prototype.u=function(T,A){A===void 0&&(A=T.length);for(var E=A-this.blockSize,y=this.B,I=this.h,D=0;D<A;){if(I==0)for(;D<=E;)r(this,T,D),D+=this.blockSize;if(typeof T=="string"){for(;D<A;)if(y[I++]=T.charCodeAt(D++),I==this.blockSize){r(this,y),I=0;break}}else for(;D<A;)if(y[I++]=T[D++],I==this.blockSize){r(this,y),I=0;break}}this.h=I,this.o+=A},i.prototype.v=function(){var T=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);T[0]=128;for(var A=1;A<T.length-8;++A)T[A]=0;var E=8*this.o;for(A=T.length-8;A<T.length;++A)T[A]=E&255,E/=256;for(this.u(T),T=Array(16),A=E=0;4>A;++A)for(var y=0;32>y;y+=8)T[E++]=this.g[A]>>>y&255;return T};function s(T,A){var E=a;return Object.prototype.hasOwnProperty.call(E,T)?E[T]:E[T]=A(T)}function o(T,A){this.h=A;for(var E=[],y=!0,I=T.length-1;0<=I;I--){var D=T[I]|0;y&&D==A||(E[I]=D,y=!1)}this.g=E}var a={};function c(T){return-128<=T&&128>T?s(T,function(A){return new o([A|0],0>A?-1:0)}):new o([T|0],0>T?-1:0)}function l(T){if(isNaN(T)||!isFinite(T))return h;if(0>T)return m(l(-T));for(var A=[],E=1,y=0;T>=E;y++)A[y]=T/E|0,E*=4294967296;return new o(A,0)}function d(T,A){if(T.length==0)throw Error("number format error: empty string");if(A=A||10,2>A||36<A)throw Error("radix out of range: "+A);if(T.charAt(0)=="-")return m(d(T.substring(1),A));if(0<=T.indexOf("-"))throw Error('number format error: interior "-" character');for(var E=l(Math.pow(A,8)),y=h,I=0;I<T.length;I+=8){var D=Math.min(8,T.length-I),C=parseInt(T.substring(I,I+D),A);8>D?(D=l(Math.pow(A,D)),y=y.j(D).add(l(C))):(y=y.j(E),y=y.add(l(C)))}return y}var h=c(0),p=c(1),_=c(16777216);n=o.prototype,n.m=function(){if(S(this))return-m(this).m();for(var T=0,A=1,E=0;E<this.g.length;E++){var y=this.i(E);T+=(0<=y?y:4294967296+y)*A,A*=4294967296}return T},n.toString=function(T){if(T=T||10,2>T||36<T)throw Error("radix out of range: "+T);if(g(this))return"0";if(S(this))return"-"+m(this).toString(T);for(var A=l(Math.pow(T,6)),E=this,y="";;){var I=b(E,A).g;E=f(E,I.j(A));var D=((0<E.g.length?E.g[0]:E.h)>>>0).toString(T);if(E=I,g(E))return D+y;for(;6>D.length;)D="0"+D;y=D+y}},n.i=function(T){return 0>T?0:T<this.g.length?this.g[T]:this.h};function g(T){if(T.h!=0)return!1;for(var A=0;A<T.g.length;A++)if(T.g[A]!=0)return!1;return!0}function S(T){return T.h==-1}n.l=function(T){return T=f(this,T),S(T)?-1:g(T)?0:1};function m(T){for(var A=T.g.length,E=[],y=0;y<A;y++)E[y]=~T.g[y];return new o(E,~T.h).add(p)}n.abs=function(){return S(this)?m(this):this},n.add=function(T){for(var A=Math.max(this.g.length,T.g.length),E=[],y=0,I=0;I<=A;I++){var D=y+(this.i(I)&65535)+(T.i(I)&65535),C=(D>>>16)+(this.i(I)>>>16)+(T.i(I)>>>16);y=C>>>16,D&=65535,C&=65535,E[I]=C<<16|D}return new o(E,E[E.length-1]&-2147483648?-1:0)};function f(T,A){return T.add(m(A))}n.j=function(T){if(g(this)||g(T))return h;if(S(this))return S(T)?m(this).j(m(T)):m(m(this).j(T));if(S(T))return m(this.j(m(T)));if(0>this.l(_)&&0>T.l(_))return l(this.m()*T.m());for(var A=this.g.length+T.g.length,E=[],y=0;y<2*A;y++)E[y]=0;for(y=0;y<this.g.length;y++)for(var I=0;I<T.g.length;I++){var D=this.i(y)>>>16,C=this.i(y)&65535,W=T.i(I)>>>16,Z=T.i(I)&65535;E[2*y+2*I]+=C*Z,M(E,2*y+2*I),E[2*y+2*I+1]+=D*Z,M(E,2*y+2*I+1),E[2*y+2*I+1]+=C*W,M(E,2*y+2*I+1),E[2*y+2*I+2]+=D*W,M(E,2*y+2*I+2)}for(y=0;y<A;y++)E[y]=E[2*y+1]<<16|E[2*y];for(y=A;y<2*A;y++)E[y]=0;return new o(E,0)};function M(T,A){for(;(T[A]&65535)!=T[A];)T[A+1]+=T[A]>>>16,T[A]&=65535,A++}function w(T,A){this.g=T,this.h=A}function b(T,A){if(g(A))throw Error("division by zero");if(g(T))return new w(h,h);if(S(T))return A=b(m(T),A),new w(m(A.g),m(A.h));if(S(A))return A=b(T,m(A)),new w(m(A.g),A.h);if(30<T.g.length){if(S(T)||S(A))throw Error("slowDivide_ only works with positive integers.");for(var E=p,y=A;0>=y.l(T);)E=R(E),y=R(y);var I=P(E,1),D=P(y,1);for(y=P(y,2),E=P(E,2);!g(y);){var C=D.add(y);0>=C.l(T)&&(I=I.add(E),D=C),y=P(y,1),E=P(E,1)}return A=f(T,I.j(A)),new w(I,A)}for(I=h;0<=T.l(A);){for(E=Math.max(1,Math.floor(T.m()/A.m())),y=Math.ceil(Math.log(E)/Math.LN2),y=48>=y?1:Math.pow(2,y-48),D=l(E),C=D.j(A);S(C)||0<C.l(T);)E-=y,D=l(E),C=D.j(A);g(D)&&(D=p),I=I.add(D),T=f(T,C)}return new w(I,T)}n.A=function(T){return b(this,T).h},n.and=function(T){for(var A=Math.max(this.g.length,T.g.length),E=[],y=0;y<A;y++)E[y]=this.i(y)&T.i(y);return new o(E,this.h&T.h)},n.or=function(T){for(var A=Math.max(this.g.length,T.g.length),E=[],y=0;y<A;y++)E[y]=this.i(y)|T.i(y);return new o(E,this.h|T.h)},n.xor=function(T){for(var A=Math.max(this.g.length,T.g.length),E=[],y=0;y<A;y++)E[y]=this.i(y)^T.i(y);return new o(E,this.h^T.h)};function R(T){for(var A=T.g.length+1,E=[],y=0;y<A;y++)E[y]=T.i(y)<<1|T.i(y-1)>>>31;return new o(E,T.h)}function P(T,A){var E=A>>5;A%=32;for(var y=T.g.length-E,I=[],D=0;D<y;D++)I[D]=0<A?T.i(D+E)>>>A|T.i(D+E+1)<<32-A:T.i(D+E);return new o(I,T.h)}i.prototype.digest=i.prototype.v,i.prototype.reset=i.prototype.s,i.prototype.update=i.prototype.u,i0=i,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.A,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=l,o.fromString=d,Xr=o}).apply(typeof bm<"u"?bm:typeof self<"u"?self:typeof window<"u"?window:{});var Bc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 4888Copyright The Closure Library Authors. 4889SPDX-License-Identifier: Apache-2.0 4890*/var r0,s0,sa,o0,il,vh,a0,c0,l0;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(u,v,x){return u==Array.prototype||u==Object.prototype||(u[v]=x.value),u};function t(u){u=[typeof globalThis=="object"&&globalThis,u,typeof window=="object"&&window,typeof self=="object"&&self,typeof Bc=="object"&&Bc];for(var v=0;v<u.length;++v){var x=u[v];if(x&&x.Math==Math)return x}throw Error("Cannot find global object")}var i=t(this);function r(u,v){if(v)e:{var x=i;u=u.split(".");for(var N=0;N<u.length-1;N++){var H=u[N];if(!(H in x))break e;x=x[H]}u=u[u.length-1],N=x[u],v=v(N),v!=N&&v!=null&&e(x,u,{configurable:!0,writable:!0,value:v})}}function s(u,v){u instanceof String&&(u+="");var x=0,N=!1,H={next:function(){if(!N&&x<u.length){var j=x++;return{value:v(j,u[j]),done:!1}}return N=!0,{done:!0,value:void 0}}};return H[Symbol.iterator]=function(){return H},H}r("Array.prototype.values",function(u){return u||function(){return s(this,function(v,x){return x})}});/** @license 4891 4892 Copyright The Closure Library Authors. 4893 SPDX-License-Identifier: Apache-2.0 4894*/var o=o||{},a=this||self;function c(u){var v=typeof u;return v=v!="object"?v:u?Array.isArray(u)?"array":v:"null",v=="array"||v=="object"&&typeof u.length=="number"}function l(u){var v=typeof u;return v=="object"&&u!=null||v=="function"}function d(u,v,x){return u.call.apply(u.bind,arguments)}function h(u,v,x){if(!u)throw Error();if(2<arguments.length){var N=Array.prototype.slice.call(arguments,2);return function(){var H=Array.prototype.slice.call(arguments);
4894return Array.prototype.unshift.apply(H,N),u.apply(v,H)}}return function(){return u.apply(v,arguments)}}function p(u,v,x){return p=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?d:h,p.apply(null,arguments)}function _(u,v){var x=Array.prototype.slice.call(arguments,1);return function(){var N=x.slice();return N.push.apply(N,arguments),u.apply(this,N)}}function g(u,v){function x(){}x.prototype=v.prototype,u.aa=v.prototype,u.prototype=new x,u.prototype.constructor=u,u.Qb=function(N,H,j){for(var he=Array(arguments.length-2),At=2;At<arguments.length;At++)he[At-2]=arguments[At];return v.prototype[H].apply(N,he)}}function S(u){const v=u.length;if(0<v){const x=Array(v);for(let N=0;N<v;N++)x[N]=u[N];return x}return[]}function m(u,v){for(let x=1;x<arguments.length;x++){const N=arguments[x];if(c(N)){const H=u.length||0,j=N.length||0;u.length=H+j;for(let he=0;he<j;he++)u[H+he]=N[he]}else u.push(N)}}class f{constructor(v,x){this.i=v,this.j=x,this.h=0,this.g=null}get(){let v;return 0<this.h?(this.h--,v=this.g,this.g=v.next,v.
vendor: 39,861 bytes, lines 4894-4921
4894next=null):v=this.i(),v}}function M(u){return/^[\s\xa0]*$/.test(u)}function w(){var u=a.navigator;return u&&(u=u.userAgent)?u:""}function b(u){return b[" "](u),u}b[" "]=function(){};var R=w().indexOf("Gecko")!=-1&&!(w().toLowerCase().indexOf("webkit")!=-1&&w().indexOf("Edge")==-1)&&!(w().indexOf("Trident")!=-1||w().indexOf("MSIE")!=-1)&&w().indexOf("Edge")==-1;function P(u,v,x){for(const N in u)v.call(x,u[N],N,u)}function T(u,v){for(const x in u)v.call(void 0,u[x],x,u)}function A(u){const v={};for(const x in u)v[x]=u[x];return v}const E="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function y(u,v){let x,N;for(let H=1;H<arguments.length;H++){N=arguments[H];for(x in N)u[x]=N[x];for(let j=0;j<E.length;j++)x=E[j],Object.prototype.hasOwnProperty.call(N,x)&&(u[x]=N[x])}}function I(u){var v=1;u=u.split(":");const x=[];for(;0<v&&u.length;)x.push(u.shift()),v--;return u.length&&x.push(u.join(":")),x}function D(u){a.setTimeout(()=>{throw u},0)}function C(){var u=ue;let v=null;return u.g&&(v=u.g,u.g=u.g.next,u.g||(u.h=null),v.next=null),v}class W{constructor(){this.h=this.g=null}add(v,x){const N=Z.get();N.set(v,x),this.h?this.h.next=N:this.g=N,this.h=N}}var Z=new f(()=>new Y,u=>u.reset());class Y{constructor(){this.next=this.g=this.h=null}set(v,x){this.h=v,this.g=x,this.next=null}reset(){this.next=this.g=this.h=null}}let ce,K=!1,ue=new W,ve=()=>{const u=a.Promise.resolve(void 0);ce=()=>{u.then(ye)}};var ye=()=>{for(var u;u=C();){try{u.h.call(u.g)}catch(x){D(x)}var v=Z;v.j(u),100>v.h&&(v.h++,u.next=v.g,v.g=u)}K=!1};function Oe(){this.s=this.s,this.C=this.C}Oe.prototype.s=!1,Oe.prototype.ma=function(){this.s||(this.s=!0,this.N())},Oe.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ve(u,v){this.type=u,this.g=this.target=v,this.defaultPrevented=!1}Ve.prototype.h=function(){this.defaultPrevented=!0};var J=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var u=!1,v=Object.defineProperty({},"passive",{get:function(){u=!0}});try{const x=()=>{};a.addEventListener("test",x,v),a.removeEventListener("test",x,v)}catch{}return u}();function re(u,v){if(Ve.call(this,u?u.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,u){var x=this.type=u.type,N=u.changedTouches&&u.changedTouches.length?u.changedTouches[0]:null;if(this.target=u.target||u.srcElement,this.g=v,v=u.relatedTarget){if(R){e:{try{b(v.nodeName);var H=!0;break e}catch{}H=!1}H||(v=null)}}else x=="mouseover"?v=u.fromElement:x=="mouseout"&&(v=u.toElement);this.relatedTarget=v,N?(this.clientX=N.clientX!==void 0?N.clientX:N.pageX,this.clientY=N.clientY!==void 0?N.clientY:N.pageY,this.screenX=N.screenX||0,this.screenY=N.screenY||0):(this.clientX=u.clientX!==void 0?u.clientX:u.pageX,this.clientY=u.clientY!==void 0?u.clientY:u.pageY,this.screenX=u.screenX||0,this.screenY=u.screenY||0),this.button=u.button,this.key=u.key||"",this.ctrlKey=u.ctrlKey,this.altKey=u.altKey,this.shiftKey=u.shiftKey,this.metaKey=u.metaKey,this.pointerId=u.pointerId||0,this.pointerType=typeof u.pointerType=="string"?u.pointerType:De[u.pointerType]||"",this.state=u.state,this.i=u,u.defaultPrevented&&re.aa.h.call(this)}}g(re,Ve);var De={2:"touch",3:"pen",4:"mouse"};re.prototype.h=function(){re.aa.h.call(this);var u=this.i;u.preventDefault?u.preventDefault():u.returnValue=!1};var pe="closure_listenable_"+(1e6*Math.random()|0),ze=0;function se(u,v,x,N,H){this.listener=u,this.proxy=null,this.src=v,this.type=x,this.capture=!!N,this.ha=H,this.key=++ze,this.da=this.fa=!1}function Ee(u){u.da=!0,u.listener=null,u.proxy=null,u.src=null,u.ha=null}function He(u){this.src=u,this.g={},this.h=0}He.prototype.add=function(u,v,x,N,H){var j=u.toString();u=this.g[j],u||(u=this.g[j]=[],this.h++);var he=dt(u,v,N,H);return-1<he?(v=u[he],x||(v.fa=!1)):(v=new se(v,this.src,j,!!N,H),v.fa=x,u.push(v)),v};function Ke(u,v){var x=v.type;if(x in u.g){var N=u.g[x],H=Array.prototype.indexOf.call(N,v,void 0),j;(j=0<=H)&&Array.prototype.splice.call(N,H,1),j&&(Ee(v),u.g[x].length==0&&(delete u.g[x],u.h--))}}function dt(u,v,x,N){for(var H=0;H<u.length;++H){var j=u[H];if(!j.da&&j.listener==v&&j.capture==!!x&&j.ha==N)return H}return-1}var V="closure_lm_"+(1e6*Math.random()|0),Pt={};function Ge(u,v,x,N,H){if(N&&N.once)return ot(u,v,x,N,H);if(Array.isArray(v)){for(var j=0;j<v.length;j++)Ge(u,v[j],x,N,H);return null}return x=$(x),u&&u[pe]?u.K(v,x,l(N)?!!N.capture:!!N,H):Ie(u,v,x,!1,N,H)}function Ie(u,v,x,N,H,j){if(!v)throw Error("Invalid event type");var he=l(H)?!!H.capture:!!H,At=ee(u);if(At||(u[V]=At=new He(u)),x=At.add(v,x,N,he,j),x.proxy)return x;if(N=Ce(),x.proxy=N,N.src=u,N.listener=x,u.addEventListener)J||(H=he),H===void 0&&(H=!1),u.addEventListener(v.toString(),N,H);else if(u.attachEvent)u.attachEvent(L(v.toString()),N);else if(u.addListener&&u.removeListener)u.addListener(N);else throw Error("addEventListener and attachEvent are unavailable.");return x}function Ce(){function u(x){return v.call(u.src,u.listener,x)}const v=G;return u}function ot(u,v,x,N,H){if(Array.isArray(v)){for(var j=0;j<v.length;j++)ot(u,v[j],x,N,H);return null}return x=$(x),u&&u[pe]?u.L(v,x,l(N)?!!N.capture:!!N,H):Ie(u,v,x,!0,N,H)}function Re(u,v,x,N,H){if(Array.isArray(v))for(var j=0;j<v.length;j++)Re(u,v[j],x,N,H);else N=l(N)?!!N.capture:!!N,x=$(x),u&&u[pe]?(u=u.i,v=String(v).toString(),v in u.g&&(j=u.g[v],x=dt(j,x,N,H),-1<x&&(Ee(j[x]),Array.prototype.splice.call(j,x,1),j.length==0&&(delete u.g[v],u.h--)))):u&&(u=ee(u))&&(v=u.g[v.toString()],u=-1,v&&(u=dt(v,x,N,H)),(x=-1<u?v[u]:null)&&U(x))}function U(u){if(typeof u!="number"&&u&&!u.da){var v=u.src;if(v&&v[pe])Ke(v.i,u);else{var x=u.type,N=u.proxy;v.removeEventListener?v.removeEventListener(x,N,u.capture):v.detachEvent?v.detachEvent(L(x),N):v.addListener&&v.removeListener&&v.removeListener(N),(x=ee(v))?(Ke(x,u),x.h==0&&(x.src=null,v[V]=null)):Ee(u)}}}function L(u){return u in Pt?Pt[u]:Pt[u]="on"+u}function G(u,v){if(u.da)u=!0;else{v=new re(v,this);var x=u.listener,N=u.ha||u.src;u.fa&&U(u),u=x.call(N,v)}return u}function ee(u){return u=u[V],u instanceof He?u:null}var ie="__closure_events_fn_"+(1e9*Math.random()>>>0);function $(u){return typeof u=="function"?u:(u[ie]||(u[ie]=function(v){return u.handleEvent(v)}),u[ie])}function _e(){Oe.call(this),this.i=new He(this),this.M=this,this.F=null}g(_e,Oe),_e.prototype[pe]=!0,_e.prototype.removeEventListener=function(u,v,x,N){Re(this,u,v,x,N)};function ne(u,v){var x,N=u.F;if(N)for(x=[];N;N=N.F)x.push(N);if(u=u.M,N=v.type||v,typeof v=="string")v=new Ve(v,u);else if(v instanceof Ve)v.target=v.target||u;else{var H=v;v=new Ve(N,u),y(v,H)}if(H=!0,x)for(var j=x.length-1;0<=j;j--){var he=v.g=x[j];H=fe(he,N,!0,v)&&H}if(he=v.g=u,H=fe(he,N,!0,v)&&H,H=fe(he,N,!1,v)&&H,x)for(j=0;j<x.length;j++)he=v.g=x[j],H=fe(he,N,!1,v)&&H}_e.prototype.N=function(){if(_e.aa.N.call(this),this.i){var u=this.i,v;for(v in u.g){for(var x=u.g[v],N=0;N<x.length;N++)Ee(x[N]);delete u.g[v],u.h--}}this.F=null},_e.prototype.K=function(u,v,x,N){return this.i.add(String(u),v,!1,x,N)},_e.prototype.L=function(u,v,x,N){return this.i.add(String(u),v,!0,x,N)};function fe(u,v,x,N){if(v=u.i.g[String(v)],!v)return!0;v=v.concat();for(var H=!0,j=0;j<v.length;++j){var he=v[j];if(he&&!he.da&&he.capture==x){var At=he.listener,en=he.ha||he.src;he.fa&&Ke(u.i,he),H=At.call(en,N)!==!1&&H}}return H&&!N.defaultPrevented}function tt(u,v,x){if(typeof u=="function")x&&(u=p(u,x));else if(u&&typeof u.handleEvent=="function")u=p(u.handleEvent,u);else throw Error("Invalid listener argument");return 2147483647<Number(v)?-1:a.setTimeout(u,v||0)}function ae(u){u.g=tt(()=>{u.g=null,u.i&&(u.i=!1,ae(u))},u.l);const v=u.h;u.h=null,u.m.apply(null,v)}class we extends Oe{constructor(v,x){super(),this.m=v,this.l=x,this.h=null,this.i=!1,this.g=null}j(v){this.h=arguments,this.g?this.i=!0:ae(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ue(u){Oe.call(this),this.h=u,this.g={}}g(Ue,Oe);var Xe=[];function Ae(u){P(u.g,function(v,x){this.g.hasOwnProperty(x)&&U(v)},u),u.g={}}Ue.prototype.N=function(){Ue.aa.N.call(this),Ae(this)},Ue.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var rt=a.JSON.stringify,nt=a.JSON.parse,yt=class{stringify(u){return a.JSON.stringify(u,void 0)}parse(u){return a.JSON.parse(u,void 0)}};function F(){}F.prototype.h=null;function me(u){return u.h||(u.h=u.i())}function Q(){}var te={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function be(){Ve.call(this,"d")}g(be,Ve);function Te(){Ve.call(this,"c")}g(Te,Ve);var je={},Mt=null;function Vt(){return Mt=Mt||new _e}je.La="serverreachability";function _t(u){Ve.call(this,je.La,u)}g(_t,Ve);function Jt(u){const v=Vt();ne(v,new _t(v))}je.STAT_EVENT="statevent";function Un(u,v){Ve.call(this,je.STAT_EVENT,u),this.stat=v}g(Un,Ve);function jt(u){const v=Vt();ne(v,new Un(v,u))}je.Ma="timingevent";function bo(u,v){Ve.call(this,je.Ma,u),this.size=v}g(bo,Ve);function wn(u,v){if(typeof u!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){u()},v)}function Ai(){this.g=!0}Ai.prototype.xa=function(){this.g=!1};function Za(u,v,x,N,H,j){u.info(function(){if(u.g)if(j)for(var he="",At=j.split("&"),en=0;en<At.length;en++){var mt=At[en].split("=");if(1<mt.length){var on=mt[0];mt=mt[1];var an=on.split("_");he=2<=an.length&&an[1]=="type"?he+(on+"="+mt+"&"):he+(on+"=redacted&")}}else he=null;else he=j;return"XMLHTTP REQ ("+N+") [attempt "+H+"]: "+v+` 4895`+x+` 4896`+he})}function Ja(u,v,x,N,H,j,he){u.info(function(){return"XMLHTTP RESP ("+N+") [ attempt "+H+"]: "+v+` 4897`+x+` 4898`+j+" "+he})}function qn(u,v,x,N){u.info(function(){return"XMLHTTP TEXT ("+v+"): "+ss(u,x)+(N?" "+N:"")})}function $a(u,v){u.info(function(){return"TIMEOUT: "+v})}Ai.prototype.info=function(){};function ss(u,v){if(!u.g)return v;if(!v)return null;try{var x=JSON.parse(v);if(x){for(u=0;u<x.length;u++)if(Array.isArray(x[u])){var N=x[u];if(!(2>N.length)){var H=N[1];if(Array.isArray(H)&&!(1>H.length)){var j=H[0];if(j!="noop"&&j!="stop"&&j!="close")for(var he=1;he<H.length;he++)H[he]=""}}}}return rt(x)}catch{return v}}var Ir={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},So={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Ao;function os(){}g(os,F),os.prototype.g=function(){return new XMLHttpRequest},os.prototype.i=function(){return{}},Ao=new os;function ai(u,v,x,N){this.j=u,this.i=v,this.l=x,this.R=N||1,this.U=new Ue(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new k}function k(){this.i=null,this.g="",this.h=!1}var B={},q={};function X(u,v,x){u.L=1,u.v=ec(Nt(v)),u.m=x,u.P=!0,z(u,null)}function z(u,v){u.F=Date.now(),Pe(u),u.A=Nt(u.v);var x=u.A,N=u.R;Array.isArray(N)||(N=[String(N)]),Gp(x.i,"t",N),u.C=0,x=u.j.J,u.h=new k,u.g=cf(u.j,x?v:null,!u.m),0<u.O&&(u.M=new we(p(u.Y,u,u.g),u.O)),v=u.U,x=u.g,N=u.ca;var H="readystatechange";Array.isArray(H)||(H&&(Xe[0]=H.toString()),H=Xe);for(var j=0;j<H.length;j++){var he=Ge(x,H[j],N||v.handleEvent,!1,v.h||v);if(!he)break;v.g[he.key]=he}v=u.H?A(u.H):{},u.m?(u.u||(u.u="POST"),v["Content-Type"]="application/x-www-form-urlencoded",u.g.ea(u.A,u.u,u.m,v)):(u.u="GET",u.g.ea(u.A,u.u,null,v)),Jt(),Za(u.i,u.u,u.A,u.l,u.R,u.m)}ai.prototype.ca=function(u){u=u.target;const v=this.M;v&&xi(u)==3?v.j():this.Y(u)},ai.prototype.Y=function(u){try{if(u==this.g)e:{const an=xi(this.g);var v=this.g.Ba();const ls=this.g.Z();if(!(3>an)&&(an!=3||this.g&&(this.h.h||this.g.oa()||Qp(this.g)))){this.J||an!=4||v==7||(v==8||0>=ls?Jt(3):Jt(2)),Ye(this);var x=this.g.Z();this.X=x;t:if(de(this)){var N=Qp(this.g);u="";var H=N.length,j=xi(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Me(this),Ze(this);var he="";break t}this.h.i=new a.TextDecoder}for(v=0;v<H;v++)this.h.h=!0,u+=this.h.i.decode(N[v],{stream:!(j&&v==H-1)});N.length=0,this.h.g+=u,this.C=0,he=this.h.g}else he=this.g.oa();if(this.o=x==200,Ja(this.i,this.u,this.A,this.l,this.R,an,x),this.o){if(this.T&&!this.K){t:{if(this.g){var At,en=this.g;if((At=en.g?en.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!M(At)){var mt=At;break t}}mt=null}if(x=mt)qn(this.i,this.l,x,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,at(this,x);else{this.o=!1,this.s=3,jt(12),Me(this),Ze(this);break e}}if(this.P){x=!0;let Xn;for(;!this.J&&this.C<he.length;)if(Xn=Se(this,he),Xn==q){an==4&&(this.s=4,jt(14),x=!1),qn(this.i,this.l,null,"[Incomplete Response]");break}else if(Xn==B){this.s=4,jt(15),qn(this.i,this.l,he,"[Invalid Chunk]"),x=!1;break}else qn(this.i,this.l,Xn,null),at(this,Xn);if(de(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),an!=4||he.length!=0||this.h.h||(this.s=1,jt(16),x=!1),this.o=this.o&&x,!x)qn(this.i,this.l,he,"[Invalid Chunked Response]"),Me(this),Ze(this);else if(0<he.length&&!this.W){this.W=!0;var on=this.j;on.g==this&&on.ba&&!on.M&&(on.j.info("Great, no buffering proxy detected. Bytes received: "+he.length),pu(on),on.M=!0,jt(11))}}else qn(this.i,this.l,he,null),at(this,he);an==4&&Me(this),this.o&&!this.J&&(an==4?rf(this.j,this):(this.o=!1,Pe(this)))}else Wy(this.g),x==400&&0<he.indexOf("Unknown SID")?(this.s=3,jt(12)):(this.s=0,jt(13)),Me(this),Ze(this)}}}catch{}finally{}};function de(u){return u.g?u.u=="GET"&&u.L!=2&&u.j.Ca:!1}function Se(u,v){var x=u.C,N=v.indexOf(` 4899`,x);return N==-1?q:(x=Number(v.substring(x,N)),isNaN(x)?B:(N+=1,N+x>v.length?q:(v=v.slice(N,N+x),u.C=N+x,v)))}ai.prototype.cancel=function(){this.J=!0,Me(this)};function Pe(u){u.S=Date.now()+u.I,Ne(u,u.I)}function Ne(u,v){if(u.B!=null)throw Error("WatchDog timer not null");u.B=wn(p(u.ba,u),v)}function Ye(u){u.B&&(a.clearTimeout(u.B),u.B=null)}ai.prototype.ba=function(){this.B=null;const u=Date.now();0<=u-this.S?($a(this.i,this.A),this.L!=2&&(Jt(),jt(17)),Me(this),this.s=2,Ze(this)):Ne(this,this.S-u)};function Ze(u){u.j.G==0||u.J||rf(u.j,u)}function Me(u){Ye(u);var v=u.M;v&&typeof v.ma=="function"&&v.ma(),u.M=null,Ae(u.U),u.g&&(v=u.g,u.g=null,v.abort(),v.ma())}function at(u,v){try{var x=u.j;if(x.G!=0&&(x.g==u||ke(x.h,u))){if(!u.K&&ke(x.h,u)&&x.G==3){try{var N=x.Da.g.parse(v)}catch{N=null}if(Array.isArray(N)&&N.length==3){var H=N;if(H[0]==0){e:if(!x.u){if(x.g)if(x.g.F+3e3<u.F)sc(x),ic(x);else break e;hu(x),jt(18)}}else x.za=H[1],0<x.za-x.T&&37500>H[2]&&x.F&&x.v==0&&!x.C&&(x.C=wn(p(x.Za,x),6e3));if(1>=ht(x.h)&&x.ca){try{x.ca()}catch{}x.ca=void 0}}else Mr(x,11)}else if((u.K||x.g==u)&&sc(x),!M(v))for(H=x.Da.g.parse(v),v=0;v<H.length;v++){let mt=H[v];if(x.T=mt[0],mt=mt[1],x.G==2)if(mt[0]=="c"){x.K=mt[1],x.ia=mt[2];const on=mt[3];on!=null&&(x.la=on,x.j.info("VER="+x.la));const an=mt[4];an!=null&&(x.Aa=an,x.j.info("SVER="+x.Aa));const ls=mt[5];ls!=null&&typeof ls=="number"&&0<ls&&(N=1.5*ls,x.L=N,x.j.info("backChannelRequestTimeoutMs_="+N)),N=x;const Xn=u.g;if(Xn){const ac=Xn.g?Xn.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(ac){var j=N.h;j.g||ac.indexOf("spdy")==-1&&ac.indexOf("quic")==-1&&ac.indexOf("h2")==-1||(j.j=j.l,j.g=new Set,j.h&&(In(j,j.h),j.h=null))}if(N.D){const fu=Xn.g?Xn.g.getResponseHeader("X-HTTP-Session-Id"):null;fu&&(N.ya=fu,Ct(N.I,N.D,fu))}}x.G=3,x.l&&x.l.ua(),x.ba&&(x.R=Date.now()-u.F,x.j.info("Handshake RTT: "+x.R+"ms")),N=x;var he=u;if(N.qa=af(N,N.J?N.ia:null,N.W),he.K){pt(N.h,he);var At=he,en=N.L;en&&(At.I=en),At.B&&(Ye(At),Pe(At)),N.g=he}else tf(N);0<x.i.length&&rc(x)}else mt[0]!="stop"&&mt[0]!="close"||Mr(x,7);else x.G==3&&(mt[0]=="stop"||mt[0]=="close"?mt[0]=="stop"?Mr(x,7):du(x):mt[0]!="noop"&&x.l&&x.l.ta(mt),x.v=0)}}Jt(4)}catch{}}var Et=class{constructor(u,v){this.g=u,this.map=v}};function Tt(u){this.l=u||10,a.PerformanceNavigationTiming?(u=a.performance.getEntriesByType("navigation"),u=0<u.length&&(u[0].nextHopProtocol=="hq"||u[0].nextHopProtocol=="h2")):u=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=u?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function $t(u){return u.h?!0:u.g?u.g.size>=u.j:!1}function ht(u){return u.h?1:u.g?u.g.size:0}function ke(u,v){return u.h?u.h==v:u.g?u.g.has(v):!1}function In(u,v){u.g?u.g.add(v):u.h=v}function pt(u,v){u.h&&u.h==v?u.h=null:u.g&&u.g.has(v)&&u.g.delete(v)}Tt.prototype.cancel=function(){if(this.i=Tn(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const u of this.g.values())u.cancel();this.g.clear()}};function Tn(u){if(u.h!=null)return u.i.concat(u.h.D);if(u.g!=null&&u.g.size!==0){let v=u.i;for(const x of u.g.values())v=v.concat(x.D);return v}return S(u.i)}function er(u){if(u.V&&typeof u.V=="function")return u.V();if(typeof Map<"u"&&u instanceof Map||typeof Set<"u"&&u instanceof Set)return Array.from(u.values());if(typeof u=="string")return u.split("");if(c(u)){for(var v=[],x=u.length,N=0;N<x;N++)v.push(u[N]);return v}v=[],x=0;for(N in u)v[x++]=u[N];return v}function fn(u){if(u.na&&typeof u.na=="function")return u.na();if(!u.V||typeof u.V!="function"){if(typeof Map<"u"&&u instanceof Map)return Array.from(u.keys());if(!(typeof Set<"u"&&u instanceof Set)){if(c(u)||typeof u=="string"){var v=[];u=u.length;for(var x=0;x<u;x++)v.push(x);return v}v=[],x=0;for(const N in u)v[x++]=N;return v}}}function tr(u,v){if(u.forEach&&typeof u.forEach=="function")u.forEach(v,void 0);else if(c(u)||typeof u=="string")Array.prototype.forEach.call(u,v,void 0);else for(var x=fn(u),N=er(u),H=N.length,j=0;j<H;j++)v.call(void 0,N[j],x&&x[j],u)}var bt=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function On(u,v){if(u){u=u.split("&");for(var x=0;x<u.length;x++){var N=u[x].indexOf("="),H=null;if(0<=N){var j=u[x].substring(0,N);H=u[x].substring(N+1)}else j=u[x];v(j,H?decodeURIComponent(H.replace(/\+/g," ")):"")}}}function Mn(u){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,u instanceof Mn){this.h=u.h,Cn(this,u.j),this.o=u.o,this.g=u.g,Rn(this,u.s),this.l=u.l;var v=u.i,x=new Mo;x.i=v.i,v.g&&(x.g=new Map(v.g),x.h=v.h),xo(this,x),this.m=u.m}else u&&(v=String(u).match(bt))?(this.h=!1,Cn(this,v[1]||"",!0),this.o=wo(v[2]||""),this.g=wo(v[3]||"",!0),Rn(this,v[4]),this.l=wo(v[5]||"",!0),xo(this,v[6]||"",!0),this.m=wo(v[7]||"")):(this.h=!1,this.i=new Mo(null,this.h))}Mn.prototype.toString=function(){var u=[],v=this.j;v&&u.push(Io(v,Bp,!0),":");var x=this.g;return(x||v=="file")&&(u.push("//"),(v=this.o)&&u.push(Io(v,Bp,!0),"@"),u.push(encodeURIComponent(String(x)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),x=this.s,x!=null&&u.push(":",String(x))),(x=this.l)&&(this.g&&x.charAt(0)!="/"&&u.push("/"),u.push(Io(x,x.charAt(0)=="/"?Ny:Dy,!0))),(x=this.i.toString())&&u.push("?",x),(x=this.m)&&u.push("#",Io(x,Uy)),u.join("")};function Nt(u){return new Mn(u)}function Cn(u,v,x){u.j=x?wo(v,!0):v,u.j&&(u.j=u.j.replace(/:$/,""))}function Rn(u,v){if(v){if(v=Number(v),isNaN(v)||0>v)throw Error("Bad port number "+v);u.s=v}else u.s=null}function xo(u,v,x){v instanceof Mo?(u.i=v,Oy(u.i,u.h)):(x||(v=Io(v,ky)),u.i=new Mo(v,u.h))}function Ct(u,v,x){u.i.set(v,x)}function ec(u){return Ct(u,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),u}function wo(u,v){return u?v?decodeURI(u.replace(/%25/g,"%2525")):decodeURIComponent(u):""}function Io(u,v,x){return typeof u=="string"?(u=encodeURI(u).replace(v,Ly),x&&(u=u.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),u):null}function Ly(u){return u=u.charCodeAt(0),"%"+(u>>4&15).toString(16)+(u&15).toString(16)}var Bp=/[#\/\?@]/g,Dy=/[#\?:]/g,Ny=/[#\?]/g,ky=/[#\?@]/g,Uy=/#/g;function Mo(u,v){this.h=this.g=null,this.i=u||null,this.j=!!v}function nr(u){u.g||(u.g=new Map,u.h=0,u.i&&On(u.i,function(v,x){u.add(decodeURIComponent(v.replace(/\+/g," ")),x)}))}n=Mo.prototype,n.add=function(u,v){nr(this),this.i=null,u=as(this,u);var x=this.g.get(u);return x||this.g.set(u,x=[]),x.push(v),this.h+=1,this};function zp(u,v){nr(u),v=as(u,v),u.g.has(v)&&(u.i=null,u.h-=u.g.get(v).length,u.g.delete(v))}function Hp(u,v){return nr(u),v=as(u,v),u.g.has(v)}n.forEach=function(u,v){nr(this),this.g.forEach(function(x,N){x.forEach(function(H){u.call(v,H,N,this)},this)},this)},n.na=function(){nr(this);const u=Array.from(this.g.values()),v=Array.from(this.g.keys()),x=[];for(let N=0;N<v.length;N++){const H=u[N];for(let j=0;j<H.length;j++)x.push(v[N])}return x},n.V=function(u){nr(this);let v=[];if(typeof u=="string")Hp(this,u)&&(v=v.concat(this.g.get(as(this,u))));else{u=Array.from(this.g.values());for(let x=0;x<u.length;x++)v=v.concat(u[x])}return v},n.set=function(u,v){return nr(this),this.i=null,u=as(this,u),Hp(this,u)&&(this.h-=this.g.get(u).length),this.g.set(u,[v]),this.h+=1,this},n.get=function(u,v){return u?(u=this.V(u),0<u.length?String(u[0]):v):v};function Gp(u,v,x){zp(u,v),0<x.length&&(u.i=null,u.g.set(as(u,v),S(x)),u.h+=x.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const u=[],v=Array.from(this.g.keys());for(var x=0;x<v.length;x++){var N=v[x];const j=encodeURIComponent(String(N)),he=this.V(N);for(N=0;N<he.length;N++){var H=j;he[N]!==""&&(H+="="+encodeURIComponent(String(he[N]))),u.push(H)}}return this.i=u.join("&")};function as(u,v){return v=String(v),u.j&&(v=v.toLowerCase()),v}function Oy(u,v){v&&!u.j&&(nr(u),u.i=null,u.g.forEach(function(x,N){var H=N.toLowerCase();N!=H&&(zp(this,N),Gp(this,H,x))},u)),u.j=v}function Fy(u,v){const x=new Ai;if(a.Image){const N=new Image;N.onload=_(ir,x,"TestLoadImage: loaded",!0,v,N),N.onerror=_(ir,x,"TestLoadImage: error",!1,v,N),N.onabort=_(ir,x,"TestLoadImage: abort",!1,v,N),N.ontimeout=_(ir,x,"TestLoadImage: timeout",!1,v,N),a.setTimeout(function(){N.ontimeout&&N.ontimeout()},1e4),N.src=u}else v(!1)}function Vy(u,v){const x=new Ai,N=new AbortController,H=setTimeout(()=>{N.abort(),ir(x,"TestPingServer: timeout",!1,v)},1e4);fetch(u,{signal:N.signal}).then(j=>{clearTimeout(H),j.ok?ir(x,"TestPingServer: ok",!0,v):ir(x,"TestPingServer: server error",!1,v)}).catch(()=>{clearTimeout(H),ir(x,"TestPingServer: error",!1,v)})}function ir(u,v,x,N,H){try{H&&(H.onload=null,H.onerror=null,H.onabort=null,H.ontimeout=null),N(x)}catch{}}function By(){this.g=new yt}function zy(u,v,x){const N=x||"";try{tr(u,function(H,j){let he=H;l(H)&&(he=rt(H)),v.push(N+j+"="+encodeURIComponent(he))})}catch(H){throw v.push(N+"type="+encodeURIComponent("_badmap")),H}}function Co(u){this.l=u.Ub||null,this.j=u.eb||!1}g(Co,F),Co.prototype.g=function(){return new tc(this.l,this.j)},Co.prototype.i=function(u){return function(){return u}}({});function tc(u,v){_e.call(this),this.D=u,this.o=v,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}g(tc,_e),n=tc.prototype,n.open=function(u,v){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=u,this.A=v,this.readyState=1,Po(this)},n.send=function(u){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const v={headers:this.u,method:this.B,credentials:this.m,cache:void 0};u&&(v.body=u),(this.D||a).fetch(new Request(this.A,v)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Ro(this)),this.readyState=0},n.Sa=function(u){if(this.g&&(this.l=u,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=u.headers,this.readyState=2,Po(this)),this.g&&(this.readyState=3,Po(this),this.g)))if(this.responseType==="arraybuffer")u.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in u){if(this.j=u.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Wp(this)}else u.text().then(this.Ra.bind(this),this.ga.bind(this))};function Wp(u){u.j.read().then(u.Pa.bind(u)).catch(u.ga.bind(u))}n.Pa=function(u){if(this.g){if(this.o&&u.value)this.response.push(u.value);else if(!this.o){var v=u.value?u.value:new Uint8Array(0);(v=this.v.decode(v,{stream:!u.done}))&&(this.response=this.responseText+=v)}u.done?Ro(this):Po(this),this.readyState==3&&Wp(this)}},n.Ra=function(u){this.g&&(this.response=this.responseText=u,Ro(this))},n.Qa=function(u){this.g&&(this.response=u,Ro(this))},n.ga=function(){this.g&&Ro(this)};function Ro(u){u.readyState=4,u.l=null,u.j=null,u.v=null,Po(u)}n.setRequestHeader=function(u,v){this.u.append(u,v)},n.getResponseHeader=function(u){return this.h&&this.h.get(u.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const u=[],v=this.h.entries();for(var x=v.next();!x.done;)x=x.value,u.push(x[0]+": "+x[1]),x=v.next();return u.join(`\r 4900`)};function Po(u){u.onreadystatechange&&u.onreadystatechange.call(u)}Object.defineProperty(tc.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(u){this.m=u?"include":"same-origin"}});function qp(u){let v="";return P(u,function(x,N){v+=N,v+=":",v+=x,v+=`\r 4901`}),v}function uu(u,v,x){e:{for(N in x){var N=!1;break e}N=!0}N||(x=qp(x),typeof u=="string"?x!=null&&encodeURIComponent(String(x)):Ct(u,v,x))}function kt(u){_e.call(this),this.headers=new Map,this.o=u||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}g(kt,_e);var Hy=/^https?$/i,Gy=["POST","PUT"];n=kt.prototype,n.Ha=function(u){this.J=u},n.ea=function(u,v,x,N){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+u);v=v?v.toUpperCase():"GET",this.D=u,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Ao.g(),this.v=this.o?me(this.o):me(Ao),this.g.onreadystatechange=p(this.Ea,this);try{this.B=!0,this.g.open(v,String(u),!0),this.B=!1}catch(j){Xp(this,j);return}if(u=x||"",x=new Map(this.headers),N)if(Object.getPrototypeOf(N)===Object.prototype)for(var H in N)x.set(H,N[H]);else if(typeof N.keys=="function"&&typeof N.get=="function")for(const j of N.keys())x.set(j,N.get(j));else throw Error("Unknown input type for opt_headers: "+String(N));N=Array.from(x.keys()).find(j=>j.toLowerCase()=="content-type"),H=a.FormData&&u instanceof a.FormData,!(0<=Array.prototype.indexOf.call(Gy,v,void 0))||N||H||x.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[j,he]of x)this.g.setRequestHeader(j,he);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Yp(this),this.u=!0,this.g.send(u),this.u=!1}catch(j){Xp(this,j)}};function Xp(u,v){u.h=!1,u.g&&(u.j=!0,u.g.abort(),u.j=!1),u.l=v,u.m=5,jp(u),nc(u)}function jp(u){u.A||(u.A=!0,ne(u,"complete"),ne(u,"error"))}n.abort=function(u){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=u||7,ne(this,"complete"),ne(this,"abort"),nc(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),nc(this,!0)),kt.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?Kp(this):this.bb())},n.bb=function(){Kp(this)};function Kp(u){if(u.h&&typeof o<"u"&&(!u.v[1]||xi(u)!=4||u.Z()!=2)){if(u.u&&xi(u)==4)tt(u.Ea,0,u);else if(ne(u,"readystatechange"),xi(u)==4){u.h=!1;try{const he=u.Z();e:switch(he){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var v=!0;break e;default:v=!1}var x;if(!(x=v)){var N;if(N=he===0){var H=String(u.D).match(bt)[1]||null;!H&&a.self&&a.self.location&&(H=a.self.location.protocol.slice(0,-1)),N=!Hy.test(H?H.toLowerCase():"")}x=N}if(x)ne(u,"complete"),ne(u,"success");else{u.m=6;try{var j=2<xi(u)?u.g.statusText:""}catch{j=""}u.l=j+" ["+u.Z()+"]",jp(u)}}finally{nc(u)}}}}function nc(u,v){if(u.g){Yp(u);const x=u.g,N=u.v[0]?()=>{}:null;u.g=null,u.v=null,v||ne(u,"ready");try{x.onreadystatechange=N}catch{}}}function Yp(u){u.I&&(a.clearTimeout(u.I),u.I=null)}n.isActive=function(){return!!this.g};function xi(u){return u.g?u.g.readyState:0}n.Z=function(){try{return 2<xi(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(u){if(this.g){var v=this.g.responseText;return u&&v.indexOf(u)==0&&(v=v.substring(u.length)),nt(v)}};function Qp(u){try{if(!u.g)return null;if("response"in u.g)return u.g.response;switch(u.H){case"":case"text":return u.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in u.g)return u.g.mozResponseArrayBuffer}return null}catch{return null}}function Wy(u){const v={};u=(u.g&&2<=xi(u)&&u.g.getAllResponseHeaders()||"").split(`\r 4902`);for(let N=0;N<u.length;N++){if(M(u[N]))continue;var x=I(u[N]);const H=x[0];if(x=x[1],typeof x!="string")continue;x=x.trim();const j=v[H]||[];v[H]=j,j.push(x)}T(v,function(N){return N.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Lo(u,v,x){return x&&x.internalChannelParams&&x.internalChannelParams[u]||v}function Zp(u){this.Aa=0,this.i=[],this.j=new Ai,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Lo("failFast",!1,u),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Lo("baseRetryDelayMs",5e3,u),this.cb=Lo("retryDelaySeedMs",1e4,u),this.Wa=Lo("forwardChannelMaxRetries",2,u),this.wa=Lo("forwardChannelRequestTimeoutMs",2e4,u),this.pa=u&&u.xmlHttpFactory||void 0,this.Xa=u&&u.Tb||void 0,this.Ca=u&&u.useFetchStreams||!1,this.L=void 0,this.J=u&&u.supportsCrossDomainXhr||!1,this.K="",this.h=new Tt(u&&u.concurrentRequestLimit),this.Da=new By,this.P=u&&u.fastHandshake||!1,this.O=u&&u.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=u&&u.Rb||!1,u&&u.xa&&this.j.xa(),u&&u.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&u&&u.detectBufferingProxy||!1,this.ja=void 0,u&&u.longPollingTimeout&&0<u.longPollingTimeout&&(this.ja=u.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=Zp.prototype,n.la=8,n.G=1,n.connect=function(u,v,x,N){jt(0),this.W=u,this.H=v||{},x&&N!==void 0&&(this.H.OSID=x,this.H.OAID=N),this.F=this.X,this.I=af(this,null,this.W),rc(this)};function du(u){if(Jp(u),u.G==3){var v=u.U++,x=Nt(u.I);if(Ct(x,"SID",u.K),Ct(x,"RID",v),Ct(x,"TYPE","terminate"),Do(u,x),v=new ai(u,u.j,v),v.L=2,v.v=ec(Nt(x)),x=!1,a.navigator&&a.navigator.sendBeacon)try{x=a.navigator.sendBeacon(v.v.toString(),"")}catch{}!x&&a.Image&&(new Image().src=v.v,x=!0),x||(v.g=cf(v.j,null),v.g.ea(v.v)),v.F=Date.now(),Pe(v)}of(u)}function ic(u){u.g&&(pu(u),u.g.cancel(),u.g=null)}function Jp(u){ic(u),u.u&&(a.clearTimeout(u.u),u.u=null),sc(u),u.h.cancel(),u.s&&(typeof u.s=="number"&&a.clearTimeout(u.s),u.s=null)}function rc(u){if(!$t(u.h)&&!u.s){u.s=!0;var v=u.Ga;ce||ve(),K||(ce(),K=!0),ue.add(v,u),u.B=0}}function qy(u,v){return ht(u.h)>=u.h.j-(u.s?1:0)?!1:u.s?(u.i=v.D.concat(u.i),!0):u.G==1||u.G==2||u.B>=(u.Va?0:u.Wa)?!1:(u.s=wn(p(u.Ga,u,v),sf(u,u.B)),u.B++,!0)}n.Ga=function(u){if(this.s)if(this.s=null,this.G==1){if(!u){this.U=Math.floor(1e5*Math.random()),u=this.U++;const H=new ai(this,this.j,u);let j=this.o;if(this.S&&(j?(j=A(j),y(j,this.S)):j=this.S),this.m!==null||this.O||(H.H=j,j=null),this.P)e:{for(var v=0,x=0;x<this.i.length;x++){t:{var N=this.i[x];if("__data__"in N.map&&(N=N.map.__data__,typeof N=="string")){N=N.length;break t}N=void 0}if(N===void 0)break;if(v+=N,4096<v){v=x;break e}if(v===4096||x===this.i.length-1){v=x+1;break e}}v=1e3}else v=1e3;v=ef(this,H,v),x=Nt(this.I),Ct(x,"RID",u),Ct(x,"CVER",22),this.D&&Ct(x,"X-HTTP-Session-Id",this.D),Do(this,x),j&&(this.O?v="headers="+encodeURIComponent(String(qp(j)))+"&"+v:this.m&&uu(x,this.m,j)),In(this.h,H),this.Ua&&Ct(x,"TYPE","init"),this.P?(Ct(x,"$req",v),Ct(x,"SID","null"),H.T=!0,X(H,x,null)):X(H,x,v),this.G=2}}else this.G==3&&(u?$p(this,u):this.i.length==0||$t(this.h)||$p(this))};function $p(u,v){var x;v?x=v.l:x=u.U++;const N=Nt(u.I);Ct(N,"SID",u.K),Ct(N,"RID",x),Ct(N,"AID",u.T),Do(u,N),u.m&&u.o&&uu(N,u.m,u.o),x=new ai(u,u.j,x,u.B+1),u.m===null&&(x.H=u.o),v&&(u.i=v.D.concat(u.i)),v=ef(u,x,1e3),x.I=Math.round(.5*u.wa)+Math.round(.5*u.wa*Math.random()),In(u.h,x),X(x,N,v)}function Do(u,v){u.H&&P(u.H,function(x,N){Ct(v,N,x)}),u.l&&tr({},function(x,N){Ct(v,N,x)})}function ef(u,v,x){x=Math.min(u.i.length,x);var N=u.l?p(u.l.Na,u.l,u):null;e:{var H=u.i;let j=-1;for(;;){const he=["count="+x];j==-1?0<x?(j=H[0].g,he.push("ofs="+j)):j=0:he.push("ofs="+j);let At=!0;for(let en=0;en<x;en++){let mt=H[en].g;const on=H[en].map;if(mt-=j,0>mt)j=Math.max(0,H[en].g-100),At=!1;else try{zy(on,he,"req"+mt+"_")}catch{N&&N(on)}}if(At){N=he.join("&");break e}}}return u=u.i.splice(0,x),v.D=u,N}function tf(u){if(!u.g&&!u.u){u.Y=1;var v=u.Fa;ce||ve(),K||(ce(),K=!0),ue.add(v,u),u.v=0}}function hu(u){return u.g||u.u||3<=u.v?!1:(u.Y++,u.u=wn(p(u.Fa,u),sf(u,u.v)),u.v++,!0)}n.Fa=function(){if(this.u=null,nf(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var u=2*this.R;this.j.info("BP detection timer enabled: "+u),this.A=wn(p(this.ab,this),u)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,jt(10),ic(this),nf(this))};function pu(u){u.A!=null&&(a.clearTimeout(u.A),u.A=null)}function nf(u){u.g=new ai(u,u.j,"rpc",u.Y),u.m===null&&(u.g.H=u.o),u.g.O=0;var v=Nt(u.qa);Ct(v,"RID","rpc"),Ct(v,"SID",u.K),Ct(v,"AID",u.T),Ct(v,"CI",u.F?"0":"1"),!u.F&&u.ja&&Ct(v,"TO",u.ja),Ct(v,"TYPE","xmlhttp"),Do(u,v),u.m&&u.o&&uu(v,u.m,u.o),u.L&&(u.g.I=u.L);var x=u.g;u=u.ia,x.L=1,x.v=ec(Nt(v)),x.m=null,x.P=!0,z(x,u)}n.Za=function(){this.C!=null&&(this.C=null,ic(this),hu(this),jt(19))};function sc(u){u.C!=null&&(a.clearTimeout(u.C),u.C=null)}function rf(u,v){var x=null;if(u.g==v){sc(u),pu(u),u.g=null;var N=2}else if(ke(u.h,v))x=v.D,pt(u.h,v),N=1;else return;if(u.G!=0){if(v.o)if(N==1){x=v.m?v.m.length:0,v=Date.now()-v.F;var H=u.B;N=Vt(),ne(N,new bo(N,x)),rc(u)}else tf(u);else if(H=v.s,H==3||H==0&&0<v.X||!(N==1&&qy(u,v)||N==2&&hu(u)))switch(x&&0<x.length&&(v=u.h,v.i=v.i.concat(x)),H){case 1:Mr(u,5);break;case 4:Mr(u,10);break;case 3:Mr(u,6);break;default:Mr(u,2)}}}function sf(u,v){let x=u.Ta+Math.floor(Math.random()*u.cb);return u.isActive()||(x*=2),x*v}function Mr(u,v){if(u.j.info("Error code "+v),v==2){var x=p(u.fb,u),N=u.Xa;const H=!N;N=new Mn(N||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||Cn(N,"https"),ec(N),H?Fy(N.toString(),x):Vy(N.toString(),x)}else jt(2);u.G=0,u.l&&u.l.sa(v),of(u),Jp(u)}n.fb=function(u){u?(this.j.info("Successfully pinged google.com"),jt(2)):(this.j.info("Failed to ping google.com"),jt(1))};function of(u){if(u.G=0,u.ka=[],u.l){const v=Tn(u.h);(v.length!=0||u.i.length!=0)&&(m(u.ka,v),m(u.ka,u.i),u.h.i.length=0,S(u.i),u.i.length=0),u.l.ra()}}function af(u,v,x){var N=x instanceof Mn?Nt(x):new Mn(x);if(N.g!="")v&&(N.g=v+"."+N.g),Rn(N,N.s);else{var H=a.location;N=H.protocol,v=v?v+"."+H.hostname:H.hostname,H=+H.port;var j=new Mn(null);N&&Cn(j,N),v&&(j.g=v),H&&Rn(j,H),x&&(j.l=x),N=j}return x=u.D,v=u.ya,x&&v&&Ct(N,x,v),Ct(N,"VER",u.la),Do(u,N),N}function cf(u,v,x){if(v&&!u.J)throw Error("Can't create secondary domain capable XhrIo object.");return v=u.Ca&&!u.pa?new kt(new Co({eb:x})):new kt(u.pa),v.Ha(u.J),v}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function lf(){}n=lf.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function oc(){}oc.prototype.g=function(u,v){return new Pn(u,v)};function Pn(u,v){_e.call(this),this.g=new Zp(v),this.l=u,this.h=v&&v.messageUrlParams||null,u=v&&v.messageHeaders||null,v&&v.clientProtocolHeaderRequired&&(u?u["X-Client-Protocol"]="webchannel":u={"X-Client-Protocol":"webchannel"}),this.g.o=u,u=v&&v.initMessageHeaders||null,v&&v.messageContentType&&(u?u["X-WebChannel-Content-Type"]=v.messageContentType:u={"X-WebChannel-Content-Type":v.messageContentType}),v&&v.va&&(u?u["X-WebChannel-Client-Profile"]=v.va:u={"X-WebChannel-Client-Profile":v.va}),this.g.S=u,(u=v&&v.Sb)&&!M(u)&&(this.g.m=u),this.v=v&&v.supportsCrossDomainXhr||!1,this.u=v&&v.sendRawJson||!1,(v=v&&v.httpSessionIdParam)&&!M(v)&&(this.g.D=v,u=this.h,u!==null&&v in u&&(u=this.h,v in u&&delete u[v])),this.j=new cs(this)}g(Pn,_e),Pn.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Pn.prototype.close=function(){du(this.g)},Pn.prototype.o=function(u){var v=this.g;if(typeof u=="string"){var x={};x.__data__=u,u=x}else this.u&&(x={},x.__data__=rt(u),u=x);v.i.push(new Et(v.Ya++,u)),v.G==3&&rc(v)},Pn.prototype.N=function(){this.g.l=null,delete this.j,du(this.g),delete this.g,Pn.aa.N.call(this)};function uf(u){be.call(this),u.__headers__&&(this.headers=u.__headers__,this.statusCode=u.__status__,delete u.__headers__,delete u.__status__);var v=u.__sm__;if(v){e:{for(const x in v){u=x;break e}u=void 0}(this.i=u)&&(u=this.i,v=v!==null&&u in v?v[u]:void 0),this.data=v}else this.data=u}g(uf,be);function df(){Te.call(this),this.status=1}g(df,Te);function cs(u){this.g=u}g(cs,lf),cs.prototype.ua=function(){ne(this.g,"a")},cs.prototype.ta=function(u){ne(this.g,new uf(u))},cs.prototype.sa=function(u){ne(this.g,new df)},cs.prototype.ra=function(){ne(this.g,"b")},oc.prototype.createWebChannel=oc.prototype.g,Pn.prototype.send=Pn.prototype.o,Pn.prototype.open=Pn.prototype.m,Pn.prototype.close=Pn.prototype.close,l0=function(){return new oc},c0=function(){return Vt()},a0=je,vh={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Ir.NO_ERROR=0,Ir.TIMEOUT=8,Ir.HTTP_ERROR=6,il=Ir,So.COMPLETE="complete",o0=So,Q.EventType=te,te.OPEN="a",te.CLOSE="b",te.ERROR="c",te.MESSAGE="d",_e.prototype.listen=_e.prototype.K,sa=Q,s0=Co,kt.prototype.listenOnce=kt.prototype.L,kt.prototype.getLastError=kt.prototype.Ka,kt.prototype.getLastErrorCode=kt.prototype.Ba,kt.prototype.getStatus=kt.prototype.Z,kt.prototype.getResponseJson=kt.prototype.Oa,kt.prototype.getResponseText=kt.prototype.oa,kt.prototype.send=kt.prototype.ea,kt.prototype.setWithCredentials=kt.prototype.Ha,r0=kt}).apply(typeof Bc<"u"?Bc:typeof self<"u"?self:typeof window<"u"?window:{});const Sm="@firebase/firestore";/** 4903 * @license 4904 * Copyright 2017 Google LLC 4905 * 4906 * Licensed under the Apache License, Version 2.0 (the "License"); 4907 * you may not use this file except in compliance with the License. 4908 * You may obtain a copy of the License at 4909 * 4910 * http://www.apache.org/licenses/LICENSE-2.0 4911 * 4912 * Unless required by applicable law or agreed to in writing, software 4913 * distributed under the License is distributed on an "AS IS" BASIS, 4914 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4915 * See the License for the specific language governing permissions and 4916 * limitations under the License. 4917 */class dn{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}dn.UNAUTHENTICATED=new dn(null),dn.GOOGLE_CREDENTIALS=new dn("google-credentials-uid"),dn.FIRST_PARTY=new dn("first-party-uid"),dn.MOCK_USER=new dn("mock-user");/** 4918 * @license 4919 * Copyright 2017 Google LLC 4920 * 4921 * Licensed under the Apache License, Version 2.0 (the "License");
4922 * you may not use this file except in compliance with the License. 4923 * You may obtain a copy of the License at 4924 * 4925 * http://www.apache.org/licenses/LICENSE-2.0 4926 * 4927 * Unless required by applicable law or agreed to in writing, software 4928 * distributed under the License is distributed on an "AS IS" BASIS, 4929 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4930 * See the License for the specific language governing permissions and 4931 * limitations under the License. 4932 */let vo="10.12.5";/** 4933 * @license 4934 * Copyright 2017 Google LLC 4935 * 4936 * Licensed under the Apache License, Version 2.0 (the "License"); 4937 * you may not use this file except in compliance with the License. 4938 * You may obtain a copy of the License at 4939 * 4940 * http://www.apache.org/licenses/LICENSE-2.0 4941 * 4942 * Unless required by applicable law or agreed to in writing, software 4943 * distributed under the License is distributed on an "AS IS" BASIS, 4944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4945 * See the License for the specific language governing permissions and 4946 * limitations under the License. 4947 */const Jr=new cg("@firebase/firestore");function Zo(){return Jr.logLevel}function Le(n,...e){if(Jr.logLevel<=ui.DEBUG){const t=e.map(hp);Jr.debug(`Firestore (${vo}): ${n}`,...t)}}function Ji(n,...e){if(Jr.logLevel<=ui.ERROR){const t=e.map(hp);Jr.error(`Firestore (${vo}): ${n}`,...t)}}function to(n,...e){if(Jr.logLevel<=ui.WARN){const t=e.map(hp);Jr.warn(`Firestore (${vo}): ${n}`,...t)}}function hp(n){if(typeof n=="string")return n;try{/** 4948* @license 4949* Copyright 2020 Google LLC 4950* 4951* Licensed under the Apache License, Version 2.0 (the "License"); 4952* you may not use this file except in compliance with the License. 4953* You may obtain a copy of the License at 4954* 4955* http://www.apache.org/licenses/LICENSE-2.0 4956* 4957* Unless required by applicable law or agreed to in writing, software 4958* distributed under the License is distributed on an "AS IS" BASIS, 4959* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4960* See the License for the specific language governing permissions and 4961* limitations under the License. 4962*/return function(t){return JSON.stringify(t)}(n)}catch{return n}}/** 4963 * @license 4964 * Copyright 2017 Google LLC 4965 * 4966 * Licensed under the Apache License, Version 2.0 (the "License"); 4967 * you may not use this file except in compliance with the License. 4968 * You may obtain a copy of the License at 4969 * 4970 * http://www.apache.org/licenses/LICENSE-2.0 4971 * 4972 * Unless required by applicable law or agreed to in writing, software 4973 * distributed under the License is distributed on an "AS IS" BASIS, 4974 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4975 * See the License for the specific language governing permissions and 4976 * limitations under the License. 4977 */function Je(n="Unexpected state"){const e=`FIRESTORE (${vo}) INTERNAL ASSERTION FAILED: `+n;throw Ji(e),new Error(e)}function It(n,e){n||Je()}function et(n,e){return n}/** 4978 * @license 4979 * Copyright 2017 Google LLC 4980 * 4981 * Licensed under the Apache License, Version 2.0 (the "License"); 4982 * you may not use this file except in compliance with the License. 4983 * You may obtain a copy of the License at 4984 * 4985 * http://www.apache.org/licenses/LICENSE-2.0 4986 * 4987 * Unless required by applicable law or agreed to in writing, software 4988 * distributed under the License is distributed on an "AS IS" BASIS, 4989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4990 * See the License for the specific language governing permissions and 4991 * limitations under the License. 4992 */const le={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class We extends Nl{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** 4993 * @license 4994 * Copyright 2017 Google LLC 4995 * 4996 * Licensed under the Apache License, Version 2.0 (the "License");
4997 * you may not use this file except in compliance with the License. 4998 * You may obtain a copy of the License at 4999 * 5000 * http://www.apache.org/licenses/LICENSE-2.0 5001 * 5002 * Unless required by applicable law or agreed to in writing, software 5003 * distributed under the License is distributed on an "AS IS" BASIS, 5004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5005 * See the License for the specific language governing permissions and 5006 * limitations under the License. 5007 */class jr{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/** 5008 * @license 5009 * Copyright 2017 Google LLC 5010 * 5011 * Licensed under the Apache License, Version 2.0 (the "License"); 5012 * you may not use this file except in compliance with the License. 5013 * You may obtain a copy of the License at 5014 * 5015 * http://www.apache.org/licenses/LICENSE-2.0 5016 * 5017 * Unless required by applicable law or agreed to in writing, software 5018 * distributed under the License is distributed on an "AS IS" BASIS, 5019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5020 * See the License for the specific language governing permissions and 5021 * limitations under the License. 5022 */class u0{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class mP{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(dn.UNAUTHENTICATED))}shutdown(){}}class gP{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class vP{constructor(e){this.t=e,this.currentUser=dn.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let i=this.i;const r=c=>this.i!==i?(i=this.i,t(c)):Promise.resolve();let s=new jr;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new jr,e.enqueueRetryable(()=>r(this.currentUser))};const o=()=>{const c=s;e.enqueueRetryable(async()=>{await c.promise,await r(this.currentUser)})},a=c=>{Le("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.auth.addAuthTokenListener(this.o),o()};this.t.onInit(c=>a(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?a(c):(Le("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new jr)}},0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(i=>this.i!==e?(Le("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):i?(It(typeof i.accessToken=="string"),new u0(i.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return It(e===null||typeof e=="string"),new dn(e)}}class yP{constructor(e,t,i){this.l=e,this.h=t,this.P=i,this.type="FirstParty",this.user=dn.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class EP{constructor(e,t,i){this.l=e,this.h=t,this.P=i}getToken(){return Promise.resolve(new yP(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(dn.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class TP{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class bP{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){const i=s=>{s.error!=null&&Le("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${s.error.message}`);const o=s.token!==this.R;return this.R=s.token,Le("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(s.token):Promise.resolve()};this.o=s=>{e.enqueueRetryable(()=>i(s))};const r=s=>{Le("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=s,this.appCheck.addTokenListener(this.o)};this.A.onInit(s=>r(s)),setTimeout(()=>{if(!this.appCheck){const s=this.A.getImmediate({optional:!0});s?r(s):Le("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(It(typeof t.token=="string"),this.R=t.token,new TP(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}/** 5023 * @license 5024 * Copyright 2020 Google LLC 5025 * 5026 * Licensed under the Apache License, Version 2.0 (the "License");
5027 * you may not use this file except in compliance with the License. 5028 * You may obtain a copy of the License at 5029 * 5030 * http://www.apache.org/licenses/LICENSE-2.0 5031 * 5032 * Unless required by applicable law or agreed to in writing, software 5033 * distributed under the License is distributed on an "AS IS" BASIS, 5034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5035 * See the License for the specific language governing permissions and 5036 * limitations under the License. 5037 */function SP(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<n;i++)t[i]=Math.floor(256*Math.random());return t}/** 5038 * @license 5039 * Copyright 2017 Google LLC 5040 * 5041 * Licensed under the Apache License, Version 2.0 (the "License"); 5042 * you may not use this file except in compliance with the License. 5043 * You may obtain a copy of the License at 5044 * 5045 * http://www.apache.org/licenses/LICENSE-2.0 5046 * 5047 * Unless required by applicable law or agreed to in writing, software 5048 * distributed under the License is distributed on an "AS IS" BASIS, 5049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5050 * See the License for the specific language governing permissions and 5051 * limitations under the License. 5052 */class d0{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length;let i="";for(;i.length<20;){const r=SP(40);for(let s=0;s<r.length;++s)i.length<20&&r[s]<t&&(i+=e.charAt(r[s]%e.length))}return i}}function gt(n,e){return n<e?-1:n>e?1:0}function no(n,e,t){return n.length===e.length&&n.every((i,r)=>t(i,e[r]))}/** 5053 * @license 5054 * Copyright 2017 Google LLC 5055 * 5056 * Licensed under the Apache License, Version 2.0 (the "License"); 5057 * you may not use this file except in compliance with the License. 5058 * You may obtain a copy of the License at 5059 * 5060 * http://www.apache.org/licenses/LICENSE-2.0 5061 * 5062 * Unless required by applicable law or agreed to in writing, software 5063 * distributed under the License is distributed on an "AS IS" BASIS, 5064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5065 * See the License for the specific language governing permissions and 5066 * limitations under the License. 5067 */class Wt{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new We(le.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new We(le.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new We(le.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new We(le.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return Wt.fromMillis(Date.now())}static fromDate(e){return Wt.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),i=Math.floor(1e6*(e-1e3*t));return new Wt(t,i)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?gt(this.nanoseconds,e.nanoseconds):gt(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/** 5068 * @license 5069 * Copyright 2017 Google LLC 5070 * 5071 * Licensed under the Apache License, Version 2.0 (the "License"); 5072 * you may not use this file except in compliance with the License. 5073 * You may obtain a copy of the License at 5074 * 5075 * http://www.apache.org/licenses/LICENSE-2.0 5076 * 5077 * Unless required by applicable law or agreed to in writing, software 5078 * distributed under the License is distributed on an "AS IS" BASIS, 5079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5080 * See the License for the specific language governing permissions and 5081 * limitations under the License. 5082 */class $e{constructor(e){this.timestamp=e}static fromTimestamp(e){return new $e(e)}static min(){return new $e(new Wt(0,0))}static max(){return new $e(new Wt(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/** 5083 * @license 5084 * Copyright 2017 Google LLC 5085 * 5086 * Licensed under the Apache License, Version 2.0 (the "License");
5087 * you may not use this file except in compliance with the License. 5088 * You may obtain a copy of the License at 5089 * 5090 * http://www.apache.org/licenses/LICENSE-2.0 5091 * 5092 * Unless required by applicable law or agreed to in writing, software 5093 * distributed under the License is distributed on an "AS IS" BASIS, 5094 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5095 * See the License for the specific language governing permissions and 5096 * limitations under the License. 5097 */class Ra{constructor(e,t,i){t===void 0?t=0:t>e.length&&Je(),i===void 0?i=e.length-t:i>e.length-t&&Je(),this.segments=e,this.offset=t,this.len=i}get length(){return this.len}isEqual(e){return Ra.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Ra?e.forEach(i=>{t.push(i)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,i=this.limit();t<i;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const i=Math.min(e.length,t.length);for(let r=0;r<i;r++){const s=e.get(r),o=t.get(r);if(s<o)return-1;if(s>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class Ut extends Ra{construct(e,t,i){return new Ut(e,t,i)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const i of e){if(i.indexOf("//")>=0)throw new We(le.INVALID_ARGUMENT,`Invalid segment (${i}). Paths must not contain // in them.`);t.push(...i.split("/").filter(r=>r.length>0))}return new Ut(t)}static emptyPath(){return new Ut([])}}const AP=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class nn extends Ra{construct(e,t,i){return new nn(e,t,i)}static isValidIdentifier(e){return AP.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),nn.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new nn(["__name__"])}static fromServerFormat(e){const t=[];let i="",r=0;const s=()=>
5097{if(i.length===0)throw new We(le.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(i),i=""};let o=!1;for(;r<e.length;){const a=e[r];if(a==="\\"){if(r+1===e.length)throw new We(le.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const c=e[r+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new We(le.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);i+=c,r+=2}else a==="`"?(o=!o,r++):a!=="."||o?(i+=a,r++):(s(),r++)}if(s(),o)throw new We(le.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new nn(t)}static emptyPath(){return new nn([])}}/** 5098 * @license 5099 * Copyright 2017 Google LLC 5100 * 5101 * Licensed under the Apache License, Version 2.0 (the "License"); 5102 * you may not use this file except in compliance with the License. 5103 * You may obtain a copy of the License at 5104 * 5105 * http://www.apache.org/licenses/LICENSE-2.0 5106 * 5107 * Unless required by applicable law or agreed to in writing, software 5108 * distributed under the License is distributed on an "AS IS" BASIS, 5109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5110 * See the License for the specific language governing permissions and 5111 * limitations under the License. 5112 */class qe{constructor(e){this.path=e}static fromPath(e){return new qe(Ut.fromString(e))}static fromName(e){return new qe(Ut.fromString(e).popFirst(5))}static empty(){return new qe(Ut.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Ut.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Ut.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new qe(new Ut(e.slice()))}}function xP(n,e){const t=n.toTimestamp().seconds,i=n.toTimestamp().nanoseconds+1,r=$e.fromTimestamp(i===1e9?new Wt(t+1,0):new Wt(t,i));return new br(r,qe.empty(),e)}function wP(n){return new br(n.readTime,n.key,-1)}class br{constructor(e,t,i){this.readTime=e,this.documentKey=t,this.largestBatchId=i}static min(){return new br($e.min(),qe.empty(),-1)}static max(){return new br($e.max(),qe.empty(),-1)}}function IP(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=qe.comparator(n.documentKey,e.documentKey),t!==0?t:gt(n.largestBatchId,e.largestBatchId))}/** 5113 * @license 5114 * Copyright 2020 Google LLC 5115 * 5116 * Licensed under the Apache License, Version 2.0 (the "License"); 5117 * you may not use this file except in compliance with the License. 5118 * You may obtain a copy of the License at 5119 * 5120 * http://www.apache.org/licenses/LICENSE-2.0 5121 * 5122 * Unless required by applicable law or agreed to in writing, software 5123 * distributed under the License is distributed on an "AS IS" BASIS, 5124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5125 * See the License for the specific language governing permissions and 5126 * limitations under the License. 5127 */const MP="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class CP{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/** 5128 * @license 5129 * Copyright 2017 Google LLC 5130 * 5131 * Licensed under the Apache License, Version 2.0 (the "License"); 5132 * you may not use this file except in compliance with the License. 5133 * You may obtain a copy of the License at 5134 * 5135 * http://www.apache.org/licenses/LICENSE-2.0 5136 * 5137 * Unless required by applicable law or agreed to in writing, software 5138 * distributed under the License is distributed on an "AS IS" BASIS, 5139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5140 * See the License for the specific language governing permissions and 5141 * limitations under the License. 5142 */async function qa(n){if(n.code!==le.FAILED_PRECONDITION||n.message!==MP)throw n;Le("LocalStore","Unexpectedly lost primary lease")}/** 5143 * @license 5144 * Copyright 2017 Google LLC 5145 * 5146 * Licensed under the Apache License, Version 2.0 (the "License");
5147 * you may not use this file except in compliance with the License. 5148 * You may obtain a copy of the License at 5149 * 5150 * http://www.apache.org/licenses/LICENSE-2.0 5151 * 5152 * Unless required by applicable law or agreed to in writing, software 5153 * distributed under the License is distributed on an "AS IS" BASIS, 5154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5155 * See the License for the specific language governing permissions and 5156 * limitations under the License. 5157 */class oe{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&Je(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new oe((i,r)=>{this.nextCallback=s=>{this.wrapSuccess(e,s).next(i,r)},this.catchCallback=s=>{this.wrapFailure(t,s).next(i,r)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof oe?t:oe.resolve(t)}catch(t){return oe.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):oe.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):oe.reject(t)}static resolve(e){return new oe((t,i)=>{t(e)})}static reject(e){return new oe((t,i)=>{i(e)})}static waitFor(e){return new oe((t,i)=>{let r=0,s=0,o=!1;e.forEach(a=>{++r,a.next(()=>{++s,o&&s===r&&t()},c=>i(c))}),o=!0,s===r&&t()})}static or(e){let t=oe.resolve(!1);for(const i of e)t=t.next(r=>r?oe.resolve(r):i());return t}static forEach(e,t){const i=[];return e.forEach((r,s)=>{i.push(t.call(this,r,s))}),this.waitFor(i)}static mapArray(e,t){return new oe((i,r)=>{const s=e.length,o=new Array(s);let a=0;for(let c=0;c<s;c++){const l=c;t(e[l]).next(d=>{o[l]=d,++a,a===s&&i(o)},d=>r(d))}})}static doWhile(e,t){return new oe((i,r)=>{const s=()=>{e()===!0?t().next(()=>{s()},r):i()};s()})}}function RP(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Xa(n){return n.name==="IndexedDbTransactionError"}/** 5158 * @license 5159 * Copyright 2018 Google LLC 5160 * 5161 * Licensed under the Apache License, Version 2.0 (the "License"); 5162 * you may not use this file except in compliance with the License. 5163 * You may obtain a copy of the License at 5164 * 5165 * http://www.apache.org/licenses/LICENSE-2.0 5166 * 5167 * Unless required by applicable law or agreed to in writing, software 5168 * distributed under the License is distributed on an "AS IS" BASIS, 5169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5170 * See the License for the specific language governing permissions and 5171 * limitations under the License. 5172 */class pp{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=i=>this.ie(i),this.se=i=>t.writeSequenceNumber(i))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}pp.oe=-1;function Zl(n){return n==null}function Al(n){return n===0&&1/n==-1/0}function PP(n){return typeof n=="number"&&Number.isInteger(n)&&!Al(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/** 5173 * @license 5174 * Copyright 2017 Google LLC 5175 * 5176 * Licensed under the Apache License, Version 2.0 (the "License"); 5177 * you may not use this file except in compliance with the License. 5178 * You may obtain a copy of the License at 5179 * 5180 * http://www.apache.org/licenses/LICENSE-2.0 5181 * 5182 * Unless required by applicable law or agreed to in writing, software 5183 * distributed under the License is distributed on an "AS IS" BASIS, 5184 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5185 * See the License for the specific language governing permissions and 5186 * limitations under the License. 5187 */function Am(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function yo(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function h0(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/** 5188 * @license 5189 * Copyright 2017 Google LLC 5190 * 5191 * Licensed under the Apache License, Version 2.0 (the "License");
5192 * you may not use this file except in compliance with the License. 5193 * You may obtain a copy of the License at 5194 * 5195 * http://www.apache.org/licenses/LICENSE-2.0 5196 * 5197 * Unless required by applicable law or agreed to in writing, software 5198 * distributed under the License is distributed on an "AS IS" BASIS, 5199 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5200 * See the License for the specific language governing permissions and 5201 * limitations under the License. 5202 */class Dt{constructor(e,t){this.comparator=e,this.root=t||tn.EMPTY}insert(e,t){return new Dt(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,tn.BLACK,null,null))}remove(e){return new Dt(this.comparator,this.root.remove(e,this.comparator).copy(null,null,tn.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const i=this.comparator(e,t.key);if(i===0)return t.value;i<0?t=t.left:i>0&&(t=t.right)}return null}indexOf(e){let t=0,i=this.root;for(;!i.isEmpty();){const r=this.comparator(e,i.key);if(r===0)return t+i.left.size;r<0?i=i.left:(t+=i.left.size+1,i=i.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,i)=>(e(t,i),!1))}toString(){const e=[];return this.inorderTraversal((t,i)=>(e.push(`${t}:${i}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new zc(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new zc(this.root,e,this.comparator,!1)}getReverseIterator(){return new zc(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new zc(this.root,e,this.comparator,!0)}}class zc{constructor(e,t,i,r){this.isReverse=r,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?i(e.key,t):1,t&&r&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(s===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class tn{constructor(e,t,i,r,s){this.key=e,this.value=t,this.color=i??tn.RED,this.left=r??tn.EMPTY,this.right=s??tn.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,i,r,s){return new tn(e??this.key,t??this.value,i??this.color,r??this.left,s??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,i){let r=this;const s=i(e,r.key);return r=s<0?r.copy(null,null,null,r.left.insert(e,t,i),null):s===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,i)),r.fixUp()}removeMin(){if(this.left.isEmpty())return tn.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let i,r=this;if(t(e,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),t(e,r.key)===0){if(r.right.isEmpty())return tn.EMPTY;i=r.right.min(),r=r.copy(i.key,i.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,tn.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,tn.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw Je();const e=this.left.check();if(e!==this.right.check())throw Je();return e+(this.isRed()?0:1)}}tn.EMPTY=null,tn.RED=!0,tn.BLACK=!1;
5202tn.EMPTY=new class{constructor(){this.size=0}get key(){throw Je()}get value(){throw Je()}get color(){throw Je()}get left(){throw Je()}get right(){throw Je()}copy(e,t,i,r,s){return this}insert(e,t,i){return new tn(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** 5203 * @license 5204 * Copyright 2017 Google LLC 5205 * 5206 * Licensed under the Apache License, Version 2.0 (the "License"); 5207 * you may not use this file except in compliance with the License. 5208 * You may obtain a copy of the License at 5209 * 5210 * http://www.apache.org/licenses/LICENSE-2.0 5211 * 5212 * Unless required by applicable law or agreed to in writing, software 5213 * distributed under the License is distributed on an "AS IS" BASIS, 5214 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5215 * See the License for the specific language governing permissions and 5216 * limitations under the License. 5217 */class rn{constructor(e){this.comparator=e,this.data=new Dt(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,i)=>(e(t),!1))}forEachInRange(e,t){const i=this.data.getIteratorFrom(e[0]);for(;i.hasNext();){const r=i.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let i;for(i=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();i.hasNext();)if(!e(i.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new xm(this.data.getIterator())}getIteratorFrom(e){return new xm(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(i=>{t=t.add(i)}),t}isEqual(e){if(!(e instanceof rn)||this.size!==e.size)return!1;const t=this.data.getIterator(),i=e.data.getIterator();for(;t.hasNext();){const r=t.getNext().key,s=i.getNext().key;if(this.comparator(r,s)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new rn(this.comparator);return t.data=e,t}}class xm{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/** 5218 * @license 5219 * Copyright 2020 Google LLC 5220 * 5221 * Licensed under the Apache License, Version 2.0 (the "License"); 5222 * you may not use this file except in compliance with the License. 5223 * You may obtain a copy of the License at 5224 * 5225 * http://www.apache.org/licenses/LICENSE-2.0 5226 * 5227 * Unless required by applicable law or agreed to in writing, software 5228 * distributed under the License is distributed on an "AS IS" BASIS, 5229 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5230 * See the License for the specific language governing permissions and 5231 * limitations under the License. 5232 */class ii{constructor(e){this.fields=e,e.sort(nn.comparator)}static empty(){return new ii([])}unionWith(e){let t=new rn(nn.comparator);for(const i of this.fields)t=t.add(i);for(const i of e)t=t.add(i);return new ii(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return no(this.fields,e.fields,(t,i)=>t.isEqual(i))}}/** 5233 * @license 5234 * Copyright 2023 Google LLC 5235 * 5236 * Licensed under the Apache License, Version 2.0 (the "License"); 5237 * you may not use this file except in compliance with the License. 5238 * You may obtain a copy of the License at 5239 * 5240 * http://www.apache.org/licenses/LICENSE-2.0 5241 * 5242 * Unless required by applicable law or agreed to in writing, software 5243 * distributed under the License is distributed on an "AS IS" BASIS, 5244 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5245 * See the License for the specific language governing permissions and 5246 * limitations under the License.
5247 */class p0 extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** 5248 * @license 5249 * Copyright 2020 Google LLC 5250 * 5251 * Licensed under the Apache License, Version 2.0 (the "License"); 5252 * you may not use this file except in compliance with the License. 5253 * You may obtain a copy of the License at 5254 * 5255 * http://www.apache.org/licenses/LICENSE-2.0 5256 * 5257 * Unless required by applicable law or agreed to in writing, software 5258 * distributed under the License is distributed on an "AS IS" BASIS, 5259 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5260 * See the License for the specific language governing permissions and 5261 * limitations under the License. 5262 */class sn{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(r){try{return atob(r)}catch(s){throw typeof DOMException<"u"&&s instanceof DOMException?new p0("Invalid base64 string: "+s):s}}(e);return new sn(t)}static fromUint8Array(e){const t=function(r){let s="";for(let o=0;o<r.length;++o)s+=String.fromCharCode(r[o]);return s}(e);return new sn(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const i=new Uint8Array(t.length);for(let r=0;r<t.length;r++)i[r]=t.charCodeAt(r);return i}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return gt(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}sn.EMPTY_BYTE_STRING=new sn("");const LP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Sr(n){if(It(!!n),typeof n=="string"){let e=0;const t=LP.exec(n);if(It(!!t),t[1]){let r=t[1];r=(r+"000000000").substr(0,9),e=Number(r)}const i=new Date(n);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:Ht(n.seconds),nanos:Ht(n.nanos)}}function Ht(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function $r(n){return typeof n=="string"?sn.fromBase64String(n):sn.fromUint8Array(n)}/** 5263 * @license 5264 * Copyright 2020 Google LLC 5265 * 5266 * Licensed under the Apache License, Version 2.0 (the "License"); 5267 * you may not use this file except in compliance with the License. 5268 * You may obtain a copy of the License at 5269 * 5270 * http://www.apache.org/licenses/LICENSE-2.0 5271 * 5272 * Unless required by applicable law or agreed to in writing, software 5273 * distributed under the License is distributed on an "AS IS" BASIS, 5274 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5275 * See the License for the specific language governing permissions and 5276 * limitations under the License. 5277 */function fp(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="server_timestamp"}function _p(n){const e=n.mapValue.fields.__previous_value__;return fp(e)?_p(e):e}function Pa(n){const e=Sr(n.mapValue.fields.__local_write_time__.timestampValue);return new Wt(e.seconds,e.nanos)}/** 5278 * @license 5279 * Copyright 2017 Google LLC 5280 * 5281 * Licensed under the Apache License, Version 2.0 (the "License"); 5282 * you may not use this file except in compliance with the License. 5283 * You may obtain a copy of the License at 5284 * 5285 * http://www.apache.org/licenses/LICENSE-2.0 5286 * 5287 * Unless required by applicable law or agreed to in writing, software 5288 * distributed under the License is distributed on an "AS IS" BASIS, 5289 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5290 * See the License for the specific language governing permissions and 5291 * limitations under the License. 5292 */class DP{constructor(e,t,i,r,s,o,a,c,l){this.databaseId=e,this.appId=t,this.persistenceKey=i,this.host=r,this.ssl=s,this.forceLongPolling=o,this.autoDetectLongPolling=a,this.longPollingOptions=c,this.useFetchStreams=l}}class La{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new La("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof La&&e.projectId===this.projectId&&e.database===this.database}}/** 5293 * @license 5294 * Copyright 2020 Google LLC 5295 * 5296 * Licensed under the Apache License, Version 2.0 (the "License");
5297 * you may not use this file except in compliance with the License. 5298 * You may obtain a copy of the License at 5299 * 5300 * http://www.apache.org/licenses/LICENSE-2.0 5301 * 5302 * Unless required by applicable law or agreed to in writing, software 5303 * distributed under the License is distributed on an "AS IS" BASIS, 5304 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5305 * See the License for the specific language governing permissions and 5306 * limitations under the License. 5307 */const Hc={mapValue:{fields:{__type__:{stringValue:"__max__"}}}};function es(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?fp(n)?4:NP(n)?9007199254740991:10:Je()}function Ti(n,e){if(n===e)return!0;const t=es(n);if(t!==es(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Pa(n).isEqual(Pa(e));case 3:return function(r,s){if(typeof r.timestampValue=="string"&&typeof s.timestampValue=="string"&&r.timestampValue.length===s.timestampValue.length)return r.timestampValue===s.timestampValue;const o=Sr(r.timestampValue),a=Sr(s.timestampValue);return o.seconds===a.seconds&&o.nanos===a.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(r,s){return $r(r.bytesValue).isEqual($r(s.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(r,s){return Ht(r.geoPointValue.latitude)===Ht(s.geoPointValue.latitude)&&Ht(r.geoPointValue.longitude)===Ht(s.geoPointValue.longitude)}(n,e);case 2:return function(r,s){if("integerValue"in r&&"integerValue"in s)return Ht(r.integerValue)===Ht(s.integerValue);if("doubleValue"in r&&"doubleValue"in s){const o=Ht(r.doubleValue),a=Ht(s.doubleValue);return o===a?Al(o)===Al(a):isNaN(o)&&isNaN(a)}return!1}(n,e);case 9:return no(n.arrayValue.values||[],e.arrayValue.values||[],Ti);case 10:return function(r,s){const o=r.mapValue.fields||{},a=s.mapValue.fields||{};if(Am(o)!==Am(a))return!1;for(const c in o)if(o.hasOwnProperty(c)&&(a[c]===void 0||!Ti(o[c],a[c])))return!1;return!0}(n,e);default:return Je()}}function Da(n,e){return(n.values||[]).find(t=>Ti(t,e))!==void 0}function io(n,e){if(n===e)return 0;const t=es(n),i=es(e);if(t!==i)return gt(t,i);switch(t){case 0:case 9007199254740991:return 0;case 1:return gt(n.booleanValue,e.booleanValue);case 2:return function(s,o){const a=Ht(s.integerValue||s.doubleValue),c=Ht(o.integerValue||o.doubleValue);return a<c?-1:a>c?1:a===c?0:isNaN(a)?isNaN(c)?0:-1:1}(n,e);case 3:return wm(n.timestampValue,e.timestampValue);case 4:return wm(Pa(n),Pa(e));case 5:return gt(n.stringValue,e.stringValue);case 6:return function(s,o){const a=$r(s),c=$r(o);return a.compareTo(c)}(n.bytesValue,e.bytesValue);case 7:return function(s,o){const a=s.split("/"),c=o.split("/");for(let l=0;l<a.length&&l<c.length;l++){const d=gt(a[l],c[l]);if(d!==0)return d}return gt(a.length,c.length)}(n.referenceValue,e.referenceValue);case 8:return function(s,o){const a=gt(Ht(s.latitude),Ht(o.latitude));return a!==0?a:gt(Ht(s.longitude),Ht(o.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return function(s,o){const a=s.values||[],c=o.values||[];for(let l=0;l<a.length&&l<c.length;++l){const d=io(a[l],c[l]);if(d)return d}return gt(a.length,c.length)}(n.arrayValue,e.arrayValue);case 10:return function(s,o){if(s===Hc.mapValue&&o===Hc.mapValue)return 0;if(s===Hc.mapValue)return 1;if(o===Hc.mapValue)return-1;const a=s.fields||{},c=Object.keys(a),l=o.fields||{},d=Object.keys(l);c.sort(),d.sort();for(let h=0;h<c.length&&h<d.length;++h){const p=gt(c[h],d[h]);if(p!==0)return p;const _=io(a[c[h]],l[d[h]]);if(_!==0)return _}return gt(c.length,d.length)}(n.mapValue,e.mapValue);default:throw Je()}}function wm(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return gt(n,e);const t=Sr(n),i=Sr(e),r=gt(t.seconds,i.seconds);return r!==0?r:gt(t.nanos,i.nanos)}function ro(n){return yh(n)}function yh(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){const i=Sr(t);return`time(${i.seconds},${i.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return $r(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return qe.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let i="[",r=!0;for(const s of t.values||[])r?r=!1:i+=",",i+=yh(s);return i+"]"}(n.arrayValue):"mapValue"in n?function(t){const i=Object.keys(t.fields||{}).sort();let r="{",s=!0;for(const o of i)s?s=!1:r+=",",r+=`${o}:${yh(t.fields[o])}`;return r+"}"}(n.mapValue):Je()}function Eh(n){return!!n&&"integerValue"in n}function mp(n){return!!n&&"arrayValue"in n}function Im(n){return!!n&&"nullValue"in n}function Mm(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function rl(n){return!!n&&"mapValue"in n}function _a(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return yo(n.mapValue.fields,(t,i)=>e.mapValue.fields[t]=_a(i)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=_a(n.arrayValue.values[t]);return e}return Object.assign({},n)}function NP(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}/** 5308 * @license 5309 * Copyright 2017 Google LLC 5310 * 5311 * Licensed under the Apache License, Version 2.0 (the "License");
5312 * you may not use this file except in compliance with the License. 5313 * You may obtain a copy of the License at 5314 * 5315 * http://www.apache.org/licenses/LICENSE-2.0 5316 * 5317 * Unless required by applicable law or agreed to in writing, software 5318 * distributed under the License is distributed on an "AS IS" BASIS, 5319 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5320 * See the License for the specific language governing permissions and 5321 * limitations under the License. 5322 */class Hn{constructor(e){this.value=e}static empty(){return new Hn({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let i=0;i<e.length-1;++i)if(t=(t.mapValue.fields||{})[e.get(i)],!rl(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=_a(t)}setAll(e){let t=nn.emptyPath(),i={},r=[];e.forEach((o,a)=>{if(!t.isImmediateParentOf(a)){const c=this.getFieldsMap(t);this.applyChanges(c,i,r),i={},r=[],t=a.popLast()}o?i[a.lastSegment()]=_a(o):r.push(a.lastSegment())});const s=this.getFieldsMap(t);this.applyChanges(s,i,r)}delete(e){const t=this.field(e.popLast());rl(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Ti(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let i=0;i<e.length;++i){let r=t.mapValue.fields[e.get(i)];rl(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(i)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,i){yo(t,(r,s)=>e[r]=s);for(const r of i)delete e[r]}clone(){return new Hn(_a(this.value))}}function f0(n){const e=[];return yo(n.fields,(t,i)=>{const r=new nn([t]);if(rl(i)){const s=f0(i.mapValue).fields;
5322if(s.length===0)e.push(r);else for(const o of s)e.push(r.child(o))}else e.push(r)}),new ii(e)}/** 5323 * @license 5324 * Copyright 2017 Google LLC 5325 * 5326 * Licensed under the Apache License, Version 2.0 (the "License"); 5327 * you may not use this file except in compliance with the License. 5328 * You may obtain a copy of the License at 5329 * 5330 * http://www.apache.org/licenses/LICENSE-2.0 5331 * 5332 * Unless required by applicable law or agreed to in writing, software 5333 * distributed under the License is distributed on an "AS IS" BASIS, 5334 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5335 * See the License for the specific language governing permissions and 5336 * limitations under the License. 5337 */class hn{constructor(e,t,i,r,s,o,a){this.key=e,this.documentType=t,this.version=i,this.readTime=r,this.createTime=s,this.data=o,this.documentState=a}static newInvalidDocument(e){return new hn(e,0,$e.min(),$e.min(),$e.min(),Hn.empty(),0)}static newFoundDocument(e,t,i,r){return new hn(e,1,t,$e.min(),i,r,0)}static newNoDocument(e,t){return new hn(e,2,t,$e.min(),$e.min(),Hn.empty(),0)}static newUnknownDocument(e,t){return new hn(e,3,t,$e.min(),$e.min(),Hn.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual($e.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Hn.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Hn.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=$e.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof hn&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new hn(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** 5338 * @license 5339 * Copyright 2022 Google LLC 5340 * 5341 * Licensed under the Apache License, Version 2.0 (the "License"); 5342 * you may not use this file except in compliance with the License. 5343 * You may obtain a copy of the License at 5344 * 5345 * http://www.apache.org/licenses/LICENSE-2.0 5346 * 5347 * Unless required by applicable law or agreed to in writing, software 5348 * distributed under the License is distributed on an "AS IS" BASIS, 5349 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5350 * See the License for the specific language governing permissions and 5351 * limitations under the License. 5352 */class xl{constructor(e,t){this.position=e,this.inclusive=t}}function Cm(n,e,t){let i=0;for(let r=0;r<n.position.length;r++){const s=e[r],o=n.position[r];if(s.field.isKeyField()?i=qe.comparator(qe.fromName(o.referenceValue),t.key):i=io(o,t.data.field(s.field)),s.dir==="desc"&&(i*=-1),i!==0)break}return i}function Rm(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Ti(n.position[t],e.position[t]))return!1;return!0}/** 5353 * @license 5354 * Copyright 2022 Google LLC 5355 * 5356 * Licensed under the Apache License, Version 2.0 (the "License"); 5357 * you may not use this file except in compliance with the License. 5358 * You may obtain a copy of the License at 5359 * 5360 * http://www.apache.org/licenses/LICENSE-2.0 5361 * 5362 * Unless required by applicable law or agreed to in writing, softw
5362are 5363 * distributed under the License is distributed on an "AS IS" BASIS, 5364 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5365 * See the License for the specific language governing permissions and 5366 * limitations under the License. 5367 */class wl{constructor(e,t="asc"){this.field=e,this.dir=t}}function kP(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/** 5368 * @license 5369 * Copyright 2022 Google LLC 5370 * 5371 * Licensed under the Apache License, Version 2.0 (the "License"); 5372 * you may not use this file except in compliance with the License. 5373 * You may obtain a copy of the License at 5374 * 5375 * http://www.apache.org/licenses/LICENSE-2.0 5376 * 5377 * Unless required by applicable law or agreed to in writing, software 5378 * distributed under the License is distributed on an "AS IS" BASIS, 5379 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5380 * See the License for the specific language governing permissions and 5381 * limitations under the License. 5382 */class _0{}class Gt extends _0{constructor(e,t,i){super(),this.field=e,this.op=t,this.value=i}static create(e,t,i){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,i):new OP(e,t,i):t==="array-contains"?new BP(e,i):t==="in"?new zP(e,i
5382):t==="not-in"?new HP(e,i):t==="array-contains-any"?new GP(e,i):new Gt(e,t,i)}static createKeyFieldInFilter(e,t,i){return t==="in"?new FP(e,i):new VP(e,i)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(io(t,this.value)):t!==null&&es(this.value)===es(t)&&this.matchesComparison(io(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return Je()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class bi extends _0{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new bi(e,t)}matches(e){return m0(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function m0(n){return n.op==="and"}function g0(n){return UP(n)&&m0(n)}function UP(n){for(const e of n.filters)if(e instanceof bi)return!1;return!0}function Th(n){if(n instanceof Gt)return n.field.canonicalString()+n.op.toString()+ro(n.value);if(g0(n))return n.filters.map(e=>Th(e)).join(",");{const e=n.filters.map(t=>Th(t)).join(",");return`${n.op}(${e})`}}function v0(n,e){return n instanceof Gt?function(i,r){return r instanceof Gt&&i.op===r.op&&i.field.isEqual(r.field)&&Ti(i.value,r.value)}(n,e):n instanceof bi?function(i,r){return r instanceof bi&&i.op===r.op&&i.filters.length===r.filters.length?i.filters.reduce((s,o,a)=>s&&v0(o,r.filters[a]),!0):!1}(n,e):void Je()}function y0(n){return n instanceof Gt?function(t){return`${t.field.canonicalString()} ${t.op} ${ro(t.value)}`}(n):n instanceof bi?function(t){return t.op.toString()+" {"+t.getFilters().map(y0).join(" ,")+"}"}(n):"Filter"}class OP extends Gt{constructor(e,t,i){super(e,t,i),this.key=qe.fromName(i.referenceValue)}matches(e){const t=qe.comparator(e.key,this.key);return this.matchesComparison(t)}}class FP extends Gt{constructor(e,t){super(e,"in",t),this.keys=E0("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class VP extends Gt{constructor(e,t){super(e,"not-in",t),this.keys=E0("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function E0(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(i=>qe.fromName(i.referenceValue))}class BP extends Gt{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return mp(t)&&Da(t.arrayValue,this.value)}}class zP extends Gt{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Da(this.value.arrayValue,t)}}class HP extends Gt{constructor(e,t){super(e,"not-in",t)}matches(e){if(Da(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&!Da(this.value.arrayValue,t)}}class GP extends Gt{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!mp(t)||!t.arrayValue.values)&&t.arrayValue.values.some(i=>Da(this.value.arrayValue,i))}}/** 5383 * @license 5384 * Copyright 2019 Google LLC 5385 * 5386 * Licensed under the Apache License, Version 2.0 (the "License"); 5387 * you may not use this file except in compliance with the License. 5388 * You may obtain a copy of the License at 5389 * 5390 * http://www.apache.org/licenses/LICENSE-2.0 5391 * 5392 * Unless required by applicable law or agreed to in writing, software 5393 * distributed under the License is distributed on an "AS IS" BASIS, 5394 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5395 * See the License for the specific language governing permissions and 5396 * limitations under the License. 5397 */class WP{constructor(e,t=null,i=[],r=[],s=null,o=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=i,this.filters=r,this.limit=s,this.startAt=o,this.endAt=a,this.ue=null}}function Pm(n,e=null,t=[],i=[],r=null,s=null,o=null){return new WP(n,e,t,i,r,s,o)}function gp(n){const e=et(n);if(e.ue===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(i=>Th(i)).join(","),t+="|ob:",t+=e.orderBy.map(i=>function(s){return s.field.canonicalString()+s.dir}(i)).join(","),Zl(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(i=>ro(i)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(i=>ro(i)).join(",")),e.ue=t}return e.ue}function vp(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!kP(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!v0(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Rm(n.startAt,e.startAt)&&Rm(n.endAt,e.endAt)}function bh(n){return qe.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/** 5398 * @license 5399 * Copyright 2017 Google LLC 5400 * 5401 * Licensed under the Apache License, Version 2.0 (the "License");
5402 * you may not use this file except in compliance with the License. 5403 * You may obtain a copy of the License at 5404 * 5405 * http://www.apache.org/licenses/LICENSE-2.0 5406 * 5407 * Unless required by applicable law or agreed to in writing, software 5408 * distributed under the License is distributed on an "AS IS" BASIS, 5409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5410 * See the License for the specific language governing permissions and 5411 * limitations under the License. 5412 */class Jl{constructor(e,t=null,i=[],r=[],s=null,o="F",a=null,c=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=i,this.filters=r,this.limit=s,this.limitType=o,this.startAt=a,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function qP(n,e,t,i,r,s,o,a){return new Jl(n,e,t,i,r,s,o,a)}function yp(n){return new Jl(n)}function Lm(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function XP(n){return n.collectionGroup!==null}function ma(n){const e=et(n);if(e.ce===null){e.ce=[];const t=new Set;for(const s of e.explicitOrderBy)e.ce.push(s),t.add(s.field.canonicalString());const i=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let a=new rn(nn.comparator);return o.filters.forEach(c=>{c.getFlattenedFilters().forEach(l=>{l.isInequality()&&(a=a.add(l.field))})}),a})(e).forEach(s=>{t.has(s.canonicalString())||s.isKeyField()||e.ce.push(new wl(s,i))}),t.has(nn.keyField().canonicalString())||e.ce.push(new wl(nn.keyField(),i))}return e.ce}function mi(n){const e=et(n);return e.le||(e.le=jP(e,ma(n))),e.le}function jP(n,e){if(n.limitType==="F")return Pm(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(r=>{const s=r.dir==="desc"?"asc":"desc";return new wl(r.field,s)});const t=n.endAt?new xl(n.endAt.position,n.endAt.inclusive):null,i=n.startAt?new xl(n.startAt.position,n.startAt.inclusive):null;return Pm(n.path,n.collectionGroup,e,n.filters,n.limit,t,i)}}function Sh(n,e,t){return new Jl(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function $l(n,e){return vp(mi(n),mi(e))&&n.limitType===e.limitType}function T0(n){return`${gp(mi(n))}|lt:${n.limitType}`}function Rs(n){return`Query(target=${function(t){let i=t.path.canonicalString();return t.collectionGroup!==null&&(i+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(i+=`, filters: [${t.filters.map(r=>y0(r)).join(", ")}]`),Zl(t.limit)||(i+=", limit: "+t.limit),t.orderBy.length>0&&(i+=`, orderBy: [${t.orderBy.map(r=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(r)).join(", ")}]`),t.startAt&&(i+=", startAt: ",i+=t.startAt.inclusive?"b:":"a:",i+=t.startAt.position.map(r=>ro(r)).join(",")),t.endAt&&(i+=", endAt: ",i+=t.endAt.inclusive?"a:":"b:",i+=t.endAt.position.map(r=>ro(r)).join(",")),`Target(${i})`}(mi(n))}; limitType=${n.limitType})`}function eu(n,e){return e.isFoundDocument()&&function(i,r){const s=r.key.path;return i.collectionGroup!==null?r.key.hasCollectionId(i.collectionGroup)&&i.path.isPrefixOf(s):qe.isDocumentKey(i.path)?i.path.isEqual(s):i.path.isImmediateParentOf(s)}(n,e)&&function(i,r){for(const s of ma(i))if(!s.field.isKeyField()&&r.data.field(s.field)===null)return!1;return!0}(n,e)&&function(i,r){for(const s of i.filters)if(!s.matches(r))return!1;return!0}(n,e)&&function(i,r){return!(i.startAt&&!function(o,a,c){const l=Cm(o,a,c);return o.inclusive?l<=0:l<0}(i.startAt,ma(i),r)||i.endAt&&!function(o,a,c){const l=Cm(o,a,c);return o.inclusive?l>=0:l>0}(i.endAt,ma(i),r))}(n,e)}function KP(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function b0(n){return(e,t)=>{let i=!1;for(const r of ma(n)){const s=YP(r,e,t);if(s!==0)return s;i=i||r.field.isKeyField()}return 0}}function YP(n,e,t){const i=n.field.isKeyField()?qe.comparator(e.key,t.key):function(s,o,a){const c=o.data.field(s),l=a.data.field(s);return c!==null&&l!==null?io(c,l):Je()}(n.field,e,t);switch(n.dir){case"asc":return i;
5412case"desc":return-1*i;default:return Je()}}/** 5413 * @license 5414 * Copyright 2017 Google LLC 5415 * 5416 * Licensed under the Apache License, Version 2.0 (the "License"); 5417 * you may not use this file except in compliance with the License. 5418 * You may obtain a copy of the License at 5419 * 5420 * http://www.apache.org/licenses/LICENSE-2.0 5421 * 5422 * Unless required by applicable law or agreed to in writing, software 5423 * distributed under the License is distributed on an "AS IS" BASIS, 5424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5425 * See the License for the specific language governing permissions and 5426 * limitations under the License. 5427 */class Eo{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),i=this.inner[t];if(i!==void 0){for(const[r,s]of i)if(this.equalsFn(r,e))return s}}has(e){return this.get(e)!==void 0}set(e,t){const i=this.mapKeyFn(e),r=this.inner[i];if(r===void 0)return this.inner[i]=[[e,t]],void this.innerSize++;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return void(r[s]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),i=this.inner[t];if(i===void 0)return!1;for(let r=0;r<i.length;r++)if(this.equalsFn(i[r][0],e))return i.length===1?delete this.inner[t]:i.splice(r,1),this.innerSize--,!0;return!1}forEach(e){yo(this.inner,(t,i)=>{for(const[r,s]of i)e(r,s)})}isEmpty(){return h0(this.inner)}size(){return this.innerSize}}/** 5428 * @license 5429 * Copyright 2017 Google LLC 5430 * 5431 * Licensed under the Apache License, Version 2.0 (the "License"); 5432 * you may not use this file except in compliance with the License. 5433 * You may obtain a copy of the License at 5434 * 5435 * http://www.apache.org/licenses/LICENSE-2.0 5436 * 5437 * Unless required by applicable law or agreed to in writing, software 5438 * distributed under the License is distributed on an "AS IS" BASIS, 5439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5440 * See the License for the specific language governing permissions and 5441 * limitations under the License. 5442 */const QP=new Dt(qe.comparator);function $i(){return QP}const S0=new Dt(qe.comparator);function oa(...n){let e=S0;for(const t of n)e=e.insert(t.key,t);return e}function A0(n){let e=S0;return n.forEach((t,i)=>e=e.insert(t,i.overlayedDocument)),e}function Gr(){return ga()}function x0(){return ga()}function ga(){return new Eo(n=>n.toString(),(n,e)=>n.isEqual(e))}const ZP=new Dt(qe.comparator),JP=new rn(qe.comparator);function ct(...n){let e=JP;for(const t of n)e=e.add(t);return e}const $P=new rn(gt);function eL(){return $P}/** 5443 * @license 5444 * Copyright 2020 Google LLC 5445 * 5446 * Licensed under the Apache License, Version 2.0 (the "License"); 5447 * you may not use this file except in compliance with the License. 5448 * You may obtain a copy of the License at 5449 * 5450 * http://www.apache.org/licenses/LICENSE-2.0 5451 * 5452 * Unless required by applicable law or agreed to in writing, software 5453 * distributed under the License is distributed on an "AS IS" BASIS, 5454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5455 * See the License for the specific language governing permissions and 5456 * limitations under the License. 5457 */function w0(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Al(e)?"-0":e}}function I0(n){return{integerValue:""+n}}function tL(n,e){return PP(e)?I0(e):w0(n,e)}/** 5458 * @license 5459 * Copyright 2018 Google LLC 5460 * 5461 * Licensed under the Apache License, Version 2.0 (the "License"); 5462 * you may not use this file except in compliance with the License. 5463 * You may obtain a copy of the License at 5464 * 5465 * http://www.apache.org/licenses/LICENSE-2.0 5466 * 5467 * Unless required by applicable law or agreed to in writing, software 5468 * distributed under the License is distributed on an "AS IS" BASIS, 5469 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5470 * See the License for the specific language governing permissions and 5471 * limitations under the License. 5472 */class tu{constructor(){this._=void 0}}function nL(n,e,t){return n instanceof Il?function(r,s){const o={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}};return s&&fp(s)&&(s=_p(s)),s&&(o.fields.__previous_value__=s),{mapValue:o}}(t,e):n instanceof Na?C0(n,e):n instanceof ka?R0(n,e):function(r,s){const o=M0(r,s),a=Dm(o)+Dm(r.Pe);return Eh(o)&&Eh(r.Pe)?I0(a):w0(r.serializer,a)}(n,e)}function iL(n,e,t){return n instanceof Na?C0(n,e):n instanceof ka?R0(n,e):t}function M0(n,e){return n instanceof Ml?function(i){return Eh(i)||function(s){return!!s&&"doubleValue"in s}(i)}(e)?e:{integerValue:0}:null}class Il extends tu{}class Na extends tu{constructor(e){super(),this.elements=e}}function C0(n,e){const t=P0(e);for(const i of n.elements)t.some(r=>
5472Ti(r,i))||t.push(i);return{arrayValue:{values:t}}}class ka extends tu{constructor(e){super(),this.elements=e}}function R0(n,e){let t=P0(e);for(const i of n.elements)t=t.filter(r=>!Ti(r,i));return{arrayValue:{values:t}}}class Ml extends tu{constructor(e,t){super(),this.serializer=e,this.Pe=t}}function Dm(n){return Ht(n.integerValue||n.doubleValue)}function P0(n){return mp(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function rL(n,e){return n.field.isEqual(e.field)&&function(i,r){return i instanceof Na&&r instanceof Na||i instanceof ka&&r instanceof ka?no(i.elements,r.elements,Ti):i instanceof Ml&&r instanceof Ml?Ti(i.Pe,r.Pe):i instanceof Il&&r instanceof Il}(n.transform,e.transform)}class sL{constructor(e,t){this.version=e,this.transformResults=t}}class Ki{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ki}static exists(e){return new Ki(void 0,e)}static updateTime(e){return new Ki(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function sl(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class nu{}function L0(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new N0(n.key,Ki.none()):new ja(n.key,n.data,Ki.none());{const t=n.data,i=Hn.empty();let r=new rn(nn.comparator);for(let s of e.fields)if(!r.has(s)){let o=t.field(s);o===null&&s.length>1&&(s=s.popLast(),o=t.field(s)),o===null?i.delete(s):i.set(s,o),r=r.add(s)}return new is(n.key,i,new ii(r.toArray()),Ki.none())}}function oL(n,e,t){n instanceof ja?function(r,s,o){const a=r.value.clone(),c=km(r.fieldTransforms,s,o.transformResults);a.setAll(c),s.convertToFoundDocument(o.version,a).setHasCommittedMutations()}(n,e,t):n instanceof is?function(r,s,o){if(!sl(r.precondition,s))return void s.convertToUnknownDocument(o.version);const a=km(r.fieldTransforms,s,o.transformResults),c=s.data;c.setAll(D0(r)),c.setAll(a),s.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(n,e,t):function(r,s,o){s.convertToNoDocument(o.version).setHasCommittedMutations()}(0,e,t)}function va(n,e,t,i){return n instanceof ja?function(s,o,a,c){if(!sl(s.precondition,o))return a;const l=s.value.clone(),d=Um(s.fieldTransforms,c,o);return l.setAll(d),o.convertToFoundDocument(o.version,l).setHasLocalMutations(),null}(n,e,t,i):n instanceof is?function(s,o,a,c){if(!sl(s.precondition,o))return a;const l=Um(s.fieldTransforms,c,o),d=o.data;return d.setAll(D0(s)),d.setAll(l),o.convertToFoundDocument(o.version,d).setHasLocalMutations(),a===null?null:a.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(h=>h.field))}(n,e,t,i):function(s,o,a){return sl(s.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):a}(n,e,t)}function aL(n,e){let t=null;for(const i of n.fieldTransforms){const r=e.data.field(i.field),s=M0(i.transform,r||null);s!=null&&(t===null&&(t=Hn.empty()),t.set(i.field,s))}return t||null}function Nm(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(i,r){return i===void 0&&r===void 0||!(!i||!r)&&no(i,r,(s,o)=>rL(s,o))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class ja extends nu{constructor(e,t,i,r=[]){super(),this.key=e,this.value=t,this.precondition=i,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class is extends nu{constructor(e,t,i,r,s=[]){super(),this.key=e,this.data=t,this.fieldMask=i,this.precondition=r,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function D0(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const i=n.data.field(t);e.set(t,i)}}),e}function km(n,e,t){const i=new Map;It(n.length===t.length);for(let r=0;r<t.length;r++){const s=n[r],o=s.transform,a=e.data.field(s.field);i.set(s.field,iL(o,a,t[r]))}return i}function Um(n,e,t){const i=new Map;for(const r of n){const s=r.transform,o=t.data.field(r.field);i.set(r.field,nL(s,o,e))}return i}class N0 extends nu{constructor(e,t){super(),this.key=e,this.prec
5472ondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class cL extends nu{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/** 5473 * @license 5474 * Copyright 2017 Google LLC 5475 * 5476 * Licensed under the Apache License, Version 2.0 (the "License"); 5477 * you may not use this file except in compliance with the License. 5478 * You may obtain a copy of the License at 5479 * 5480 * http://www.apache.org/licenses/LICENSE-2.0 5481 * 5482 * Unless required by applicable law or agreed to in writing, software 5483 * distributed under the License is distributed on an "AS IS" BASIS, 5484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5485 * See the License for the specific language governing permissions and 5486 * limitations under the License. 5487 */class lL{constructor(e,t,i,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=i,this.mutations=r}applyToRemoteDocument(e,t){const i=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const s=this.mutations[r];s.key.isEqual(e.key)&&oL(s,e,i[r])}}applyToLocalView(e,t){for(const i of this.baseMutations)i.key.isEqual(e.key)&&(t=va(i,e,t,this.localWriteTime));for(const i of this.mutations)i.key.isEqual(e.key)&&(t=va(i,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const i=x0();return this.mutations.forEach(r=>{const s=e.get(r.key),o=s.overlayedDocument;let a=this.applyToLocalView(o,s.mutatedFields);a=t.has(r.key)?null:a;const c=L0(o,a);c!==null&&i.set(r.key,c),o.isValidDocument()||o.convertToNoDocument($e.min())}),i}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),ct())}isEqual(e){return this.batchId===e.batchId&&no(this.mutations,e.mutations,(t,i)=>Nm(t,i))&&no(this.baseMutations,e.baseMutations,(t,i)=>Nm(t,i))}}class Ep{constructor(e,t,i,r){this.batch=e,this.commitVersion=t,this.mutationResults=i,this.docVersions=r}static from(e,t,i){It(e.mutations.length===i.length);let r=function(){return ZP}();const s=e.mutations;for(let o=0;o<s.length;o++)r=r.insert(s[o].key,i[o].version);return new Ep(e,t,i,r)}}/** 5488 * @license 5489 * Copyright 2022 Google LLC 5490 * 5491 * Licensed under the Apache License, Version 2.0 (the "License"); 5492 * you may not use this file except in compliance with the License. 5493 * You may obtain a copy of the License at 5494 * 5495 * http://www.apache.org/licenses/LICENSE-2.0 5496 * 5497 * Unless required by applicable law or agreed to in writing, software 5498 * distributed under the License is distributed on an "AS IS" BASIS, 5499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5500 * See the License for the specific language governing permissions and 5501 * limitations under the License. 5502 */class uL{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{ 5503 largestBatchId: ${this.largestBatchId}, 5504 mutation: ${this.mutation.toString()} 5505 }`}}/** 5506 * @license 5507 * Copyright 2017 Google LLC 5508 * 5509 * Licensed under the Apache License, Version 2.0 (the "License"); 5510 * you may not use this file except in compliance with the License. 5511 * You may obtain a copy of the License at 5512 * 5513 * http://www.apache.org/licenses/LICENSE-2.0 5514 * 5515 * Unless required by applicable law or agreed to in writing, software 5516 * distributed under the License is distributed on an "AS IS" BASIS, 5517 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5518 * See the License for the specific language governing permissions and 5519 * limitations under the License. 5520 */class dL{constructor(e,t){this.count=e,this.unchangedNames=t}}/** 5521 * @license 5522 * Copyright 2017 Google LLC 5523 * 5524 * Licensed under the Apache License, Version 2.0 (the "License"); 5525 * you may not use this file except in compliance with the License. 5526 * You may obtain a copy of the License at 5527 * 5528 * http://www.apache.org/licenses/LICENSE-2.0 5529 * 5530 * Unless required by applicable law or agreed to in writing, software 5531 * distributed under the License is distributed on an "AS IS" BASIS, 5532 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5533 * See the License for the specific language governing permissions and 5534 * limitations under the License. 5535 */var zt,lt;function hL(n){switch(n){default:return Je();case le.CANCELLED:case le.UNKNOWN:case le.DEADLINE_EXCEEDED:case le.RESOURCE_EXHAUSTED:case le.INTERNAL:case le.UNAVAILABLE:case le.UNAUTHENTICATED:return!1;case le.INVALID_ARGUMENT:case le.NOT_FOUND:case le.ALREADY_EXISTS:case le.PERMISSION_DENIED:case le.FAILED_PRECONDITION:case le.ABORTED:case le.OUT_OF_RANGE:case le.UNIMPLEMENT
5535ED:case le.DATA_LOSS:return!0}}function k0(n){if(n===void 0)return Ji("GRPC error has no .code"),le.UNKNOWN;switch(n){case zt.OK:return le.OK;case zt.CANCELLED:return le.CANCELLED;case zt.UNKNOWN:return le.UNKNOWN;case zt.DEADLINE_EXCEEDED:return le.DEADLINE_EXCEEDED;case zt.RESOURCE_EXHAUSTED:return le.RESOURCE_EXHAUSTED;case zt.INTERNAL:return le.INTERNAL;case zt.UNAVAILABLE:return le.UNAVAILABLE;case zt.UNAUTHENTICATED:return le.UNAUTHENTICATED;case zt.INVALID_ARGUMENT:return le.INVALID_ARGUMENT;case zt.NOT_FOUND:return le.NOT_FOUND;case zt.ALREADY_EXISTS:return le.ALREADY_EXISTS;case zt.PERMISSION_DENIED:return le.PERMISSION_DENIED;case zt.FAILED_PRECONDITION:return le.FAILED_PRECONDITION;case zt.ABORTED:return le.ABORTED;case zt.OUT_OF_RANGE:return le.OUT_OF_RANGE;case zt.UNIMPLEMENTED:return le.UNIMPLEMENTED;case zt.DATA_LOSS:return le.DATA_LOSS;default:return Je()}}(lt=zt||(zt={}))[lt.OK=0]="OK",lt[lt.CANCELLED=1]="CANCELLED",lt[lt.UNKNOWN=2]="UNKNOWN",lt[lt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",lt[lt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",lt[lt.NOT_FOUND=5]="NOT_FOUND",lt[lt.ALREADY_EXISTS=6]="ALREADY_EXISTS",lt[lt.PERMISSION_DENIED=7]="PERMISSION_DENIED",lt[lt.UNAUTHENTICATED=16]="UNAUTHENTICATED",lt[lt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",lt[lt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",lt[lt.ABORTED=10]="ABORTED",lt[lt.OUT_OF_RANGE=11]="OUT_OF_RANGE",lt[lt.UNIMPLEMENTED=12]="UNIMPLEMENTED",lt[lt.INTERNAL=13]="INTERNAL",lt[lt.UNAVAILABLE=14]="UNAVAILABLE",lt[lt.DATA_LOSS=15]="DATA_LOSS";/** 5536 * @license 5537 * Copyright 2023 Google LLC 5538 * 5539 * Licensed under the Apache License, Version 2.0 (the "License"); 5540 * you may not use this file except in compliance with the License. 5541 * You may obtain a copy of the License at 5542 * 5543 * http://www.apache.org/licenses/LICENSE-2.0 5544 * 5545 * Unless required by applicable law or agreed to in writing, software 5546 * distributed under the License is distributed on an "AS IS" BASIS, 5547 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5548 * See the License for the specific language governing permissions and 5549 * limitations under the License. 5550 */function pL(){return new TextEncoder}/** 5551 * @license 5552 * Copyright 2022 Google LLC 5553 * 5554 * Licensed under the Apache License, Version 2.0 (the "License"); 5555 * you may not use this file except in compliance with the License. 5556 * You may obtain a copy of the License at 5557 * 5558 * http://www.apache.org/licenses/LICENSE-2.0 5559 * 5560 * Unless required by applicable law or agreed to in writing, software 5561 * distributed under the License is distributed on an "AS IS" BASIS, 5562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5563 * See the License for the specific language governing permissions and 5564 * limitations under the License. 5565 */const fL=new Xr([4294967295,4294967295],0);function Om(n){const e=pL().encode(n),t=new i0;return t.update(e),new Uint8Array(t.digest())}function Fm(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),i=e.getUint32(4,!0),r=e.getUint32(8,!0),s=e.getUint32(12,!0);return[new Xr([t,i],0),new Xr([r,s],0)]}class Tp{constructor(e,t,i){if(this.bitmap=e,this.padding=t,this.hashCount=i,t<0||t>=8)throw new aa(`Invalid padding: ${t}`);if(i<0)throw new aa(`Invalid hash count: ${i}`);if(e.length>0&&this.hashCount===0)throw new aa(`Invalid hash count: ${i}`);if(e.length===0&&t!==0)throw new aa(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=Xr.fromNumber(this.Ie)}Ee(e,t,i){let r=e.add(t.multiply(Xr.fromNumber(i)));return r.compare(fL)===1&&(r=new Xr([r.getBits(0),r.getBits(1)],0)),r.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<<e%8)!=0}mightContain(e){if(this.Ie===0)return!1;const t=Om(e),[i,r]=Fm(t);for(let s=0;s<this.hashCount;s++){const o=this.Ee(i,r,s);if(!this.de(o))return!1}return!0}static create(e,t,i){const r=e%8==0?0:8-e%8,s=new Uint8Array(Math.ceil(e/8)),o=new Tp(s,r,t);return i.forEach(a=>o.insert(a)),o}insert(e){if(this.Ie===0)return;const t=Om(e),[i,r]=Fm(t);for(let s=0;s<this.hashCount;s++){const o=this.Ee(i,r,s);this.Ae(o)}}Ae(e){const t=Math.floor(e/8),i=e%8;this.bitmap[t]|=1<<i}}
5565class aa extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/** 5566 * @license 5567 * Copyright 2017 Google LLC 5568 * 5569 * Licensed under the Apache License, Version 2.0 (the "License"); 5570 * you may not use this file except in compliance with the License. 5571 * You may obtain a copy of the License at 5572 * 5573 * http://www.apache.org/licenses/LICENSE-2.0 5574 * 5575 * Unless required by applicable law or agreed to in writing, software 5576 * distributed under the License is distributed on an "AS IS" BASIS, 5577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5578 * See the License for the specific language governing permissions and 5579 * limitations under the License. 5580 */class iu{constructor(e,t,i,r,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=i,this.documentUpdates=r,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,i){const r=new Map;return r.set(e,Ka.createSynthesizedTargetChangeForCurrentChange(e,t,i)),new iu($e.min(),r,new Dt(gt),$i(),ct())}}class Ka{constructor(e,t,i,r,s){this.resumeToken=e,this.current=t,this.addedDocuments=i,this.modifiedDocuments=r,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,i){return new Ka(i,t,ct(),ct(),ct())}}/** 5581 * @license 5582 * Copyright 2017 Google LLC 5583 * 5584 * Licensed under the Apache License, Version 2.0 (the "License"); 5585 * you may not use this file except in compliance with the License. 5586 * You may obtain a copy of the License at 5587 * 5588 * http://www.apache.org/licenses/LICENSE-2.0 5589 * 5590 * Unless required by applicable law or agreed to in writing, software 5591 * distributed under the License is distributed on an "AS IS" BASIS, 5592 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5593 * See the License for the specific language governing permissions and 5594 * limitations under the License. 5595 */class ol{constructor(e,t,i,r){this.Re=e,this.removedTargetIds=t,this.key=i,this.Ve=r}}class U0{constructor(e,t){this.targetId=e,this.me=t}}class O0{constructor(e,t,i=sn.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=i,this.cause=r}}class Vm{constructor(){this.fe=0,this.ge=zm(),this.pe=sn.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return this.fe!==0}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}Ce(){let e=ct(),t=ct(),i=ct();return this.ge.forEach((r,s)=>{switch(s){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:i=i.add(r);break;default:Je()}}),new Ka(this.pe,this.ye,e,t,i)}ve(){this.we=!1,this.ge=zm()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,It(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class _L{constructor(e){this.Le=e,this.Be=new Map,this.ke=$i(),this.qe=Bm(),this.Qe=new Dt(gt)}Ke(e){for(const t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(const t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,t=>{const i=this.Ge(t);switch(e.state){case 0:this.ze(t)&&i.De(e.resumeToken);break;case 1:i.Oe(),i.Se||i.ve(),i.De(e.resumeToken);break;case 2:i.Oe(),i.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(i.Ne(),i.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),i.De(e.resumeToken));break;default:Je()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach((i,r)=>{this.ze(r)&&t(r)})}He(e){const t=e.targetId,i=e.me.count,r=this.Je(t);if(r){const s=r.target;if(bh(s))if(i===0){const o=new qe(s.path);this.Ue(t,o,hn.newNoDocument(o,$e.min()))}else It(i===1);else{const o=this.Ye(t);if(o!==i){const a=this.Ze(e),c=a?this.Xe(a,e,o):1;if(c!==0){this.je(t);const l=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,l)}}}}}Ze(e){const t=e.me.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:i="",padding:r=0},hashCount:s=0}=t;let o,a;try{o=$r(i).toUint8Array()}catch(c){if(c instanceof p0)return to("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{a=new Tp(o,r,s)}catch(c){return to(c instanceof aa?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return a.Ie===0?null:a}Xe(e,t,i){return t.me.count===i-this.nt(e,t.targetId)?0:2}nt(e,t){const i=this.Le.getRemoteKeysForTarget(t);let r=0;
5595return i.forEach(s=>{const o=this.Le.tt(),a=`projects/${o.projectId}/databases/${o.database}/documents/${s.path.canonicalString()}`;e.mightContain(a)||(this.Ue(t,s,null),r++)}),r}rt(e){const t=new Map;this.Be.forEach((s,o)=>{const a=this.Je(o);if(a){if(s.current&&bh(a.target)){const c=new qe(a.target.path);this.ke.get(c)!==null||this.it(o,c)||this.Ue(o,c,hn.newNoDocument(c,e))}s.be&&(t.set(o,s.Ce()),s.ve())}});let i=ct();this.qe.forEach((s,o)=>{let a=!0;o.forEachWhile(c=>{const l=this.Je(c);return!l||l.purpose==="TargetPurposeLimboResolution"||(a=!1,!1)}),a&&(i=i.add(s))}),this.ke.forEach((s,o)=>o.setReadTime(e));const r=new iu(e,t,this.Qe,this.ke,i);return this.ke=$i(),this.qe=Bm(),this.Qe=new Dt(gt),r}$e(e,t){if(!this.ze(e))return;const i=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,i),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,i){if(!this.ze(e))return;const r=this.Ge(e);this.it(e,t)?r.Fe(t,1):r.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),i&&(this.ke=this.ke.insert(t,i))}removeTarget(e){this.Be.delete(e)}Ye(e){const t=this.Ge(e).Ce();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new Vm,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new rn(gt),this.qe=this.qe.insert(e,t)),t}ze(e){const t=this.Je(e)!==null;return t||Le("WatchChangeAggregator","Detected inactive target",e),t}Je(e){const t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new Vm),this.Le.getRemoteKeysForTarget(e).forEach(t=>{this.Ue(e,t,null)})}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}function Bm(){return new Dt(qe.comparator)}function zm(){return new Dt(qe.comparator)}const mL=(()=>({asc:"ASCENDING",desc:"DESCENDING"}))(),gL=(()=>({"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"}))(),vL=(()=>({and:"AND",or:"OR"}))();class yL{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Ah(n,e){return n.useProto3Json||Zl(e)?e:{value:e}}function Cl(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function F0(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function EL(n,e){return Cl(n,e.toTimestamp())}function gi(n){return It(!!n),$e.fromTimestamp(function(t){const i=Sr(t);return new Wt(i.seconds,i.nanos)}(n))}function bp(n,e){return xh(n,e).canonicalString()}function xh(n,e){const t=function(r){return new Ut(["projects",r.projectId,"databases",r.database])}(n).child("documents");return e===void 0?t:t.child(e)}function V0(n){const e=Ut.fromString(n);return It(W0(e)),e}function wh(n,e){return bp(n.databaseId,e.path)}function sd(n,e){const t=V0(e);if(t.get(1)!==n.databaseId.projectId)throw new We(le.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new We(le.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new qe(z0(t))}function B0(n,e){return bp(n.databaseId,e)}function TL(n){const e=V0(n);return e.length===4?Ut.emptyPath():z0(e)}function Ih(n){return new Ut(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function z0(n){return It(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function Hm(n,e,t){return{name:wh(n,e),fields:t.value.mapValue.fields}}function bL(n,e){let t;if("targetChange"in e){e.targetChange;const i=function(l){return l==="NO_CHANGE"?0:l==="ADD"?1:l==="REMOVE"?2:l==="CURRENT"?3:l==="RESET"?4:Je()}(e.targetChange.targetChangeType||"NO_CHANGE"),r=e.targetChange.targetIds||[],s=function(l,d){return l.useProto3Json?(It(d===void 0||typeof d=="string"),sn.fromBase64String(d||"")):(It(d===void 0||d instanceof Buffer||d instanceof Uint8Array),sn.fromUint8Array(d||new Uint8Array))}(n,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(l){const d=l.code===void 0?le.UNKNOWN:k0(l.code);return new We(d,l.message||"")}(o);t=new O0(i,r,s,a||null)}else if("documentChange"in e){e.documentChange;const i=e.documentChange;i.document,i.document.name,i.document.updateTime;const r=sd(n,i.document.name),s=gi(i.document.updateTime),o=i.document.createTime?gi(i.document.createTime):$e.min(),a=new Hn({mapValue:{fields:i.document.fields}}),c=hn.newFoundDocument(r,s,o,a),l=i.targetIds||[],d=i.removedTargetIds||[];t=new ol(l,d,c.key,c)}else if("documentDelete"in e){e.documentDelete;const i=e.documentDelete;i.document;const r=sd(n,i.document),s=i.readTime?gi(i.readTime):$e.min(),o=hn.newNoDocument(r,s),a=i.removedTargetIds||[];t=new ol([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const i=e.documentRemove;i.document;const r=sd(n,i.document),s=i.removedTargetIds||[];t=new ol([],s,r,null)}else{if(!("filter"in e))return Je();{e.filter;const i=e.filter;i.targetId;const{count:r=0,unchangedNames:s}=i,o=new dL(r,s),a=i.targetId;
5595t=new U0(a,o)}}return t}function SL(n,e){let t;if(e instanceof ja)t={update:Hm(n,e.key,e.value)};else if(e instanceof N0)t={delete:wh(n,e.key)};else if(e instanceof is)t={update:Hm(n,e.key,e.data),updateMask:LL(e.fieldMask)};else{if(!(e instanceof cL))return Je();t={verify:wh(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(i=>function(s,o){const a=o.transform;if(a instanceof Il)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(a instanceof Na)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:a.elements}};if(a instanceof ka)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:a.elements}};if(a instanceof Ml)return{fieldPath:o.field.canonicalString(),increment:a.Pe};throw Je()}(0,i))),e.precondition.isNone||(t.currentDocument=function(r,s){return s.updateTime!==void 0?{updateTime:EL(r,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:Je()}(n,e.precondition)),t}function AL(n,e){return n&&n.length>0?(It(e!==void 0),n.map(t=>function(r,s){let o=r.updateTime?gi(r.updateTime):gi(s);return o.isEqual($e.min())&&(o=gi(s)),new sL(o,r.transformResults||[])}(t,e))):[]}function xL(n,e){return{documents:[B0(n,e.path)]}}function wL(n,e){const t={structuredQuery:{}},i=e.path;let r;e.collectionGroup!==null?(r=i,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(r=i.popLast(),t.structuredQuery.from=[{collectionId:i.lastSegment()}]),t.parent=B0(n,r);const s=function(l){if(l.length!==0)return G0(bi.create(l,"and"))}(e.filters);s&&(t.structuredQuery.where=s);const o=function(l){if(l.length!==0)return l.map(d=>function(p){return{field:Ps(p.field),direction:CL(p.dir)}}(d))}(e.orderBy);o&&(t.structuredQuery.orderBy=o);const a=Ah(n,e.limit);return a!==null&&(t.structuredQuery.limit=a),e.startAt&&(t.structuredQuery.startAt=function(l){return{before:l.inclusive,values:l.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(l){return{before:!l.inclusive,values:l.position}}(e.endAt)),{_t:t,parent:r}}function IL(n){let e=TL(n.parent);const t=n.structuredQuery,i=t.from?t.from.length:0;let r=null;if(i>0){It(i===1);const d=t.from[0];d.allDescendants?r=d.collectionId:e=e.child(d.collectionId)}let s=[];t.where&&(s=function(h){const p=H0(h);return p instanceof bi&&g0(p)?p.getFilters():[p]}(t.where));let o=[];t.orderBy&&(o=function(h){return h.map(p=>function(g){return new wl(Ls(g.field),function(m){switch(m){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(g.direction))}(p))}(t.orderBy));let a=null;t.limit&&(a=function(h){let p;return p=typeof h=="object"?h.value:h,Zl(p)?null:p}(t.limit));let c=null;t.startAt&&(c=function(h){const p=!!h.before,_=h.values||[];return new xl(_,p)}(t.startAt));let l=null;return t.endAt&&(l=function(h){const p=!h.before,_=h.values||[];return new xl(_,p)}(t.endAt)),qP(e,r,o,s,a,"F",c,l)}function ML(n,e){const t=function(r){switch(r){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Je()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function H0(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const i=Ls(t.unaryFilter.field);return Gt.create(i,"==",{doubleValue:NaN});case"IS_NULL":const r=Ls(t.unaryFilter.field);return Gt.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const s=Ls(t.unaryFilter.field);return Gt.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=Ls(t.unaryFilter.field);return Gt.create(o,"!=",{nullValue:"NULL_VALUE"});default:return Je()}}(n):n.fieldFilter!==void 0?function(t){return Gt.create(Ls(t.fieldFilter.field),function(r){switch(r){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return Je()}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return bi.create(t.compositeFilter.filters.map(i=>H0(i)),function(r){switch(r){case"AND":return"and";case"OR":return"or";default:return Je()}}(t.compositeFilter.op))}(n):Je()}function CL(n){return mL[n]}function RL(n){return gL[n]}function PL(n){return vL[n]}function Ps(n){return{fieldPath:n.canonicalString()}}function Ls(n){return nn.fromServerFormat(n.fieldPath)}function G0(n){return n instanceof Gt?function(t){if(t.op==="=="){if(Mm(t.value))return{unaryFilter:{field:Ps(t.field),op:"IS_NAN"}};if(Im(t.value))return{unaryFilter:{field:Ps(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Mm(t.value))return{unaryFilter:{field:Ps(t.field),op:"IS_NOT_NA
5595N"}};if(Im(t.value))return{unaryFilter:{field:Ps(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Ps(t.field),op:RL(t.op),value:t.value}}}(n):n instanceof bi?function(t){const i=t.getFilters().map(r=>G0(r));return i.length===1?i[0]:{compositeFilter:{op:PL(t.op),filters:i}}}(n):Je()}function LL(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function W0(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/** 5596 * @license 5597 * Copyright 2017 Google LLC 5598 * 5599 * Licensed under the Apache License, Version 2.0 (the "License"); 5600 * you may not use this file except in compliance with the License. 5601 * You may obtain a copy of the License at 5602 * 5603 * http://www.apache.org/licenses/LICENSE-2.0 5604 * 5605 * Unless required by applicable law or agreed to in writing, software 5606 * distributed under the License is distributed on an "AS IS" BASIS, 5607 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5608 * See the License for the specific language governing permissions and 5609 * limitations under the License. 5610 */class gr{constructor(e,t,i,r,s=$e.min(),o=$e.min(),a=sn.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=t,this.purpose=i,this.sequenceNumber=r,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a,this.expectedCount=c}withSequenceNumber(e){return new gr(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new gr(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new gr(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new gr(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/** 5611 * @license 5612 * Copyright 2017 Google LLC 5613 * 5614 * Licensed under the Apache License, Version 2.0 (the "License"); 5615 * you may not use this file except in compliance with the License. 5616 * You may obtain a copy of the License at 5617 * 5618 * http://www.apache.org/licenses/LICENSE-2.0 5619 * 5620 * Unless required by applicable law or agreed to in writing, software 5621 * distributed under the License is distributed on an "AS IS" BASIS, 5622 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5623 * See the License for the specific language governing permissions and 5624 * limitations under the License. 5625 */class DL{constructor(e){this.ct=e}}function NL(n){const e=IL({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Sh(e,e.limit,"L"):e}/** 5626 * @license 5627 * Copyright 2019 Google LLC 5628 * 5629 * Licensed under the Apache License, Version 2.0 (the "License"); 5630 * you may not use this file except in compliance with the License. 5631 * You may obtain a copy of the License at 5632 * 5633 * http://www.apache.org/licenses/LICENSE-2.0 5634 * 5635 * Unless required by applicable law or agreed to in writing, software 5636 * distributed under the License is distributed on an "AS IS" BASIS, 5637 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5638 * See the License for the specific language governing permissions and 5639 * limitations under the License. 5640 */class kL{constructor(){this.an=new UL}addToCollectionParentIndex(e,t){return this.an.add(t),oe.resolve()}getCollectionParents(e,t){return oe.resolve(this.an.getEntries(t))}addFieldIndex(e,t){return oe.resolve()}deleteFieldIndex(e,t){return oe.resolve()}deleteAllFieldIndexes(e){return oe.resolve()}createTargetIndexes(e,t){return oe.resolve()}getDocumentsMatchingTarget(e,t){return oe.resolve(null)}getIndexType(e,t){return oe.resolve(0)}getFieldIndexes(e,t){return oe.resolve([])}getNextCollectionGroupToUpdate(e){return oe.resolve(null)}getMinOffset(e,t){return oe.resolve(br.min())}getMinOffsetFromCollectionGroup(e,t){return oe.resolve(br.min())}updateCollectionGroup(e,t,i){return oe.resolve()}updateIndexEntries(e,t){return oe.resolve()}}class UL{constructor(){this.index={}}add(e){const t=e.lastSegment(),i=e.popLast(),r=this.index[t]||new rn(Ut.comparator),s=!r.has(i);return this.index[t]=r.add(i),s}has(e){const t=e.lastSegment(),i=e.popLast(),r=this.index[t];return r&&r.has(i)}getEntries(e){return(this.index[e]||new rn(Ut.comparator)).toArray()}}/** 5641 * @license 5642 * Copyright 2017 Google LLC 5643 * 5644 * Licensed under the Apache License, Version 2.0 (the "License");
5645 * you may not use this file except in compliance with the License. 5646 * You may obtain a copy of the License at 5647 * 5648 * http://www.apache.org/licenses/LICENSE-2.0 5649 * 5650 * Unless required by applicable law or agreed to in writing, software 5651 * distributed under the License is distributed on an "AS IS" BASIS, 5652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5653 * See the License for the specific language governing permissions and 5654 * limitations under the License. 5655 */class so{constructor(e){this.Nn=e}next(){return this.Nn+=2,this.Nn}static Ln(){return new so(0)}static Bn(){return new so(-1)}}/** 5656 * @license 5657 * Copyright 2017 Google LLC 5658 * 5659 * Licensed under the Apache License, Version 2.0 (the "License"); 5660 * you may not use this file except in compliance with the License. 5661 * You may obtain a copy of the License at 5662 * 5663 * http://www.apache.org/licenses/LICENSE-2.0 5664 * 5665 * Unless required by applicable law or agreed to in writing, software 5666 * distributed under the License is distributed on an "AS IS" BASIS, 5667 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5668 * See the License for the specific language governing permissions and 5669 * limitations under the License. 5670 */class OL{constructor(){this.changes=new Eo(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,hn.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const i=this.changes.get(t);return i!==void 0?oe.resolve(i):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/** 5671 * @license 5672 * Copyright 2017 Google LLC 5673 * 5674 * Licensed under the Apache License, Version 2.0 (the "License"); 5675 * you may not use this file except in compliance with the License. 5676 * You may obtain a copy of the License at 5677 * 5678 * http://www.apache.org/licenses/LICENSE-2.0 5679 * 5680 * Unless required by applicable law or agreed to in writing, software 5681 * distributed under the License is distributed on an "AS IS" BASIS, 5682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5683 * See the License for the specific language governing permissions and 5684 * limitations under the License. 5685 *//** 5686 * @license 5687 * Copyright 2022 Google LLC 5688 * 5689 * Licensed under the Apache License, Version 2.0 (the "License"); 5690 * you may not use this file except in compliance with the License. 5691 * You may obtain a copy of the License at 5692 * 5693 * http://www.apache.org/licenses/LICENSE-2.0 5694 * 5695 * Unless required by applicable law or agreed to in writing, software 5696 * distributed under the License is distributed on an "AS IS" BASIS, 5697 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5698 * See the License for the specific language governing permissions and 5699 * limitations under the License. 5700 */class FL{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/** 5701 * @license 5702 * Copyright 2017 Google LLC 5703 * 5704 * Licensed under the Apache License, Version 2.0 (the "License"); 5705 * you may not use this file except in compliance with the License. 5706 * You may obtain a copy of the License at 5707 * 5708 * http://www.apache.org/licenses/LICENSE-2.0 5709 * 5710 * Unless required by applicable law or agreed to in writing, software 5711 * distributed under the License is distributed on an "AS IS" BASIS, 5712 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5713 * See the License for the specific language governing permissions and 5714 * limitations under the License. 5715 */class VL{constructor(e,t,i,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=i,this.indexManager=r}getDocument(e,t){let i=null;return this.documentOverlayCache.getOverlay(e,t).next(r=>(i=r,this.remoteDocumentCache.getEntry(e,t))).next(r=>(i!==null&&va(i.mutation,r,ii.empty(),Wt.now()),r))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(i=>this.getLocalViewOfDocuments(e,i,ct()).next(()=>i))}getLocalViewOfDocuments(e,t,i=ct()){const r=Gr();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,i).next(s=>{let o=oa();
5715return s.forEach((a,c)=>{o=o.insert(a,c.overlayedDocument)}),o}))}getOverlayedDocuments(e,t){const i=Gr();return this.populateOverlays(e,i,t).next(()=>this.computeViews(e,t,i,ct()))}populateOverlays(e,t,i){const r=[];return i.forEach(s=>{t.has(s)||r.push(s)}),this.documentOverlayCache.getOverlays(e,r).next(s=>{s.forEach((o,a)=>{t.set(o,a)})})}computeViews(e,t,i,r){let s=$i();const o=ga(),a=function(){return ga()}();return t.forEach((c,l)=>{const d=i.get(l.key);r.has(l.key)&&(d===void 0||d.mutation instanceof is)?s=s.insert(l.key,l):d!==void 0?(o.set(l.key,d.mutation.getFieldMask()),va(d.mutation,l,d.mutation.getFieldMask(),Wt.now())):o.set(l.key,ii.empty())}),this.recalculateAndSaveOverlays(e,s).next(c=>(c.forEach((l,d)=>o.set(l,d)),t.forEach((l,d)=>{var h;return a.set(l,new FL(d,(h=o.get(l))!==null&&h!==void 0?h:null))}),a))}recalculateAndSaveOverlays(e,t){const i=ga();let r=new Dt((o,a)=>o-a),s=ct();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(o=>{for(const a of o)a.keys().forEach(c=>{const l=t.get(c);if(l===null)return;let d=i.get(c)||ii.empty();d=a.applyToLocalView(l,d),i.set(c,d);const h=(r.get(a.batchId)||ct()).add(c);r=r.insert(a.batchId,h)})}).next(()=>{const o=[],a=r.getReverseIterator();for(;a.hasNext();){const c=a.getNext(),l=c.key,d=c.value,h=x0();d.forEach(p=>{if(!s.has(p)){const _=L0(t.get(p),i.get(p));_!==null&&h.set(p,_),s=s.add(p)}}),o.push(this.documentOverlayCache.saveOverlays(e,l,h))}return oe.waitFor(o)}).next(()=>i)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(i=>this.recalculateAndSaveOverlays(e,i))}getDocumentsMatchingQuery(e,t,i,r){return function(o){return qe.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):XP(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,i,r):this.getDocumentsMatchingCollectionQuery(e,t,i,r)}getNextDocuments(e,t,i,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,i,r).next(s=>{const o=r-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,i.largestBatchId,r-s.size):oe.resolve(Gr());let a=-1,c=s;return o.next(l=>oe.forEach(l,(d,h)=>(a<h.largestBatchId&&(a=h.largestBatchId),s.get(d)?oe.resolve():this.remoteDocumentCache.getEntry(e,d).next(p=>{c=c.insert(d,p)}))).next(()=>this.populateOverlays(e,l,s)).next(()=>this.computeViews(e,c,l,ct())).next(d=>({batchId:a,changes:A0(d)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new qe(t)).next(i=>{let r=oa();return i.isFoundDocument()&&(r=r.insert(i.key,i)),r})}getDocumentsMatchingCollectionGroupQuery(e,t,i,r){const s=t.collectionGroup;let o=oa();return this.indexManager.getCollectionParents(e,s).next(a=>oe.forEach(a,c=>{const l=function(h,p){return new Jl(p,null,h.explicitOrderBy.slice(),h.filters.slice(),h.limit,h.limitType,h.startAt,h.endAt)}(t,c.child(s));return this.getDocumentsMatchingCollectionQuery(e,l,i,r).next(d=>{d.forEach((h,p)=>{o=o.insert(h,p)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,t,i,r){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,i.largestBatchId).next(o=>(s=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,i,s,r))).next(o=>{s.forEach((c,l)=>{const d=l.getKey();o.get(d)===null&&(o=o.insert(d,hn.newInvalidDocument(d)))});let a=oa();return o.forEach((c,l)=>{const d=s.get(c);d!==void 0&&va(d.mutation,l,ii.empty(),Wt.now()),eu(t,l)&&(a=a.insert(c,l))}),a})}}/** 5716 * @license 5717 * Copyright 2020 Google LLC 5718 * 5719 * Licensed under the Apache License, Version 2.0 (the "License"); 5720 * you may not use this file except in compliance with the License. 5721 * You may obtain a copy of the License at 5722 * 5723 * http://www.apache.org/licenses/LICENSE-2.0 5724 * 5725 * Unless required by applicable law or agreed to in writing, software 5726 * distributed under the License is distributed on an "AS IS" BASIS, 5727 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5728 * See the License for the specific language governing permissions and 5729 * limitations under the License.
5730 */class BL{constructor(e){this.serializer=e,this.lr=new Map,this.hr=new Map}getBundleMetadata(e,t){return oe.resolve(this.lr.get(t))}saveBundleMetadata(e,t){return this.lr.set(t.id,function(r){return{id:r.id,version:r.version,createTime:gi(r.createTime)}}(t)),oe.resolve()}getNamedQuery(e,t){return oe.resolve(this.hr.get(t))}saveNamedQuery(e,t){return this.hr.set(t.name,function(r){return{name:r.name,query:NL(r.bundledQuery),readTime:gi(r.readTime)}}(t)),oe.resolve()}}/** 5731 * @license 5732 * Copyright 2022 Google LLC 5733 * 5734 * Licensed under the Apache License, Version 2.0 (the "License"); 5735 * you may not use this file except in compliance with the License. 5736 * You may obtain a copy of the License at 5737 * 5738 * http://www.apache.org/licenses/LICENSE-2.0 5739 * 5740 * Unless required by applicable law or agreed to in writing, software 5741 * distributed under the License is distributed on an "AS IS" BASIS, 5742 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5743 * See the License for the specific language governing permissions and 5744 * limitations under the License. 5745 */class zL{constructor(){this.overlays=new Dt(qe.comparator),this.Pr=new Map}getOverlay(e,t){return oe.resolve(this.overlays.get(t))}getOverlays(e,t){const i=Gr();return oe.forEach(t,r=>this.getOverlay(e,r).next(s=>{s!==null&&i.set(r,s)})).next(()=>i)}saveOverlays(e,t,i){return i.forEach((r,s)=>{this.ht(e,t,s)}),oe.resolve()}removeOverlaysForBatchId(e,t,i){const r=this.Pr.get(i);return r!==void 0&&(r.forEach(s=>this.overlays=this.overlays.remove(s)),this.Pr.delete(i)),oe.resolve()}getOverlaysForCollection(e,t,i){const r=Gr(),s=t.length+1,o=new qe(t.child("")),a=this.overlays.getIteratorFrom(o);for(;a.hasNext();){const c=a.getNext().value,l=c.getKey();if(!t.isPrefixOf(l.path))break;l.path.length===s&&c.largestBatchId>i&&r.set(c.getKey(),c)}return oe.resolve(r)}getOverlaysForCollectionGroup(e,t,i,r){let s=new Dt((l,d)=>l-d);const o=this.overlays.getIterator();for(;o.hasNext();){const l=o.getNext().value;if(l.getKey().getCollectionGroup()===t&&l.largestBatchId>i){let d=s.get(l.largestBatchId);d===null&&(d=Gr(),s=s.insert(l.largestBatchId,d)),d.set(l.getKey(),l)}}const a=Gr(),c=s.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((l,d)=>a.set(l,d)),!(a.size()>=r)););return oe.resolve(a)}ht(e,t,i){const r=this.overlays.get(i.key);if(r!==null){const o=this.Pr.get(r.largestBatchId).delete(i.key);this.Pr.set(r.largestBatchId,o)}this.overlays=this.overlays.insert(i.key,new uL(t,i));let s=this.Pr.get(t);s===void 0&&(s=ct(),this.Pr.set(t,s)),this.Pr.set(t,s.add(i.key))}}/** 5746 * @license 5747 * Copyright 2024 Google LLC 5748 * 5749 * Licensed under the Apache License, Version 2.0 (the "License"); 5750 * you may not use this file except in compliance with the License. 5751 * You may obtain a copy of the License at 5752 * 5753 * http://www.apache.org/licenses/LICENSE-2.0 5754 * 5755 * Unless required by applicable law or agreed to in writing, software 5756 * distributed under the License is distributed on an "AS IS" BASIS, 5757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5758 * See the License for the specific language governing permissions and 5759 * limitations under the License. 5760 */class HL{constructor(){this.sessionToken=sn.EMPTY_BYTE_STRING}getSessionToken(e){return oe.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,oe.resolve()}}/** 5761 * @license 5762 * Copyright 2017 Google LLC 5763 * 5764 * Licensed under the Apache License, Version 2.0 (the "License"); 5765 * you may not use this file except in compliance with the License. 5766 * You may obtain a copy of the License at 5767 * 5768 * http://www.apache.org/licenses/LICENSE-2.0 5769 * 5770 * Unless required by applicable law or agreed to in writing, software 5771 * distributed under the License is distributed on an "AS IS" BASIS, 5772 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5773 * See the License for the specific language governing permissions and 5774 * limitations under the License. 5775 */class Sp{constructor(){this.Ir=new rn(Yt.Tr),this.Er=new rn(Yt.dr)}isEmpty(){return this.Ir.isEmpty()}addReference(e,t){const i=new Yt(e,t);this.Ir=this.Ir.add(i),this.Er=this.Er.add(i)}Ar(e,t){e.forEach(i=>
5775this.addReference(i,t))}removeReference(e,t){this.Rr(new Yt(e,t))}Vr(e,t){e.forEach(i=>this.removeReference(i,t))}mr(e){const t=new qe(new Ut([])),i=new Yt(t,e),r=new Yt(t,e+1),s=[];return this.Er.forEachInRange([i,r],o=>{this.Rr(o),s.push(o.key)}),s}gr(){this.Ir.forEach(e=>this.Rr(e))}Rr(e){this.Ir=this.Ir.delete(e),this.Er=this.Er.delete(e)}pr(e){const t=new qe(new Ut([])),i=new Yt(t,e),r=new Yt(t,e+1);let s=ct();return this.Er.forEachInRange([i,r],o=>{s=s.add(o.key)}),s}containsKey(e){const t=new Yt(e,0),i=this.Ir.firstAfterOrEqual(t);return i!==null&&e.isEqual(i.key)}}class Yt{constructor(e,t){this.key=e,this.yr=t}static Tr(e,t){return qe.comparator(e.key,t.key)||gt(e.yr,t.yr)}static dr(e,t){return gt(e.yr,t.yr)||qe.comparator(e.key,t.key)}}/** 5776 * @license 5777 * Copyright 2017 Google LLC 5778 * 5779 * Licensed under the Apache License, Version 2.0 (the "License"); 5780 * you may not use this file except in compliance with the License. 5781 * You may obtain a copy of the License at 5782 * 5783 * http://www.apache.org/licenses/LICENSE-2.0 5784 * 5785 * Unless required by applicable law or agreed to in writing, software 5786 * distributed under the License is distributed on an "AS IS" BASIS, 5787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5788 * See the License for the specific language governing permissions and 5789 * limitations under the License. 5790 */class GL{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.wr=1,this.Sr=new rn(Yt.Tr)}checkEmpty(e){return oe.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,i,r){const s=this.wr;this.wr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new lL(s,t,i,r);this.mutationQueue.push(o);for(const a of r)this.Sr=this.Sr.add(new Yt(a.key,s)),this.indexManager.addToCollectionParentIndex(e,a.key.path.popLast());return oe.resolve(o)}lookupMutationBatch(e,t){return oe.resolve(this.br(t))}getNextMutationBatchAfterBatchId(e,t){const i=t+1,r=this.Dr(i),s=r<0?0:r;return oe.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return oe.resolve(this.mutationQueue.length===0?-1:this.wr-1)}getAllMutationBatches(e){return oe.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const i=new Yt(t,0),r=new Yt(t,Number.POSITIVE_INFINITY),s=[];return this.Sr.forEachInRange([i,r],o=>{const a=this.br(o.yr);s.push(a)}),oe.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let i=new rn(gt);return t.forEach(r=>{const s=new Yt(r,0),o=new Yt(r,Number.POSITIVE_INFINITY);this.Sr.forEachInRange([s,o],a=>{i=i.add(a.yr)})}),oe.resolve(this.Cr(i))}getAllMutationBatchesAffectingQuery(e,t){const i=t.path,r=i.length+1;let s=i;qe.isDocumentKey(s)||(s=s.child(""));const o=new Yt(new qe(s),0);let a=new rn(gt);return this.Sr.forEachWhile(c=>{const l=c.key.path;return!!i.isPrefixOf(l)&&(l.length===r&&(a=a.add(c.yr)),!0)},o),oe.resolve(this.Cr(a))}Cr(e){const t=[];return e.forEach(i=>{const r=this.br(i);r!==null&&t.push(r)}),t}removeMutationBatch(e,t){It(this.vr(t.batchId,"removed")===0),this.mutationQueue.shift();let i=this.Sr;return oe.forEach(t.mutations,r=>{const s=new Yt(r.key,t.batchId);return i=i.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Sr=i})}xn(e){}containsKey(e,t){const i=new Yt(t,0),r=this.Sr.firstAfterOrEqual(i);return oe.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,oe.resolve()}vr(e,t){return this.Dr(e)}Dr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}br(e){const t=this.Dr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/** 5791 * @license 5792 * Copyright 2017 Google LLC 5793 * 5794 * Licensed under the Apache License, Version 2.0 (the "License"); 5795 * you may not use this file except in compliance with the License. 5796 * You may obtain a copy of the License at 5797 * 5798 * http://www.apache.org/licenses/LICENSE-2.0 5799 * 5800 * Unless required by applicable law or agreed to in writing, software 5801 * distributed under the License is distributed on an "AS IS" BASIS, 5802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5803 * See the License for the specific language governing permissions and 5804 * limitations under the License. 5805 */class WL{constructor(e){this.Fr=e,this.docs=function(){return new Dt(qe.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const i=t.key,r=this.docs.get(i),s=r?r.size:0,o=this.Fr(t);return this.docs=this.docs.insert(i,{document:t.mutableCopy(),size:o}),this.size+=o-s,this.indexManager.addToCollectionParentIndex(e,i.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const i=this.docs.get(t);return oe.resolve(i?i.document.mutableCopy():hn.newInvalidDocument(t))}getEntries(e,t){let i=$i();return t.forEach(r=>{const s=this.docs.get(r);i=i.insert(r,s?s.document.mutableCopy():hn.newInvalidDocument(r))}),oe.resolve(i)}getDocumentsMatchingQuery(e,t,i,r){let s=$i();const o=t.path,a=new qe(o.child("")),c=this.docs.getIteratorFrom(a);for(;c.hasNext();){const{key:l,value:{document:d}}=c.getNext();if(!o.isPrefixOf(l.path))break;l.path.length>o.length+1||IP(wP(d),i)<=0||(r.has(d.key)||eu(t,d))&&(s=s.insert(d.
5805key,d.mutableCopy()))}return oe.resolve(s)}getAllFromCollectionGroup(e,t,i,r){Je()}Mr(e,t){return oe.forEach(this.docs,i=>t(i))}newChangeBuffer(e){return new qL(this)}getSize(e){return oe.resolve(this.size)}}class qL extends OL{constructor(e){super(),this.ur=e}applyChanges(e){const t=[];return this.changes.forEach((i,r)=>{r.isValidDocument()?t.push(this.ur.addEntry(e,r)):this.ur.removeEntry(i)}),oe.waitFor(t)}getFromCache(e,t){return this.ur.getEntry(e,t)}getAllFromCache(e,t){return this.ur.getEntries(e,t)}}/** 5806 * @license 5807 * Copyright 2017 Google LLC 5808 * 5809 * Licensed under the Apache License, Version 2.0 (the "License"); 5810 * you may not use this file except in compliance with the License. 5811 * You may obtain a copy of the License at 5812 * 5813 * http://www.apache.org/licenses/LICENSE-2.0 5814 * 5815 * Unless required by applicable law or agreed to in writing, software 5816 * distributed under the License is distributed on an "AS IS" BASIS, 5817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5818 * See the License for the specific language governing permissions and 5819 * limitations under the License. 5820 */class XL{constructor(e){this.persistence=e,this.Or=new Eo(t=>gp(t),vp),this.lastRemoteSnapshotVersion=$e.min(),this.highestTargetId=0,this.Nr=0,this.Lr=new Sp,this.targetCount=0,this.Br=so.Ln()}forEachTarget(e,t){return this.Or.forEach((i,r)=>t(r)),oe.resolve()}getLastRemoteSnapshotVersion(e){return oe.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return oe.resolve(this.Nr)}allocateTargetId(e){return this.highestTargetId=this.Br.next(),oe.resolve(this.highestTargetId)}setTargetsMetadata(e,t,i){return i&&(this.lastRemoteSnapshotVersion=i),t>this.Nr&&(this.Nr=t),oe.resolve()}Qn(e){this.Or.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.Br=new so(t),this.highestTargetId=t),e.sequenceNumber>this.Nr&&(this.Nr=e.sequenceNumber)}addTargetData(e,t){return this.Qn(t),this.targetCount+=1,oe.resolve()}updateTargetData(e,t){return this.Qn(t),oe.resolve()}removeTargetData(e,t){return this.Or.delete(t.target),this.Lr.mr(t.targetId),this.targetCount-=1,oe.resolve()}removeTargets(e,t,i){let r=0;const s=[];return this.Or.forEach((o,a)=>{a.sequenceNumber<=t&&i.get(a.targetId)===null&&(this.Or.delete(o),s.push(this.removeMatchingKeysForTargetId(e,a.targetId)),r++)}),oe.waitFor(s).next(()=>r)}getTargetCount(e){return oe.resolve(this.targetCount)}getTargetData(e,t){const i=this.Or.get(t)||null;return oe.resolve(i)}addMatchingKeys(e,t,i){return this.Lr.Ar(t,i),oe.resolve()}removeMatchingKeys(e,t,i){this.Lr.Vr(t,i);const r=this.persistence.referenceDelegate,s=[];return r&&t.forEach(o=>{s.push(r.markPotentiallyOrphaned(e,o))}),oe.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Lr.mr(t),oe.resolve()}getMatchingKeysForTargetId(e,t){const i=this.Lr.pr(t);return oe.resolve(i)}containsKey(e,t){return oe.resolve(this.Lr.containsKey(t))}}/** 5821 * @license 5822 * Copyright 2017 Google LLC 5823 * 5824 * Licensed under the Apache License, Version 2.0 (the "License"); 5825 * you may not use this file except in compliance with the License. 5826 * You may obtain a copy of the License at 5827 * 5828 * http://www.apache.org/licenses/LICENSE-2.0 5829 * 5830 * Unless required by applicable law or agreed to in writing, software 5831 * distributed under the License is distributed on an "AS IS" BASIS, 5832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5833 * See the License for the specific language governing permissions and 5834 * limitations under the License. 5835 */class jL{constructor(e,t){this.kr={},this.overlays={},this.qr=new pp(0),this.Qr=!1,this.Qr=!0,this.Kr=new HL,this.referenceDelegate=e(this),this.$r=new XL(this),this.indexManager=new kL,this.remoteDocumentCache=function(r){return new WL(r)}(i=>this.referenceDelegate.Ur(i)),this.serializer=new DL(t),this.Wr=new BL(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Qr=!1,Promise.resolve()}get started(){return this.Qr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new zL,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let i=this.kr[e.toKey()];
5835return i||(i=new GL(t,this.referenceDelegate),this.kr[e.toKey()]=i),i}getGlobalsCache(){return this.Kr}getTargetCache(){return this.$r}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Wr}runTransaction(e,t,i){Le("MemoryPersistence","Starting transaction:",e);const r=new KL(this.qr.next());return this.referenceDelegate.Gr(),i(r).next(s=>this.referenceDelegate.zr(r).next(()=>s)).toPromise().then(s=>(r.raiseOnCommittedEvent(),s))}jr(e,t){return oe.or(Object.values(this.kr).map(i=>()=>i.containsKey(e,t)))}}class KL extends CP{constructor(e){super(),this.currentSequenceNumber=e}}class Ap{constructor(e){this.persistence=e,this.Hr=new Sp,this.Jr=null}static Yr(e){return new Ap(e)}get Zr(){if(this.Jr)return this.Jr;throw Je()}addReference(e,t,i){return this.Hr.addReference(i,t),this.Zr.delete(i.toString()),oe.resolve()}removeReference(e,t,i){return this.Hr.removeReference(i,t),this.Zr.add(i.toString()),oe.resolve()}markPotentiallyOrphaned(e,t){return this.Zr.add(t.toString()),oe.resolve()}removeTarget(e,t){this.Hr.mr(t.targetId).forEach(r=>this.Zr.add(r.toString()));const i=this.persistence.getTargetCache();return i.getMatchingKeysForTargetId(e,t.targetId).next(r=>{r.forEach(s=>this.Zr.add(s.toString()))}).next(()=>i.removeTargetData(e,t))}Gr(){this.Jr=new Set}zr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return oe.forEach(this.Zr,i=>{const r=qe.fromPath(i);return this.Xr(e,r).next(s=>{s||t.removeEntry(r,$e.min())})}).next(()=>(this.Jr=null,t.apply(e)))}updateLimboDocument(e,t){return this.Xr(e,t).next(i=>{i?this.Zr.delete(t.toString()):this.Zr.add(t.toString())})}Ur(e){return 0}Xr(e,t){return oe.or([()=>oe.resolve(this.Hr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.jr(e,t)])}}/** 5836 * @license 5837 * Copyright 2017 Google LLC 5838 * 5839 * Licensed under the Apache License, Version 2.0 (the "License"); 5840 * you may not use this file except in compliance with the License. 5841 * You may obtain a copy of the License at 5842 * 5843 * http://www.apache.org/licenses/LICENSE-2.0 5844 * 5845 * Unless required by applicable law or agreed to in writing, software 5846 * distributed under the License is distributed on an "AS IS" BASIS, 5847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5848 * See the License for the specific language governing permissions and 5849 * limitations under the License. 5850 */class xp{constructor(e,t,i,r){this.targetId=e,this.fromCache=t,this.Ki=i,this.$i=r}static Ui(e,t){let i=ct(),r=ct();for(const s of t.docChanges)switch(s.type){case 0:i=i.add(s.doc.key);break;case 1:r=r.add(s.doc.key)}return new xp(e,t.fromCache,i,r)}}/** 5851 * @license 5852 * Copyright 2023 Google LLC 5853 * 5854 * Licensed under the Apache License, Version 2.0 (the "License"); 5855 * you may not use this file except in compliance with the License. 5856 * You may obtain a copy of the License at 5857 * 5858 * http://www.apache.org/licenses/LICENSE-2.0 5859 * 5860 * Unless required by applicable law or agreed to in writing, software 5861 * distributed under the License is distributed on an "AS IS" BASIS, 5862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5863 * See the License for the specific language governing permissions and 5864 * limitations under the License. 5865 */class YL{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/** 5866 * @license 5867 * Copyright 2019 Google LLC 5868 * 5869 * Licensed under the Apache License, Version 2.0 (the "License"); 5870 * you may not use this file except in compliance with the License. 5871 * You may obtain a copy of the License at 5872 * 5873 * http://www.apache.org/licenses/LICENSE-2.0 5874 * 5875 * Unless required by applicable law or agreed to in writing, software 5876 * distributed under the License is distributed on an "AS IS" BASIS, 5877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5878 * See the License for the specific language governing permissions and 5879 * limitations under the License. 5880 */class QL{constructor(){this.Wi=!1,this.Gi=!1,this.zi=100,this.ji=function(){return iE()?8:RP(yn())>0?6:4}()}initialize(e,t){this.Hi=e,this.indexManager=t,this.Wi=!0}getDocumentsMatchingQuery(e,t,i,r){const s={result:null};return this.Ji(e,t).next(o=>{s.result=o}).next(()=>{if(!s.result)return this.Yi(e,t,r,i).next(o=>{s.result=o})}).next(()=>{if(s.result)return;const o=new YL;return this.Zi(e,t,o).next(a=>{if(s.result=a,this.Gi)return this.Xi(e,t,o,a.size)})}).next(()=>s.result)}Xi(e,t,i,r){return i.documentReadCount<this.zi?(Zo()<=ui.DEBUG&&Le("QueryEngine","SDK will not create cache indexes for query:",Rs(t),"since it only creates cache indexes for collection contains","more than or equal to",this.zi,"documents"),oe.resolve()):(Zo()<=ui.DEBUG&&Le("QueryEngine","Query:",Rs(t),"scans",i.documentReadCount,"local documents and returns",r,"documents as results."),i.documentReadCount>this.ji*r?(Zo()<=ui.DEBUG&&Le("QueryEngine","The SDK decides to create cache indexes for query:",Rs(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,mi(t))):oe.resolve())}Ji(e,t){if(Lm(t))return oe.resolve(null);let i=mi(t);return this.indexManager.getIndexType(e,i).next(r=>r===0?null:(t.limit!==null&&r===1&&(t=Sh(t,null,"F"),i=mi(t)),this.indexManager.getDocumentsMatchingTarget(e,i).next(s=>{const o=ct(...s);return this.Hi.getDocuments(e,o).next(a=>this.indexManager.getMinOffset(e,i).next(c=>{const l=this.es(t,a);return this.ts(t,l,o,c.readTime)?this.Ji(e,Sh(t,null,"F")):this.ns(e,l,t,c)}))})))}Yi(e,t,i,r){return Lm(t)||r.isEqual($e.min())?oe.resolve(null):this.Hi.getDocuments(e,i).next(s=>{const o=this.es(t,s);return this.ts(t,o,i,r)?oe.resolve(null):(Zo()<=ui.DEBUG&&Le("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Rs(t)),this.ns(e,o,t,xP(r,-1)).next(a=>a))})}es(e,t){let i=new rn(b0(e));return t.forEach((r,s)=>{eu(e,s)&&(i=i.add(s))}),i}ts(e,t,i,r){if(e.limit===null)return!1;if(i.size!==t.size)return!0;const s=e.limitType==="F"?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(r)>0)}Zi(e,t,i){return Zo()<=ui.DEBUG&&Le("QueryEngine","Using full collection scan to execute query:",Rs(t)),this.Hi.getDocumentsMatchingQuery(e,t,br.min(),i)}ns(e,t,i,r){return this.Hi.getDocumentsMatchingQuery(e,i,r).next(s=>(t.forEach(o=>{s=s.insert(o.key,o)}),s))}}/** 5881 * @license 5882 * Copyright 2020 Google LLC 5883 * 5884 * Licensed under the Apache License, Version 2.0 (the "License");
5885 * you may not use this file except in compliance with the License. 5886 * You may obtain a copy of the License at 5887 * 5888 * http://www.apache.org/licenses/LICENSE-2.0 5889 * 5890 * Unless required by applicable law or agreed to in writing, software 5891 * distributed under the License is distributed on an "AS IS" BASIS, 5892 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5893 * See the License for the specific language governing permissions and 5894 * limitations under the License. 5895 */class ZL{constructor(e,t,i,r){this.persistence=e,this.rs=t,this.serializer=r,this.ss=new Dt(gt),this.os=new Eo(s=>gp(s),vp),this._s=new Map,this.us=e.getRemoteDocumentCache(),this.$r=e.getTargetCache(),this.Wr=e.getBundleCache(),this.cs(i)}cs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new VL(this.us,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.us.setIndexManager(this.indexManager),this.rs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.ss))}}function JL(n,e,t,i){return new ZL(n,e,t,i)}async function q0(n,e){const t=et(n);return await t.persistence.runTransaction("Handle user change","readonly",i=>{let r;return t.mutationQueue.getAllMutationBatches(i).next(s=>(r=s,t.cs(e),t.mutationQueue.getAllMutationBatches(i))).next(s=>{const o=[],a=[];let c=ct();for(const l of r){o.push(l.batchId);for(const d of l.mutations)c=c.add(d.key)}for(const l of s){a.push(l.batchId);for(const d of l.mutations)c=c.add(d.key)}return t.localDocuments.getDocuments(i,c).next(l=>({ls:l,removedBatchIds:o,addedBatchIds:a}))})})}function $L(n,e){const t=et(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",i=>{const r=e.batch.keys(),s=t.us.newChangeBuffer({trackRemovals:!0});return function(a,c,l,d){const h=l.batch,p=h.keys();let _=oe.resolve();return p.forEach(g=>{_=_.next(()=>d.getEntry(c,g)).next(S=>{const m=l.docVersions.get(g);It(m!==null),S.version.compareTo(m)<0&&(h.applyToRemoteDocument(S,l),S.isValidDocument()&&(S.setReadTime(l.commitVersion),d.addEntry(S)))})}),_.next(()=>a.mutationQueue.removeMutationBatch(c,h))}(t,i,e,s).next(()=>s.apply(i)).next(()=>t.mutationQueue.performConsistencyCheck(i)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(i,r,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(i,function(a){let c=ct();for(let l=0;l<a.mutationResults.length;++l)a.mutationResults[l].transformResults.length>0&&(c=c.add(a.batch.mutations[l].key));return c}(e))).next(()=>t.localDocuments.getDocuments(i,r))})}function X0(n){const e=et(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.$r.getLastRemoteSnapshotVersion(t))}function eD(n,e){const t=et(n),i=e.snapshotVersion;let r=t.ss;return t.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const o=t.us.newChangeBuffer({trackRemovals:!0});r=t.ss;const a=[];
5895e.targetChanges.forEach((d,h)=>{const p=r.get(h);if(!p)return;a.push(t.$r.removeMatchingKeys(s,d.removedDocuments,h).next(()=>t.$r.addMatchingKeys(s,d.addedDocuments,h)));let _=p.withSequenceNumber(s.currentSequenceNumber);e.targetMismatches.get(h)!==null?_=_.withResumeToken(sn.EMPTY_BYTE_STRING,$e.min()).withLastLimboFreeSnapshotVersion($e.min()):d.resumeToken.approximateByteSize()>0&&(_=_.withResumeToken(d.resumeToken,i)),r=r.insert(h,_),function(S,m,f){return S.resumeToken.approximateByteSize()===0||m.snapshotVersion.toMicroseconds()-S.snapshotVersion.toMicroseconds()>=3e8?!0:f.addedDocuments.size+f.modifiedDocuments.size+f.removedDocuments.size>0}(p,_,d)&&a.push(t.$r.updateTargetData(s,_))});let c=$i(),l=ct();if(e.documentUpdates.forEach(d=>{e.resolvedLimboDocuments.has(d)&&a.push(t.persistence.referenceDelegate.updateLimboDocument(s,d))}),a.push(tD(s,o,e.documentUpdates).next(d=>{c=d.hs,l=d.Ps})),!i.isEqual($e.min())){const d=t.$r.getLastRemoteSnapshotVersion(s).next(h=>t.$r.setTargetsMetadata(s,s.currentSequenceNumber,i));a.push(d)}return oe.waitFor(a).next(()=>o.apply(s)).next(()=>t.localDocuments.getLocalViewOfDocuments(s,c,l)).next(()=>c)}).then(s=>(t.ss=r,s))}function tD(n,e,t){let i=ct(),r=ct();return t.forEach(s=>i=i.add(s)),e.getEntries(n,i).next(s=>{let o=$i();return t.forEach((a,c)=>{const l=s.get(a);c.isFoundDocument()!==l.isFoundDocument()&&(r=r.add(a)),c.isNoDocument()&&c.version.isEqual($e.min())?(e.removeEntry(a,c.readTime),o=o.insert(a,c)):!l.isValidDocument()||c.version.compareTo(l.version)>0||c.version.compareTo(l.version)===0&&l.hasPendingWrites?(e.addEntry(c),o=o.insert(a,c)):Le("LocalStore","Ignoring outdated watch update for ",a,". Current version:",l.version," Watch version:",c.version)}),{hs:o,Ps:r}})}function nD(n,e){const t=et(n);return t.persistence.runTransaction("Get next mutation batch","readonly",i=>(e===void 0&&(e=-1),t.mutationQueue.getNextMutationBatchAfterBatchId(i,e)))}function iD(n,e){const t=et(n);return t.persistence.runTransaction("Allocate target","readwrite",i=>{let r;return t.$r.getTargetData(i,e).next(s=>s?(r=s,oe.resolve(r)):t.$r.allocateTargetId(i).next(o=>(r=new gr(e,o,"TargetPurposeListen",i.currentSequenceNumber),t.$r.addTargetData(i,r).next(()=>r))))}).then(i=>{const r=t.ss.get(i.targetId);return(r===null||i.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(t.ss=t.ss.insert(i.targetId,i),t.os.set(e,i.targetId)),i})}async function Mh(n,e,t){const i=et(n),r=i.ss.get(e),s=t?"readwrite":"readwrite-primary";try{t||await i.persistence.runTransaction("Release target",s,o=>i.persistence.referenceDelegate.removeTarget(o,r))}catch(o){if(!Xa(o))throw o;Le("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}i.ss=i.ss.remove(e),i.os.delete(r.target)}function Gm(n,e,t){const i=et(n);let r=$e.min(),s=ct();return i.persistence.runTransaction("Execute query","readwrite",o=>function(c,l,d){const h=et(c),p=h.os.get(d);return p!==void 0?oe.resolve(h.ss.get(p)):h.$r.getTargetData(l,d)}(i,o,mi(e)).next(a=>{if(a)return r=a.lastLimboFreeSnapshotVersion,i.$r.getMatchingKeysForTargetId(o,a.targetId).next(c=>{s=c})}).next(()=>i.rs.getDocumentsMatchingQuery(o,e,t?r:$e.min(),t?s:ct())).next(a=>(rD(i,KP(e),a),{documents:a,Is:s})))}function rD(n,e,t){let i=n._s.get(e)||$e.min();t.forEach((r,s)=>{s.readTime.compareTo(i)>0&&(i=s.readTime)}),n._s.set(e,i)}class Wm{constructor(){this.activeTargetIds=eL()}Vs(e){this.activeTargetIds=this.activeTargetIds.add(e)}fs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Rs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class sD{constructor(){this.io=new Wm,this.so={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,i){}addLocalQueryTarget(e){return this.io.Vs(e),this.so[e]||"not-current"}updateQueryState(e,t,i){this.so[e]=t}removeLocalQueryTarget(e){this.io.fs(e)}isLocalQueryTarget(e){return this.io.activeTargetIds.has(e)}clearQueryState(e){delete this.so[e]}getAllActiveQueryTargets(){return this.io.activeTargetIds}isActiveQueryTarget(e){return this.io.activeTargetIds.has(e)}start(){return this.io=new Wm,Promise.resolve()}handleUserChange(e,t,i){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/** 5896 * @license 5897 * Copyright 2019 Google LLC 5898 * 5899 * Licensed under the Apache License, Version 2.0 (the "License");
5900 * you may not use this file except in compliance with the License. 5901 * You may obtain a copy of the License at 5902 * 5903 * http://www.apache.org/licenses/LICENSE-2.0 5904 * 5905 * Unless required by applicable law or agreed to in writing, software 5906 * distributed under the License is distributed on an "AS IS" BASIS, 5907 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5908 * See the License for the specific language governing permissions and 5909 * limitations under the License. 5910 */class oD{oo(e){}shutdown(){}}/** 5911 * @license 5912 * Copyright 2019 Google LLC 5913 * 5914 * Licensed under the Apache License, Version 2.0 (the "License"); 5915 * you may not use this file except in compliance with the License. 5916 * You may obtain a copy of the License at 5917 * 5918 * http://www.apache.org/licenses/LICENSE-2.0 5919 * 5920 * Unless required by applicable law or agreed to in writing, software 5921 * distributed under the License is distributed on an "AS IS" BASIS, 5922 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5923 * See the License for the specific language governing permissions and 5924 * limitations under the License. 5925 */class qm{constructor(){this._o=()=>this.ao(),this.uo=()=>this.co(),this.lo=[],this.ho()}oo(e){this.lo.push(e)}shutdown(){window.removeEventListener("online",this._o),window.removeEventListener("offline",this.uo)}ho(){window.addEventListener("online",this._o),window.addEventListener("offline",this.uo)}ao(){Le("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.lo)e(0)}co(){Le("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.lo)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** 5926 * @license 5927 * Copyright 2023 Google LLC 5928 * 5929 * Licensed under the Apache License, Version 2.0 (the "License"); 5930 * you may not use this file except in compliance with the License. 5931 * You may obtain a copy of the License at 5932 * 5933 * http://www.apache.org/licenses/LICENSE-2.0 5934 * 5935 * Unless required by applicable law or agreed to in writing, software 5936 * distributed under the License is distributed on an "AS IS" BASIS, 5937 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5938 * See the License for the specific language governing permissions and 5939 * limitations under the License. 5940 */let Gc=null;function od(){return Gc===null?Gc=function(){return 268435456+Math.round(2147483648*Math.random())}():Gc++,"0x"+Gc.toString(16)}/** 5941 * @license 5942 * Copyright 2020 Google LLC 5943 * 5944 * Licensed under the Apache License, Version 2.0 (the "License"); 5945 * you may not use this file except in compliance with the License. 5946 * You may obtain a copy of the License at 5947 * 5948 * http://www.apache.org/licenses/LICENSE-2.0 5949 * 5950 * Unless required by applicable law or agreed to in writing, software 5951 * distributed under the License is distributed on an "AS IS" BASIS, 5952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5953 * See the License for the specific language governing permissions and 5954 * limitations under the License. 5955 */const aD={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/** 5956 * @license 5957 * Copyright 2017 Google LLC 5958 * 5959 * Licensed under the Apache License, Version 2.0 (the "License"); 5960 * you may not use this file except in compliance with the License. 5961 * You may obtain a copy of the License at 5962 * 5963 * http://www.apache.org/licenses/LICENSE-2.0 5964 * 5965 * Unless required by applicable law or agreed to in writing, software 5966 * distributed under the License is distributed on an "AS IS" BASIS, 5967 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5968 * See the License for the specific language governing permissions and 5969 * limitations under the License. 5970 */class cD{constructor(e){this.Po=e.Po,this.Io=e.Io}To(e){this.Eo=e}Ao(e){this.Ro=e}Vo(e){this.mo=e}onMessage(e){this.fo=e}close(){this.Io()}send(e){this.Po(e)}po(){this.Eo()}yo(){this.Ro()}wo(e){this.mo(e)}So(e){this.fo(e)}}/** 5971 * @license 5972 * Copyright 2017 Google LLC 5973 * 5974 * Licensed under the Apache License, Version 2.0 (the "License");
5975 * you may not use this file except in compliance with the License. 5976 * You may obtain a copy of the License at 5977 * 5978 * http://www.apache.org/licenses/LICENSE-2.0 5979 * 5980 * Unless required by applicable law or agreed to in writing, software 5981 * distributed under the License is distributed on an "AS IS" BASIS, 5982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5983 * See the License for the specific language governing permissions and 5984 * limitations under the License. 5985 */const un="WebChannelConnection";class lD extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const i=t.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.bo=i+"://"+t.host,this.Do=`projects/${r}/databases/${s}`,this.Co=this.databaseId.database==="(default)"?`project_id=${r}`:`project_id=${r}&database_id=${s}`}get vo(){return!1}Fo(t,i,r,s,o){const a=od(),c=this.Mo(t,i.toUriEncodedString());Le("RestConnection",`Sending RPC '${t}' ${a}:`,c,r);const l={"google-cloud-resource-prefix":this.Do,"x-goog-request-params":this.Co};return this.xo(l,s,o),this.Oo(t,c,l,r).then(d=>(Le("RestConnection",`Received RPC '${t}' ${a}: `,d),d),d=>{throw to("RestConnection",`RPC '${t}' ${a} failed with error: `,d,"url: ",c,"request:",r),d})}No(t,i,r,s,o,a){return this.Fo(t,i,r,s,o)}xo(t,i,r){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+vo}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),i&&i.headers.forEach((s,o)=>t[o]=s),r&&r.headers.forEach((s,o)=>t[o]=s)}Mo(t,i){const r=aD[t];return`${this.bo}/v1/${i}:${r}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Oo(e,t,i,r){const s=od();return new Promise((o,a)=>{const c=new r0;c.setWithCredentials(!0),c.listenOnce(o0.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case il.NO_ERROR:const d=c.getResponseJson();Le(un,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(d)),o(d);break;case il.TIMEOUT:Le(un,`RPC '${e}' ${s} timed out`),a(new We(le.DEADLINE_EXCEEDED,"Request time out"));break;case il.HTTP_ERROR:const h=c.getStatus();if(Le(un,`RPC '${e}' ${s} failed with status:`,h,"response text:",c.getResponseText()),h>0){let p=c.getResponseJson();Array.isArray(p)&&(p=p[0]);const _=p==null?void 0:p.error;if(_&&_.status&&_.message){const g=function(m){const f=m.toLowerCase().replace(/_/g,"-");return Object.values(le).indexOf(f)>=0?f:le.UNKNOWN}(_.status);a(new We(g,_.message))}else a(new We(le.UNKNOWN,"Server responded with status "+c.getStatus()))}else a(new We(le.UNAVAILABLE,"Connection failed."));break;default:Je()}}finally{Le(un,`RPC '${e}' ${s} completed.`)}});const l=JSON.stringify(r);Le(un,`RPC '${e}' ${s} sending request:`,r),c.send(t,"POST",l,i,15)})}Lo(e,t,i){const r=od(),s=[this.bo,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=l0(),a=c0(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(c.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(c.xmlHttpFactory=new s0({})),this.xo(c.initMessageHeaders,t,i),c.encodeInitMessageHeaders=!0;const d=s.join("");Le(un,`Creating RPC '${e}' stream ${r}: ${d}`,c);const h=o.createWebChannel(d,c);let p=!1,_=!1;const g=new cD({Po:m=>{_?Le(un,`Not sending because RPC '${e}' stream ${r} is closed:`,m):(p||(Le(un,`Opening RPC '${e}' stream ${r} transport.`),h.open(),p=!0),Le(un,`RPC '${e}' stream ${r} sending:`,m),h.send(m))},Io:()=>h.close()}),S=(m,f,M)=>{m.listen(f,w=>{try{M(w)}catch(b){setTimeout(()=>{throw b},0)}})};return S(h,sa.EventType.OPEN,()=>{_||(Le(un,`RPC '${e}' stream ${r} transport opened.`),g.po())}),S(h,sa.EventType.CLOSE,()=>{_||(_=!0,Le(un,`RPC '${e}' stream ${r} transport closed`),g.wo())}
5985),S(h,sa.EventType.ERROR,m=>{_||(_=!0,to(un,`RPC '${e}' stream ${r} transport errored:`,m),g.wo(new We(le.UNAVAILABLE,"The operation could not be completed")))}),S(h,sa.EventType.MESSAGE,m=>{var f;if(!_){const M=m.data[0];It(!!M);const w=M,b=w.error||((f=w[0])===null||f===void 0?void 0:f.error);if(b){Le(un,`RPC '${e}' stream ${r} received error:`,b);const R=b.status;let P=function(E){const y=zt[E];if(y!==void 0)return k0(y)}(R),T=b.message;P===void 0&&(P=le.INTERNAL,T="Unknown error status: "+R+" with message "+b.message),_=!0,g.wo(new We(P,T)),h.close()}else Le(un,`RPC '${e}' stream ${r} received:`,M),g.So(M)}}),S(a,a0.STAT_EVENT,m=>{m.stat===vh.PROXY?Le(un,`RPC '${e}' stream ${r} detected buffering proxy`):m.stat===vh.NOPROXY&&Le(un,`RPC '${e}' stream ${r} detected no buffering proxy`)}),setTimeout(()=>{g.yo()},0),g}}function ad(){return typeof document<"u"?document:null}/** 5986 * @license 5987 * Copyright 2020 Google LLC 5988 * 5989 * Licensed under the Apache License, Version 2.0 (the "License"); 5990 * you may not use this file except in compliance with the License. 5991 * You may obtain a copy of the License at 5992 * 5993 * http://www.apache.org/licenses/LICENSE-2.0 5994 * 5995 * Unless required by applicable law or agreed to in writing, software 5996 * distributed under the License is distributed on an "AS IS" BASIS, 5997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5998 * See the License for the specific language governing permissions and 5999 * limitations under the License. 6000 */function ru(n){return new yL(n,!0)}/** 6001 * @license 6002 * Copyright 2017 Google LLC 6003 * 6004 * Licensed under the Apache License, Version 2.0 (the "License"); 6005 * you may not use this file except in compliance with the License. 6006 * You may obtain a copy of the License at 6007 * 6008 * http://www.apache.org/licenses/LICENSE-2.0 6009 * 6010 * Unless required by applicable law or agreed to in writing, software 6011 * distributed under the License is distributed on an "AS IS" BASIS, 6012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6013 * See the License for the specific language governing permissions and 6014 * limitations under the License. 6015 */class j0{constructor(e,t,i=1e3,r=1.5,s=6e4){this.ai=e,this.timerId=t,this.Bo=i,this.ko=r,this.qo=s,this.Qo=0,this.Ko=null,this.$o=Date.now(),this.reset()}reset(){this.Qo=0}Uo(){this.Qo=this.qo}Wo(e){this.cancel();const t=Math.floor(this.Qo+this.Go()),i=Math.max(0,Date.now()-this.$o),r=Math.max(0,t-i);r>0&&Le("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Qo} ms, delay with jitter: ${t} ms, last attempt: ${i} ms ago)`),this.Ko=this.ai.enqueueAfterDelay(this.timerId,r,()=>(this.$o=Date.now(),e())),this.Qo*=this.ko,this.Qo<this.Bo&&(this.Qo=this.Bo),this.Qo>this.qo&&(this.Qo=this.qo)}zo(){this.Ko!==null&&(this.Ko.skipDelay(),this.Ko=null)}cancel(){this.Ko!==null&&(this.Ko.cancel(),this.Ko=null)}Go(){return(Math.random()-.5)*this.Qo}}/** 6016 * @license 6017 * Copyright 2017 Google LLC 6018 * 6019 * Licensed under the Apache License, Version 2.0 (the "License"); 6020 * you may not use this file except in compliance with the License. 6021 * You may obtain a copy of the License at 6022 * 6023 * http://www.apache.org/licenses/LICENSE-2.0 6024 * 6025 * Unless required by applicable law or agreed to in writing, software 6026 * distributed under the License is distributed on an "AS IS" BASIS, 6027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6028 * See the License for the specific language governing permissions and 6029 * limitations under the License. 6030 */class K0{constructor(e,t,i,r,s,o,a,c){this.ai=e,this.jo=i,this.Ho=r,this.connection=s,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=a,this.listener=c,this.state=0,this.Jo=0,this.Yo=null,this.Zo=null,this.stream=null,this.Xo=0,this.e_=new j0(e,t)}t_(){return this.state===1||this.state===5||this.n_()}n_(){return this.state===2||this.state===3}start(){this.Xo=0,this.state!==4?this.auth():this.r_()}async stop(){this.t_()&&await this.close(0)}i_(){this.state=0,this.e_.reset()}s_(){this.n_()&&this.Yo===null&&(this.Yo=this.ai.enqueueAfterDelay(this.jo,6e4,()=>this.o_()))}__(e){this.a_(),this.stream.send(e)}async o_(){if(this.n_())return this.close(0)}a_(){this.Yo&&(this.Yo.cancel(),this.Yo=null)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}async close(e,t){this.a_(),this.u_(),this.e_.cancel(),this.Jo++,e!==4?this.e_.reset():t&&t.code===le.RESOURCE_EXHAUSTED?(Ji(t.toString()),Ji("Using maximum backoff delay to prevent overloading the backend."),this.e_.Uo()):t&&t.code===le.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.c_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Vo(t)}c_(){}auth(){this.state=1;const e=this.l_(this.Jo),t=this.Jo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([i,r])=>{this.Jo===t&&this.h_(i,r)},i=>{e(()=>{const r=new We(le.UNKNOWN,"Fetching auth token failed: "+i.message);return this.P_(r)})})}h_(e,t){const i=this.l_(this.Jo);this.stream=this.I_(e,t),this.stream.To(()=>{i(()=>this.listener.To())}),this.stream.Ao(()=>{i(()=>(this.state=2,this.Zo=this.ai.enqueueAfterDelay(this.Ho,1e4,()=>(this.n_()&&(this.state=3),Promise.resolve())),this.listener.Ao()))}),this.stream.Vo(r=>{i(()=>this.P_(r))}),this.stream.onMessage(r=>{i(()=>++this.Xo==1?this.T_(r):this.onNext(r))})}r_(){this.state=5,this.e_.Wo(async()=>{this.state=0,this.start()})}P_(e){return Le("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}l_(e){return t=>{this.ai.enqueueAndForget(()=>this.Jo===e?t():(Le("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class uD extends K0{constructor(e,t,i,r,s,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,i,r,o),this.serializer
6030=s}I_(e,t){return this.connection.Lo("Listen",e,t)}T_(e){return this.onNext(e)}onNext(e){this.e_.reset();const t=bL(this.serializer,e),i=function(s){if(!("targetChange"in s))return $e.min();const o=s.targetChange;return o.targetIds&&o.targetIds.length?$e.min():o.readTime?gi(o.readTime):$e.min()}(e);return this.listener.E_(t,i)}d_(e){const t={};t.database=Ih(this.serializer),t.addTarget=function(s,o){let a;const c=o.target;if(a=bh(c)?{documents:xL(s,c)}:{query:wL(s,c)._t},a.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){a.resumeToken=F0(s,o.resumeToken);const l=Ah(s,o.expectedCount);l!==null&&(a.expectedCount=l)}else if(o.snapshotVersion.compareTo($e.min())>0){a.readTime=Cl(s,o.snapshotVersion.toTimestamp());const l=Ah(s,o.expectedCount);l!==null&&(a.expectedCount=l)}return a}(this.serializer,e);const i=ML(this.serializer,e);i&&(t.labels=i),this.__(t)}A_(e){const t={};t.database=Ih(this.serializer),t.removeTarget=e,this.__(t)}}class dD extends K0{constructor(e,t,i,r,s,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,i,r,o),this.serializer=s}get R_(){return this.Xo>0}start(){this.lastStreamToken=void 0,super.start()}c_(){this.R_&&this.V_([])}I_(e,t){return this.connection.Lo("Write",e,t)}T_(e){return It(!!e.streamToken),this.lastStreamToken=e.streamToken,It(!e.writeResults||e.writeResults.length===0),this.listener.m_()}onNext(e){It(!!e.streamToken),this.lastStreamToken=e.streamToken,this.e_.reset();const t=AL(e.writeResults,e.commitTime),i=gi(e.commitTime);return this.listener.f_(i,t)}g_(){const e={};e.database=Ih(this.serializer),this.__(e)}V_(e){const t={streamToken:this.lastStreamToken,writes:e.map(i=>SL(this.serializer,i))};this.__(t)}}/** 6031 * @license 6032 * Copyright 2017 Google LLC 6033 * 6034 * Licensed under the Apache License, Version 2.0 (the "License"); 6035 * you may not use this file except in compliance with the License. 6036 * You may obtain a copy of the License at 6037 * 6038 * http://www.apache.org/licenses/LICENSE-2.0 6039 * 6040 * Unless required by applicable law or agreed to in writing, software 6041 * distributed under the License is distributed on an "AS IS" BASIS, 6042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6043 * See the License for the specific language governing permissions and 6044 * limitations under the License. 6045 */class hD extends class{}{constructor(e,t,i,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=i,this.serializer=r,this.p_=!1}y_(){if(this.p_)throw new We(le.FAILED_PRECONDITION,"The client has already been terminated.")}Fo(e,t,i,r){return this.y_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Fo(e,xh(t,i),r,s,o)).catch(s=>{throw s.name==="FirebaseError"?(s.code===le.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new We(le.UNKNOWN,s.toString())})}No(e,t,i,r,s){return this.y_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,a])=>this.connection.No(e,xh(t,i),r,o,a,s)).catch(o=>{throw o.name==="FirebaseError"?(o.code===le.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new We(le.UNKNOWN,o.toString())})}terminate(){this.p_=!0,this.connection.terminate()}}class pD{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.w_=0,this.S_=null,this.b_=!0}D_(){this.w_===0&&(this.C_("Unknown"),this.S_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.S_=null,this.v_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}F_(e){this.state==="Online"?this.C_("Unknown"):(this.w_++,this.w_>=1&&(this.M_(),this.v_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.M_(),this.w_=0,e==="Online"&&(this.b_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}v_(e){const t=`Could not reach Cloud Firestore backend. ${e} 6046This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.b_?(Ji(t),this.b_=!1):Le("OnlineStateTracker",t)}M_(){this.S_!==null&&(this.S_.cancel(),this.S_=null)}}/** 6047 * @license 6048 * Copyright 2017 Google LLC 6049 * 6050 * Licensed under the Apache License, Version 2.0 (the "License");
6051 * you may not use this file except in compliance with the License. 6052 * You may obtain a copy of the License at 6053 * 6054 * http://www.apache.org/licenses/LICENSE-2.0 6055 * 6056 * Unless required by applicable law or agreed to in writing, software 6057 * distributed under the License is distributed on an "AS IS" BASIS, 6058 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6059 * See the License for the specific language governing permissions and 6060 * limitations under the License. 6061 */class fD{constructor(e,t,i,r,s){this.localStore=e,this.datastore=t,this.asyncQueue=i,this.remoteSyncer={},this.x_=[],this.O_=new Map,this.N_=new Set,this.L_=[],this.B_=s,this.B_.oo(o=>{i.enqueueAndForget(async()=>{rs(this)&&(Le("RemoteStore","Restarting streams for network reachability change."),await async function(c){const l=et(c);l.N_.add(4),await Ya(l),l.k_.set("Unknown"),l.N_.delete(4),await su(l)}(this))})}),this.k_=new pD(i,r)}}async function su(n){if(rs(n))for(const e of n.L_)await e(!0)}async function Ya(n){for(const e of n.L_)await e(!1)}function Y0(n,e){const t=et(n);t.O_.has(e.targetId)||(t.O_.set(e.targetId,e),Cp(t)?Mp(t):To(t).n_()&&Ip(t,e))}function wp(n,e){const t=et(n),i=To(t);t.O_.delete(e),i.n_()&&Q0(t,e),t.O_.size===0&&(i.n_()?i.s_():rs(t)&&t.k_.set("Unknown"))}function Ip(n,e){if(n.q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo($e.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}To(n).d_(e)}function Q0(n,e){n.q_.xe(e),To(n).A_(e)}function Mp(n){n.q_=new _L({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>n.O_.get(e)||null,tt:()=>n.datastore.serializer.databaseId}),To(n).start(),n.k_.D_()}function Cp(n){return rs(n)&&!To(n).t_()&&n.O_.size>0}function rs(n){return et(n).N_.size===0}function Z0(n){n.q_=void 0}async function _D(n){n.k_.set("Online")}async function mD(n){n.O_.forEach((e,t)=>{Ip(n,e)})}async function gD(n,e){Z0(n),Cp(n)?(n.k_.F_(e),Mp(n)):n.k_.set("Unknown")}async function vD(n,e,t){if(n.k_.set("Online"),e instanceof O0&&e.state===2&&e.cause)try{await async function(r,s){const o=s.cause;for(const a of s.targetIds)r.O_.has(a)&&(await r.remoteSyncer.rejectListen(a,o),r.O_.delete(a),r.q_.removeTarget(a))}(n,e)}catch(i){Le("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),i),await Rl(n,i)}else if(e instanceof ol?n.q_.Ke(e):e instanceof U0?n.q_.He(e):n.q_.We(e),!t.isEqual($e.min()))try{const i=await X0(n.localStore);t.compareTo(i)>=0&&await function(s,o){const a=s.q_.rt(o);
6061return a.targetChanges.forEach((c,l)=>{if(c.resumeToken.approximateByteSize()>0){const d=s.O_.get(l);d&&s.O_.set(l,d.withResumeToken(c.resumeToken,o))}}),a.targetMismatches.forEach((c,l)=>{const d=s.O_.get(c);if(!d)return;s.O_.set(c,d.withResumeToken(sn.EMPTY_BYTE_STRING,d.snapshotVersion)),Q0(s,c);const h=new gr(d.target,c,l,d.sequenceNumber);Ip(s,h)}),s.remoteSyncer.applyRemoteEvent(a)}(n,t)}catch(i){Le("RemoteStore","Failed to raise snapshot:",i),await Rl(n,i)}}async function Rl(n,e,t){if(!Xa(e))throw e;n.N_.add(1),await Ya(n),n.k_.set("Offline"),t||(t=()=>X0(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{Le("RemoteStore","Retrying IndexedDB access"),await t(),n.N_.delete(1),await su(n)})}function J0(n,e){return e().catch(t=>Rl(n,t,e))}async function ou(n){const e=et(n),t=Ar(e);let i=e.x_.length>0?e.x_[e.x_.length-1].batchId:-1;for(;yD(e);)try{const r=await nD(e.localStore,i);if(r===null){e.x_.length===0&&t.s_();break}i=r.batchId,ED(e,r)}catch(r){await Rl(e,r)}$0(e)&&ey(e)}function yD(n){return rs(n)&&n.x_.length<10}function ED(n,e){n.x_.push(e);const t=Ar(n);t.n_()&&t.R_&&t.V_(e.mutations)}function $0(n){return rs(n)&&!Ar(n).t_()&&n.x_.length>0}function ey(n){Ar(n).start()}async function TD(n){Ar(n).g_()}async function bD(n){const e=Ar(n);for(const t of n.x_)e.V_(t.mutations)}async function SD(n,e,t){const i=n.x_.shift(),r=Ep.from(i,e,t);await J0(n,()=>n.remoteSyncer.applySuccessfulWrite(r)),await ou(n)}async function AD(n,e){e&&Ar(n).R_&&await async function(i,r){if(function(o){return hL(o)&&o!==le.ABORTED}(r.code)){const s=i.x_.shift();Ar(i).i_(),await J0(i,()=>i.remoteSyncer.rejectFailedWrite(s.batchId,r)),await ou(i)}}(n,e),$0(n)&&ey(n)}async function Xm(n,e){const t=et(n);t.asyncQueue.verifyOperationInProgress(),Le("RemoteStore","RemoteStore received new credentials");const i=rs(t);t.N_.add(3),await Ya(t),i&&t.k_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.N_.delete(3),await su(t)}async function xD(n,e){const t=et(n);e?(t.N_.delete(2),await su(t)):e||(t.N_.add(2),await Ya(t),t.k_.set("Unknown"))}function To(n){return n.Q_||(n.Q_=function(t,i,r){const s=et(t);return s.y_(),new uD(i,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,r)}(n.datastore,n.asyncQueue,{To:_D.bind(null,n),Ao:mD.bind(null,n),Vo:gD.bind(null,n),E_:vD.bind(null,n)}),n.L_.push(async e=>{e?(n.Q_.i_(),Cp(n)?Mp(n):n.k_.set("Unknown")):(await n.Q_.stop(),Z0(n))})),n.Q_}function Ar(n){return n.K_||(n.K_=function(t,i,r){const s=et(t);return s.y_(),new dD(i,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,r)}(n.datastore,n.asyncQueue,{To:()=>Promise.resolve(),Ao:TD.bind(null,n),Vo:AD.bind(null,n),m_:bD.bind(null,n),f_:SD.bind(null,n)}),n.L_.push(async e=>{e?(n.K_.i_(),await ou(n)):(await n.K_.stop(),n.x_.length>0&&(Le("RemoteStore",`Stopping write stream with ${n.x_.length} pending writes`),n.x_=[]))})),n.K_}/** 6062 * @license 6063 * Copyright 2017 Google LLC 6064 * 6065 * Licensed under the Apache License, Version 2.0 (the "License"); 6066 * you may not use this file except in compliance with the License. 6067 * You may obtain a copy of the License at 6068 * 6069 * http://www.apache.org/licenses/LICENSE-2.0 6070 * 6071 * Unless required by applicable law or agreed to in writing, software 6072 * distributed under the License is distributed on an "AS IS" BASIS, 6073 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6074 * See the License for the specific language governing permissions and 6075 * limitations under the License. 6076 */class Rp{constructor(e,t,i,r,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=i,this.op=r,this.removalCallback=s,this.deferred=new jr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,i,r,s){const o=Date.now()+i,a=new Rp(e,t,o,r,s);return a.start(i),a}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new We(le.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Pp(n,e){if(Ji("AsyncQueue",`${e}: ${n}`),Xa(n))return new We(le.UNAVAILABLE,`${e}: ${n}`);throw n}/** 6077 * @license 6078 * Copyright 2017 Google LLC 6079 * 6080 * Licensed under the Apache License, Version 2.0 (the "License");
6081 * you may not use this file except in compliance with the License. 6082 * You may obtain a copy of the License at 6083 * 6084 * http://www.apache.org/licenses/LICENSE-2.0 6085 * 6086 * Unless required by applicable law or agreed to in writing, software 6087 * distributed under the License is distributed on an "AS IS" BASIS, 6088 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6089 * See the License for the specific language governing permissions and 6090 * limitations under the License. 6091 */class Ws{constructor(e){this.comparator=e?(t,i)=>e(t,i)||qe.comparator(t.key,i.key):(t,i)=>qe.comparator(t.key,i.key),this.keyedMap=oa(),this.sortedSet=new Dt(this.comparator)}static emptySet(e){return new Ws(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,i)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof Ws)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),i=e.sortedSet.getIterator();for(;t.hasNext();){const r=t.getNext().key,s=i.getNext().key;if(!r.isEqual(s))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet ( 6092 `+e.join(` 6093`)+` 6094)`}copy(e,t){const i=new Ws;return i.comparator=this.comparator,i.keyedMap=e,i.sortedSet=t,i}}/** 6095 * @license 6096 * Copyright 2017 Google LLC 6097 * 6098 * Licensed under the Apache License, Version 2.0 (the "License"); 6099 * you may not use this file except in compliance with the License. 6100 * You may obtain a copy of the License at 6101 * 6102 * http://www.apache.org/licenses/LICENSE-2.0 6103 * 6104 * Unless required by applicable law or agreed to in writing, software 6105 * distributed under the License is distributed on an "AS IS" BASIS, 6106 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6107 * See the License for the specific language governing permissions and 6108 * limitations under the License. 6109 */class jm{constructor(){this.U_=new Dt(qe.comparator)}track(e){const t=e.doc.key,i=this.U_.get(t);i?e.type!==0&&i.type===3?this.U_=this.U_.insert(t,e):e.type===3&&i.type!==1?this.U_=this.U_.insert(t,{type:i.type,doc:e.doc}):e.type===2&&i.type===2?this.U_=this.U_.insert(t,{type:2,doc:e.doc}):e.type===2&&i.type===0?this.U_=this.U_.insert(t,{type:0,doc:e.doc}):e.type===1&&i.type===0?this.U_=this.U_.remove(t):e.type===1&&i.type===2?this.U_=this.U_.insert(t,{type:1,doc:i.doc}):e.type===0&&i.type===1?this.U_=this.U_.insert(t,{type:2,doc:e.doc}):Je():this.U_=this.U_.insert(t,e)}W_(){const e=[];return this.U_.inorderTraversal((t,i)=>{e.push(i)}),e}}class oo{constructor(e,t,i,r,s,o,a,c,l){this.query=e,this.docs=t,this.oldDocs=i,this.docChanges=r,this.mutatedKeys=s,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=c,this.hasCachedResults=l}static fromInitialDocuments(e,t,i,r,s){const o=[];return t.forEach(a=>{o.push({type:0,doc:a})}),new oo(e,t,Ws.emptySet(t),o,i,r,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&$l(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,i=e.docChanges;if(t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==i[r].type||!t[r].doc.isEqual(i[r].doc))return!1;return!0}}/** 6110 * @license 6111 * Copyright 2017 Google LLC 6112 * 6113 * Licensed under the Apache License, Version 2.0 (the "License"); 6114 * you may not use this file except in compliance with the License. 6115 * You may obtain a copy of the License at 6116 * 6117 * http://www.apache.org/licenses/LICENSE-2.0 6118 * 6119 * Unless required by applicable law or agreed to in writing, softw
6119are 6120 * distributed under the License is distributed on an "AS IS" BASIS, 6121 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6122 * See the License for the specific language governing permissions and 6123 * limitations under the License. 6124 */class wD{constructor(){this.G_=void 0,this.z_=[]}j_(){return this.z_.some(e=>e.H_())}}class ID{constructor(){this.queries=Km(),this.onlineState="Unknown",this.J_=new Set}terminate(){(function(t,i){const r=et(t),s=r.queries;r.queries=Km(),s.forEach((o,a)=>{for(const c of a.z_)c.onError(i)})})(this,new We(le.ABORTED,"Firestore shutting down"))}}function Km(){return new Eo(n=>T0(n),$l)}async function MD(n,e){const t=et(n);let i=3;const r=e.query;let s=t.queries.get(r);s?!s.j_()&&e.H_()&&(i=2):(s=new wD,i=e.H_()?0:1);try{switch(i){case 0:s.G_=await t.onListen(r,!0);break;case 1:s.G_=await t.onListen(r,!1);break;case 2:await t.onFirstRemoteStoreListen(r)}}catch(o){const a=Pp(o,`Initialization of query '${Rs(e.query)}' failed`);return void e.onError(a)}t.queries.set(r,s),s.z_.push(e),e.Y_(t.onlineState),s.G_&&e.Z_(s.G_)&&Lp(t)}async function CD(n,e){const t=et(n),i=e.query;let r=3;const s=t.queries.get(i);if(s){const o=s.z_.indexOf(e);o>=0&&(s.z_.splice(o,1),s.z_.length===0?r=e.H_()?0:1:!s.j_()&&e.H_()&&(r=2))}switch(r){case 0:return t.queries.delete(i),t.onUnlisten(i,!0);case 1:return t.queries.delete(i),t.onUnlisten(i,!1);case 2:return t.onLastRemoteStoreUnlisten(i);default:return}}function RD(n,e){const t=et(n);let i=!1;for(const r of e){const s=r.query,o=t.queries.get(s);if(o){for(const a of o.z_)a.Z_(r)&&(i=!0);o.G_=r}}i&&Lp(t)}function PD(n,e,t){const i=et(n),r=i.queries.get(e);if(r)for(const s of r.z_)s.onError(t);i.queries.delete(e)}function Lp(n){n.J_.forEach(e=>{e.next()})}var Ch,Ym;(Ym=Ch||(Ch={})).X_="default",Ym.Cache="cache";class LD{constructor(e,t,i){this.query=e,this.ea=t,this.ta=!1,this.na=null,this.onlineState="Unknown",this.options=i||{}}Z_(e){if(!this.options.includeMetadataChanges){const i=[];for(const r of e.docChanges)r.type!==3&&i.push(r);e=new oo(e.query,e.docs,e.oldDocs,i,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ta?this.ra(e)&&(this.ea.next(e),t=!0):this.ia(e,this.onlineState)&&(this.sa(e),t=!0),this.na=e,t}onError(e){this.ea.error(e)}Y_(e){this.onlineState=e;let t=!1;return this.na&&!this.ta&&this.ia(this.na,e)&&(this.sa(this.na),t=!0),t}ia(e,t){if(!e.fromCache||!this.H_())return!0;const i=t!=="Offline";return(!this.options.oa||!i)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}ra(e){if(e.docChanges.length>0)return!0;const t=this.na&&this.na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}sa(e){e=oo.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ta=!0,this.ea.next(e)}H_(){return this.options.source!==Ch.Cache}}/** 6125 * @license 6126 * Copyright 2017 Google LLC 6127 * 6128 * Licensed under the Apache License, Version 2.0 (the "License"); 6129 * you may not use this file except in compliance with the License. 6130 * You may obtain a copy of the License at 6131 * 6132 * http://www.apache.org/licenses/LICENSE-2.0 6133 * 6134 * Unless required by applicable law or agreed to in writing, software 6135 * distributed under the License is distributed on an "AS IS" BASIS, 6136 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6137 * See the License for the specific language governing permissions and 6138 * limitations under the License. 6139 */class ty{constructor(e){this.key=e}}class ny{constructor(e){this.key=e}}class DD{constructor(e,t){this.query=e,this.Ia=t,this.Ta=null,this.hasCachedResults=!1,this.current=!1,this.Ea=ct(),this.mutatedKeys=ct(),this.da=b0(e),this.Aa=new Ws(this.da)}get Ra(){return this.Ia}Va(e,t){const i=t?t.ma:new jm,r=t?t.Aa:this.Aa;let s=t?t.mutatedKeys:this.mutatedKeys,o=r,a=!1;const c=this.query.limitType==="F"&&r.size===this.query.limit?r.last():null,l=this.query.limitType==="L"&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal((d,h)=>{const p=r.get(d),_=eu(this.query,h)?h:null,g=!!p&&this.mutatedKeys.has(p.key),S=!!_&&(_.hasLocalMutations||this.mutatedKeys.has(_.key)&&_.hasCommittedMutations);let m=!1;p&&_?p.data.isEqual(_.data)?g!==S&&(i.track({type:3,doc:_}),m=!0):this.fa(p,_)||(i.track({type:2,doc:_}),m=!0,(c&&this.da(_,c)>0||l&&this.da(_,l)<0)&&(a=!0)):!p&&_?(i.track({type:0,doc:_}),m=!0):p&&!_&&(i.track({type:1,doc:p}
6139),m=!0,(c||l)&&(a=!0)),m&&(_?(o=o.add(_),s=S?s.add(d):s.delete(d)):(o=o.delete(d),s=s.delete(d)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const d=this.query.limitType==="F"?o.last():o.first();o=o.delete(d.key),s=s.delete(d.key),i.track({type:1,doc:d})}return{Aa:o,ma:i,ts:a,mutatedKeys:s}}fa(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,i,r){const s=this.Aa;this.Aa=e.Aa,this.mutatedKeys=e.mutatedKeys;const o=e.ma.W_();o.sort((d,h)=>function(_,g){const S=m=>{switch(m){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Je()}};return S(_)-S(g)}(d.type,h.type)||this.da(d.doc,h.doc)),this.ga(i),r=r!=null&&r;const a=t&&!r?this.pa():[],c=this.Ea.size===0&&this.current&&!r?1:0,l=c!==this.Ta;return this.Ta=c,o.length!==0||l?{snapshot:new oo(this.query,e.Aa,s,o,e.mutatedKeys,c===0,l,!1,!!i&&i.resumeToken.approximateByteSize()>0),ya:a}:{ya:a}}Y_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Aa:this.Aa,ma:new jm,mutatedKeys:this.mutatedKeys,ts:!1},!1)):{ya:[]}}wa(e){return!this.Ia.has(e)&&!!this.Aa.has(e)&&!this.Aa.get(e).hasLocalMutations}ga(e){e&&(e.addedDocuments.forEach(t=>this.Ia=this.Ia.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ia=this.Ia.delete(t)),this.current=e.current)}pa(){if(!this.current)return[];const e=this.Ea;this.Ea=ct(),this.Aa.forEach(i=>{this.wa(i.key)&&(this.Ea=this.Ea.add(i.key))});const t=[];return e.forEach(i=>{this.Ea.has(i)||t.push(new ny(i))}),this.Ea.forEach(i=>{e.has(i)||t.push(new ty(i))}),t}Sa(e){this.Ia=e.Is,this.Ea=ct();const t=this.Va(e.documents);return this.applyChanges(t,!0)}ba(){return oo.fromInitialDocuments(this.query,this.Aa,this.mutatedKeys,this.Ta===0,this.hasCachedResults)}}class ND{constructor(e,t,i){this.query=e,this.targetId=t,this.view=i}}class kD{constructor(e){this.key=e,this.Da=!1}}class UD{constructor(e,t,i,r,s,o){this.localStore=e,this.remoteStore=t,this.eventManager=i,this.sharedClientState=r,this.currentUser=s,this.maxConcurrentLimboResolutions=o,this.Ca={},this.va=new Eo(a=>T0(a),$l),this.Fa=new Map,this.Ma=new Set,this.xa=new Dt(qe.comparator),this.Oa=new Map,this.Na=new Sp,this.La={},this.Ba=new Map,this.ka=so.Bn(),this.onlineState="Unknown",this.qa=void 0}get isPrimaryClient(){return this.qa===!0}}async function OD(n,e,t=!0){const i=cy(n);let r;const s=i.va.get(e);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),r=s.view.ba()):r=await iy(i,e,t,!0),r}async function FD(n,e){const t=cy(n);await iy(t,e,!0,!1)}async function iy(n,e,t,i){const r=await iD(n.localStore,mi(e)),s=r.targetId,o=t?n.sharedClientState.addLocalQueryTarget(s):"not-current";let a;return i&&(a=await VD(n,e,s,o==="current",r.resumeToken)),n.isPrimaryClient&&t&&Y0(n.remoteStore,r),a}async function VD(n,e,t,i,r){n.Qa=(h,p,_)=>async function(S,m,f,M){let w=m.view.Va(f);w.ts&&(w=await Gm(S.localStore,m.query,!1).then(({documents:T})=>m.view.Va(T,w)));const b=M&&M.targetChanges.get(m.targetId),R=M&&M.targetMismatches.get(m.targetId)!=null,P=m.view.applyChanges(w,S.isPrimaryClient,b,R);return Zm(S,m.targetId,P.ya),P.snapshot}(n,h,p,_);const s=await Gm(n.localStore,e,!0),o=new DD(e,s.Is),a=o.Va(s.documents),c=Ka.createSynthesizedTargetChangeForCurrentChange(t,i&&n.onlineState!=="Offline",r),l=o.applyChanges(a,n.isPrimaryClient,c);Zm(n,t,l.ya);const d=new ND(e,t,o);return n.va.set(e,d),n.Fa.has(t)?n.Fa.get(t).push(e):n.Fa.set(t,[e]),l.snapshot}async function BD(n,e,t){const i=et(n),r=i.va.get(e),s=i.Fa.get(r.targetId);if(s.length>1)return i.Fa.set(r.targetId,s.filter(o=>!$l(o,e))),void i.va.delete(e);i.isPrimaryClient?(i.sharedClientState.removeLocalQueryTarget(r.targetId),i.sharedClientState.isActiveQueryTarget(r.targetId)||await Mh(i.localStore,r.targetId,!1).then(()=>{i.sharedClientState.clearQueryState(r.targetId),t&&wp(i.remoteStore,r.targetId),Rh(i,r.targetId)}).catch(qa)):(Rh(i,r.targetId),await Mh(i.localStore,r.targetId,!0))}async function zD(n,e){const t=et(n),i=t.va.get(e),r=t.Fa.get(i.targetId);t.isPrimaryClient&&r.length===1&&(t.sharedClientState.removeLocalQueryTarget(i.targetId),wp(t.remoteStore,i.targetId))}async function HD(n,e,t){const i=YD(n);
6139try{const r=await function(o,a){const c=et(o),l=Wt.now(),d=a.reduce((_,g)=>_.add(g.key),ct());let h,p;return c.persistence.runTransaction("Locally write mutations","readwrite",_=>{let g=$i(),S=ct();return c.us.getEntries(_,d).next(m=>{g=m,g.forEach((f,M)=>{M.isValidDocument()||(S=S.add(f))})}).next(()=>c.localDocuments.getOverlayedDocuments(_,g)).next(m=>{h=m;const f=[];for(const M of a){const w=aL(M,h.get(M.key).overlayedDocument);w!=null&&f.push(new is(M.key,w,f0(w.value.mapValue),Ki.exists(!0)))}return c.mutationQueue.addMutationBatch(_,l,f,a)}).next(m=>{p=m;const f=m.applyToLocalDocumentSet(h,S);return c.documentOverlayCache.saveOverlays(_,m.batchId,f)})}).then(()=>({batchId:p.batchId,changes:A0(h)}))}(i.localStore,e);i.sharedClientState.addPendingMutation(r.batchId),function(o,a,c){let l=o.La[o.currentUser.toKey()];l||(l=new Dt(gt)),l=l.insert(a,c),o.La[o.currentUser.toKey()]=l}(i,r.batchId,t),await Qa(i,r.changes),await ou(i.remoteStore)}catch(r){const s=Pp(r,"Failed to persist write");t.reject(s)}}async function ry(n,e){const t=et(n);try{const i=await eD(t.localStore,e);
6139e.targetChanges.forEach((r,s)=>{const o=t.Oa.get(s);o&&(It(r.addedDocuments.size+r.modifiedDocuments.size+r.removedDocuments.size<=1),r.addedDocuments.size>0?o.Da=!0:r.modifiedDocuments.size>0?It(o.Da):r.removedDocuments.size>0&&(It(o.Da),o.Da=!1))}),await Qa(t,i,e)}catch(i){await qa(i)}}function Qm(n,e,t){const i=et(n);if(i.isPrimaryClient&&t===0||!i.isPrimaryClient&&t===1){const r=[];i.va.forEach((s,o)=>{const a=o.view.Y_(e);a.snapshot&&r.push(a.snapshot)}),function(o,a){const c=et(o);c.onlineState=a;let l=!1;c.queries.forEach((d,h)=>{for(const p of h.z_)p.Y_(a)&&(l=!0)}),l&&Lp(c)}(i.eventManager,e),r.length&&i.Ca.E_(r),i.onlineState=e,i.isPrimaryClient&&i.sharedClientState.setOnlineState(e)}}async function GD(n,e,t){const i=et(n);i.sharedClientState.updateQueryState(e,"rejected",t);const r=i.Oa.get(e),s=r&&r.key;if(s){let o=new Dt(qe.comparator);o=o.insert(s,hn.newNoDocument(s,$e.min()));const a=ct().add(s),c=new iu($e.min(),new Map,new Dt(gt),o,a);await ry(i,c),i.xa=i.xa.remove(s),i.Oa.delete(e),Dp(i)}else await Mh(i.localStore,e,!1).then(()=>Rh(i,e,t)).catch(qa)}async function WD(n,e){const t=et(n),i=e.batch.batchId;try{const r=await $L(t.localStore,e);oy(t,i,null),sy(t,i),t.sharedClientState.updateMutationState(i,"acknowledged"),await Qa(t,r)}catch(r){await qa(r)}}async function qD(n,e,t){const i=et(n);
6139try{const r=await function(o,a){const c=et(o);return c.persistence.runTransaction("Reject batch","readwrite-primary",l=>{let d;return c.mutationQueue.lookupMutationBatch(l,a).next(h=>(It(h!==null),d=h.keys(),c.mutationQueue.removeMutationBatch(l,h))).next(()=>c.mutationQueue.performConsistencyCheck(l)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(l,d,a)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(l,d)).next(()=>c.localDocuments.getDocuments(l,d))})}(i.localStore,e);oy(i,e,t),sy(i,e),i.sharedClientState.updateMutationState(e,"rejected",t),await Qa(i,r)}catch(r){await qa(r)}}function sy(n,e){(n.Ba.get(e)||[]).forEach(t=>{t.resolve()}),n.Ba.delete(e)}function oy(n,e,t){const i=et(n);let r=i.La[i.currentUser.toKey()];if(r){const s=r.get(e);s&&(t?s.reject(t):s.resolve(),r=r.remove(e)),i.La[i.currentUser.toKey()]=r}}function Rh(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const i of n.Fa.get(e))n.va.delete(i),t&&n.Ca.Ka(i,t);n.Fa.delete(e),n.isPrimaryClient&&n.Na.mr(e).forEach(i=>{n.Na.containsKey(i)||ay(n,i)})}function ay(n,e){n.Ma.delete(e.path.canonicalString());const t=n.xa.get(e);t!==null&&(wp(n.remoteStore,t),n.xa=n.xa.remove(e),n.Oa.delete(t),Dp(n))}function Zm(n,e,t){for(const i of t)i instanceof ty?(n.Na.addReference(i.key,e),XD(n,i)):i instanceof ny?(Le("SyncEngine","Document no longer in limbo: "+i.key),n.Na.removeReference(i.key,e),n.Na.containsKey(i.key)||ay(n,i.key)):Je()}function XD(n,e){const t=e.key,i=t.path.canonicalString();n.xa.get(t)||n.Ma.has(i)||(Le("SyncEngine","New document in limbo: "+t),n.Ma.add(i),Dp(n))}function Dp(n){for(;n.Ma.size>0&&n.xa.size<n.maxConcurrentLimboResolutions;){const e=n.Ma.values().next().value;n.Ma.delete(e);const t=new qe(Ut.fromString(e)),i=n.ka.next();n.Oa.set(i,new kD(t)),n.xa=n.xa.insert(t,i),Y0(n.remoteStore,new gr(mi(yp(t.path)),i,"TargetPurposeLimboResolution",pp.oe))}}async function Qa(n,e,t){const i=et(n),r=[],s=[],o=[];i.va.isEmpty()||(i.va.forEach((a,c)=>{o.push(i.Qa(c,e,t).then(l=>{var d;if((l||t)&&i.isPrimaryClient){const h=l?!l.fromCache:(d=t==null?void 0:t.targetChanges.get(c.targetId))===null||d===void 0?void 0:d.current;i.sharedClientState.updateQueryState(c.targetId,h?"current":"not-current")}if(l){r.push(l);const h=xp.Ui(c.targetId,l);s.push(h)}}))}),await Promise.all(o),i.Ca.E_(r),await async function(c,l){const d=et(c);try{await d.persistence.runTransaction("notifyLocalViewChanges","readwrite",h=>oe.forEach(l,p=>oe.forEach(p.Ki,_=>d.persistence.referenceDelegate.addReference(h,p.targetId,_)).next(()=>oe.forEach(p.$i,_=>d.persistence.referenceDelegate.removeReference(h,p.targetId,_)))))}catch(h){if(!Xa(h))throw h;Le("LocalStore","Failed to update sequence numbers: "+h)}for(const h of l){const p=h.targetId;if(!h.fromCache){const _=d.ss.get(p),g=_.snapshotVersion,S=_.withLastLimboFreeSnapshotVersion(g);d.ss=d.ss.insert(p,S)}}}(i.localStore,s))}async function jD(n,e){const t=et(n);if(!t.currentUser.isEqual(e)){Le("SyncEngine","User change. New user:",e.toKey());const i=await q0(t.localStore,e);t.currentUser=e,function(s,o){s.Ba.forEach(a=>{a.forEach(c=>{c.reject(new We(le.CANCELLED,o))})}),s.Ba.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,i.removedBatchIds,i.addedBatchIds),await Qa(t,i.ls)}}function KD(n,e){const t=et(n),i=t.Oa.get(e);if(i&&i.Da)return ct().add(i.key);{let r=ct();const s=t.Fa.get(e);if(!s)return r;for(const o of s){const a=t.va.get(o);r=r.unionWith(a.view.Ra)}return r}}function cy(n){const e=et(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=ry.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=KD.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=GD.bind(null,e),e.Ca.E_=RD.bind(null,e.eventManager),e.Ca.Ka=PD.bind(null,e.eventManager),e}function YD(n){const e=et(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=WD.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=qD.bind(null,e),e}class Jm{constructor(){this.synchronizeTabs=!1}async initialize(e){this.serializer=ru(e.databaseInfo.databaseId),this.sharedCl
6139ientState=this.createSharedClientState(e),this.persistence=this.createPersistence(e),await this.persistence.start(),this.localStore=this.createLocalStore(e),this.gcScheduler=this.createGarbageCollectionScheduler(e,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(e,this.localStore)}createGarbageCollectionScheduler(e,t){return null}createIndexBackfillerScheduler(e,t){return null}createLocalStore(e){return JL(this.persistence,new QL,e.initialUser,this.serializer)}createPersistence(e){return new jL(Ap.Yr,this.serializer)}createSharedClientState(e){return new sD}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class QD{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=i=>Qm(this.syncEngine,i,1),this.remoteStore.remoteSyncer.handleCredentialChange=jD.bind(null,this.syncEngine),await xD(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new ID}()}createDatastore(e){const t=ru(e.databaseInfo.databaseId),i=function(s){return new lD(s)}(e.databaseInfo);return function(s,o,a,c){return new hD(s,o,a,c)}(e.authCredentials,e.appCheckCredentials,i,t)}createRemoteStore(e){return function(i,r,s,o,a){return new fD(i,r,s,o,a)}(this.localStore,this.datastore,e.asyncQueue,t=>Qm(this.syncEngine,t,0),function(){return qm.D()?new qm:new oD}())}createSyncEngine(e,t){return function(r,s,o,a,c,l,d){const h=new UD(r,s,o,a,c,l);return d&&(h.qa=!0),h}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(r){const s=et(r);Le("RemoteStore","RemoteStore shutting down."),s.N_.add(5),await Ya(s),s.B_.shutdown(),s.k_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}/** 6140 * @license 6141 * Copyright 2020 Google LLC 6142 * 6143 * Licensed under the Apache License, Version 2.0 (the "License"); 6144 * you may not use this file except in compliance with the License. 6145 * You may obtain a copy of the License at 6146 * 6147 * http://www.apache.org/licenses/LICENSE-2.0 6148 * 6149 * Unless required by applicable law or agreed to in writing, software 6150 * distributed under the License is distributed on an "AS IS" BASIS, 6151 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6152 * See the License for the specific language governing permissions and 6153 * limitations under the License. 6154 *//** 6155 * @license 6156 * Copyright 2017 Google LLC 6157 * 6158 * Licensed under the Apache License, Version 2.0 (the "License"); 6159 * you may not use this file except in compliance with the License. 6160 * You may obtain a copy of the License at 6161 * 6162 * http://www.apache.org/licenses/LICENSE-2.0 6163 * 6164 * Unless required by applicable law or agreed to in writing, software 6165 * distributed under the License is distributed on an "AS IS" BASIS, 6166 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6167 * See the License for the specific language governing permissions and 6168 * limitations under the License. 6169 */class ZD{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.Wa(this.observer.next,e)}error(e){this.observer.error?this.Wa(this.observer.error,e):Ji("Uncaught Error in snapshot listener:",e.toString())}Ga(){this.muted=!0}Wa(e,t){this.muted||setTimeout(()=>{this.muted||e(t)},0)}}/** 6170 * @license 6171 * Copyright 2017 Google LLC 6172 * 6173 * Licensed under the Apache License, Version 2.0 (the "License"); 6174 * you may not use this file except in compliance with the License. 6175 * You may obtain a copy of the License at 6176 * 6177 * http://www.apache.org/licenses/LICENSE-2.0 6178 * 6179 * Unless required by applicable law or agreed to in writing, softw
6179are 6180 * distributed under the License is distributed on an "AS IS" BASIS, 6181 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6182 * See the License for the specific language governing permissions and 6183 * limitations under the License. 6184 */class JD{constructor(e,t,i,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=i,this.databaseInfo=r,this.user=dn.UNAUTHENTICATED,this.clientId=d0.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(i,async s=>{Le("FirestoreClient","Received user=",s.uid),await this.authCredentialListener(s),this.user=s}),this.appCheckCredentials.start(i,s=>(Le("FirestoreClient","Received new app check token=",s),this.appCheckCredentialListener(s,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new We(le.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new jr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const i=Pp(t,"Failed to shutdown persistence");e.reject(i)}}),e.promise}}async function cd(n,e){n.asyncQueue.verifyOperationInProgress(),Le("FirestoreClient","Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let i=t.initialUser;n.setCredentialChangeListener(async r=>{i.isEqual(r)||(await q0(e.localStore,r),i=r)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function $m(n,e){n.asyncQueue.verifyOperationInProgress();const t=await eN(n);Le("FirestoreClient","Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(i=>Xm(e.remoteStore,i)),n.setAppCheckTokenChangeListener((i,r)=>Xm(e.remoteStore,r)),n._onlineComponents=e}function $D(n){return n.name==="FirebaseError"?n.code===le.FAILED_PRECONDITION||n.code===le.UNIMPLEMENTED:!(typeof DOMException<"u"&&n instanceof DOMException)||n.code===22||n.code===20||n.code===11}async function eN(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){Le("FirestoreClient","Using user provided OfflineComponentProvider");try{await cd(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!$D(t))throw t;to("Error using user provided cache. Falling back to memory cache: "+t),await cd(n,new Jm)}}else Le("FirestoreClient","Using default OfflineComponentProvider"),await cd(n,new Jm);return n._offlineComponents}async function ly(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(Le("FirestoreClient","Using user provided OnlineComponentProvider"),await $m(n,n._uninitializedComponentsProvider._online)):(Le("FirestoreClient","Using default OnlineComponentProvider"),await $m(n,new QD))),n._onlineComponents}function tN(n){return ly(n).then(e=>e.syncEngine)}async function eg(n){const e=await ly(n),t=e.eventManager;return t.onListen=OD.bind(null,e.syncEngine),t.onUnlisten=BD.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=FD.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=zD.bind(null,e.syncEngine),t}/** 6185 * @license 6186 * Copyright 2023 Google LLC 6187 * 6188 * Licensed under the Apache License, Version 2.0 (the "License"); 6189 * you may not use this file except in compliance with the License. 6190 * You may obtain a copy of the License at 6191 * 6192 * http://www.apache.org/licenses/LICENSE-2.0 6193 * 6194 * Unless required by applicable law or agreed to in writing, software 6195 * distributed under the License is distributed on an "AS IS" BASIS, 6196 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6197 * See the License for the specific language governing permissions and 6198 * limitations under the License. 6199 */function uy(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/** 6200 * @license 6201 * Copyright 2020 Google LLC 6202 * 6203 * Licensed under the Apache License, Version 2.0 (the "License");
6204 * you may not use this file except in compliance with the License. 6205 * You may obtain a copy of the License at 6206 * 6207 * http://www.apache.org/licenses/LICENSE-2.0 6208 * 6209 * Unless required by applicable law or agreed to in writing, software 6210 * distributed under the License is distributed on an "AS IS" BASIS, 6211 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6212 * See the License for the specific language governing permissions and 6213 * limitations under the License. 6214 */const tg=new Map;/** 6215 * @license 6216 * Copyright 2017 Google LLC 6217 * 6218 * Licensed under the Apache License, Version 2.0 (the "License"); 6219 * you may not use this file except in compliance with the License. 6220 * You may obtain a copy of the License at 6221 * 6222 * http://www.apache.org/licenses/LICENSE-2.0 6223 * 6224 * Unless required by applicable law or agreed to in writing, software 6225 * distributed under the License is distributed on an "AS IS" BASIS, 6226 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6227 * See the License for the specific language governing permissions and 6228 * limitations under the License. 6229 */function nN(n,e,t){if(!t)throw new We(le.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function iN(n,e,t,i){if(e===!0&&i===!0)throw new We(le.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function ng(n){if(!qe.isDocumentKey(n))throw new We(le.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function Np(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=function(i){return i.constructor?i.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":Je()}function qs(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new We(le.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=Np(n);throw new We(le.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/** 6230 * @license 6231 * Copyright 2020 Google LLC 6232 * 6233 * Licensed under the Apache License, Version 2.0 (the "License"); 6234 * you may not use this file except in compliance with the License. 6235 * You may obtain a copy of the License at 6236 * 6237 * http://www.apache.org/licenses/LICENSE-2.0 6238 * 6239 * Unless required by applicable law or agreed to in writing, software 6240 * distributed under the License is distributed on an "AS IS" BASIS, 6241 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6242 * See the License for the specific language governing permissions and 6243 * limitations under the License. 6244 */class ig{constructor(e){var t,i;if(e.host===void 0){if(e.ssl!==void 0)throw new We(le.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(t=e.ssl)===null||t===void 0||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new We(le.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}iN("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=uy((i=e.experimentalLongPollingOptions)!==null&&i!==void 0?i:{}),function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new We(le.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new We(le.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new We(le.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(i,r){return i.timeoutSeconds===r.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class kp{constructor(e,t,i,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=i,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ig({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new We(le.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!==void 0}_setSettings(e){if(this._settingsFrozen)throw new We(le.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new ig(e),e.credentials!==void 0&&(this._authCredentials=function(i){if(!i)return new mP;switch(i.type){case"firstParty":return new EP(i.sessionIndex||"0",i.iamToken||null,i.authTokenFactory||null);case"provider":return i.client;default:throw new We(le.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
6244d credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const i=tg.get(t);i&&(Le("ComponentProvider","Removing Datastore"),tg.delete(t),i.terminate())}(this),Promise.resolve()}}function rN(n,e,t,i={}){var r;const s=(n=qs(n,kp))._getSettings(),o=`${e}:${t}`;if(s.host!=="firestore.googleapis.com"&&s.host!==o&&to("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),n._setSettings(Object.assign(Object.assign({},s),{host:o,ssl:!1})),i.mockUserToken){let a,c;if(typeof i.mockUserToken=="string")a=i.mockUserToken,c=dn.MOCK_USER;else{a=nE(i.mockUserToken,(r=n._app)===null||r===void 0?void 0:r.options.projectId);const l=i.mockUserToken.sub||i.mockUserToken.user_id;if(!l)throw new We(le.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new dn(l)}n._authCredentials=new gP(new u0(a,c))}}/** 6245 * @license 6246 * Copyright 2020 Google LLC 6247 * 6248 * Licensed under the Apache License, Version 2.0 (the "License"); 6249 * you may not use this file except in compliance with the License. 6250 * You may obtain a copy of the License at 6251 * 6252 * http://www.apache.org/licenses/LICENSE-2.0 6253 * 6254 * Unless required by applicable law or agreed to in writing, software 6255 * distributed under the License is distributed on an "AS IS" BASIS, 6256 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6257 * See the License for the specific language governing permissions and 6258 * limitations under the License. 6259 */class au{constructor(e,t,i){this.converter=t,this._query=i,this.type="query",this.firestore=e}withConverter(e){return new au(this.firestore,e,this._query)}}class Wn{constructor(e,t,i){this.converter=t,this._key=i,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Ua(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Wn(this.firestore,e,this._key)}}class Ua extends au{constructor(e,t,i){super(e,t,yp(i)),this._path=i,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Wn(this.firestore,null,new qe(e))}withConverter(e){return new Ua(this.firestore,e,this._path)}}function dy(n,e,...t){if(n=oi(n),arguments.length===1&&(e=d0.newId()),nN("doc","path",e),n instanceof kp){const i=Ut.fromString(e,...t);return ng(i),new Wn(n,null,new qe(i))}{if(!(n instanceof Wn||n instanceof Ua))throw new We(le.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const i=n._path.child(Ut.fromString(e,...t));return ng(i),new Wn(n.firestore,n instanceof Ua?n.converter:null,new qe(i))}}/** 6260 * @license 6261 * Copyright 2020 Google LLC 6262 * 6263 * Licensed under the Apache License, Version 2.0 (the "License"); 6264 * you may not use this file except in compliance with the License. 6265 * You may obtain a copy of the License at 6266 * 6267 * http://www.apache.org/licenses/LICENSE-2.0 6268 * 6269 * Unless required by applicable law or agreed to in writing, software 6270 * distributed under the License is distributed on an "AS IS" BASIS, 6271 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6272 * See the License for the specific language governing permissions and 6273 * limitations under the License. 6274 */class sN{constructor(){this._u=Promise.resolve(),this.au=[],this.uu=!1,this.cu=[],this.lu=null,this.hu=!1,this.Pu=!1,this.Iu=[],this.e_=new j0(this,"async_queue_retry"),this.Tu=()=>{const t=ad();t&&Le("AsyncQueue","Visibility state changed to "+t.visibilityState),this.e_.zo()};const e=ad();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.Tu)}get isShuttingDown(){return this.uu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Eu(),this.du(e)}enterRestrictedMode(e){if(!this.uu){this.uu=!0,this.Pu=e||!1;const t=ad();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Tu)}}enqueue(e){if(this.Eu(),this.uu)return new Promise(()=>{});const t=new jr;return this.du(()=>this.uu&&this.Pu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.au.push(e),this.Au()))}async Au(){if(this.au.length!==0){try{await this.au[0](),this.au.shift(),this.e_.reset()}catch(e){if(!Xa(e))throw e;Le("AsyncQueue","Operation failed with retryable error: "+e)}this.au.length>0&&this.e_.Wo(()=>this.Au())}}du(e){const t=this._u.then(()=>(this.hu=!0,e().catch(i=>{this.lu=i,this.hu=!1;const r=function(o){let a=o.message||"";return o.stack&&(a=o.stack.includes(o.message)?o.stack:o.message+` 6275`+o.stack),a}(i);throw Ji("INTERNAL UNHANDLED ERROR: ",r),i}).then(i=>(this.hu=!1,i))));return this._u=t,t}enqueueAfterDelay(e,t,i){this.Eu(),this.Iu.indexOf(e)>-1&&(t=0);const r=Rp.createAndSchedule(this,e,t,i,s=>this.Ru(s));return this.cu.push(r),r}Eu(){this.lu&&Je()}verifyOperationInProgress(){}async Vu(){let e;do e=this._u,await e;while(e!==this._u)}mu(e){for(const t of this.cu)if(t.timerId===e)return!0;return!1}fu(e){return this.Vu().then(()=>{this.cu.sort((t,i)=>t.targetTimeMs-i.targetTimeMs);for(const t of this.cu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Vu()})}gu(e){this.Iu.push(e)}Ru(e){const t=this.cu.indexOf(e);this.cu.splice(t,1)}}function rg(n){return function(t,i){if(typeof t!="object"||t===null)return!1;const r=t;for(const s of i)if(s in r&&typeof r[s]=="function")return!0;return!1}(n,["next","error","complete"])}class Pl extends kp{constructor(e,t,i,r){super(e,t,i,r),this.type="firestore",this._queue=function(){return new sN}(),this._persistenceKey=(r==null?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||py(this),this._firestoreClient.terminate()}}function oN(n,e){const t=typeof n=="object"?n:ag(),i=typeof n=="string"?n:e||"(default)",r=Lh(t,"firestore").getImmediate({identifier:i});if(!r._initialized){const s=tE("firestore");s&&rN(r,...s)}return r}function hy(n){return n._firestoreClient||py(n),n._firestoreClient.verifyNotTerminated(),n._firestoreClient}function py(n){var e,t,i;const r=n._freezeSettings(),s=function(a,c,l,d){return new DP(a,c,l,d.host,d.ssl,d.experimentalForceLongPolling,d.experimentalAutoDetectLongPolling,uy(d.experimentalLongPollingOptions),d.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,r);n._firestoreClient=new JD(n._authCredentials,n._appCheckCredentials,n._queue,s),!((t=r.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((i=r.localCache)===null||i===void 0)&&i._onlineComponentProvider)&&(n._firestoreClient._uninitializedComponentsProvider={_offlineKind:r.localCache.kind,_offline:r.localCache._offlineComponentProvider,_online:r.localCache._onlineComponentProvider})}/** 6276 * @license 6277 * Copyright 2020 Google LLC 6278 * 6279 * Licensed under the Apache License, Version 2.0 (the "License");
6280 * you may not use this file except in compliance with the License. 6281 * You may obtain a copy of the License at 6282 * 6283 * http://www.apache.org/licenses/LICENSE-2.0 6284 * 6285 * Unless required by applicable law or agreed to in writing, software 6286 * distributed under the License is distributed on an "AS IS" BASIS, 6287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6288 * See the License for the specific language governing permissions and 6289 * limitations under the License. 6290 */class ao{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ao(sn.fromBase64String(e))}catch(t){throw new We(le.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new ao(sn.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/** 6291 * @license 6292 * Copyright 2020 Google LLC 6293 * 6294 * Licensed under the Apache License, Version 2.0 (the "License"); 6295 * you may not use this file except in compliance with the License. 6296 * You may obtain a copy of the License at 6297 * 6298 * http://www.apache.org/licenses/LICENSE-2.0 6299 * 6300 * Unless required by applicable law or agreed to in writing, software 6301 * distributed under the License is distributed on an "AS IS" BASIS, 6302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6303 * See the License for the specific language governing permissions and 6304 * limitations under the License. 6305 */class Up{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new We(le.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new nn(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/** 6306 * @license 6307 * Copyright 2020 Google LLC 6308 * 6309 * Licensed under the Apache License, Version 2.0 (the "License"); 6310 * you may not use this file except in compliance with the License. 6311 * You may obtain a copy of the License at 6312 * 6313 * http://www.apache.org/licenses/LICENSE-2.0 6314 * 6315 * Unless required by applicable law or agreed to in writing, software 6316 * distributed under the License is distributed on an "AS IS" BASIS, 6317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6318 * See the License for the specific language governing permissions and 6319 * limitations under the License. 6320 */class fy{constructor(e){this._methodName=e}}/** 6321 * @license 6322 * Copyright 2017 Google LLC 6323 * 6324 * Licensed under the Apache License, Version 2.0 (the "License"); 6325 * you may not use this file except in compliance with the License. 6326 * You may obtain a copy of the License at 6327 * 6328 * http://www.apache.org/licenses/LICENSE-2.0 6329 * 6330 * Unless required by applicable law or agreed to in writing, software 6331 * distributed under the License is distributed on an "AS IS" BASIS, 6332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6333 * See the License for the specific language governing permissions and 6334 * limitations under the License. 6335 */class Op{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new We(le.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new We(le.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return gt(this._lat,e._lat)||gt(this._long,e._long)}}/** 6336 * @license 6337 * Copyright 2017 Google LLC 6338 * 6339 * Licensed under the Apache License, Version 2.0 (the "License"); 6340 * you may not use this file except in compliance with the License. 6341 * You may obtain a copy of the License at 6342 * 6343 * http://www.apache.org/licenses/LICENSE-2.0 6344 * 6345 * Unless required by applicable law or agreed to in writing, software 6346 * distributed under the License is distributed on an "AS IS" BASIS, 6347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6348 * See the License for the specific language governing permissions and 6349 * limitations under the License. 6350 */const aN=/^__.*__$/;class cN{constructor(e,t,i){this.data=e,this.fieldMask=t,this.fieldTransforms=i}toMutation(e,t){return this.fieldMask!==null?new is(e,this.data,this.fieldMask,t,this.fieldTransforms):new ja(e,this.data,t,this.fieldTransforms)}}function _y(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Je()}}class Fp{constructor(e,t,i,r,s,o){this.settings=e,this.databaseId=t,this.serializer
6350=i,this.ignoreUndefinedProperties=r,s===void 0&&this.pu(),this.fieldTransforms=s||[],this.fieldMask=o||[]}get path(){return this.settings.path}get yu(){return this.settings.yu}wu(e){return new Fp(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Su(e){var t;const i=(t=this.path)===null||t===void 0?void 0:t.child(e),r=this.wu({path:i,bu:!1});return r.Du(e),r}Cu(e){var t;const i=(t=this.path)===null||t===void 0?void 0:t.child(e),r=this.wu({path:i,bu:!1});return r.pu(),r}vu(e){return this.wu({path:void 0,bu:!0})}Fu(e){return Ll(e,this.settings.methodName,this.settings.Mu||!1,this.path,this.settings.xu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}pu(){if(this.path)for(let e=0;e<this.path.length;e++)this.Du(this.path.get(e))}Du(e){if(e.length===0)throw this.Fu("Document fields must not be empty");if(_y(this.yu)&&aN.test(e))throw this.Fu('Document fields cannot begin and end with "__"')}}class lN{constructor(e,t,i){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=i||ru(e)}Ou(e,t,i,r=!1){return new Fp({yu:e,methodName:t,xu:i,path:nn.emptyPath(),bu:!1,Mu:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function uN(n){const e=n._freezeSettings(),t=ru(n._databaseId);return new lN(n._databaseId,!!e.ignoreUndefinedProperties,t)}function dN(n,e,t,i,r,s={}){const o=n.Ou(s.merge||s.mergeFields?2:0,e,t,r);yy("Data must be an object, but it was:",o,i);const a=gy(i,o);let c,l;if(s.merge)c=new ii(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const d=[];for(const h of s.mergeFields){const p=hN(e,h,t);if(!o.contains(p))throw new We(le.INVALID_ARGUMENT,`Field '${p}' is specified in your field mask but missing from your input data.`);fN(d,p)||d.push(p)}c=new ii(d),l=o.fieldTransforms.filter(h=>c.covers(h.field))}else c=null,l=o.fieldTransforms;return new cN(new Hn(a),c,l)}function my(n,e){if(vy(n=oi(n)))return yy("Unsupported field value:",e,n),gy(n,e);if(n instanceof fy)return function(i,r){if(!_y(r.yu))throw r.Fu(`${i._methodName}() can only be used with update() and set()`);if(!r.path)throw r.Fu(`${i._methodName}() is not currently supported inside arrays`);const s=i._toFieldTransform(r);s&&r.fieldTransforms.push(s)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.bu&&e.yu!==4)throw e.Fu("Nested arrays are not supported");return function(i,r){const s=[];let o=0;for(const a of i){let c=my(a,r.vu(o));c==null&&(c={nullValue:"NULL_VALUE"}),s.push(c),o++}return{arrayValue:{values:s}}}(n,e)}return function(i,r){if((i=oi(i))===null)return{nullValue:"NULL_VALUE"};if(typeof i=="number")return tL(r.serializer,i);if(typeof i=="boolean")return{booleanValue:i};if(typeof i=="string")return{stringValue:i};if(i instanceof Date){const s=Wt.fromDate(i);return{timestampValue:Cl(r.serializer,s)}}if(i instanceof Wt){const s=new Wt(i.seconds,1e3*Math.floor(i.nanoseconds/1e3));return{timestampValue:Cl(r.serializer,s)}}if(i instanceof Op)return{geoPointValue:{latitude:i.latitude,longitude:i.longitude}};if(i instanceof ao)return{bytesValue:F0(r.serializer,i._byteString)};if(i instanceof Wn){const s=r.databaseId,o=i.firestore._databaseId;if(!o.isEqual(s))throw r.Fu(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:bp(i.firestore._databaseId||r.databaseId,i._key.path)}}throw r.Fu(`Unsupported field value: ${Np(i)}`)}(n,e)}function gy(n,e){const t={};return h0(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):yo(n,(i,r)=>{const s=my(r,e.Su(i));s!=null&&(t[i]=s)}),{mapValue:{fields:t}}}function vy(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof Wt||n instanceof Op||n instanceof ao||n instanceof Wn||n instanceof fy)}function yy(n,e,t){if(!vy(t)||!function(r){return typeof r=="object"&&r!==null&&(Object.getPrototypeOf(r)===Object.prototype||Ob
6350ject.getPrototypeOf(r)===null)}(t)){const i=Np(t);throw i==="an object"?e.Fu(n+" a custom object"):e.Fu(n+" "+i)}}function hN(n,e,t){if((e=oi(e))instanceof Up)return e._internalPath;if(typeof e=="string")return Ey(n,e);throw Ll("Field path arguments must be of type string or ",n,!1,void 0,t)}const pN=new RegExp("[~\\*/\\[\\]]");function Ey(n,e,t){if(e.search(pN)>=0)throw Ll(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Up(...e.split("."))._internalPath}catch{throw Ll(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Ll(n,e,t,i,r){const s=i&&!i.isEmpty(),o=r!==void 0;let a=`Function ${e}() called with invalid data`;t&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${i}`),o&&(c+=` in document ${r}`),c+=")"),new We(le.INVALID_ARGUMENT,a+n+c)}function fN(n,e){return n.some(t=>t.isEqual(e))}/** 6351 * @license 6352 * Copyright 2020 Google LLC 6353 * 6354 * Licensed under the Apache License, Version 2.0 (the "License"); 6355 * you may not use this file except in compliance with the License. 6356 * You may obtain a copy of the License at 6357 * 6358 * http://www.apache.org/licenses/LICENSE-2.0 6359 * 6360 * Unless required by applicable law or agreed to in writing, software 6361 * distributed under the License is distributed on an "AS IS" BASIS, 6362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6363 * See the License for the specific language governing permissions and 6364 * limitations under the License. 6365 */class Ty{constructor(e,t,i,r,s){this._firestore=e,this._userDataWriter=t,this._key=i,this._document=r,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new Wn(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new _N(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(by("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class _N extends Ty{data(){return super.data()}}function by(n,e){return typeof e=="string"?Ey(n,e):e instanceof Up?e._internalPath:e._delegate._internalPath}/** 6366 * @license 6367 * Copyright 2020 Google LLC 6368 * 6369 * Licensed under the Apache License, Version 2.0 (the "License"); 6370 * you may not use this file except in compliance with the License. 6371 * You may obtain a copy of the License at 6372 * 6373 * http://www.apache.org/licenses/LICENSE-2.0 6374 * 6375 * Unless required by applicable law or agreed to in writing, software 6376 * distributed under the License is distributed on an "AS IS" BASIS, 6377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6378 * See the License for the specific language governing permissions and 6379 * limitations under the License. 6380 */function mN(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new We(le.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class gN{convertValue(e,t="none"){switch(es(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Ht(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes($r(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw Je()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const i={};return yo(e,(r,s)=>{i[r]=this.convertValue(s,t)}),i}convertGeoPoint(e){return new Op(Ht(e.latitude),Ht(e.longitude))}convertArray(e,t){return(e.values||[]).map(i=>this.convertValue(i,t))}convertServerTimestamp(e,t){switch(t){case"previous":const i=_p(e);return i==null?null:this.convertValue(i,t);case"estimate":return this.convertTimestamp(Pa(e));default:return null}}convertTimestamp(e){const t=Sr(e);return new Wt(t.seconds,t.nanos)}convertDocumentKey(e,t){const i=Ut.fromString(e);It(W0(i));const r=new La(i.get(1),i.get(3)),s=new qe(i.popFirst(5));return r.isEqual(t)||Ji(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}}/** 6381 * @license 6382 * Copyright 2020 Google LLC 6383 * 6384 * Licensed under the Apache License, Version 2.0 (the "License");
6385 * you may not use this file except in compliance with the License. 6386 * You may obtain a copy of the License at 6387 * 6388 * http://www.apache.org/licenses/LICENSE-2.0 6389 * 6390 * Unless required by applicable law or agreed to in writing, software 6391 * distributed under the License is distributed on an "AS IS" BASIS, 6392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6393 * See the License for the specific language governing permissions and 6394 * limitations under the License. 6395 */function vN(n,e,t){let i;return i=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,i}/** 6396 * @license 6397 * Copyright 2020 Google LLC 6398 * 6399 * Licensed under the Apache License, Version 2.0 (the "License"); 6400 * you may not use this file except in compliance with the License. 6401 * You may obtain a copy of the License at 6402 * 6403 * http://www.apache.org/licenses/LICENSE-2.0 6404 * 6405 * Unless required by applicable law or agreed to in writing, software 6406 * distributed under the License is distributed on an "AS IS" BASIS, 6407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6408 * See the License for the specific language governing permissions and 6409 * limitations under the License. 6410 */class ca{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Sy extends Ty{constructor(e,t,i,r,s,o){super(e,t,i,r,o),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new al(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const i=this._document.data.field(by("DocumentSnapshot.get",e));if(i!==null)return this._userDataWriter.convertValue(i,t.serverTimestamps)}}}class al extends Sy{data(e={}){return super.data(e)}}class yN{constructor(e,t,i,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new ca(r.hasPendingWrites,r.fromCache),this.query=i}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(i=>{e.call(t,new al(this._firestore,this._userDataWriter,i.key,i,new ca(this._snapshot.mutatedKeys.has(i.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new We(le.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(r,s){if(r._snapshot.oldDocs.isEmpty()){let o=0;return r._snapshot.docChanges.map(a=>{const c=new al(r._firestore,r._userDataWriter,a.doc.key,a.doc,new ca(r._snapshot.mutatedKeys.has(a.doc.key),r._snapshot.fromCache),r.query.converter);return a.doc,{type:"added",doc:c,oldIndex:-1,newIndex:o++}})}{let o=r._snapshot.oldDocs;return r._snapshot.docChanges.filter(a=>s||a.type!==3).map(a=>{const c=new al(r._firestore,r._userDataWriter,a.doc.key,a.doc,new ca(r._snapshot.mutatedKeys.has(a.doc.key),r._snapshot.fromCache),r.query.converter);let l=-1,d=-1;return a.type!==0&&(l=o.indexOf(a.doc.key),o=o.delete(a.doc.key)),a.type!==1&&(o=o.add(a.doc),d=o.indexOf(a.doc.key)),{type:EN(a.type),doc:c,oldIndex:l,newIndex:d}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function EN(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Je()}}class Ay extends gN{constructor(e){super(),this.firestore=e}convertBytes(e){return new ao(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Wn(this.firestore,null,t)}}function TN(n,e,t){n=qs(n,Wn);const i=qs(n.firestore,Pl),r=vN(n.converter,e,t);return SN(i,[dN(uN(i),"setDoc",n._key,r,n.converter!==null,t).toMutation(n._key,Ki.none())])}function bN(n,...e){var t,i,r;n=oi(n);let s={includeMetadataChanges:!1,source:"default"},o=0;typeof e[o]!="object"||rg(e[o])||(s=e[o],o++);const a={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(rg(e[o])){const h=e[o];e[o]=(t=h.next)===null||t===void 0?void 0:t.bind(h),e[o+1]=(i=h.error)===null||i===void 0?void 0:i.bind(h),e[o+2]=(r=h.complete)===null||r===void 0?void 0:r.bind(h)}let c,l,d;if(n instanceof Wn)l=qs(n.firestore,Pl),d=yp(n._key.path),c={next:h=>{e[o]&&e[o](AN(l,n,h))},error:e[o+1],complete:e[o+2]};else{const h=qs(n,au);l=qs(h.firestore,Pl),d=h._query;const p=new Ay(l);c={next:_=>{e[o]&&e[o](new yN(l,p,h,_))},error:e[o+1],complete:e[o+2]},mN(n._query)}return function(p,_,g,S){const m=new ZD(S),f=new LD(_,m,g);return p.asyncQueue.enqueueAndForget(async()=>MD(await eg(p),f)),()=>{m.Ga(),p.asyncQueue.enqueueAndForget(async()=>CD(await eg(p),f))}}(hy(l),d,a,c)}function SN(n,e){return function(i,r){const s=new jr;return i.asyncQueue.enqueueAndForget(async()=>HD(await tN(i),r,s)),s.promise}(hy(n),e)}function AN(n,e,t){const i=t.docs.get(e._key),r=new Ay(n);return new Sy(n,r,e._key,i,new ca(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(r){vo=r})(uo),ud(new dd("firestore",(i,{instanceIdentifier:r,options:s})=>{const o=i.getProvider("app").getImmediate(),a=new Pl(new vP(i.getProvider("auth-internal")),new bP(i.getProvider("app-check-internal")),function(l,d){if(!Object.prototype.hasOwnProperty.apply(l.options,["projectId"]))throw new We(le.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');
6410return new La(l.options.projectId,d)}(o,r),o);return s=Object.assign({useFetchStreams:t},s),a._setSettings(s),a},"PUBLIC").setMultipleInstances(!0)),cl(Sm,"4.6.5",e),cl(Sm,"4.6.5","esm2017")})();const Ph=oN(window.firebaseApp),xy=fP(window.firebaseApp),cu="user01_unreg",Vp="user02_reg",Oa="user03_paying",wy="user03_01_plus",Iy="user03_02_pro",My="user03_03_premium",Cy="user03_04_lifetime",sg={[cu]:"guest",[Vp]:"register",[Oa]:"paying"},ld={[wy]:"plus",[Iy]:"pro",[My]:"premium",[Cy]:"lifetime"},xN={[wy]:"/images/plan-plus.svg",[Iy]:"/images/plan-pro.svg",[My]:"/images/plan-premium.svg",[Cy]:"/images/plan-lifetime.svg"};window.addEventListener("load",()=>{document.getElementById("btn-account").addEventListener("click",()=>{popupPanelContainer.style.visibility!="visible"?(menuPanelContainer.style.left="",menuPanelContainer.style.top="",showMenuPanel("accountMenu","account-menu")):hideMenuPanel()}),document.getElementById("btn-login-register").addEventListener("click",()=>{wN()}),document.getElementById("feedback-center").addEventListener("click",()=>{showPopupPanel("feedback");const n=document.getElementById("btn-ratings-group"),e=document.getElementById("feedback-emotions");n.querySelectorAll(".btn-rating").forEach(t=>{t.addEventListener("mouseenter",changeRatingScorce),t.addEventListener("mouseleave",resetRatingScorce),t.addEventListener("click",lockRatingScorce)}),e.querySelectorAll("svg").forEach(t=>{t.addEventListener("click",lockEmotion)})}),window.addEventListener("Authenticate",n=>{n.preventDefault(),n.detail.eventType=="tokenExpired"||n.detail.eventType=="logout"?(Ry(),IN()):n.detail.eventType=="signup"&&n.detail.data?PN(n.detail.data):n.detail.eventType=="login"&&n.detail.data?LN(n.detail.data):n.detail.eventType=="forgotPassword"&&n.detail.data?NN(n.detail.data):n.detail.eventType=="changePassword"&&n.detail.data?kN(n.detail.data):n.detail.eventType=="delete"&&DN()}),window.addEventListener("StripeEvent",n=>{n.preventDefault(),n.detail.eventType&&(n.detail.eventType=="getLifeTime"?window.open("https://buy.stripe.com/8wMcNef1Z1Dl0SsbII?prefilled_email="+accountInfo.email,"_blank").focus():n.detail.eventType=="getPlus"?window.open("https://buy.stripe.com/6oE9B22fd6XF30A5kn?prefilled_email="+accountInfo.email,"_blank").focus():n.detail.eventType=="getPro"?window.open("https://buy.stripe.com/cN2dRi5rpeq78kUbIK?prefilled_email="+accountInfo.email,"_blank").focus():n.detail.eventType=="getPremium"&&window.open("https://buy.stripe.com/5kA3cEaLJ0zhbx68wx?prefilled_email="+accountInfo.email,"_blank").focus())}),window.addEventListener("Feedback",n=>{n.preventDefault(),n.detail.data&&ON(n.detail.data)}),Ph?bN(dy(Ph,"broadcast","global"),n=>{}):console.log("Can not subscribe to realtime data")});const Fe=(n="",e="",t={message:"",stack:""},i="")=>{const r=new Date().toISOString().replace(/:/g,"-"),s={component:n,url:e,date:new Date,extraInfo:i,error:{message:t.message??"",stack:t.stack??""}};TN(dy(Ph,"ErrorLogs",r),{log:s}
6410).catch(o=>{console.error("Error sending message: ",o)})};function wN(){showPopupPanel("welcome");const n=popupPanelContainer.querySelector("#btn-signin-gmail");n&&n.addEventListener("click",MN);const e=popupPanelContainer.querySelector("#btn-signin-apple");e&&e.addEventListener("click",CN)}function IN(){const n=getCookie("user_token");if(n)return accountInfo.credits=getCookie("user_credits"),accountInfo.initials=getCookie("initials"),accountInfo.picture=getCookie("picture"),accountInfo.nickname=getCookie("nickname"),accountInfo.userToken=n,accountInfo.userType=getCookie("user_type")??Vp,accountInfo.subscriptionType=getCookie("subscription_type"),accountInfo.firstName=getCookie("first_name"),accountInfo.lastName=getCookie("last_name"),accountInfo.email=getCookie("email"),accountInfo.lastLoginAt=getCookie("last_login_at"),document.getElementById("account-nick-name").textContent=accountInfo.nickname,document.getElementById("btn-login-register").style.display="none",document.getElementById("btn-account").style.display="flex",accountInfo.picture?(document.getElementById("account-picture").src=accountInfo.picture,document.getElementById("account-initials").style.display="none",document.getElementById("account-picture").style.display="block"):(document.getElementById("account-initials").textContent=accountInfo.initials,document.getElementById("account-initials").style.display="block",document.getElementById("account-picture").style.display="none"),getCookie("payment_session")&&(UN(),document.cookie="payment_session=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"),accountInfo.credits==null?co():Fa(accountInfo.credits),n;accountInfo.guestToken=getCookie("guest_token"),accountInfo.userType=getCookie("user_type")??cu,accountInfo.credits=getCookie("guest_credits"),accountInfo.guestToken!=null?accountInfo.credits==null?co(accountInfo.guestToken):Fa(accountInfo.credits):lu()}function Ry(){accountInfo.initials="",accountInfo.picture="",accountInfo.nickname="",accountInfo.userToken="",accountInfo.userType="",accountInfo.subscriptionType="",accountInfo.credits=null,accountInfo.firstName="",accountInfo.lastName="",accountInfo.email="",accountInfo.lastLoginAt="",accountInfo.sessionList=[],document.cookie="initials=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="nickname=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="user_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="user_type=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="subscription_type=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="picture=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="last_login_at=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="email=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="first_name=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="last_name=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="login_time=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="user_credits=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.getElementById("btn-session").classList.contains("selected")&&(leftPanelContainer.style.visibility="hidden",leftPanelContainer.style.opacity=0,leftPanelContent.innerHTML="",document.getElementById("btn-session").classList.remove("selected")),document.getElementById("btn-login-register").style.display="flex",document.getElementById("btn-account").style.display="none",document.getElementById("account-initials").style.display="block",document.getElementById("account-picture").src="/images/logo.svg",document.getElementById("account-picture").style.display="none",document.getElementById("subscriptions-info").textContent="AI Credits:",document.getElementById("credit-balance").textContent="0"}async function MN(){document.getElementById("btn-signin-group").style.display="none",document.getElementById("spinner-signin-group").style.display="flex";const n=new Fi;try{const e=await t0(xy,n),t=e.user,i=t2(e),r={email:t.email,first_name:i.profile.given_name??"",last_name:i.profile.family_name??"",picture:i.profile.picture,user_token:t.accessToken,isNewUser:i.isNewUser??!1,nickname:t.displayName??"",method_of_registration:"GMAIL",email_verified:i.profile.verified_email,current_credits:0};i.isNewUser?await Dl(r)?(r.user_token=accountInfo.userToken,r.guest_token=getCookie("guest_token"),r.guest_credit_balance=getCookie("guest_credits"),await RN(r),hidePopupPanel()):(document.getElementById("btn-signin-group").style.display="flex",document.getElementById("spinner-signin-group").style.display="none"):await Dl(r)?(hidePopupPanel(),showNoticePanel("info","Successful signin","Hello "+t.displayName+"! Welcome back.")):(document.getElementById("btn-signin-group").style.display="flex",document.getElementById("spinner-signin-group").style.display="none")}catch(e){hidePopupPanel(),console.log(e.message),showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,e,"signinWithGoogle")}}function CN(){const n=new qr("apple.com");n.addScope("email"),n.addScope("name"),t0(xy,n).then(e=>{qr.credentialFromResult(e).accessToken;const i=e.user;showNoticePanel("info","Successful signin","Hello "+i.displayName+"! Welcome to mapster it"),hidePopupPanel()}).catch(e=>{qr.credentialFromError(e),hidePopupPanel(),showNoticePanel("error","",e.message),Fe("authenticate.js",window.location.href,e,"signinWithApple")})}async function RN(n){try{let e=await fetch("https://api.mapster.ai/api/v1/user_signup_gmail_or_apple",{method:"POST",headers:{"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)});if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");e=await e.json(),e.status==!0&&e.status_code==200?(hidePopupPanel(),showNoticePanel("receivedCreadit",null,"You received free Credits because you registered."),co()):e.message?(showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"registerNewUser")):(showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"registerNewUser"))}catch(e){showNoticePanel("error","Error",e.message),console.log(e.message),Fe("authenticate.js",window.location.href,e,"registerNewUser")}}async function PN(n){document.getElementById("btn-register").style.display="none",document.getElementById("spinner-register").style.display="block";try{n.guest_token=getCookie("guest_token"),n.guest_credit_balance=getCookie("guest_credits"),fetch("https://api.mapster.ai/api/v1/user_signup",{method:"POST",headers:{"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status==!0&&e.status_code==200?(hidePopupPanel(),e.data.user_type=Vp,e.data.email||(e.data.email=n.email),Dl(e.data),showNoticePanel("receivedCreadit",null,"You received free Credits because you registered.")):e.status==!1?(document.getElementById("btn-register").style.display="block",document.getElementById("spinner-register").style.display="none",showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"signinWithEmail")):(document.getElementById("btn-register").style.display="block",document.getElementById("spinner-register").style.display="none",showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"signinWithEmail"))})}catch(e){document.getElementById("btn-register").style.display="block",document.getElementById("spinner-register").style.display="none",console.log(e),finishedProgressDataIndicator(),Fe("authenticate.js",window.location.href,e,"signinWithEmail")}}function LN(n){fetch("https://api.mapster.ai/api/v1/user_login",{method:"POST",headers:{"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status==!0&&e.status_code==200&&e.data?(Dl(e.data),hidePopupPanel(),e.data.email_verified?showNoticePanel("info","Success","Successful login!"):showNoticePanel("notice","Verify for free credits","We sent you an Email. Please verify your Email and receive additional credits.","/images/notice-email.svg")):e.status==!1?(document.getElementById("btn-login").style.display="block",document.getElementById("spinner-login").style.display="none",showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"loginWithEmail")):(document.getElementById("btn-login").style.display="block",document.getElementById("spinner-login").style.display="none",showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"loginWithEmail"))}).catch(e=>{showNoticePanel("error","Error",e.message),document.getElementById("btn-login").style.display="block",document.getElementById("spinner-login").style.display="none",Fe("authenticate.js",window.location.href,e,"loginWithEmail"),console.log(e)})}function DN(){if(!accountInfo.userToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("authenticate.js",window.location.href,{message:"User token is empty!",stack:""},"deleteAccount");return}const n={user_token:accountInfo.userToken};document.getElementById("btn-delete-account").style.display="none",document.getElementById("spinner-delete-account").style.display="block",fetch("https://api.mapster.ai/api/v1/delete_user_account",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status_code===200&&e.status===!0&&e.data?e.data.deleted&&(showNoticePanel("info","Susscess","Your account is removed successfully!"),window.dispatchEvent(logout
6410Event),hidePopupPanel()):e.status_code===401?(window.dispatchEvent(tokenExpired),document.getElementById("btn-delete-account").style.display="block",document.getElementById("spinner-delete-account").style.display="none"):e.message&&(showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"deleteAccount"),document.getElementById("btn-delete-account").style.display="block",document.getElementById("spinner-delete-account").style.display="none")}).catch(e=>{showNoticePanel("error","Error",e.message),document.getElementById("btn-delete-account").style.display="block",document.getElementById("spinner-delete-account").style.display="none",Fe("authenticate.js",window.location.href,e,"deleteAccount")})}function NN(n){fetch("https://api.mapster.ai/api/v1/user_forgot_password",{method:"POST",headers:{"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status==!0&&e.status_code==200?(hidePopupPanel(),showNoticePanel("resetPassword")):e.status==!1?(document.getElementById("btn-send-email-reset").style.display="block",document.getElementById("spinner-reset-password").style.display="none",showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"forgotPassword")):(document.getElementById("btn-send-email-reset").style.display="block",document.getElementById("spinner-reset-password").style.display="none",showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"forgotPassword"))}).catch(e=>{showNoticePanel("error","Error",e.message),document.getElementById("btn-send-email-reset").style.display="block",document.getElementById("spinner-reset-password").style.display="none",Fe("authenticate.js",window.location.href,e,"forgotPassword")})}function kN(n){if(!accountInfo.userToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("authenticate.js",window.location.href,{message:"User token is empty!",stack:""},"changePassword");return}n.user_token=accountInfo.userToken,fetch("https://api.mapster.ai/api/v1/change_password",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status==!0&&e.status_code==200?(Ry(),hidePopupPanel(),showNoticePanel("info","Success","Your password has been changed, please re-login with your new password!")):e.status==!1?(document.getElementById("btn-change-password").style.display="block",document.getElementById("spinner-change-password").style.display="none",showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"changePassword")):(document.getElementById("btn-change-password").style.display="block",document.getElementById("spinner-change-password").style.display="none",showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"changePassword"))}).catch(e=>{showNoticePanel("error","Error",e.message),document.getElementById("btn-change-password").style.display="block",document.getElementById("spinner-change-password").style.display="none",console.log(e),Fe("authenticate.js",window.location.href,e,"changePassword")})}async function Dl(n){if(n.user_token&&n.method_of_registration&&n.method_of_registration==="GMAIL")try{let e=await fetch("https://api.mapster.ai/api/v1/get_user_token_from_firebase_token",{method:"POST",headers:{"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify({firebase_token:n.user_token})});if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");if(e=await e.json(),e.status==!0&&e.status_code==200&&e.data&&e.data.user_token&&e.data.user_type){const t=Date.now();accountInfo.userToken=e.data.user_token,accountInfo.userType=e.data.user_type,accountInfo.subscriptionType=e.data.subscription_type??"",setCookie("user_token",accountInfo.userToken,TIME_TO_LIVE_USER_TOKEN),setCo
6410okie("user_type",accountInfo.userType,TIME_TO_LIVE_USER_TOKEN),setCookie("subscription_type",accountInfo.subscriptionType,TIME_TO_LIVE_USER_TOKEN),setCookie("login_time",t,TIME_TO_LIVE_USER_TOKEN),n.isNewUser||await co()}else return e.status==!1?(showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"handleValidCredentials"),console.log(e.message),!1):(showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"handleValidCredentials"),console.log(e.message),!1)}catch(e){return showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,e,"handleValidCredentials"),console.log(e),!1}else if(n.user_token&&n.user_type){const e=Date.now();accountInfo.userToken=n.user_token,accountInfo.userType=n.user_type,accountInfo.subscriptionType=n.subscription_type??"",setCookie("user_token",accountInfo.userToken,TIME_TO_LIVE_USER_TOKEN),setCookie("user_type",accountInfo.userType,TIME_TO_LIVE_USER_TOKEN),setCookie("subscription_type",accountInfo.subscriptionType,TIME_TO_LIVE_USER_TOKEN),setCookie("login_time",e,TIME_TO_LIVE_USER_TOKEN),co()}else return showNoticePanel("error","","User token is undefined"),Fe("authenticate.js",window.location.href,{message:"User token is undefined",stack:""},"handleValidCredentials"),window.dispatchEvent(tokenExpired),!1;return n.picture&&(setCookie("picture",n.picture,TIME_TO_LIVE_USER_TOKEN),document.getElementById("account-initials").style.display="none",document.getElementById("account-picture").style.display="block",document.getElementById("account-picture").src=n.picture),accountInfo.initials=n.initials??"",setCookie("initials",accountInfo.initials,TIME_TO_LIVE_USER_TOKEN),document.getElementById("account-initials").textContent=accountInfo.initials,accountInfo.initials==""&&(document.getElementById("account-initials").style.display="none",document.getElementById("account-picture").style.display="block"),accountInfo.nickname=n.nickname??"",setCookie("nickname",accountInfo.nickname,TIME_TO_LIVE_USER_TOKEN),document.getElementById("account-nick-name").textContent=accountInfo.nickname,accountInfo.email=n.email??"",setCookie("email",accountInfo.email,TIME_TO_LIVE_USER_TOKEN),document.getElementById("account-nick-name").textContent=accountInfo.email,accountInfo.lastLoginAt=n.last_login_at??"",setCookie("last_login_at",accountInfo.lastLoginAt,TIME_TO_LIVE_USER_TOKEN),accountInfo.firstName=n.first_name??"",setCookie("first_name",accountInfo.firstName,TIME_TO_LIVE_USER_TOKEN),accountInfo.lastName=n.last_name??"",setCookie("last_name",accountInfo.lastName,TIME_TO_LIVE_USER_TOKEN),accountInfo.sessionList=[],document.getElementById("btn-login-register").style.display="none",document.getElementById("btn-account").style.display="flex",window.dispatchEvent(new CustomEvent("SessionEvent",{detail:{action:"list"}})),!0}async function lu(){let n=!1;try{startProgressDataIndicator("Accessing as guest...");let e=await fetch("https://api.mapster.ai/api/v1/sign_in_anonymous",{mode:"cors"});if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");e=await e.json(),e.status==!0&&e.status_code==200&&e.data&&e.data.user_token?(accountInfo.guestToken=e.data.user_token,accountInfo.userType=e.data.user_type??cu,setCookie("guest_token",accountInfo.guestToken,TIME_TO_LIVE_GUEST_TOKEN),setCookie("user_type",accountInfo.userType,TIME_TO_LIVE_GUEST_TOKEN),await co(),n=!0):(showNoticePanel("error","Undefined token","User token is empty! Can not register a new token"),Fe("authenticate.js",window.location.href,{message:"User token is empty! Can not register a new token",stack:""},"getGuestToken"),console.log(e.message)),finishedProgressDataIndicator()}catch(e){return finishedProgressDataIndicator(),showNoticePanel("error","",e.message),Fe("authenticate.js",window.location.href,e,"getGuestToken"),!1}return n}async function co(){if(accountInfo.userType==Oa){Fa(accountInfo.credits);return}if(!accountInfo.userToken&&!accountInfo.guestToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("authenticate.js",window.location.href,{message:"User token is empty!",stack:""},"getRemainingCredit");return}const e={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken};try{let t=await fetch("https://api.mapster.ai/api/v1/get_credit_balance",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(e)});if(!t.ok)throw console.log(t.status+" "+t.statusText),new Error("Promise resolved but request to API failed");t=await t.json(),t.status==!0&&t.status_code==200&&t.data.current_credits!=null?Fa(t.data.current_credits):(showNoticePanel("error","Get remaining credits",t.message),Fe("authenticate.js",window.location.href,{message:t.message,stack:""},"getRemainingCredit"),console.log(t.message))}catch(t){return showNoticePanel("error","Get remaining credits",t.message),Fe("authenticate.js",window.location.href,t,"getRemainingCredit"),!1}}function Fa(n){const e=accountInfo.userType,t=accountInfo.subscriptionType;e!=Oa?(accountInfo.credits=n,e==null||e==cu?setCookie("guest_credits",accountInfo.credits,TIME_TO_LIVE_GUEST_TOKEN):setCookie("user_credits",accountInfo.credits,TIME_TO_LIVE_USER_TOKEN),document.getElementById("subscriptions-info").textContent="AI Credits:",document.getElementById("credit-balance").textContent=parseFloat(accountInfo.credits).toFixed(0),sg[e]&&(document.getElementById("subscriptions-center").className=sg[e])):ld[t]&&(document.getElementById("subscriptions-center").className=ld[t],document.getElementById("subscriptions-info").innerHTML=`<img src='${xN[t]}'><a>${ld[t]}</a>`,document.getElementById("credit-balance").textContent="")}async function UN(){if(!accountInfo.userToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("authenticate.js",window.location.href,{message:"User token is empty!",stack:""},"getUserType");return}const n={user_token:accountInfo.userToken};try{let e=await fetch("https://api.mapster.ai/api/v1/get_user_type",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)});if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");e=await e.json(),e.status==!0&&e.status_code==200&&e.data.user_type&&e.data.subscription_type?(accountInfo.userType=e.data.user_type,accountInfo.subscriptionType=e.data.subscription_type,setCookie("user_type",accountInfo.userType,TIME_TO_LIVE_USER_TOKEN),setCo
6410okie("subscription_type",accountInfo.subscriptionType,TIME_TO_LIVE_USER_TOKEN),Fa(accountInfo.credits)):(showNoticePanel("error","Get user subscription",e.message),Fe("authenticate.js",window.location.href,{message:e.message,stack:""},"getUserType"),console.log(e.message))}catch(e){return showNoticePanel("error","Get user subscription",e.message),Fe("authenticate.js",window.location.href,e,"getUserType"),!1}}function Gk(){return accountInfo.userType==Oa||accountInfo.userType!=Oa&&accountInfo.credits>0}function ON(n){if(!accountInfo.userToken&&!accountInfo.guestToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("authenticate.js",window.location.href,{message:"User token is empty!",stack:""},"handleSendFeedback");return}fetch("https://api.mapster.ai/api/v1/user_feedback",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status==!0&&e.status_code==200?(hidePopupPanel(),showNoticePanel("info","Success","Thank you for taking the time to share your experience with us.")):(hidePopupPanel(),showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("authenticate.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"handleSendFeedback"))}).catch(e=>{hidePopupPanel(),showNoticePanel("error","Error",e.message),Fe("authenticate.js",window.location.href,e,"handleSendFeedback"),console.log(e)})}window.addEventListener("SessionEvent",n=>{if(n.preventDefault(),n.detail.mindmap_id)if(!accountInfo.userToken&&!accountInfo.guestToken){showNoticePanel("error","Undefined token","User token is empty!"),Fe("session.js",window.location.href,{message:"User token is empty!",stack:""},"SessionEvent");return}else n.detail.action=="delete"?zN(n.detail.mindmap_id):n.detail.action=="share"&&HN(n,n.detail.mindmap_id,n.detail.module);else n.detail.action=="rename"&&n.detail.data?VN(n.detail.data):n.detail.action=="list"?FN():n.detail.action=="delete-all"&&qN()});function FN(){accountInfo.sessionList.length?(leftPanelContent.innerHTML="",leftPanelContent.append(lo("Sessions",accountInfo.sessionList)),leftPanelContainer.style.visibility="visible",leftPanelContainer.style.opacity=1,document.getElementById("btn-analysis").classList.remove("selected"),document.getElementById("btn-session").classList.add("selected")):Py()}async function Py(n=!0){if(!accountInfo.userToken&&!accountInfo.guestToken&&!await lu())return;const e={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken};n&&startProgressDataIndicator("Loading session history..."),fetch("https://api.mapster.ai/api/v1/user_get_sessions",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(e)}).then(t=>{if(!t.ok)throw console.log(t.status+" "+t.statusText),new Error("Promise resolved but request to API failed");return t.json()}).then(t=>{t.status_code==200&&t.status==!0&&t.data.sessions?(accountInfo.sessionList=t.data.sessions,(!isMobile||n)&&(leftPanelContent.innerHTML="",leftPanelContent.append(lo("Sessions",accountInfo.sessionList)),leftPanelContainer.style.visibility="visible",leftPanelContainer.style.opacity=1,document.getElementById("btn-analysis").classList.remove("selected"),document.getElementById("btn-session").classList.add("selected"))):t.status_code==400?(accountInfo.sessionList=[],leftPanelContent.innerHTML="",(!isMobile||n)&&(leftPanelContent.append(lo("Sessions",accountInfo.sessionList)),leftPanelContainer.style.visibility="visible",leftPanelContainer.style.opacity=1,document.getElementById("btn-analysis").classList.remove("selected"),document.getElementById("btn-session").classList.add("selected"))):t.status_code===401?window.dispatchEvent(tokenExpired):t.message?(showNoticePanel("error","Error",t.message),Fe("session.js",window.location.href,{message:t.message,stack:""},"getSessions")):(showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("session.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"getSessions")),n&&finishedProgressDataIndicator()}).catch(t=>{showNoticePanel("error","Error",t.message),n&&finishedProgressDataIndicator(),Fe("session.js",window.location.href,t,"getSessions")})}async function Wk(){if(!accountInfo.userToken&&!accountInfo.guestToken&&!await lu())return;const n={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken};startProgressDataIndicator("Setting up your session...");let e=await fetch("https://api.mapster.ai/api/v1/user_create_session",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)});if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");if(e=await e.json(),e.status==!0&&e.status_code==200&&e.data){const t=e.data;return accountInfo.activeMindmapId=t.mindmap_id,accountInfo.sessionList.length==0?Py(!1):(accountInfo.sessionList.unshift(t),document.getElementById("btn-session").classList.contains("selected")&&(leftPanelContent.innerHTML="",leftPanelContent.append(lo("Sessions",accountInfo.sessionList)),leftPanelContainer.style.visibility="visible",leftPanelContainer.style.opacity=1,document.getElementById("btn-analysis").classList.remove("selected"),document.getElementById("btn-session").classList.add("selected"))),finishedProgressDataIndicator(),!0}else e.message?(showNoticePanel("error","Error",e.message),Fe("session.js",window.location.href,{message:e.message,stack:""},"registerNewSession")):(showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("session.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"registerNewSession"));
6410finishedProgressDataIndicator()}function VN(n){n&&(document.getElementById("btn-change-name").style.display="none",document.getElementById("spinner-change-name").style.display="block",fetch("https://api.mapster.ai/api/v1/user_update_session_name",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status_code===200&&e.status===!0&&e.data?e.data.updated&&(document.getElementById("session-"+n.mindmap_id).textContent=e.data.session_name,accountInfo.sessionList.forEach(t=>{t.mindmap_id==n.mindmap_id&&(t.session_name=e.data.session_name)}),showNoticePanel("info","Susscess","Session name is updated successfully!")):e.status_code===401?window.dispatchEvent(tokenExpired):e.message?(showNoticePanel("error","Error",e.message),Fe("session.js",window.location.href,{message:e.message,stack:""},"renameSession")):(showNoticePanel("error","Error","Unfortunately, we have encountered an error"),Fe("session.js",window.location.href,{message:"Unfortunately, we have encountered an error",stack:""},"renameSession")),hidePopupPanel()}).catch(e=>{hidePopupPanel(),showNoticePanel("error","Error",e.message),Fe("session.js",window.location.href,e,"renameSession")}))}async function BN(n,e=null){if(!accountInfo.userToken&&!accountInfo.guestToken&&!await lu())return;const t=getCacheWithExpiry(n);if(t){accountInfo.activeMindmapId=n,t.mindmap_id=t.mindmap_id??n,window.dispatchEvent(new CustomEvent("virtualizationEvent",{detail:{data:t}}));return}const i={mindmap_id:n,user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken};e&&(i.short_token=e),startProgressDataIndicator("Gathering information..."),fetch("https://api.mapster.ai/api/v1/user_get_mindmap_data",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(i)}).then(r=>{if(!r.ok)throw console.log(r.status+" "+r.statusText),new Error("Promise resolved but request to API failed");return r.json()}).then(r=>{r.status_code===200&&r.status===!0&&r.data?(accountInfo.activeMindmapId=n,r.data.mindmap_id=n,window.dispatchEvent(new CustomEvent("virtualizationEvent",{detail:{data:r.data}})),setCacheWithExpiry(n,r.data,TIME_TO_LIVE_SESSION_DATA)):r.status_code===401?window.dispatchEvent(tokenExpired):r.message&&(showNoticePanel("error","Error",r.message),Fe("session.js",window.location.href,{message:r.message,stack:""},"getMindmapData")),finishedProgressDataIndicator()}).catch(r=>{showNoticePanel("error","Error",r.message),finishedProgressDataIndicator(),Fe("session.js",window.location.href,r,"getMindmapData")})}function zN(n){const e={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken,mindmap_id:n};startProgressDataIndicator("Deleting session..."),fetch("https://api.mapster.ai/api/v1/user_delete_session",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(e)}).then(t=>{if(!t.ok)throw console.log(t.status+" "+t.statusText),new Error("Promise resolved but request to API failed");return t.json()}).then(t=>{t.status_code===200&&t.status===!0&&t.data?t.data.deleted&&(showNoticePanel("info","Susscess","Mindmap is removed successfully!"),accountInfo.sessionList=accountInfo.sessionList.filter(i=>i.mindmap_id!=accountInfo.interactiveMindmapId),leftPanelContent.innerHTML="",leftPanelContent.append(lo("Sessions",accountInfo.sessionList))):t.status_code===401?window.dispatchEvent(tokenExpired):t.message&&(showNoticePanel("error","Error",t.message),Fe("session.js",window.location.href,{message:t.message,stack:""},"deleteMindmapData")),finishedProgressDataIndicator()}).catch(t=>{showNoticePanel("error","Error",t.message),finishedProgressDataIndicator(),Fe("session.js",window.location.href,t,"deleteMindmapData")})}function HN(n,e=null,t="force"){e==null&&(e=accountInfo.activeMindmapId);const i={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken,mindmap_id:e};startProgressDataIndicator("Creating shareable link..."),fetch("https://api.mapster.ai/api/v1/user_generate_share_link",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(i)}).then(r=>{if(!r.ok)throw console.log(r.status+" "+r.statusText),new Error("Promise resolved but request to API failed");return r.json()}).then(r=>{if(r.status_code===200&&r.status===!0&&r.data){showPopupPanel("sessionShare");const s=popupPanelContainer.querySelector("#session_link");if(r.data.mindmap_id&&r.data.token&&s){const o={npm_package_dependencies_force_graph:"^1.43.5",npm_package_scripts_deploy_pro:"firebase deploy -P production --only hosting:mapster-pro",USER:"david",SSH_CLIENT:"127.0.0.1 60902 22",npm_config_version_commit_hooks:"true",npm_config_user_agent:"yarn/1.22.22 npm/? node/v20.15.1 linux x64",npm_config_bin_links:"true",XDG_SESSION_TYPE:"tty",npm_node_execpath:"/home/david/.local/node/bin/node",npm_package_devDependencies_vite:"^4.4.1",npm_config_init_version:"1.0.0",SHLVL:"1",HOME:"/home/david",OLDPWD:"/h
6410ome/david",npm_package_devDependencies_vite_plugin_static_copy:"^1.0.1",npm_config_init_license:"MIT",YARN_WRAP_OUTPUT:"false",npm_package_scripts_build_production:"env-cmd -f .env.production yarn build_pro",npm_config_version_tag_prefix:"v",LC_MONETARY:"th_TH.UTF-8",npm_package_dependencies_three_spritetext:"^1.8.2",DBUS_SESSION_BUS_ADDRESS:"unix:path=/run/user/1000/bus",npm_package_description:"## Overview",npm_package_dependencies_3d_force_graph:"^1.73.0",npm_package_readmeFilename:"README.md",npm_package_dependencies_element_resize_detector:"^1.2.4",npm_package_dependencies_d3:"^7.9.0",npm_package_dependencies_cytoscape_fcose:"^2.2.0",npm_package_dependencies_cytoscape:"^3.30.2",npm_package_scripts_dev:"vite",LOGNAME:"david",npm_package_type:"module",_:"/home/david/.local/node/bin/yarn",npm_package_devDependencies_vite_plugin_node_polyfills:"^0.22.0",npm_package_dependencies_polished:"^4.3.1",npm_package_private:"true",XDG_SESSION_CLASS:"user",npm_package_scripts_deploy_production:"env-cmd -f .env.production yarn build_pro && firebase deploy -P production --only hosting:mapster-pro",npm_config_registry:"https://registry.yarnpkg.com",XDG_SESSION_ID:"1223",npm_config_ignore_scripts:"",npm_package_dependencies_plotly_js_dist:"^2.35.2",PATH:"/tmp/yarn--1783922247123-0.8247159391701049:/home/david/Mapster_FE/node_modules/.bin:/home/david/.config/yarn/link/node_modules/.bin:/home/david/.yarn/bin:/home/david/.local/node/libexec/lib/node_modules/npm/bin/node-gyp-bin:/home/david/.local/node/lib/node_modules/npm/bin/node-gyp-bin:/home/david/.local/node/bin/node_modules/npm/bin/node-gyp-bin:/home/david/.local/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",NODE:"/home/david/.local/node/bin/node",npm_package_name:"mindmap_virtualization",LC_ADDRESS:"th_TH.UTF-8",XDG_RUNTIME_DIR:"/run/user/1000",npm_package_devDependencies_env_cmd:"^10.1.0",npm_package_dependencies_d3_force_3d:"^3.0.5",LANG:"en_US.UTF-8",LC_TELEPHONE:"th_TH.UTF-8",npm_lifecycle_script:"vite build",npm_package_dependencies_d3_bboxCollide:"^1.0.4",npm_config_version_git_message:"v%s",SHELL:"/bin/bash",LC_NAME:"th_TH.UTF-8",npm_lifecycle_event:"build_pro",npm_package_version:"1.0.0",npm_config_argv:'{"remain":[],"cooked":["run","build_pro"],"original":["build_pro"]}',npm_package_scripts_build:"vite build --mode development",npm_package_dependencies_cytoscape_layout_utilities:"^1.1.1",LC_MEASUREMENT:"th_TH.UTF-8",npm_config_version_git_tag:"true",npm_config_version_git_sign:"",LC_IDENTIFICATION:"th_TH.UTF-8",npm_package_scripts_build_pro:"vite build",npm_config_strict_ssl:"true",npm_package_dependencies_firebase:"^10.12.5",npm_package_dependencies_cytoscape_node_html_label:"^1.2.2",PWD:"/home/david/Mapster_FE",npm_execpath:"/home/david/.local/node/lib/node_modules/yarn/bin/yarn.js",SSH_CONNECTION:"127.0.0.1 60902 127.0.0.1 22",LC_NUMERIC:"th_TH.UTF-8",npm_config_save_prefix:"^",npm_config_ignore_optional:"",LC_PAPER:"th_TH.UTF-8",npm_package_scripts_deploy:"firebase deploy -P staging --only hosting:mapster-dev",npm_package_scripts_preview:"vite preview",INIT_CWD:"/home/david/Mapster_FE",NODE_ENV:"production",VITE_APP_MODE:"production",VITE_APP_TITLE:"Mapster AI",VITE_API_URL:"https://api.mapster.ai/api/v1",VITE_FIREBASE_CONFIG:'{ "apiKey": "AIzaSyCFTEyTyF-N4rtJKAN3WLyQfJ_NsMVIQEE","authDomain": "mapster-413503.firebaseapp.com", "projectId": "mapster-413503", "messagingSenderId": "600457357557", "appId": "1:600457357557:web
6410:66eed0c5628e35efaf7dbc", "measurementId": "G-EXGTCDN348"}',VITE_FIREBAE_SERVICE_ACCOUNT:`{ 6411 "type": "service_account", 6412 "project_id": "mapster-dev", 6413 "private_key_id": "298e7a87955cdb8b11dc6ada11789177022b733b", 6414 "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC/qRsbaS8f/+OF\\nYaV939GbburruQT+gqA/1BF1iwAd5ZCo8wSnd6HdQt1FVLz/40VhwmI+ZMbnSowL\\n7bs3tnXJbcF8tJ0nbp2B/vRtM3l54MZdyi3cd3SV0m4cBjCyEWEg/3vK38MvmYaO\\nXNP6orudKdh8G2L+nEXWhCWDuitnGw9E7+fJb/dGCeSbUUGwpBujNnXh7cJdUUxw\\nxFOsP8cCqN6BG0C+17wvB3iVllV+NkXSCidxXbBh5rKP8eLVfCb2c9LvNzPvm3Av\\n8+RF5VeUJyuS8q29r1amSzy2rBkgeLlE8dbeoVQWi6t85FZfs8qpErXnWzGndioB\\nShhU4VDfAgMBAAECggEAA1e4sE6yUrWMy0u7rilUJ4jUsg3FB4dRsitJrqog82SI\\nlFnAsAcHHKvI3ievMCtPj3frbLknOuty69ZWmI8nGL9AS6N+xixItPa0Xp8yNCz2\\naLZY/Gpc7yv/XZ/CA6kH76JlD1G9vrvHu/3keI+UBBaxvuBfZp9lHGurl9OMZDzt\\n0DbsKE7K4j6IZEitAvt1Lik2/Hai5Go+EwYx6ql2miZiFL4/50HzAp22SmbNl9BV\\n1IP1y1UVLB0fmguEtNh7krQn7UtP6kMZ+Fn8YSf1LEzaLveqRSdqJpuS69IICGWg\\noTm4W0IbywEm3L/9XOzCtmUhHBUzu9Cv/VT9YqNtkQKBgQD0/LXYk6j5w3pDW+ND\\nmAZwb9WvH7k2l2RQfijAk5T+2L4fMiCVDppL13xOCSfzN+J3X4RrN2JVoEqrL8B3\\nt+aU2DwLBj4T8HMq28wb5Qtf+BBUzR3YlHgDcLl5rbdZHL7tH93E8GDziASVr87L\\nMqhXhdsJqzpYNC5v737kI0BDxwKBgQDIRrfZLmW+V3cTEQ1k+dOcDlWLemUReRK5\\n0POb3QFmX+XEp9JvU4xw4yPvnlP01pTWizTP3tpRTjKaCikv58ni7h/mC6Kf+uXs\\nT3Y7sS6OD6cxTD+dNWGWZVZKcyEhH1m1G9EyL/697YERV/rdneYgrlbqc5qB35ab\\n1DTCDSnaKQKBgQDBmj/ewnojvy4Msz37OdXE3yw/89L7aFJ3Jevwm/CAISrGHmgP\\nQ3X9/3GVfbjbhUtryMktrZwBTOYVOGxib6tB70wr7if6u+dXdFFtrej6U2Ack+hF\\nMrdRCLEajoS5YHUlkSxBqTEE43W0ETZb8FGGsRpzHqTB9aLJBLwDcDQmGwKBgAME\\nJaKsszWRpaZw3E3IAWrZQGqQVlNUCncn8XNIecvr5871ZBLvJC9TDGiAbu1CCg3N\\nHOeAiLMuxU5Slto02HKFeY+CX1mfcrUDYVl2yqezDqaMamzYr/aO4iTO5RHVogk7\\nOQRTereriwUS2SFbTmrxlTeEtC/+iQshwAWoIxg5AoGBAJq06AcVPoR/t3DWudZE\\naN+CN1KA+jvVuSDUc6cqkOdMu6tePM1s6GOIrjVhnz2KToS0RmeMTrlpG6ZqksOB\\nNUQQxtVTbLWxebLRZAEckNsD8d0hwzLYU47ECorDzjEzQBkojte1mz638xG3NzJg\\npnUPqN9oZVF4lR9UnIYEjWR7\\n-----END PRIVATE KEY-----\\n", 6415 "client_email": "[email protected]", 6416 "client_id": "117644324503656154367", 6417 "auth_uri": "https://accounts.google.com/o/oauth2/auth", 6418 "token_uri": "https://oauth2.googleapis.com/token", 6419 "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 6420 "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/github-action-780784162%40mapster-dev.iam.gserviceaccount.com", 6421 "universe_domain": "googleapis.com" 6422}`,VITE_STRIPE_1_MONTH:"https://buy.stripe.com/6oE9B22fd6XF30A5kn",VITE_STRIPE_6_MONTH:"https://buy.stripe.com/cN2dRi5rpeq78kUbIK",VITE_STRIPE_12_MONTH:"https://buy.stripe.com/5kA3cEaLJ0zhbx68wx",VITE_STRIPE_LIFETIME:"https://buy.stripe.com/8wMcNef1Z1Dl0SsbII"}.VITE_APP_URL+"/"+t+"/index.html?mindmapId="+r.data.mindmap_id+"&token="+r.data.token;s.textContent=o,s.setAttribute("href",o),r.data.link&&console.log(r.data.link)}else r.data.link&&s&&(s.textContent=r.data.link,s.setAttribute("href",r.data.link))}else r.status_code===401?window.dispatchEvent(tokenExpired):r.message&&(showNoticePanel("error","Error",r.message),Fe("session.js",window.location.href,{message:r.message,stack:""},"shareMindmapData"));finishedProgressDataIndicator()}).catch(r=>{showNoticePanel("error","Error",r.message),finishedProgressDataIndicator(),Fe("session.js",window.location.href,r,"shareMindmapData")})}function GN(n){n.target.getAttribute("mindmap_id")&&!n.target.parentElement.classList.contains("selected")&&BN(n.target.getAttribute("mindmap_id"))}function WN(n){n.target.getAttribute("mindmap_id")&&(accountInfo.interactiveMindmapId=n.target.getAttribute("mindmap_id"),showMenuPanel("sessionMenu","session-menu"),menuPanelContainer.style.left=n.target.x+35+"px",menuPanelContainer.style.top=n.target.y+15+"px")}function lo(n,e){const t=document.createElement("div"),i=Object.assign(document.createElement("div"),{className:"panel-header",textContent:n});t.className="panel",t.append(i);const r=document.createElement("div");r.className="panel-body p-0 border-0",r.style.backgroundColor="unset";const s=document.createElement("div");s.className="row gap-3 m-1";const o=document.createElement("div");
6422o.className="col-12 session row mx-0";const a=document.createElement("span");a.innerHTML=`<svg width="29" height="29" viewBox="0 0 166 166" fill="none" xmlns="http://www.w3.org/2000/svg"> 6423 <mask id="mask0_4868_22796" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="166" height="166"> 6424 <path fill-rule="evenodd" clip-rule="evenodd" d="M165.42 51.5184C165.42 49.5547 165.421 47.5907 165.408 45.6268C165.399 43.9724 165.38 42.3184 165.335 40.6648C165.237 37.0607 165.025 33.4257 164.384 29.8618C163.734 26.2464 162.672 22.8816 160.999 19.5967C159.355 16.3681 157.207 13.4136 154.643 10.8522C152.081 8.29083 149.126 6.144 145.896 4.50044C142.607 2.82718 139.239 1.76601 135.62 1.11618C132.055 0.476182 128.419 0.263988 124.815 0.166624C123.161 0.121856 121.506 0.102985 119.851 0.0927471C117.886 0.0807021 115.921 0.0817058 113.956 0.0817058L91.1408 0H74.077L51.6658 0.0817058C49.697 0.0817058 47.7283 0.0807021 45.7595 0.0927471C44.1009 0.102985 42.4431 0.121856 40.7851 0.166624C37.1726 0.263988 33.5284 0.476383 29.9556 1.11718C26.3315 1.76681 22.958 2.82758 19.6653 4.49964C16.4286 6.14339 13.467 8.29043 10.899 10.8522C8.33135 13.4134 6.1791 16.3673 4.53154 19.5953C2.85407 22.8818 1.79049 26.2486 1.13886 29.866C0.497259 33.4285 0.284664 37.0623 0.186899 40.6648C0.142332 42.3186 0.12306 43.9726 0.113023 45.6268C0.100978 47.5909 0 50.0307 0 51.9946L0.000602252 74.0953L0 91.3419L0.101981 113.912C0.101981 115.879 0.101178 117.845 0.113023 119.812C0.12306 121.468 0.142332 123.125 0.1871 124.781C0.284664 128.389 0.497661 132.03 1.13986 135.598C1.7913 139.218 2.85467 142.588 4.53074 145.877C6.1785 149.11 8.33115 152.069 10.899 154.634C13.4668 157.199 16.4276 159.348 19.6637 160.994C22.9584 162.67 26.3335 163.732 29.9598 164.383C33.531 165.024 37.174 165.237 40.7851 165.334C42.4431 165.379 44.1011 165.398 45.7597 165.408C47.7285 165.42 49.697 165.419 51.6658 165.419L74.2795 165.42H91.3857L113.956 165.419C115.921 165.419 117.886 165.42 119.851 165.408C121.506 165.398 123.161 165.379 124.815 165.334C128.421 165.236 132.058 165.024 135.624 164.382C139.241 163.732 142.608 162.669 145.894 160.995C149.125 159.349 152.081 157.199 154.643 154.634C157.206 152.069 159.354 149.111 160.999 145.879C162.673 142.588 163.734 139.217 164.385 135.594C165.025 132.027 165.237 128.388 165.335 124.781C165.38 123.124 165.399 121.468 165.408 119.812C165.421 117.845 165.42 115.879 165.42 113.912C165.42 113.912 165.419 91.7404 165.419 91.3419V74.0773C165.419 73.783 165.42 51.5184 165.42 51.5184Z" fill="white"/> 6425 </mask> 6426 <g mask="url(#mask0_4868_22796)"> 6427 <rect width="165.42" height="165.42" fill="#1C1C1E"/> 6428 <path d="M74.7295 68.3629L66.6523 50.1797" stroke="#F5F5F5" stroke-width="3.97644" stroke-linecap="round" stroke-linejoin="round"/> 6429 <path d="M115.855 70.9258L98.7578 76.625" stroke="#F5F5F5" stroke-width="3.97644" stroke-linecap="round" stroke-linejoin="round"/> 6430 <path d="M119.047 111.149L97 94" stroke="#F5F5F5" stroke-width="3.97644" stroke-linecap="round" stroke-linejoin="round"/> 6431 <path d="M70.4295 92.8281L47.0898 113.583" stroke="#F5F5F5" stroke-width="3.97644" stroke-linecap="round" stroke-linejoin="round"/> 6432 <circle cx="84.4318" cy="82.506" r="15.2482" fill="#007BFF"/> 6433 <rect x="67" y="66" width="33" height="33" rx="6" fill="#007BFF" stroke="#F5F5F5" stroke-width="4"/> 6434 <rect x="113" y="46" width="33" height="33" rx="6" fill="#007BFF" stroke="#F5F5F5" stroke-width="4"/> 6435 <rect x="115" y="102" width="33" height="33" rx="6" fill="#007BFF" stroke="#F5F5F5" stroke-width="4"/> 6436 <rect x="44" y="18" width="33" height="33" rx="6" fill="#007BFF" stroke="#F5F5F5" stroke-width="4"/> 6437 <rect x="19" y="106" width="33" height="33" rx="6" fill="#007BFF" stroke="#F5F5F5" stroke-width="4"/> 6438 </g> 6439 </svg><a class='mx-3'>New Mapster Mind Map</a>`,a.className="col",a.style.borderColor="#D2EAFD",a.style.color="#D2EAFD",a.addEventListener("click",()=>{showPopupPanel("sessionNew");const l=popupPanelContainer.querySelector("#new_prompt");l&&l.addEventListener("keypress",d=>{d.keyCode===13&&l.value.trim()!=""&&window.dispatchEvent(new CustomEvent("SessionEvent",{detail:{prompt:l.value.trim(),action:"new"}}))})}),o.append(a),s.append(o),e.forEach((l,d)=>{const h=document.createElement("div");h.className=l.mindmap_id==accountInfo.activeMindmapId?"col-12 session row mx-0 selected":"col-12 session row mx-0";const p=document.createElement("img");
6439p.className="col-2",p.src="/images/three-dot.svg",p.setAttribute("mindmap_id",l.mindmap_id),p.addEventListener("click",WN);const _=document.createElement("span");_.id="session-"+l.mindmap_id,_.textContent=l.session_name,_.setAttribute("mindmap_id",l.mindmap_id),_.setAttribute("data-toggle","tooltip"),_.setAttribute("data-placement","bottom"),_.className="col",_.style.borderColor="#D2EAFD",_.style.color="#D2EAFD",_.addEventListener("click",GN),h.append(_),h.append(p),s.append(h)}),r.append(s),t.append(r);const c=Object.assign(document.createElement("div"),{className:"panel-footer"});return t.append(c),t}function qN(){const n={user_token:accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken};startProgressDataIndicator("Deleting session..."),fetch("https://api.mapster.ai/api/v1/user_delete_all_graphs",{method:"POST",headers:{Authorization:"Bearer "+(accountInfo.userToken?accountInfo.userToken:accountInfo.guestToken),"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status_code===200&&e.status===!0&&e.data?e.data.deleted&&(showNoticePanel("info","Susscess","All mindmap is removed successfully!"),accountInfo.sessionList=[],leftPanelContent.innerHTML="",leftPanelContent.append(lo("Sessions",accountInfo.sessionList))):e.status_code===401?window.dispatchEvent(tokenExpired):e.message&&(showNoticePanel("error","Error",e.message),Fe("session.js",window.location.href,{message:e.message,stack:""},"deleteAllMindmapData")),finishedProgressDataIndicator()}).catch(e=>{showNoticePanel("error","Error",e.message),finishedProgressDataIndicator(),Fe("session.js",window.location.href,e,"deleteAllMindmapData")})}window.addEventListener("load",()=>{window.addEventListener("ProfileEvent",n=>{n.preventDefault(),n.detail.eventType=="profileSettings"?XN():n.detail.eventType=="profileSubcription"?jN():n.detail.eventType=="profileStatistic"?KN():n.detail.eventType=="profileDataControl"?YN():n.detail.eventType=="profileConnectedApp"?QN():n.detail.eventType=="profileSecurity"&&ZN()})});function XN(){if(showPopupPanel("profileContainer"),popupPanelContainer.querySelector("#btn-profile-setting").classList.add("active"),!accountInfo.userToken){console.log("Undefined token","User token is empty!");return}const e={user_token:accountInfo.userToken};fetch("https://api.mapster.ai/api/v1/user_profile",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(e)}).then(t=>{if(!t.ok)throw console.log(t.status+" "+t.statusText),new Error("Promise resolved but request to API failed");return t.json()}).then(t=>{if(t.status_code==200&&t.status==!0&&t.data){const i=t.data;JN(i)}else t.message?console.log(t.message):console.log("Unfortunately, we have encountered an error")}).catch(t=>{console.log(t.message),showNoticePanel("error","Error",t.message),Fe("profile.js",window.location.href,t,"showTabProfileSetting")})}function jN(){showPopupPanel("profileContainer");const n=popupPanelContainer.querySelector("#profile-container");if(popupPanelContainer.querySelector("#btn-profile-subcription").classList.add("active"),!accountInfo.userToken){console.log("Undefined token","User token is empty!");return}const t={user_token:accountInfo.userToken};fetch("https://api.mapster.ai/api/v1/my_subscription",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw console.log(i.status+" "+i.statusText),new Error("Promise resolved but request to API failed");return i.json()}).then(i=>{if(i.status_code==200&&i.status==!0&&i.data){n.innerHTML=popupPanel.profileSubcription.innerHTML;const r=i.data;r.your_plan&&(setElementTextContent(n,"#current-plan",r.your_plan.current_plan),setElementTextContent(n,"#plan-amount",r.your_plan.plan_amount),setElementTextContent(n,"#plan-next-payment",r.your_plan.next_payment)),r.billing_history.length&&r.billing_history.forEac
6439h(s=>{let o="";s.download&&s.download.show_download&&s.download.download_link&&(o=`<a href=${s.download.download_link}><image src="/images/download.svg"></a>`),n.querySelector("#billing-history").innerHTML+=`<a class="ml-1 d-flex align-items-center"> 6440 ${s.billing_time} 6441 ${o} 6442 </a> `})}else i.message?console.log(i.message):console.log("Unfortunately, we have encountered an error")}).catch(i=>{console.log(i.message),showNoticePanel("error","Error",i.message),Fe("profile.js",window.location.href,i,"showTabProfileSubcription")})}function KN(){showPopupPanel("profileContainer");const n=popupPanelContainer.querySelector("#profile-container");if(popupPanelContainer.querySelector("#btn-profile-statistic").classList.add("active"),!accountInfo.userToken){console.log("Undefined token","User token is empty!");return}const t={user_token:accountInfo.userToken};fetch("https://api.mapster.ai/api/v1/get_user_statistics",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw console.log(i.status+" "+i.statusText),new Error("Promise resolved but request to API failed");return i.json()}).then(i=>{i.status_code==200&&i.status==!0&&i.data?(n.innerHTML=popupPanel.profileStatistic.innerHTML,setElementTextContent(n,"#profile-used-credits",parseFloat(i.data.credit_detail.used_credit??0).toFixed(0)),setElementTextContent(n,"#profile-credits",parseFloat(i.data.credit_detail.credit_balance??0).toFixed(0)),setElementTextContent(n,"#profile-links-shared",i.data.url_link_shared??0),setElementTextContent(n,"#profile-links-created",i.data.links_created??0),setElementTextContent(n,"#profile-nodes-created",i.data.nodes_created??0)):i.message?console.log(i.message):console.log("Unfortunately, we have encountered an error")}).catch(i=>{console.log(i.message),showNoticePanel("error","Error",i.message),Fe("profile.js",window.location.href,i,"showTabProfileStatistic")})}function YN(){showPopupPanel("profileContainer");const n=popupPanelContainer.querySelector("#profile-container");popupPanelContainer.querySelector("#btn-profile-data-control").classList.add("active"),n.innerHTML=popupPanel.profileDataControl.innerHTML}function QN(){showPopupPanel("profileContainer");const n=popupPanelContainer.querySelector("#profile-container");popupPanelContainer.querySelector("#btn-profile-connected-app").classList.add("active"),n.innerHTML=popupPanel.profileConnectedApp.innerHTML}function ZN(){showPopupPanel("profileContainer");const n=popupPanelContainer.querySelector("#profile-container");popupPanelContainer.querySelector("#btn-profile-security").classList.add("active"),n.innerHTML=popupPanel.profileSecurity.innerHTML}function JN(n){const e=popupPanelContainer.querySelector("#profile-container");e.innerHTML=popupPanel.profileSettings.innerHTML,accountInfo.initials=n.initials??accountInfo.initials,e.querySelector("#profile-initials").textContent=accountInfo.initials,e.querySelector("#profile-initials-button").addEventListener("click",()=>{e.querySelector("#profile-initials-input").value=accountInfo.initials,setElementStyleDisplay(e,"#profile-initials","none"),setElementStyleDisplay(e,"#profile-initials-button","none"),setElementStyleDisplay(e,"#btn-initials-group","inline"),setElementStyleDisplay(e,"#profile-initials-input","inline")}),e.querySelector("#profile-initials-update").addEventListener("click",()=>{let t=e.querySelector("#profile-initials-input").value.trim();t!=accountInfo.initials&&(accountInfo.initials=t,e.querySelector("#profile-initials").textContent=accountInfo.initials,Wc(),setElementStyleDisplay(e,"#profile-initials","inline"),setElementStyleDisplay(e,"#profile-initials-button","inline"),setElementStyleDisplay(e,"#btn-initials-group","none"),setElementStyleDisplay(e,"#profile-initials-input","none"))}),e.querySelector("#profile-initials-cancel").addEventListener("click",()=>{setElementStyleDisplay(e,"#profile-initials","inline"),setElementStyleDisplay(e,"#profile-initials-button","inline"),setElementStyleDisplay(e,"#btn-initials-group","none"),setElementStyleDisplay(e,"#profile-initials-input","none")}),accountInfo.nickname=n.nickname??accountInfo.nickname,setElementTextContent(e,"#profile-nickname",accountInfo.nickname),e.querySelector("#profile-nickname-button").addEventListener("click",()=>{e.querySelector("#profile-nickname-input").value=accountInfo.nickname,setElementStyleDisplay(e,"#profile-nickname","none"),setElementStyleDisplay(e,"#profile-nickname-button","none"),setElementStyleDisplay(e,"#btn-nickname-group","inline"),setElementStyleDisplay(e,"#profile-nickname-input","inline")}),e.querySelector("#profile-nickname-update").addEventListener("click",()=>{let t=e.querySelector("#profile-nickname-input").value.trim();t!=accountInfo.nickname&&(accountInfo.nickname=t,setElementTextContent(e,"#profile-nickname",accountInfo.nickname),Wc(),setElementStyleDisplay(e,"#profile-nickname","inline"),setElementStyleDisplay(e,"#profile-nickname-button","inline"),setElementStyleDisplay(e,"#btn-nickname-group","none"),setElementStyleDisplay(e,"#profile-nickname-input","none"))}),e.querySelector("#profile-nickname-cancel").addEventListener("click",()=>{setElementStyleDisplay(e,"#profile-nickname","inline"),setElementStyleDisplay(e,"#profile-nickname-button","inline"),setElementStyleDisplay(e,"#btn-nickname-group","none"),setElementStyleDisplay(e,"#profile-nickname-input","none")}),accountInfo.firstName=n.first_name??accountInfo.firstName,setElementTextContent(e,"#profile-first-name",accountInfo.firstName),e.querySelector("#profile-first-name-button").addEventListener("click",()=>{e.querySelector("#profile-first-name-input").value=accountInfo.firstName,setElementStyleDisplay(e,"#profile-first-name","none"),setElementStyleDisplay(e,"#profile-first-name-button","none"),setElementStyleDisplay(e,"#btn-first-name-group","inline"),setElementStyleDisplay(e,"#profile-first-name-input","inline")}),e.querySelector("#profile-first-name-update").addEventListener("click",()=>{let t=e.querySelector("#profile-first-name-input").value.trim();t!=accountInfo.firstName&&(accountInfo.firstName=t,setElementTextContent(e,"#profile-first-name",accountInfo.firstName),Wc(),setElementStyleDisplay(e,"#profile-first-name","inline"),setElementStyleDisplay(e,"#profile-first-name-button","inline"),setElementStyleDisplay(e,"#btn-first-name-group","none"),setElementStyleDisplay(e,"#profile-first-name-input","none"))}),e.querySelector("#profile-first-name-cancel").addEventListener("click",()=>{setElementStyleDisplay(e,"#profile-first-name","inline"),setElementStyleDisplay(e,"#profile-first-name-button","inline"),setElementStyleDisplay(e,"#btn-first-name-group","none"),setElementStyleDisplay(e,"#profile-first-name-input","none")}),accountInfo.lastName=n.last_name??accountInfo.lastName,setElementTextContent(e,"#profile-last-name",accountInfo.lastName),e.querySelector("#profile-last-name-button").addEventListener("click",()=>{e.querySelector("#profile-last-name-input").value=accountInfo.lastName,setElementStyleDisplay(e,"#profile-last-name","none"),setElementStyleDisplay(e,"#profile-last-name-button","none"),setElementStyleDisplay(e,"#btn-last-name-group","inline"),setElementStyleDisplay(e,"#profile-last-name-input","inline")}),e.querySelector("#profile-last-name-update").addEventListener("click",()=>{let t=e.querySelector("#profile-last-name-input").value.trim();t!=accountInfo.lastName&&(accountInfo.lastName=t,setElementTextContent(e,"#profile-last-name",accountInfo.lastName),Wc(),setElementStyleDisplay(e,"#profile-last-name","inline"),setElementStyleDisplay(e,"#profile-last-name-button","inline"),setElementStyleDisplay(e,"#btn-last-name-group","none"),setElementStyleDisplay(e,"#profile-last-name-input","none"))}),e.querySelector("#profile-last-name-cancel").addEventListener("click",()=>{setElementStyleDisplay(e,"#profile-last-name","inline"),setElementStyleDisplay(e,"#profile-last-name-button","inline"),setElementStyleDisplay(e,"#btn-last-name-group","none"),setElementStyleDisplay(e,"#profile-last-name-input","none")}),setElementTextContent(e,"#profile-email",n.email??accountInfo.email),setElementTextContent(e,"#profile-last_login_at",n.last_login_at??"")}function Wc(){const n={user_token:accountInfo.userToken,initials:accountInfo.initials,nickname:accountInfo.nickname,first_name:accountInfo.firstName,last_name:accountInfo.lastName};fetch("https://api.mapster.ai/api/v1/update_personal_profile",{method:"POST",headers:{Authorization:"Bearer "+accountInfo.userToken,"Content-type":"application/json","Access-Control-Allow-Origin":"*"},mode:"cors",body:JSON.stringify(n)}).then(e=>{if(!e.ok)throw console.log(e.status+" "+e.statusText),new Error("Promise resolved but request to API failed");return e.json()}).then(e=>{e.status_code==200&&e.status==!0&&e.data?(e.data,showNoticePanel("info","Profile","User profile has been updated!")):e.message?console.log(e.message):console.log("Unfortunately, we have encountered an error")}).catch(e=>{console.log(e.message),showNoticePanel("error","Error",e.message),Fe("profile.js",window.location.href,e,"fetchingProfileDataAndAction")})}export{Dk as $,wt as A,bn as B,ut as C,Oi as D,rv as E,cv as F,Cc as G,av as H,oh as I,qI as J,Be as K,vM as L,ak as M,Pk as N,Zt as O,Vl as P,wk as Q,Ik as R,Jg as S,rh as T,Rk as U,O as V,bk as W,Tk as X,Sk as Y,yk as Z,Ak as _,Hi as a,pa as a0,Ck as a1,Mk as a2,kr as a3,vk as a4,pk as a5,tk as a6,An as a7,Gn as a8,Kh as a9,dk as aA,uk as aB,Nh as aC,di as aD,ok as aE,Ex as aF,vn as aG,Hl as aH,ck as aI,it as aJ,Vs as aK,_k as aL,Zc as aM,eh as aN,gk as aO,$g as aa,jg as ab,Tx as ac,zg as ad,qg as ae,Lx as af,nk as ag,po as ah,Gh as ai,fk as aj,Ng as ak,Ft as al,Tr as am,IT as an,Yr as ao,Ba as ap,vr as aq,hk as ar,$s as as,Lk as at,rk as au,sk as av,Jn as aw,Vn as ax,lk as ay,ts as az,Ok as b,IN as c,BN as d,Uk as e,lu as f,Av as g,Gk as h,Wk as i,co as j,Vk as k,Ig as l,za as m,mk as n,ek as o,ql as p,Fk as q,Nk as r,Fe as s,Zg as t,kk as u,Ek as v,xk as w,_I as x,Py as y,xe as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.