!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).View360=e()}(this,(function(){"use strict";function t(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((s=s.apply(t,e||[])).next())}))} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function e(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var s,n,r=i.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}return o}function s(){for(var t=[],e=0;e0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function v(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function E(t,e,i){var s=e[0],n=e[1],r=e[2],o=i[0],a=i[1],h=i[2];return t[0]=n*h-r*a,t[1]=r*o-s*h,t[2]=s*a-n*o,t}function f(t,e,i){var s=e[0],n=e[1],r=e[2],o=i[3]*s+i[7]*n+i[11]*r+i[15];return o=o||1,t[0]=(i[0]*s+i[4]*n+i[8]*r+i[12])/o,t[1]=(i[1]*s+i[5]*n+i[9]*r+i[13])/o,t[2]=(i[2]*s+i[6]*n+i[10]*r+i[14])/o,t}function b(t,e,i){var s=i[0],n=i[1],r=i[2],o=i[3],a=e[0],h=e[1],l=e[2],c=n*l-r*h,u=r*a-s*l,_=s*h-n*a,d=n*_-r*u,m=r*c-s*_,p=s*u-n*c,g=2*o;return c*=g,u*=g,_*=g,d*=2,m*=2,p*=2,t[0]=a+c+d,t[1]=h+u+m,t[2]=l+_+p,t}function y(){var t=new l(4);return l!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function T(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function R(t,e,i){var s=e[0],n=e[1],r=e[2],o=e[3],a=i[0],h=i[1],l=i[2],c=i[3];return t[0]=s*c+o*a+n*l-r*h,t[1]=n*c+o*h+r*a-s*l,t[2]=r*c+o*l+s*h-n*a,t[3]=o*c-s*a-n*h-r*l,t}function w(t,e,i){i*=.5;var s=e[0],n=e[1],r=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);return t[0]=s*h+o*a,t[1]=n*h+r*a,t[2]=r*h-n*a,t[3]=o*h-s*a,t}function C(t,e,i){i*=.5;var s=e[0],n=e[1],r=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);return t[0]=s*h-r*a,t[1]=n*h+o*a,t[2]=r*h+s*a,t[3]=o*h-n*a,t}function L(t,e,i){i*=.5;var s=e[0],n=e[1],r=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);return t[0]=s*h+n*a,t[1]=n*h-s*a,t[2]=r*h+o*a,t[3]=o*h-r*a,t}function x(t,e,i,s){var n,r,o,a,l,c=e[0],u=e[1],_=e[2],d=e[3],m=i[0],p=i[1],g=i[2],v=i[3];return(r=c*m+u*p+_*g+d*v)<0&&(r=-r,m=-m,p=-p,g=-g,v=-v),1-r>h?(n=Math.acos(r),o=Math.sin(n),a=Math.sin((1-s)*n)/o,l=Math.sin(s*n)/o):(a=1-s,l=s),t[0]=a*c+l*m,t[1]=a*u+l*p,t[2]=a*_+l*g,t[3]=a*d+l*v,t}d(),function(){var t,e=(t=new l(4),l!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var O,A=function(t){var e=new l(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},I=function(t,e,i,s){var n=new l(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=s,n},S=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},P=function(t,e,i,s,n){return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t},M=function(t,e){var i=e[0],s=e[1],n=e[2],r=e[3],o=i*i+s*s+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),t[0]=i*o,t[1]=s*o,t[2]=n*o,t[3]=r*o,t},N=function(t,e){var i=t[0],s=t[1],n=t[2],r=t[3],o=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(i-o)<=h*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=h*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(n-l)<=h*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(r-c)<=h*Math.max(1,Math.abs(r),Math.abs(c))};d(),p(1,0,0),p(0,1,0),y(),y(),O=new l(9),l!=Float32Array&&(O[1]=0,O[2]=0,O[3]=0,O[5]=0,O[6]=0,O[7]=0),O[0]=1,O[4]=1,O[8]=1,function(){var t=function(){var t=new l(2);return l!=Float32Array&&(t[0]=0,t[1]=0),t}()}();class D extends Error{constructor(t,e){super(t),Object.setPrototypeOf(this,D.prototype),this.name="View360Error",this.code=e}}const U={WRONG_TYPE:0,WRONG_OPTION:1,ELEMENT_NOT_FOUND:2,CANVAS_NOT_FOUND:3,WEBGL_NOT_SUPPORTED:4,FAILED_CREATE_CONTEXT_2D:5,PROVIDE_PROJECTION_FIRST:6,FAILED_LINKING_PROGRAM:7,INSUFFICIENT_ARGS:8};var B=U,F={WRONG_TYPE:(t,e)=>`${typeof t} is not a ${e.map((t=>`"${t}"`)).join(" or ")}.`,WRONG_OPTION:(t,e)=>`Bad option: given "${t}" for option "${e}".`,ELEMENT_NOT_FOUND:t=>`Element with selector "${t}" not found.`,CANVAS_NOT_FOUND:"The canvas element was not found inside the given root element.",WEBGL_NOT_SUPPORTED:"WebGL is not supported on this browser.",FAILED_CREATE_CONTEXT_2D:"Failed to create canvas 2D context",PROVIDE_PROJECTION_FIRST:'"projection" should be provided before initialization.',FAILED_LINKING_PROGRAM:(t,e)=>`Failed linking WebGL program - "${t}\nShader compile Log: ${e}`,INSUFFICIENT_ARGS:(t,e)=>`Insufficient arguments: given "${t}" for "${e}".`};const z="mousedown",V="mousemove",k="mouseup",G="touchstart",H="touchmove",Y="touchend",W="wheel",X="resize",j="contextmenu",K="mouseenter",q="mouseleave",Z="keydown",$="keyup",J="click",Q="webglcontextcreationerror",tt="webglcontextlost",et="webglcontextrestored",it="deviceorientation",st="devicemotion",nt="orientationchange",rt="play",ot="pause",at="loadeddata",ht="volumechange",lt="timeupdate",ct="durationchange",ut="canplaythrough",_t="transitionend",dt="end",mt="div",pt="button";var gt;!function(t){t[t.LEFT=0]="LEFT",t[t.MIDDLE=1]="MIDDLE",t[t.RIGHT=2]="RIGHT"}(gt||(gt={}));const vt="grab",Et="grabbing",ft="",bt=["LEFT","UP","RIGHT","DOWN"];var yt;!function(t){t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN"}(yt||(yt={}));const Tt={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"},Rt=["requestFullscreen","webkitRequestFullscreen","webkitRequestFullScreen","webkitCancelFullScreen","mozRequestFullScreen","msRequestFullscreen"],wt=["fullscreenElement","webkitFullscreenElement","webkitCurrentFullScreenElement","mozFullScreenElement","msFullscreenElement"],Ct=["exitFullscreen","webkitExitFullscreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen"],Lt=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],xt={CONTAINER:"view360-container",CANVAS:"view360-canvas",CTX_LOST:"view360-ctx-lost",IN_VR:"view360-vr-presenting",HOTSPOT_CONTAINER:"view360-hotspots",HOTSPOT:"view360-hotspot",HOTSPOT_VISIBLE:"view360-hotspot-visible",HOTSPOT_FLIP_X:"view360-hotspot-flip-x",HOTSPOT_FLIP_Y:"view360-hotspot-flip-y"},Ot={READY:"ready",LOAD_START:"loadStart",LOAD:"load",PROJECTION_CHANGE:"projectionChange",RESIZE:"resize",BEFORE_RENDER:"beforeRender",RENDER:"render",INPUT_START:"inputStart",INPUT_END:"inputEnd",VIEW_CHANGE:"viewChange",STATIC_CLICK:"staticClick",VR_START:"vrStart",VR_END:"vrEnd"},At={LINEAR:t=>t,SINE_WAVE:t=>Math.sin(t*Math.PI*2),EASE_OUT_CUBIC:t=>1-Math.pow(1-t,3),EASE_OUT_BOUNCE:t=>{const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375}};var It;const St="animationEnd",Pt="update",Mt="inputStart",Nt="change",Dt="inputEnd",Ut="enable",Bt="disable",Ft="staticClick",zt=Math.PI/180,Vt=180/Math.PI,kt=At.EASE_OUT_CUBIC,Gt=300,Ht={min:-1/0,max:1/0},Yt={min:-90,max:90},Wt={min:.6,max:10};var Xt;!function(t){t[t.ZERO=0]="ZERO",t[t.CW_90=1]="CW_90",t[t.CCW_90=2]="CCW_90",t[t.CW_180=3]="CW_180"}(Xt||(Xt={}));const jt="view360videotimechange",Kt="http://www.w3.org/2000/svg",qt="immersive-vr",Zt="local",$t=null!==(It=Number.EPSILON)&&void 0!==It?It:2220446049250313e-31,Jt=t=>"string"==typeof t,Qt=(t,e=mt)=>{const i=document.createElement(e);return i.classList.add(t),i},te=(t,e)=>{let i=null;if(Jt(t)){const s=(e||document).querySelector(t);if(!s)return null;i=s}else(s=t)&&s.nodeType===Node.ELEMENT_NODE&&(i=t);var s;return i},ee=(t,e,i)=>Math.max(Math.min(t,i),e),ie=(t,e,i)=>t*(1-i)+e*i,se=(t,e,i)=>{const s=Math.abs(i-e);if(ti){t=e+(t-i)%s}return t},ne=(t,e)=>{for(let i=0;i"object"==typeof t?t:{},oe=(t,e)=>2*Math.atan(Math.tan(.5*t)/e),ae=(t,e,i="RLUDFB")=>i.split("").map((t=>e.indexOf(t))).map((e=>t[e])),he=()=>{if(!document)return!1;for(const t of wt)if(document[t])return!0;return!1},le=()=>window.isSecureContext&&!!DeviceMotionEvent&&"requestPermission"in DeviceMotionEvent,ce=(t,e,i,s)=>{T(t);const n=ee(i,-89.99,89.99);return C(t,t,e*zt),w(t,t,n*zt),L(t,t,s*zt),t},ue=t=>{const e=t[0],i=t[1],s=t[2],n=t[3],r=e*e+i*i+s*s+n*n,o=e*n-i*s;let a,h;if(o>.499995*r)a=Math.PI/2,h=2*Math.atan2(i,e);else if(o<-.499995*r)a=-Math.PI/2,h=-2*Math.atan2(i,e);else{const e=p(0,0,1),i=p(0,1,0);b(e,e,t),b(i,i,t);const s=Math.sqrt(e[0]*e[0]+e[2]*e[2]);a=Math.atan2(-e[1],s),h=Math.atan2(e[0],e[2])}return{pitch:ee(a*Vt,-90,90),yaw:se(h*Vt,0,360)}};class _e{get val(){return this._val}get start(){return this._start}get end(){return this._end}get progress(){return this._progress}get activated(){return this._activated}get duration(){return this._duration}set duration(t){this._duration=t}get loop(){return this._loop}set loop(t){this._loop=t}get range(){return this._range}get easing(){return this._easing}set easing(t){this._easing=t}constructor({duration:t=300,loop:e=!1,range:i={min:0,max:1},easing:s=kt}={}){this._duration=t,this._loop=e,this._range=i,this._easing=s,this._activated=!1,this.reset(0)}update(t){if(!this._activated)return this._val=this._end,0;const e=this._start,i=this._end,s=this._duration,n=this._val,r=this._loop,o=this._progress+t/s;this._progress=r?se(o,0,1):ee(o,0,1);const a=this._easing(this._progress);return this._val=ie(e,i,a),!r&&this._progress>=1&&(this._activated=!1),this._val-n}reset(t){const e=this._range,i=ee(t,e.min,e.max);this._start=i,this._end=i,this._val=i,this._progress=0,this._activated=!1}add(t){const e=this._range;this._start=ee(this._start+t,e.min,e.max),this._end=ee(this._end+t,e.min,e.max),this._val=ee(this._val+t,e.min,e.max)}setNewEndByDelta(t){const e=this._range;this._start=this._val,this._end=ee(this._end+t,e.min,e.max),this._progress=0,this._activated=!0}setRange(t,e){this._start=ee(this._start,t,e),this._end=ee(this._end,t,e),this._range={min:t,max:e}}}class de{get duration(){return this._motion.duration}set duration(t){this._motion.duration=t}get easing(){return this._motion.easing}set easing(t){this._motion.easing=t}constructor(t,e,i,{duration:s=300,easing:n=kt}={}){this._camera=t,this._motion=new _e({duration:s,easing:n,range:{min:0,max:1}}),this._from=e,this._to=i,this._finishPromise=new Promise((t=>{this._finish=t})),this._motion.setNewEndByDelta(1)}getFinishPromise(){return this._finishPromise}update(t){const e=this._camera,i=this._from,s=this._to,n=this._motion;n.update(t);const r=n.val,o=y(),a=ie(i.zoom,s.zoom,r);x(o,i.rotation,s.rotation,r),e.rotate(o,a),r>=1&&this._finish()}}class me extends o{get aspect(){return this._aspect}get changed(){return this._changed}get yawRange(){return this._initialYawRange}set yawRange(t){this._initialYawRange=t}get pitchRange(){return this._initialPitchRange}set pitchRange(t){this._initialPitchRange=t}get zoomRange(){return this._initialZoomRange}set zoomRange(t){this._initialZoomRange=t}constructor({initialYaw:t,initialPitch:e,initialZoom:i,yawRange:s,pitchRange:n,zoomRange:r,fov:o}){super(),this.yaw=t,this.pitch=e,this.zoom=i,this.rollOffset=0,this.initialYaw=t,this.initialPitch=e,this.initialZoom=i,this.position=d(),this.animation=null,this._up=p(0,1,0),this._aspect=1,this._initialYawRange=s,this._initialPitchRange=n,this._initialZoomRange=r,this._yawRange=s,this._pitchRange=n,this._zoomRange=r,this.quaternion=y(),this._updateQuaternion(),this.viewMatrix=c(),this.projectionMatrix=c(),this.fov=o,this._maxRenderHeight=-1}destroy(){this.off()}resize(t,e){const i=this._aspect;this._aspect=t/e,this._aspect!==i&&this.updateMatrix()}lookAt({yaw:t=this.yaw,pitch:e=this.pitch,zoom:i=this.zoom}){const s=A(this.quaternion),n=this.zoom;this.yaw=se(t,0,360),this.pitch=ee(e,-90,90),this.zoom=i,this._updateQuaternion();const r=Math.abs(i-n);(!N(this.quaternion,s)||r>=10*$t)&&this.updateMatrix()}rotate(t,e=this.zoom){const i=M(y(),t),s=N(this.quaternion,i);S(this.quaternion,i);const n=this.zoom,{yaw:r,pitch:o}=ue(i);this.yaw=r,this.pitch=o,this.zoom=e;const a=Math.abs(e-n);(!s||a>=10*$t)&&this.updateMatrix()}animateTo({yaw:e=this.yaw,pitch:i=this.pitch,zoom:s=this.zoom,duration:n=0,easing:r=kt}={}){return t(this,void 0,void 0,(function*(){if(this.yaw===e&&this.pitch===i&&this.zoom===s)return;const t={rotation:A(this.quaternion),zoom:this.zoom},o={rotation:ce(y(),e,i,this.rollOffset),zoom:s},a=new de(this,t,o,{duration:n,easing:r}),h=a.getFinishPromise();return this.animation=a,h.then((()=>{this.animation=null,this.trigger(St,{animation:a})})),h}))}restrictYawRange(t,e){this._yawRange={min:t,max:e}}restrictPitchRange(t,e){this._pitchRange={min:t,max:e}}restrictZoomRange(t,e){this._zoomRange={min:t,max:e}}restrictRenderHeight(t){this._maxRenderHeight=t}resetRange(){this._yawRange=this._initialYawRange,this._pitchRange=this._initialPitchRange,this._zoomRange=this._initialZoomRange,this._maxRenderHeight=-1}getYawRange(t){const e=this._yawRange,i=this._maxRenderHeight;if(!e)return Ht;const s=.5*this.getHorizontalFov(t);let n=e.min,r=e.max;if(i>0){const t=oe(s*zt,this._aspect),o=.5*i,a=Math.tan(t),h=Math.sqrt((1+o*o)/(1+a*a)),l=Math.atan(Math.tan(s*zt)*h)*Vt;n=e.min+l,r=e.max-l}return n>r&&(n=0,r=0),{min:n,max:r}}getPitchRange(t){const e=this._pitchRange,i=this._maxRenderHeight;if(!e)return Yt;let s=e.min,n=e.max;if(i>0){const i=.5*this.getVerticalFov(t);s=e.min+i,n=e.max-i}return s>n&&(s=0,n=0),{min:Math.max(s,-90),max:Math.min(n,90)}}getZoomRange(){var t;const e=null!==(t=this._zoomRange)&&void 0!==t?t:Wt,i=this.getHorizontalFov(e.max),s=this.getHorizontalFov(e.min),n=this.getHorizontalFov(this.zoom);return{min:Math.max(i,1),max:Math.min(s,180),current:n}}getHorizontalFov(t=this.zoom){return this._getZoomedHorizontalFov(t)*Vt}getVerticalFov(t=this.zoom){const e=this._aspect,i=this._getZoomedHorizontalFov(t);return oe(i,e)*Vt}fovToZoom(t){const e=this.fov;return Math.tan(zt*e*.5)/Math.tan(zt*t*.5)}updateMatrix(){const t=this._up,e=this._aspect,i=this.viewMatrix,s=this.projectionMatrix,n=this.position,r=this.quaternion,o=d(),a=p(0,0,-1);b(a,a,r),b(o,t,r);const l=this._getZoomedHorizontalFov(),c=oe(l,e);!function(t,e,i,s){var n,r,o,a,l,c,u,_,d,m,p=e[0],g=e[1],v=e[2],E=s[0],f=s[1],b=s[2],y=i[0],T=i[1],R=i[2];Math.abs(p-y){const e=this._el;e&&t.button===gt.LEFT&&(t.preventDefault(),e.focus?e.focus():window.focus(),this._prevPos[0]=t.clientX,this._prevPos[1]=t.clientY,window.addEventListener(V,this._onMouseMove,!1),window.addEventListener(k,this._onMouseUp,!1),this.trigger(Mt,{srcEvent:t,isTouch:!1,isKeyboard:!1}))},this._onMouseMove=t=>{t.preventDefault();const e=t.clientX,i=t.clientY,s=this._prevPos,n=e-s[0],r=i-s[1];this.trigger(Nt,{delta:{x:n,y:r},isTouch:!1,isKeyboard:!1}),s[0]=e,s[1]=i},this._onMouseUp=()=>{this._prevPos[0]=0,this._prevPos[1]=0,window.removeEventListener(V,this._onMouseMove,!1),window.removeEventListener(k,this._onMouseUp,!1),this.trigger(Dt,{isTouch:!1,isKeyboard:!1,scrolling:!1})},this._el=null,this._prevPos=[0,0]}enable(t){this._el||(t.addEventListener(z,this._onMouseDown),this._el=t)}disable(){const t=this._el;t&&(t.removeEventListener(z,this._onMouseDown),window.removeEventListener(V,this._onMouseMove,!1),window.removeEventListener(k,this._onMouseUp,!1),this._el=null)}}class ge extends o{get scrollable(){return this._scrollable}set scrollable(t){this._scrollable=t}constructor(){super(),this._onTouchStart=t=>{if(t.touches.length>1||this._scrolling)return;const e=t.touches[0];this._isFirstTouch=!0,this._prevPos[0]=e.clientX,this._prevPos[1]=e.clientY,this.trigger(Mt,{srcEvent:t,isTouch:!0,isKeyboard:!1})},this._onTouchMove=t=>{if(t.touches.length>1||this._scrolling)return;const e=t.touches[0],i=this._scrollable,s=this._prevPos,n=e.clientX,r=e.clientY,o=n-s[0],a=r-s[1];if(this._isFirstTouch){if(i&&!he()&&Math.abs(a)>Math.abs(o))return void(this._scrolling=!0);this._isFirstTouch=!1}!1!==t.cancelable&&t.preventDefault(),this.trigger(Nt,{delta:{x:o,y:a},isTouch:!0,isKeyboard:!1}),s[0]=n,s[1]=r},this._onTouchEnd=t=>{if(0!==t.touches.length)return;const e=t.touches[0],i=this._prevPos;e?(i[0]=e.clientX,i[1]=e.clientY):(i[0]=0,i[1]=0,this.trigger(Dt,{isTouch:!0,isKeyboard:!1,scrolling:this._scrolling})),!1!==t.cancelable&&t.preventDefault(),this._scrolling=!1},this._el=null,this._prevPos=[0,0],this._isFirstTouch=!1,this._scrolling=!1,this._scrollable=!1}enable(t){this._el||(t.addEventListener(G,this._onTouchStart,{passive:!1}),t.addEventListener(H,this._onTouchMove,{passive:!1}),t.addEventListener(Y,this._onTouchEnd),this._el=t)}disable(){const t=this._el;t&&(t.removeEventListener(G,this._onTouchStart),t.removeEventListener(H,this._onTouchMove),t.removeEventListener(Y,this._onTouchEnd),this._el=null)}}class ve extends o{get active(){const t=this._pressed;return t.LEFT||t.UP||t.RIGHT||t.DOWN}constructor(){super(),this._onKeyDown=t=>{if(t.location!==KeyboardEvent.DOM_KEY_LOCATION_STANDARD)return;this._updateKeyPress(t,!0);const e=this._getPressedKeyCount();e<=0||(t.preventDefault(),1!==e||t.repeat||this.trigger(Mt,{srcEvent:t,isTouch:!1,isKeyboard:!0}))},this._onKeyUp=t=>{if(t.location!==KeyboardEvent.DOM_KEY_LOCATION_STANDARD)return;this._updateKeyPress(t,!1);this._getPressedKeyCount()>0||this.trigger(Dt,{isTouch:!1,isKeyboard:!0,scrolling:!1})},this._el=null,this._clearPressedKeys()}enable(t){this._el||(t.addEventListener(Z,this._onKeyDown),t.addEventListener($,this._onKeyUp),this._el=t,this._clearPressedKeys())}disable(){const t=this._el;t&&(t.removeEventListener(Z,this._onKeyDown),t.removeEventListener($,this._onKeyUp),this._el=null,this._clearPressedKeys())}update(){const t=this._getDeltaByPressedKeys();0===t.x&&0===t.y||this.trigger(Nt,{delta:t,isTouch:!1,isKeyboard:!0})}_clearPressedKeys(){this._pressed=bt.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:!1})),{})}_updateKeyPress(t,e){const i=this._pressed,s=null!=t.keyCode?yt[t.keyCode]:Tt[t.key];s&&(i[s]=e)}_getPressedKeyCount(){return bt.filter((t=>this._pressed[t])).length}_getDeltaByPressedKeys(){const t=this._pressed;let e=0,i=0;return t.LEFT&&(e+=1),t.RIGHT&&(e-=1),t.UP&&(i+=1),t.DOWN&&(i-=1),{x:e,y:i}}}class Ee extends o{get enabled(){return this._enabled}get enableBlocked(){return this._enableBlocked}get animating(){return this._keyboardInput.active||this._xMotion.activated||this._yMotion.activated}get yaw(){return this._xMotion}get pitch(){return this._yMotion}get scrollable(){return this._touchInput.scrollable}set scrollable(t){this._touchInput.scrollable=t}get pointerScale(){return this._pointerScale}set pointerScale(t){this._pointerScale=t}get keyboardScale(){return this._keyboardScale}set keyboardScale(t){this._keyboardScale=t}get duration(){return this._duration}set duration(t){this._duration=t,this._xMotion.duration=t,this._yMotion.duration=t}get easing(){return this._easing}set easing(t){this._easing=t,this._xMotion.easing=t,this._yMotion.easing=t}get disablePitch(){return this._disablePitch}set disablePitch(t){this._disablePitch=t}get disableYaw(){return this._disableYaw}set disableYaw(t){this._disableYaw=t}get disableKeyboard(){return this._disableKeyboard}set disableKeyboard(t){this._disableKeyboard=t}constructor(t,e,{duration:i=300,easing:s=kt,pointerScale:n=[1,1],keyboardScale:r=[1,1],disablePitch:o=!1,disableYaw:a=!1,disableKeyboard:h=!1}={}){super(),this._onInputStart=t=>{this._changedWhileDragging=!1,this.trigger(Mt,Object.assign(Object.assign({},t),{inputType:"rotate"}))},this._onChange=t=>{const e=t.delta,i=1/this._zoomScale,s=this._screenScale,n=this._keyboardScale,r=this._pointerScale;let o;o=t.isKeyboard?[n[0]*i,n[1]*i]:[r[0]*s[0]*i,r[1]*s[1]*i];const a=e.x*o[0],h=e.y*o[1];this._xMotion.setNewEndByDelta(a),this._yMotion.setNewEndByDelta(h),this._changedWhileDragging=!0},this._onInputEnd=t=>{this.trigger(Dt,Object.assign(Object.assign({},t),{inputType:"rotate"})),this._changedWhileDragging||t.isKeyboard||t.scrolling||this.trigger(Ft,{isTouch:t.isTouch}),this._changedWhileDragging=!1},this._controlEl=t,this._pointerScale=n,this._keyboardScale=r,this._duration=i,this._easing=s,this._disablePitch=o,this._disableYaw=a,this._disableKeyboard=h,this._enableBlocked=e,this._mouseInput=new pe,this._touchInput=new ge,this._keyboardInput=new ve,this._xMotion=new _e({duration:i,range:Ht,easing:s}),this._yMotion=new _e({duration:i,range:Yt,easing:s}),this._screenScale=[1,1],this._zoomScale=1,this._enabled=!1,this._changedWhileDragging=!1,this._bindInputs()}destroy(){this.disable(),this._mouseInput.off(),this._touchInput.off(),this._keyboardInput.off(),this.off(),this._changedWhileDragging=!1}update(t){if(!this._enabled)return;const e=this._xMotion,i=this._yMotion,s=this._keyboardInput;this._disableKeyboard||s.update(),this._disablePitch||i.update(t),this._disableYaw||e.update(t)}updateRange(t,e){const i=t.getYawRange(e),s=t.getPitchRange(e);this._xMotion.setRange(i.min,i.max),this._yMotion.setRange(s.min,s.max)}setZoomScale(t){this._zoomScale=t}resize(t,e,i,s){const n=oe(t*zt,e)*Vt;this._screenScale[0]=t/i,this._screenScale[1]=n/s}enable(){if(this._enabled)return;const t=this._controlEl;this._mouseInput.enable(t),this._touchInput.enable(t),this._keyboardInput.enable(t),this._enabled=!0,this._enableBlocked=!1,this.trigger(Ut,{control:this,updateCursor:!0})}disable(){this._enabled&&(this._mouseInput.disable(),this._touchInput.disable(),this._keyboardInput.disable(),this._enabled=!1,this.trigger(Bt,{updateCursor:!0}))}sync(t){this.updateRange(t,t.zoom),this._xMotion.reset(t.yaw),this._yMotion.reset(t.pitch)}_bindInputs(){const t=this._mouseInput,e=this._touchInput,i=this._keyboardInput;t.on(Mt,this._onInputStart),t.on(Nt,this._onChange),t.on(Dt,this._onInputEnd),e.on(Mt,this._onInputStart),e.on(Nt,this._onChange),e.on(Dt,this._onInputEnd),i.on(Mt,this._onInputStart),i.on(Nt,this._onChange),i.on(Dt,this._onInputEnd)}}class fe extends o{get scrollable(){return this._scrollable}set scrollable(t){this._scrollable=t}constructor(){super(),this._onWheel=t=>{const e=this._scrollable;if(0===t.deltaY||e)return;t.preventDefault(),t.stopPropagation(),this._inputTimer<0?this.trigger(Mt,{srcEvent:t,isTouch:!1,isKeyboard:!1}):this._clearTimer();const i=this._baseScale*t.deltaY;this.trigger(Nt,{delta:i,isTouch:!1,isKeyboard:!1}),this._inputTimer=window.setTimeout((()=>{this.trigger(Dt,{isTouch:!1,isKeyboard:!1,scrolling:!1}),this._inputTimer=-1}),Gt)},this._el=null,this._baseScale=.04,this._scrollable=!1,this._inputTimer=-1}enable(t){this._el||(t.addEventListener(W,this._onWheel,{passive:!1,capture:!1}),this._el=t,this._clearTimer())}disable(){const t=this._el;t&&(t.removeEventListener(W,this._onWheel,!1),this._el=null,this._clearTimer())}_clearTimer(){window.clearTimeout(this._inputTimer),this._inputTimer=-1}}class be extends o{constructor(){super(),this._onTouchMove=t=>{const e=t.touches;if(2!==e.length)return;if(!t.cancelable)return;t.preventDefault(),t.stopPropagation();const i=this._prevDistance,s=[e[0].pageX-e[1].pageX,e[0].pageY-e[1].pageY],n=Math.sqrt(s[0]*s[0]+s[1]*s[1])*this._baseScale,r=this._isFirstTouch?0:n-i;this._isFirstTouch&&this.trigger(Mt,{srcEvent:t,isTouch:!0,isKeyboard:!1}),this._prevDistance=n,this._isFirstTouch=!1,this.trigger(Nt,{delta:r,isTouch:!0,isKeyboard:!1})},this._onTouchEnd=t=>{0===t.touches.length&&(this._isFirstTouch||this.trigger(Dt,{isTouch:!0,isKeyboard:!1,scrolling:!1}),this._prevDistance=-1,this._isFirstTouch=!0)},this._el=null,this._baseScale=-.2,this._prevDistance=-1,this._isFirstTouch=!0}enable(t){this._el||(t.addEventListener(H,this._onTouchMove,{passive:!1,capture:!1}),t.addEventListener(Y,this._onTouchEnd),this._el=t,this._prevDistance=-1,this._isFirstTouch=!0)}disable(){const t=this._el;t&&(t.removeEventListener(H,this._onTouchMove,!1),t.removeEventListener(Y,this._onTouchEnd),this._el=null)}}class ye extends o{get enabled(){return this._enabled}get enableBlocked(){return this._enableBlocked}get animating(){return this._motion.activated}get zoom(){return this._motion.val}get scrollable(){return this._wheelInput.scrollable}set scrollable(t){this._wheelInput.scrollable=t}get range(){return this._motion.range}get scale(){return this._scale}set scale(t){this._scale=t}get duration(){return this._motion.duration}get easing(){return this._motion.easing}constructor(t,e,{scale:i=1,duration:s=300,easing:n=kt}={}){super(),this._onInputStart=t=>{this.trigger(Mt,Object.assign(Object.assign({},t),{inputType:"zoom"}))},this._onChange=({delta:t})=>{const e=t*this._scale;this._motion.setNewEndByDelta(e)},this._onInputEnd=t=>{this.trigger(Dt,Object.assign(Object.assign({},t),{inputType:"zoom"}))},this._scale=i,this._controlEl=t,this._enableBlocked=e,this._wheelInput=new fe,this._pinchInput=new be,this._motion=new _e({duration:s,easing:n,range:Ht}),this._enabled=!1,this._bindInputs()}destroy(){this.disable(),this._wheelInput.off(),this._pinchInput.off(),this.off()}update(t){if(!this._enabled)return;this._motion.update(t)}enable(){if(this._enabled)return;const t=this._controlEl;this._wheelInput.enable(t),this._pinchInput.enable(t),this._enabled=!0,this._enableBlocked=!1,this.trigger(Ut,{control:this,updateCursor:!1})}disable(){this._enabled&&(this._wheelInput.disable(),this._pinchInput.disable(),this._enabled=!1,this.trigger(Bt,{updateCursor:!1}))}sync(t){const e=this._motion,i=t.getZoomRange();e.setRange(i.min,i.max),e.reset(i.current)}_bindInputs(){const t=this._wheelInput,e=this._pinchInput;t.on(Mt,this._onInputStart),t.on(Nt,this._onChange),t.on(Dt,this._onInputEnd),e.on(Mt,this._onInputStart),e.on(Nt,this._onChange),e.on(Dt,this._onInputEnd)}}const Te={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3};Te[Te.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1]},Te[Te.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0]},Te[Te.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1]};class Re extends o{get enabled(){return this._enabled}get orientationUpdated(){return this._orientationUpdated}get ignoreRoll(){return this._ignoreRoll}set ignoreRoll(t){this._ignoreRoll=t}constructor(){super(),this._onDeviceOrientation=t=>{const e=this._orientation,{alpha:i,beta:s,gamma:n}=t;null!=i&&null!=s&&null!=n&&(e.alpha=i,e.beta=s,e.gamma=n,this._orientationUpdated=!0,this._needsCalibrate&&(this._needsCalibrate=!1,this._calibrateSensor()))},this._updateScreenOrientation=()=>{window.screen&&window.screen.orientation&&void 0!==window.screen.orientation.angle?this._screenOrientation=screen.orientation.angle:void 0!==window.orientation?this._screenOrientation=window.orientation>=0?window.orientation:360+window.orientation:this._screenOrientation=0},this.quaternion=y(),this._orientation={alpha:0,beta:90,gamma:0},this._yawOrigin=0,this._yawOffset=0,this._orientationUpdated=!1,this._screenOrientation=0,this._needsCalibrate=!0,this._enabled=!1}enable(){this._enabled||(window.addEventListener(it,this._onDeviceOrientation),window.addEventListener(nt,this._updateScreenOrientation),this._updateScreenOrientation(),this._orientationUpdated=!1,this._needsCalibrate=!0,this._enabled=!0)}disable(){this._enabled&&(window.removeEventListener(it,this._onDeviceOrientation),window.removeEventListener(nt,this._updateScreenOrientation),this._enabled=!1)}update(){this._updateRotation(),this._orientationUpdated=!1}collectDelta(){if(!this._orientationUpdated)return{pitch:0,yaw:0};const t=A(this.quaternion);return this._updateRotation(),this._orientationUpdated=!1,this._toEulerDelta(t,this.quaternion)}setInitialRotation(t){this._yawOrigin=t}_calibrateSensor(){const t=this._yawOrigin,e=this.quaternion;this._yawOffset=0,this._updateRotation();const{yaw:i}=ue(e);this._yawOffset=i-t,this._updateRotation(),this._needsCalibrate=!1}_updateRotation(){const t=this.quaternion,{alpha:e,beta:i,gamma:s}=this._orientation;T(t),C(t,t,(e-this._yawOffset)*zt),w(t,t,i*zt),L(t,t,-s*zt);const n=y(),r=.5*-this._screenOrientation*zt,o=I(-Math.sqrt(.5),0,0,Math.sqrt(.5));P(n,0,Math.sin(r),0,Math.cos(r)),R(t,t,n),R(t,t,o),M(t,t)}_toEulerDelta(t,e){return{yaw:this._getDeltaYaw(t,e),pitch:this._getDeltaPitch(t,e)}}_getDeltaYaw(t,e){const i=this._getRotationDelta(t,e,Te.YAW_DELTA_BY_YAW);return this._getRotationDelta(t,e,Te.YAW_DELTA_BY_ROLL)*Math.sin(this._extractPitchFromQuat(e))+i}_getDeltaPitch(t,e){return this._getRotationDelta(t,e,Te.PITCH_DELTA)}_getRotationDelta(t,e,i){const s=p(Te[i].targetAxis[0],Te[i].targetAxis[1],Te[i].targetAxis[2]),n=Te[i].meshPoint,r=A(t),o=A(e);M(r,r),M(o,o);let a=p(0,0,1),h=p(0,0,1);b(a,a,r),b(h,h,o),b(s,s,o);const l=v(s,E(d(),a,h))>0?1:-1,c=p(n[0],n[1],n[2]);let u;u=i!==Te.YAW_DELTA_BY_YAW?p(0,l,0):p(l,0,0),b(c,c,o),b(u,u,o);const _=c,f=u,y=d();E(y,_,f),g(y,y);const T=y[0],R=y[1],w=y[2];h=p(n[0],n[1],n[2]),b(h,h,o),a=p(n[0],n[1],n[2]),b(a,a,r);let C=Math.abs(a[0]*T+a[1]*R+a[2]*w);const L=d();!function(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}(L,a,function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}(d(),y,C));let x=(L[0]*h[0]+L[1]*h[1]+L[2]*h[2])/(m(L)*m(h));x>1&&(x=1);const O=Math.acos(x),I=E(d(),h,L);let S;C=T*I[0]+R*I[1]+w*I[2],S=i!==Te.YAW_DELTA_BY_YAW?C>0?1:-1:C<0?1:-1;return O*S*l*Vt}_extractPitchFromQuat(t){const e=p(0,0,1);return b(e,e,t),-1*Math.atan2(e[1],Math.sqrt(Math.pow(e[0],2)+Math.pow(e[2],2)))}}class we extends o{get enabled(){return this._input.enabled}get enableBlocked(){return this._enableBlocked}get animating(){return this._input.enabled&&this._input.orientationUpdated}get ignoreRoll(){return this._ignoreRoll}set ignoreRoll(t){this._ignoreRoll=t}static isAvailable(){return t(this,void 0,void 0,(function*(){if(!DeviceMotionEvent)return!1;let t;return Promise.race([new Promise((e=>{t=t=>{e(t.rotationRate&&null!=t.rotationRate.alpha)},window.addEventListener(st,t)})),new Promise((t=>{setTimeout((()=>t(!1)),1e3)}))]).then((e=>(window.removeEventListener(st,t),e)))}))}static requestSensorPermission(){return t(this,void 0,void 0,(function*(){return!le()||DeviceMotionEvent.requestPermission().then((t=>"granted"===t)).catch((()=>!1))}))}constructor(t,{ignoreRoll:e=!0}={}){super(),this._enableBlocked=t,this._ignoreRoll=e,this._input=new Re}destroy(){this.disable(),this._input.off(),this.off()}update(t,e,i,s){this._ignoreRoll?this._updateYawPitch(t,e,i,s):this._updateQuaternion(t,s)}enable(){this._input.enabled||(this._input.enable(),this._enableBlocked=!1,this.trigger(Ut,{control:this,updateCursor:!1}))}disable(){this._input.enabled&&(this._input.disable(),this.trigger(Bt,{updateCursor:!1}))}sync(){}_updateYawPitch(t,e,i,s){const n=this._input;if(!n.enabled)return;const{yaw:r,pitch:o}=n.collectDelta();e.add(r),i.add(o),t.lookAt({yaw:e.val,pitch:i.val,zoom:s})}_updateQuaternion(t,e){const i=this._input;i.enabled&&(i.update(),t.rotate(i.quaternion,e))}}class Ce{get useGrabCursor(){return this._useGrabCursor}set useGrabCursor(t){t!==this._useGrabCursor&&(this._useGrabCursor=t,t&&this._enabled?this._setCursor(vt):t||this._setCursor(ft))}get disableContextMenu(){return this._disableContextMenu}set disableContextMenu(t){t!==this._disableContextMenu&&(this._disableContextMenu=t,t&&this._enabled?this._blockContextMenu():t||this._restoreContextMenu())}get scrollable(){return this._rotateControl.scrollable}set scrollable(t){this._rotateControl.scrollable=t}get wheelScrollable(){return this._zoomControl.scrollable}set wheelScrollable(t){this._zoomControl.scrollable=t}get ignoreZoomScale(){return this._ignoreZoomScale}set ignoreZoomScale(t){this._ignoreZoomScale=t}get enabled(){return this._enabled}get rotate(){return this._rotateControl}get zoom(){return this._zoomControl}get gyro(){return this._gyroControl}get animating(){return this._rotateControl.animating||this._zoomControl.animating||this._gyroControl.animating}constructor(t,e,{useGrabCursor:i,scrollable:s,wheelScrollable:n,disableContextMenu:r,rotate:o,zoom:a,gyro:h}){this._preventContextMenu=t=>{t.preventDefault()},this._onInputStart=t=>{this._useGrabCursor&&!t.isKeyboard&&this._setCursor(Et)},this._onInputEnd=t=>{this._useGrabCursor&&!t.isKeyboard&&this._setCursor(vt)},this._onEnable=({control:t,updateCursor:e})=>{e&&this._useGrabCursor&&this._setCursor(vt),t.sync(this._camera)},this._onDisable=({updateCursor:t})=>{t&&this._setCursor(ft)},this._onCameraAnimationEnd=({animation:t})=>{t.getFinishPromise().then((()=>{this.sync()}))},this._useGrabCursor=i,this._disableContextMenu=r,this._camera=e,this._controlEl=t,this._ignoreZoomScale=!1,this._enabled=!1,this._rotateControl=new Ee(t,!o,re(o)),this._zoomControl=new ye(t,!a,re(a)),this._gyroControl=new we(!h,re(h)),this._rotateControl.scrollable=s,this._zoomControl.scrollable=n,this._bindEvents()}destroy(){this.disable(),this._rotateControl.destroy(),this._zoomControl.destroy(),this._setCursor(ft)}resize(t,e){const i=this._camera;this._rotateControl.resize(i.fov,i.aspect,t,e)}enable(){return t(this,void 0,void 0,(function*(){this._enabled||(this._rotateControl.enableBlocked||this._rotateControl.enable(),this._zoomControl.enableBlocked||this._zoomControl.enable(),this._gyroControl.enableBlocked||(yield we.isAvailable())&&this._gyroControl.enable(),this.sync(),this._disableContextMenu&&this._blockContextMenu(),this._enabled=!0)}))}disable(){this._enabled&&(this._rotateControl.disable(),this._zoomControl.disable(),this._gyroControl.disable(),this._restoreContextMenu(),this._enabled=!1)}update(t){const e=this._camera,i=this._rotateControl,s=this._zoomControl,n=this._gyroControl;s.update(t);const r=(o=e.fov,a=s.zoom,Math.tan(zt*o*.5)/Math.tan(zt*a*.5));var o,a;const h=this._ignoreZoomScale?1:Math.max(r,1);i.setZoomScale(h),i.updateRange(e,r),i.update(t);const l=i.yaw,c=i.pitch;n.enabled?n.update(e,l,c,r):e.lookAt({yaw:l.val,pitch:c.val,zoom:r})}sync(){const t=this._camera;this._zoomControl.sync(t),this._rotateControl.sync(t)}_blockContextMenu(){this._controlEl.addEventListener(j,this._preventContextMenu)}_restoreContextMenu(){this._controlEl.removeEventListener(j,this._preventContextMenu)}_setCursor(t){if(!this._useGrabCursor&&t!==ft)return;this._controlEl.style.cursor=t}_bindEvents(){const t=this._rotateControl,e=this._zoomControl;t.on(Mt,this._onInputStart),t.on(Dt,this._onInputEnd),t.on(Ut,this._onEnable),t.on(Bt,this._onDisable),e.on(Ut,this._onEnable),e.on(Bt,this._onDisable),this._camera.on(St,this._onCameraAnimationEnd)}}var Le=function(t,e){return Le=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},Le(t,e)};function xe(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}Le(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var Oe=function(){return Oe=Object.assign||function(t){for(var e,i=1,s=arguments.length;i0},i.clear=function(){this.isPreReadyOver=!1,this.totalCount=0,this.preReadyCount=0,this.readyCount=0,this.totalErrorCount=0,this.elementInfos.forEach((function(t){t.loader&&t.loader.destroy()})),this.elementInfos=[]},i.destroy=function(){this.clear(),this.off()},i.getLoader=function(t,e){var i=this,s=t.tagName.toLowerCase(),n=this.options.loaders,r=e.prefix,o=Object.keys(n);if(n[s])return new n[s](t,e);var a=new Ke(t,e),h=Be(t.querySelectorAll(o.join(", ")));a.setHasLoading(h.some((function(t){return Fe(t,r)})));var l=!1,c=this.clone().on("error",(function(t){a.onError(t.target)})).on("ready",(function(){a.onReady(l)}));return a.on("requestChildren",(function(){var e=Ge(t,o,i.options.prefix);c.check(e).on("preReady",(function(t){(l=t.isReady)||a.onPreReady()}))})).on("reqeustReadyChildren",(function(){c.check(h)})).on("requestDestroy",(function(){c.destroy()})),a},i.clone=function(){return new e(Oe({},this.options))},i.checkPreReady=function(t){return this.elementInfos[t].isPreReady=!0,++this.preReadyCount,!(this.preReadyCount=1)&&(t.error?(this.onAlreadyError(t),!1):(this.addEvents(),!0))},e.EVENTS=["loadedmetadata","error"],e}(je),Je=function(t){function e(e){return void 0===e&&(e={}),t.call(this,Oe({loaders:{img:Ze,video:$e}},e))||this}return xe(e,t),e}(qe);class Qe{constructor({width:t,height:e,flipY:i}){this.width=t,this.height=e,this.flipY=i,this.wrapS=WebGLRenderingContext.CLAMP_TO_EDGE,this.wrapT=WebGLRenderingContext.CLAMP_TO_EDGE}destroy(){}isVideo(){return!1}isCube(){return!1}}class ti extends Qe{constructor({source:t,width:e,height:i,flipY:s}){super({width:e,height:i,flipY:s}),this.source=t}}class ei extends ti{destroy(){const t=this.source;t.pause(),t.removeAttribute("src"),t.load()}isVideo(){return!0}isPaused(){const t=this.source;return t.paused||t.ended||t.readyState<=2}hasAudio(){const t=this.source;return t.audioTracks?t.audioTracks.length>0:null!=t.webkitAudioDecodedByteCount?t.webkitAudioDecodedByteCount>0:null==t.mozHasAudio||t.mozHasAudio}}class ii extends Qe{constructor({sources:t,width:e,height:i,flipY:s}){super({width:e,height:i,flipY:s}),this.sources=t}isCube(){return!0}}class si{constructor(){this._loadChecker=new Je}load(e,i){return t(this,void 0,void 0,(function*(){if(i)return this.loadVideo(e,re(i));if(Array.isArray(e)&&e.length>1)return this.loadCubeImage(e);{const t=Array.isArray(e)?e[0]:e;return this.loadImage(t)}}))}loadImage(e){return t(this,void 0,void 0,(function*(){const t=this._toImageArray(e);return this._load(t,(e=>{const i=t[0];e(new ti({source:i,width:i.naturalWidth,height:i.naturalHeight,flipY:!0}))}))}))}loadCubeImage(e){return t(this,void 0,void 0,(function*(){const t=this._toImageArray(e);return this._load(t,(e=>{e(new ii({sources:t,width:t[0].naturalWidth,height:t[0].naturalHeight,flipY:!1}))}))}))}loadVideo(e,i){return t(this,void 0,void 0,(function*(){const t=Object.assign({autoplay:!0,muted:!0,loop:!1,volume:1},i),s=this._toVideoElement(e,t);return this._load([s],(e=>{const{autoplay:i,muted:n}=t;s.currentTime=0,i&&n&&s.play().catch((()=>{})),e(new ei({source:s,width:s.videoWidth,height:s.videoHeight,flipY:!0}))}))}))}_load(t,e){const i=this._loadChecker;return new Promise(((s,n)=>{i.once("ready",(t=>{t.errorCount>0||e(s)})),i.once("error",n),i.check(t)}))}_toImageArray(t){return(Array.isArray(t)?t:[t]).map((t=>{if(Jt(t)){const e=new Image;return e.crossOrigin="anonymous",e.src=t,e}return t}))}_toVideoElement(t,{muted:e,loop:i,volume:s}){if(t instanceof HTMLVideoElement)return t;const n=document.createElement("video");n.crossOrigin="anonymous",n.playsInline=!0,n.setAttribute("webkit-playsinline",""),n.muted=e,n.volume=s,n.loop=i,Array.isArray(t)?t.forEach((t=>this._appendSourceElement(n,t))):this._appendSourceElement(n,t);return n.querySelectorAll("source").length>0&&n.readyState<1&&n.load(),n}_appendSourceElement(t,e){if(e instanceof HTMLSourceElement)return e;const i=document.createElement("source");i.src=e,t.appendChild(i)}}class ni{constructor(t,e=window){this.maxDeltaTime=t,this._context=e,this._rafId=-1,this._rafTimer=-1,this._lastUpdateTime=-1}start(t){const e=this._context;if(!e||!t)return;if(this._rafId>=0||this._rafTimer>=0)return;const i=(s,n)=>{const r=Date.now(),o=Math.min(r-this._lastUpdateTime,1e3*this.maxDeltaTime);t(o,n),this._lastUpdateTime=r,this._rafId=e.requestAnimationFrame(i)};this._lastUpdateTime=Date.now(),this._rafId=e.requestAnimationFrame(i)}stop(){this._rafId>=0&&this._context.cancelAnimationFrame(this._rafId),this._rafTimer>=0&&clearTimeout(this._rafTimer),this._rafId=-1,this._rafTimer=-1}changeContext(t){this.stop(),this._context=t}}class ri{get useResizeObserver(){return this._useResizeObserver}get enabled(){return this._enabled}constructor(t,e){this._skipFirstResize=(()=>{let t=!0;return()=>{t?t=!1:this._onResize()}})(),this._useResizeObserver=t,this._enabled=!1,this._resizeObserver=null,this._onResize=e}enable(t){if(this._enabled&&this.disable(),this._useResizeObserver&&window.ResizeObserver){const e=t.getBoundingClientRect(),i=0!==e.width||0!==e.height,s=new ResizeObserver(i?this._skipFirstResize:this._onResize);s.observe(t),this._resizeObserver=s}else window.addEventListener(X,this._onResize);return this._enabled=!0,this}disable(){if(!this._enabled)return this;const t=this._resizeObserver;return t?(t.disconnect(),this._resizeObserver=null):window.removeEventListener(X,this._onResize),this._enabled=!1,this}}class oi{get enabled(){return this._enabled}get enableBlocked(){return this._enableBlocked}get playing(){return this._enabled&&!this._interrupted}get delay(){return this._delay}set delay(t){this._delay=t}get delayOnMouseLeave(){return this._delayOnMouseLeave}set delayOnMouseLeave(t){this._delayOnMouseLeave=t}get speed(){return this._speed}set speed(t){this._speed=t}get pauseOnHover(){return this._pauseOnHover}set pauseOnHover(t){this._pauseOnHover=t}get canInterrupt(){return this._canInterrupt}set canInterrupt(t){this._canInterrupt=t}get disableOnInterrupt(){return this._disableOnInterrupt}set disableOnInterrupt(t){this._disableOnInterrupt=t}constructor(t,e,i){this._onInputStart=()=>{this._canInterrupt&&(this._interrupted=!0,this._clearTimeout())},this._onInputEnd=()=>{this._setUninterruptedAfterDelay(this._delay)},this._onGyroEnable=()=>{this.disable()},this._onMouseEnter=()=>{this._pauseOnHover&&(this._interrupted=!0,this._hovering=!0)},this._onMouseLeave=()=>{this._pauseOnHover&&(this._hovering=!1,this._setUninterruptedAfterDelay(this._delayOnMouseLeave))},this._camera=t.camera,this._control=t.control,this._element=e,this._enabled=!1,this._interrupted=!1,this._interruptionTimer=-1,this._hovering=!1;const{delay:s=2e3,delayOnMouseLeave:n=0,speed:r=1,pauseOnHover:o=!1,canInterrupt:a=!0,disableOnInterrupt:h=!1}=re(i);this._enableBlocked=!i,this._delay=s,this._delayOnMouseLeave=n,this._speed=r,this._pauseOnHover=o,this._canInterrupt=a,this._disableOnInterrupt=h}destroy(){this.disable()}update(t){if(!this._enabled)return;if(this._interrupted)return void(this._disableOnInterrupt&&this.disable());const e=this._camera,i=-this._speed*t/100;e.yaw=se(e.yaw+i,0,360)}enable(){const t=this._control,e=this._element;this._enabled||t.gyro.enabled||(t.rotate.on(Mt,this._onInputStart),t.rotate.on(Dt,this._onInputEnd),t.zoom.on(Mt,this._onInputStart),t.zoom.on(Dt,this._onInputEnd),t.gyro.on(Ut,this._onGyroEnable),e.addEventListener(K,this._onMouseEnter,!1),e.addEventListener(q,this._onMouseLeave,!1),this._enabled=!0,this._enableBlocked=!1)}enableAfterDelay(){this.enable(),this._interrupted=!0,this._setUninterruptedAfterDelay(this._delay)}disable(){if(!this._enabled)return;const t=this._control,e=this._element;t.rotate.off(Mt,this._onInputStart),t.rotate.off(Dt,this._onInputEnd),t.zoom.off(Mt,this._onInputStart),t.zoom.off(Dt,this._onInputEnd),t.gyro.off(Ut,this._onGyroEnable),e.removeEventListener(K,this._onMouseEnter,!1),e.removeEventListener(q,this._onMouseLeave,!1),this._enabled=!1,this._interrupted=!1,this._hovering=!1,this._clearTimeout()}_setUninterruptedAfterDelay(t){this._hovering||(this._clearTimeout(),t>0?this._interruptionTimer=window.setTimeout((()=>{this._interrupted=!1,this._interruptionTimer=-1}),t):(this._interrupted=!1,this._interruptionTimer=-1))}_clearTimeout(){this._interruptionTimer>=0&&(window.clearTimeout(this._interruptionTimer),this._interruptionTimer=-1)}}class ai extends o{constructor(t,e={}){super(),this.destroy=()=>{this.exit(),this.off()},this._onSessionEnd=()=>{this.exit(),this.trigger(Ot.VR_END)},this._xrSession=null,this._xrRefSpace=null,this._ctx=t,this._options=e}isAvailable(){return t(this,void 0,void 0,(function*(){const t=window.navigator.xr;return!!t&&t.isSessionSupported(qt).then((t=>t)).catch((()=>!1))}))}enter(){return t(this,void 0,void 0,(function*(){const t=this._ctx,e=window.navigator.xr;if(!e)return;yield we.requestSensorPermission();const i=Object.assign({requiredFeatures:[Zt]},this._options);yield t.makeXRCompatible();const s=yield e.requestSession(qt,i);t.bindXRLayer(s);const n=yield s.requestReferenceSpace(Zt);this._setSession(s,n),this.trigger(Ot.VR_START,{session:s})}))}exit(){const t=this._xrSession;t&&t.end().catch((()=>{})),this._xrSession=null,this._xrRefSpace=null}canRender(t){const e=this._xrRefSpace;if(!e)return!1;return!!t.getViewerPose(e)}getEyeParams(t){const e=t.session,i=t.getViewerPose(this._xrRefSpace);if(!i)return null;const s=e.renderState.baseLayer;return s?i.views.map((t=>({viewport:s.getViewport(t),vMatrix:t.transform.inverse.matrix,pMatrix:t.projectionMatrix}))):null}_setSession(t,e){this._xrSession=t,this._xrRefSpace=e,t.addEventListener(dt,this._onSessionEnd)}}class hi{constructor(t,e){this.element=t,this.position=e}}class li{constructor(t,e,{zoom:i=!1}){this._containerEl=te(`.${xt.HOTSPOT_CONTAINER}`,t),this._renderer=e,this._hotspots=[],this._zoom=i}refresh(){const t=this._containerEl;if(!t)return;const e=[].slice.apply(t.querySelectorAll(`.${xt.HOTSPOT}`));this._hotspots=e.map((t=>this._parseHotspot(t)))}render(t){const e=this._hotspots,i=.5*this._renderer.width,s=.5*this._renderer.height,n=t.zoom,r="translate(-50%, -50%)",o=this._zoom?`scale(${n})`:"";e.forEach((e=>{const n=e.position,a=d();if(function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2]}(a,n),f(a,a,t.viewMatrix),f(a,a,t.projectionMatrix),a[2]>1||a[2]<0)return void e.element.classList.remove(xt.HOTSPOT_VISIBLE);const h=function(t,e){var i=new l(2);return i[0]=t,i[1]=e,i}(a[0]*i+i,-a[1]*s+s);e.element.classList.add(xt.HOTSPOT_VISIBLE),e.element.style.transform=[r,`translate(${h[0]}px, ${h[1]}px)`,o].join(" ")}))}_parseHotspot(t){const e=t.dataset.yaw,i=t.dataset.pitch,s=t.dataset.position;if(e||i){const s=e?parseFloat(e):0,n=i?parseFloat(i):0,r=this._yawPitchToVec3(s,n);return new hi(t,r)}if(s){const e=s.split(" ").map((t=>parseFloat(t)));if(e.length<3)throw new D(F.INSUFFICIENT_ARGS(s,'hotspot attribute "data-position"'),B.INSUFFICIENT_ARGS);return new hi(t,p(e[0],e[1],e[2]))}{const e=p(0,0,-1);return new hi(t,e)}}_yawPitchToVec3(t,e){const i=t*zt,s=e*zt,n=d();return n[1]=Math.sin(s),n[2]=Math.cos(s),n[0]=n[2]*Math.sin(-i),n[2]=-n[2]*Math.cos(-i),n}}class ci{get count(){return this.geometry.indicies.count}constructor(t,e,i){this.obj=t,this.geometry=e,this.buffers=i}}class ui{get canvas(){return this._canvas}get maxTextureSize(){return this._maxTextureSize}get isWebGL2(){return this._isWebGL2}get supportVAO(){return this._isWebGL2||!!this._extensions.vao}get lost(){return this._contextLost}get debug(){return this._debug}constructor(t,e){this._onContextLost=()=>{this._canvas.classList.add(xt.CTX_LOST),this._contextLost=!0},this._onContextRestore=()=>{this._canvas.classList.remove(xt.CTX_LOST),this._contextLost=!1},this._canvas=t,this._contextLost=!1,this._debug=e,this._extensions={vao:null,loseContext:null}}init(){const t=this._canvas,{gl:e,isWebGL2:i}=this._getContext(t);this._gl=e,this._maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this._isWebGL2=i,this._isWebGL2||(this._extensions.vao=e.getExtension("OES_vertex_array_object")),this._extensions.loseContext=e.getExtension("WEBGL_lose_context"),t.addEventListener(tt,this._onContextLost),t.addEventListener(et,this._onContextRestore)}destroy(){const t=this._gl,e=this._canvas;t&&(t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)),e.removeEventListener(tt,this._onContextLost),e.removeEventListener(et,this._onContextRestore)}forceLoseContext(){const t=this._extensions.loseContext;t&&t.loseContext()}forceRestoreContext(){const t=this._extensions.loseContext;t&&t.restoreContext()}clear(){const t=this._gl;t.clear(t.COLOR_BUFFER_BIT)}resize(){const t=this._gl;t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight)}viewport(t,e,i,s){this._gl.viewport(t,e,i,s)}createVAO(t,e){const i=this._createNativeVAO(),s=new ci(i,t,{indicies:this._createBuffer(),position:this._createBuffer(),uv:this._createBuffer()});return i&&(this._bindNativeVAO(i),this._supplyGeometryData(s,e),this._bindNativeVAO(null),this._unbindBuffers()),s}draw(t,e){const i=this._gl;t.obj?this._bindNativeVAO(t.obj):this._supplyGeometryData(t,e),i.drawElements(i.TRIANGLES,t.count,i.UNSIGNED_SHORT,0),t.obj?this._bindNativeVAO(null):this._unbindBuffers()}releaseVAO(t){t.obj&&this._deleteNativeVAO(t.obj),this._deleteBuffer(t.buffers.indicies),this._deleteBuffer(t.buffers.position),this._deleteBuffer(t.buffers.uv)}getUniformLocations(t,e){const i=this._gl,s=Object.keys(e).reduce(((e,s)=>(e[s]=i.getUniformLocation(t,s),e)),{});return Object.assign(Object.assign({},this._getCommonUniformLocations(t)),s)}updateCommonUniforms(t,e,i){const s=this._gl,n=i.uniformLocations,r=t.matrix,o=c();u(o,e.viewMatrix,r),s.uniformMatrix4fv(n.uMVMatrix,!1,o),s.uniformMatrix4fv(n.uPMatrix,!1,e.projectionMatrix)}updateVRUniforms(t,e,i,s){const n=this._gl,r=t.uniformLocations;n.uniformMatrix4fv(r.uMVMatrix,!1,e),n.uniformMatrix4fv(r.uPMatrix,!1,i),r.uEye&&n.uniform1f(r.uEye,s)}updateUniforms(t){const e=this._gl,i=t.uniforms,s=t.uniformLocations;for(const t in i){const n=i[t],r=s[t];n&&(n.needsUpdate&&n.update(e,r,this._isWebGL2))}}releaseShaderResources(t){const e=this._gl,i=t.uniforms;for(const t in i){const s=i[t];s&&(s.needsUpdate&&s.destroy(e))}e.deleteProgram(t.program)}useProgram(t){this._gl.useProgram(t.program)}createProgram(t,e){const i=this._gl,s=i.createProgram(),n=this._compileShader(i.VERTEX_SHADER,t),r=this._compileShader(i.FRAGMENT_SHADER,e);if(i.attachShader(s,n),i.attachShader(s,r),i.bindAttribLocation(s,0,"position"),i.bindAttribLocation(s,1,"uv"),i.linkProgram(s),this._debug&&!i.getProgramParameter(s,i.LINK_STATUS)){let t=null;throw i.getShaderParameter(n,i.COMPILE_STATUS)?i.getShaderParameter(r,i.COMPILE_STATUS)||(t=i.getShaderInfoLog(r)):t=i.getShaderInfoLog(n),new D(F.FAILED_LINKING_PROGRAM(i.getProgramInfoLog(s),t),B.FAILED_LINKING_PROGRAM)}return i.deleteShader(n),i.deleteShader(r),s}createWebGLTexture(t){const e=this._gl,i=e.createTexture();if(e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,t.wrapS),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,t.wrapT),!t.isVideo()&&this._isWebGL2){const i=e;i.texStorage2D(i.TEXTURE_2D,1,i.RGBA8,t.width,t.height)}return i}createWebGLCubeTexture(t,e){const i=this._gl,s=i.createTexture();if(i.bindTexture(i.TEXTURE_CUBE_MAP,s),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,t.wrapS),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,t.wrapT),this._isWebGL2){const t=i;t.texStorage2D(t.TEXTURE_CUBE_MAP,1,t.RGBA8,e,e)}return s}makeXRCompatible(){return t(this,void 0,void 0,(function*(){const t=this._gl,e=t.getContextAttributes();e&&!0!==e.xrCompatible&&(yield t.makeXRCompatible())}))}bindXRLayer(t){const e=this._gl,i=new XRWebGLLayer(t,e);t.updateRenderState({baseLayer:i})}bindXRFrame(t){const e=this._gl,i=t.session.renderState.baseLayer;e.bindFramebuffer(e.FRAMEBUFFER,i.framebuffer)}useDefaultFrameBuffer(){const t=this._gl;t.bindFramebuffer(t.FRAMEBUFFER,null)}_createBuffer(){return this._gl.createBuffer()}_deleteBuffer(t){return this._gl.deleteBuffer(t)}_createNativeVAO(){const t=this._gl;if(this._isWebGL2)return t.createVertexArray();{const t=this._extensions.vao;return(null==t?void 0:t.createVertexArrayOES())||null}}_bindNativeVAO(t){const e=this._gl;if(this._isWebGL2)e.bindVertexArray(t);else{const e=this._extensions.vao;null==e||e.bindVertexArrayOES(t)}}_deleteNativeVAO(t){const e=this._gl;if(this._isWebGL2)e.deleteVertexArray(t);else{const e=this._extensions.vao;null==e||e.deleteVertexArrayOES(t)}}_supplyGeometryData(t,e){const i=t.geometry;this._supplyIndiciesData(i.indicies,t.buffers.indicies),this._supplyAttributeData(i.vertices,e.program,"position",t.buffers.position),this._supplyAttributeData(i.uvs,e.program,"uv",t.buffers.uv)}_unbindBuffers(){const t=this._gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),t.bindBuffer(t.ARRAY_BUFFER,null)}_supplyIndiciesData(t,e){const i=this._gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.data,i.STATIC_DRAW)}_supplyAttributeData(t,e,i,s){const n=this._gl,r=n.getAttribLocation(e,i);r<0||(n.bindBuffer(n.ARRAY_BUFFER,s),n.bufferData(n.ARRAY_BUFFER,t.data,n.STATIC_DRAW),n.vertexAttribPointer(r,t.itemSize,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r))}_compileShader(t,e){const i=this._gl,s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}_getCommonUniformLocations(t){const e=this._gl;return{uMVMatrix:e.getUniformLocation(t,"uMVMatrix"),uPMatrix:e.getUniformLocation(t,"uPMatrix")}}_getContext(t){const e=["webgl2","webgl","experimental-webgl","webkit-3d","moz-webgl"];let i=null,s=!1;const n={preserveDrawingBuffer:!1,antialias:!1},r=t=>t.statusMessage;t.addEventListener(Q,r);for(const r of e){try{i=t.getContext(r,n),s="webgl2"===r}catch(t){}if(i)break}if(t.removeEventListener(Q,r),!i)throw new D(F.WEBGL_NOT_SUPPORTED,B.WEBGL_NOT_SUPPORTED);return{gl:i,isWebGL2:s}}}class _i{get canvas(){return this._canvas}get width(){return this._elementSize.x}get height(){return this._elementSize.y}get pixelRatio(){return this._pixelRatio}get aspect(){return this._elementSize.x/this._elementSize.y}constructor(t,e){this._canvas=t,this._elementSize={x:0,y:0},this._pixelRatio=1,this.ctx=new ui(t,e)}destroy(){const t=this._canvas;this.ctx.destroy(),t.width=1,t.height=1}resize(){const t=this._canvas,e=this._elementSize,i=window.devicePixelRatio;e.x=t.clientWidth,e.y=t.clientHeight,t.width=e.x*i,t.height=e.y*i,this._pixelRatio=i,this.ctx.resize()}render(t,e){const i=this.ctx;i.lost||(i.clear(),i.useProgram(t.program),i.updateCommonUniforms(t,e,t.program),t.update({camera:e}),i.updateUniforms(t.program),i.draw(t.vao,t.program))}renderVR(t,e,i){const s=this.ctx,n=e.getEyeParams(i);n&&t&&(s.bindXRFrame(i),s.useProgram(t.program),s.updateUniforms(t.program),n.forEach(((e,i)=>{const n=e.viewport,r=u(c(),e.vMatrix,t.matrix);s.viewport(n.x,n.y,n.width,n.height),s.updateVRUniforms(t.program,r,e.pMatrix,i),s.draw(t.vao,t.program)})))}}class di extends o{get rootEl(){return this._rootEl}get renderer(){return this._renderer}get camera(){return this._camera}get control(){return this._control}get vr(){return this._vr}get hotspot(){return this._hotspot}get plugins(){return this._plugins}get projection(){return this._projection}set projection(t){this._initialized&&t?this.load(t):this._projection=t}get mesh(){return this._mesh}get initialized(){return this._initialized}get autoplay(){return this._autoplay}get autoInit(){return this._autoInit}get autoResize(){return this._autoResize}get canvasSelector(){return this._canvasSelector}get useResizeObserver(){return this._useResizeObserver}get tabIndex(){return this._tabIndex}set tabIndex(t){const e=this._renderer.canvas;this._tabIndex=t,null!=t?e.tabIndex=t:e.removeAttribute("tabindex")}get maxDeltaTime(){return this._animator.maxDeltaTime}set maxDeltaTime(t){this._animator.maxDeltaTime=t}get debug(){return this._debug}set debug(t){this._debug=t}get initialYaw(){return this._camera.initialYaw}set initialYaw(t){this._camera.initialYaw=t}get initialPitch(){return this._camera.initialPitch}set initialPitch(t){this._camera.initialPitch=t}get initialZoom(){return this._camera.initialZoom}set initialZoom(t){this._camera.initialZoom=t}get yawRange(){return this._camera.yawRange}set yawRange(t){this._camera.yawRange=t,this._projection&&this._projection.updateCamera(this._camera)}get pitchRange(){return this._camera.pitchRange}set pitchRange(t){this._camera.pitchRange=t,this._projection&&this._projection.updateCamera(this._camera)}get zoomRange(){return this._camera.zoomRange}set zoomRange(t){this._camera.zoomRange=t,this._projection&&this._projection.updateCamera(this._camera)}get fov(){return this._camera.fov}set fov(t){const e=this._camera,i=this._control;e.fov=t,e.updateMatrix(),i.sync()}get rotate(){return this._control.rotate}get zoom(){return this._control.zoom}get gyro(){return this._control.gyro}get useGrabCursor(){return this._control.useGrabCursor}set useGrabCursor(t){this._control.useGrabCursor=t}get disableContextMenu(){return this._control.disableContextMenu}set disableContextMenu(t){this._control.disableContextMenu=t}get scrollable(){return this._control.scrollable}set scrollable(t){this._control.scrollable=t}get wheelScrollable(){return this._control.wheelScrollable}set wheelScrollable(t){this._control.wheelScrollable=t}constructor(t,{projection:e=null,initialYaw:i=0,initialPitch:s=0,initialZoom:n=1,yawRange:r=null,pitchRange:o=null,zoomRange:a=null,fov:h=90,useGrabCursor:l=!0,disableContextMenu:c=!1,rotate:u=!0,zoom:_=!0,gyro:d=!1,scrollable:m=!0,wheelScrollable:p=!1,autoplay:g=!1,hotspot:v={},autoInit:E=!0,autoResize:f=!0,canvasSelector:b="canvas",useResizeObserver:y=!0,on:T={},plugins:R=[],maxDeltaTime:w=1/30,tabIndex:C=0,debug:L=!1}={}){super(),this.renderFrame=t=>{const e=this._camera,i=this._renderer,s=this._control,n=this._hotspot,r=this._autoplay,o=this._mesh;o&&(this._emit(Ot.BEFORE_RENDER),r.playing&&(r.update(t),s.sync()),e.animation?e.animation.update(t):s.update(t),i.render(o,e),n.render(e),e.changed&&this._emit(Ot.VIEW_CHANGE,{yaw:e.yaw,pitch:e.pitch,zoom:e.zoom,quaternion:[e.quaternion[0],e.quaternion[1],e.quaternion[2],e.quaternion[3]]}),e.onFrameRender(),this._emit(Ot.RENDER))},this._renderFrameOnDemand=t=>{const e=this._camera,i=this._control,s=this._autoplay,n=this._mesh,r=null==n?void 0:n.getTexture();this._initialized&&r&&(e.animation||i.animating||s.playing||r.isVideo())&&this.renderFrame(t)},this._renderVRFrame=(t,e)=>{const i=this._vr,s=this._mesh,n=this._renderer;s&&(this._emit(Ot.BEFORE_RENDER),n.renderVR(s,i,e),this._emit(Ot.RENDER))},this._rootEl=((t,e)=>{const i=te(t,e);if(!i)throw Jt(t)?new D(F.ELEMENT_NOT_FOUND(t),B.ELEMENT_NOT_FOUND):new D(F.WRONG_TYPE(t,["HTMLElement","string"]),B.WRONG_TYPE);return i})(t),this._plugins=R,this._initialized=!1,this._autoInit=E,this._autoResize=f,this._canvasSelector=b,this._useResizeObserver=y,this._tabIndex=C,this._debug=L;const x=((t,e)=>{const i=t.querySelector(e);if(!i)throw new D(F.CANVAS_NOT_FOUND,B.CANVAS_NOT_FOUND);return i})(this._rootEl,b);this._renderer=new _i(x,L),this._camera=new me({initialYaw:i,initialPitch:s,initialZoom:n,fov:h,yawRange:r,pitchRange:o,zoomRange:a}),this._control=new Ce(x,this._camera,{useGrabCursor:l,scrollable:m,wheelScrollable:p,disableContextMenu:c,rotate:u,zoom:_,gyro:d}),this._animator=new ni(w),this._autoplay=new oi(this,x,g),this._projection=e,this._mesh=null,this._autoResizer=new ri(y,(()=>this.resize())),this._vr=new ai(this._renderer.ctx),this._hotspot=new li(this._rootEl,this._renderer,v),this._addEventHandlers(T),e&&E&&this.init()}destroy(){this._camera.destroy(),this._animator.stop(),this._renderer.destroy(),this._control.destroy(),this._autoResizer.disable(),this._mesh&&(this._mesh.destroy(this._renderer.ctx),this._mesh=null),this._plugins.forEach((t=>t.destroy(this))),this._initialized=!1}init(){return t(this,void 0,void 0,(function*(){if(!this._projection)throw new D(F.PROVIDE_PROJECTION_FIRST,B.PROVIDE_PROJECTION_FIRST);const t=this._renderer,e=this._camera,i=this._control,s=this._animator,n=this._hotspot,r=this._projection,o=t.canvas;this._bindComponentEvents(),t.ctx.init(),this._resizeComponents(),e.updateMatrix(),this._autoResize&&this._autoResizer.enable(o),this._autoplay.enableBlocked||this._autoplay.enable(),this._plugins.forEach((t=>{t.init(this)}));const a=yield this._loadTexture(r);this._applyProjection(r,a),n.refresh(),s.start(this._renderFrameOnDemand),yield i.enable(),null==this._tabIndex||o.hasAttribute("tabIndex")||(o.tabIndex=this._tabIndex),this._initialized=!0,this.renderFrame(0),this._emit(Ot.READY)}))}load(e){return t(this,void 0,void 0,(function*(){if(!e)return!1;if(this._initialized){const t=yield this._loadTexture(e);this._applyProjection(e,t),this.renderFrame(0)}else this._projection=e,this.init();return!0}))}resize(){if(!this._initialized)return;this._resizeComponents(),this.renderFrame(0);const{width:t,height:e}=this._renderer;this._emit(Ot.RESIZE,{width:t,height:e})}addPlugins(...t){this._initialized&&t.forEach((t=>{t.init(this)})),this._plugins.push(...t)}removePlugins(...t){t.forEach((t=>{const e=this._plugins.indexOf(t);e<0||(t.destroy(this),this._plugins.splice(e,1))}))}_emit(t,...e){const i=e?e[0]:{};this.trigger(t,Object.assign({type:t,target:this},i))}_applyProjection(t,e){const i=this._camera,s=this._control,n=this._renderer,r=this._mesh;r&&r.destroy(n.ctx);const o=t.createMesh(n.ctx,e);t.updateCamera(i),t.updateControl(s),this._mesh=o,this._emit(Ot.PROJECTION_CHANGE,{projection:t})}_loadTexture(e){return t(this,void 0,void 0,(function*(){const t=new si,{src:i,video:s}=e;this._emit(Ot.LOAD_START,{src:i,video:s});const n=yield t.load(i,s);return this._emit(Ot.LOAD,{src:i,video:s}),n}))}_resizeComponents(){const t=this._renderer,e=this._camera,i=this._control;t.resize(),e.resize(t.width,t.height),i.resize(t.width,t.height)}_addEventHandlers(t){Object.keys(t).forEach((e=>{this.on(e,t[e])}))}_bindComponentEvents(){const t=this._rootEl,e=this._control,i=this._animator,s=this._renderer,n=this._vr;[Ft,Mt,Dt].forEach((t=>{e.rotate.on(t,(e=>{this._emit(t,e)})),e.zoom.on(t,(e=>{this._emit(t,e)}))})),n.on(Ot.VR_START,(e=>{t.classList.add(xt.IN_VR),i.changeContext(e.session),i.start(this._renderVRFrame),this._emit(Ot.VR_START)})),n.on(Ot.VR_END,(()=>{t.classList.remove(xt.IN_VR),s.ctx.useDefaultFrameBuffer(),i.changeContext(window),i.start(this._renderFrameOnDemand),this.resize(),this._emit(Ot.VR_END)}))}}di.VERSION="4.0.0-beta.7";class mi extends o{constructor(){super(),this.matrix=c(),this.rotation=y(),this.position=p(0,0,0),this.scale=p(1,1,1)}updateMatrix(){!function(t,e,i,s){var n=e[0],r=e[1],o=e[2],a=e[3],h=n+n,l=r+r,c=o+o,u=n*h,_=n*l,d=n*c,m=r*l,p=r*c,g=o*c,v=a*h,E=a*l,f=a*c,b=s[0],y=s[1],T=s[2];t[0]=(1-(m+g))*b,t[1]=(_+f)*b,t[2]=(d-E)*b,t[3]=0,t[4]=(_-f)*y,t[5]=(1-(u+g))*y,t[6]=(p+v)*y,t[7]=0,t[8]=(d+E)*T,t[9]=(p-v)*T,t[10]=(1-(u+m))*T,t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1}(this.matrix,this.rotation,this.position,this.scale)}update(t){this.trigger(Pt,t)}}class pi{constructor({className:t={}}={}){this._startLoading=({target:t})=>{t.rootEl.appendChild(this._container),t.initialized?t.once(Ot.LOAD,this._detachElements):t.once(Ot.READY,this._detachElements)},this._detachElements=({target:t})=>{const e=this._container;e&&e.parentElement===t.rootEl&&t.rootEl.removeChild(e)},this.className=t,this._container=this._createElements()}init(t){t.on(Ot.LOAD_START,this._startLoading)}destroy(t){t.off(Ot.LOAD_START,this._startLoading),this._detachElements({target:t})}_createElements(){const t=Object.assign(Object.assign({},this.className),pi.DEFAULT_CLASS),e=Qt(t.CONTAINER),i=Qt(t.RING);return e.appendChild(i),e}}pi.DEFAULT_CLASS={CONTAINER:"view360-spinner",RING:"view360-spinner-ring"};class gi{constructor(t){this.position=t.position,this.order=t.order}}const vi={CONTROLS_ROOT:"view360-controls",CONTROLS_BG:"view360-controls-background",CONTROLS_MAIN:"view360-controls-main",CONTROLS_TOP:"view360-controls-top",CONTROLS_BOTTOM:"view360-controls-bottom",CONTROLS_MID:"view360-controls-mid",CONTROLS_LEFT:"view360-controls-left",CONTROLS_RIGHT:"view360-controls-right",CONTROLS_FLOAT_LEFT:"view360-controls-float-left",CONTROLS_FLOAT_RIGHT:"view360-controls-float-right",CONTROLS_BUTTON:"view360-controls-button",PROGRESS_ROOT:"view360-controls-progress",VOLUME_ROOT:"view360-controls-volume",RANGE_ROOT:"view360-range",RANGE_TRACK:"view360-range-track",RANGE_THUMB:"view360-range-thumb",RANGE_FILLER:"view360-range-filler",PLAY_BUTTON:"view360-controls-play",PAUSE_BUTTON:"view360-controls-pause",UNMUTED_BUTTON:"view360-controls-unmuted",MUTED_BUTTON:"view360-controls-muted",FULLSCREEN_BUTTON:"view360-controls-fullscreen",FULLSCREEN_EXIT_BUTTON:"view360-controls-fullscreen-exit",VR_BUTTON:"view360-controls-vr",GYRO_ENABLED:"view360-controls-gyro-enabled",GYRO_DISABLED:"view360-controls-gyro-disabled",VIDEO_TIME_DISPLAY:"view360-controls-time",PIEVIEW_ROOT:"view360-controls-pie",FIXED:"view360-controls-fixed",UNAVAILABLE:"view360-controls-unavailable",HIDDEN:"view360-controls-hidden"},Ei={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",MAIN_TOP:"main-top",MAIN_BOTTOM:"main-bottom",MAIN_LEFT:"main-left",MAIN_RIGHT:"main-right"};class fi extends o{constructor(){super(),this._onHold=({srcEvent:t,isTouch:e})=>{var i;const s=this._bbox;if(!s)return;const n=e?t.touches[0].pageX:t.pageX,r=s.x+(null!==(i=window.scrollX)&&void 0!==i?i:window.pageXOffset),o=ee(n,r,r+s.width),a=(o-r)/s.width;this._motion.reset(o),this.thumbEl.classList.add(this._fixedClass),this.trigger(Mt,a)},this._onChange=({delta:t})=>{var e;const i=this._motion,s=this._bbox;if(!s)return;i.setNewEndByDelta(t.x),i.update(1);const n=s.x+(null!==(e=window.scrollX)&&void 0!==e?e:window.pageXOffset),r=(ee(i.val,n,n+s.width)-n)/s.width;this.trigger(Nt,r)},this._onRelease=()=>{this._bbox&&(this.thumbEl.classList.remove(this._fixedClass),this.trigger(Dt))};const t=document.createElement(mt),e=document.createElement(mt),i=document.createElement(mt),s=document.createElement(mt);t.draggable=!1,e.appendChild(s),e.appendChild(i),t.appendChild(e),this.rootEl=t,this.trackEl=e,this.thumbEl=i,this.fillerEl=s,this._mouseInput=new pe,this._touchInput=new ge,this._motion=new _e({duration:1,range:Ht,easing:t=>t}),this._bbox={x:0,y:0,width:0,height:0,left:0,right:0,bottom:0,top:0},this._fixedClass=vi.FIXED}init(t){const e=this._mouseInput,i=this._touchInput;this.rootEl.classList.add(t.RANGE_ROOT),this.trackEl.classList.add(t.RANGE_TRACK),this.thumbEl.classList.add(t.RANGE_THUMB),this.fillerEl.classList.add(t.RANGE_FILLER),this._fixedClass=t.FIXED,e.on(Mt,this._onHold),i.on(Mt,this._onHold),e.on(Dt,this._onRelease),i.on(Dt,this._onRelease),e.on(Nt,this._onChange),i.on(Nt,this._onChange),e.enable(this.rootEl),i.enable(this.rootEl),this.resize()}destroy(){const t=this._mouseInput,e=this._touchInput;this.rootEl.className="",this.trackEl.className="",this.thumbEl.className="",this.fillerEl.className="",t.off(),e.off(),t.disable(),e.disable()}resize(){this._bbox=this.trackEl.getBoundingClientRect()}updateStyle(t){const e=this._bbox.width,i=ee(t,0,1);this.fillerEl.style.width=100*i+"%",this.thumbEl.style.transform=`translateX(${i*e}px)`}}class bi extends gi{get element(){return this._rangeControl.rootEl}constructor({position:t=Ei.MAIN_TOP,order:e=9999}={}){super({position:t,order:e}),this._onResize=()=>{this._rangeControl.resize()},this._onTimeUpdate=()=>{const t=this._video;t&&(this._currentTime=t.source.currentTime,this._rangeControl.updateStyle(this._currentTime/this._duration))},this._onDurationChange=()=>{const t=this._video;t&&(this._duration=t.source.duration,this._rangeControl.updateStyle(this._currentTime/this._duration))},this._onHold=t=>{const e=this._video,i=this._controlBar;if(!e||!i)return;const s=e.isPaused();e.source.pause();const n=e.source.duration*t;e.source.currentTime=n,e.source.dispatchEvent(new CustomEvent(jt,{detail:{time:n}})),i.rootEl.classList.add(i.className.FIXED),this._wasPaused=!this._playPromise&&s},this._onControl=t=>{const e=this._video;if(!e)return;const i=e.source.duration*t;e.source.currentTime=i,e.source.dispatchEvent(new CustomEvent(jt,{detail:{time:i}}))},this._onRelease=()=>{const t=this._video,e=this._controlBar;t&&e&&(this._wasPaused||this._playPromise||(this._playPromise=t.source.play().catch((()=>{})),this._playPromise.then((()=>{this._playPromise=null})),e.rootEl.classList.remove(e.className.FIXED))),this._wasPaused=!1},this.position=t,this.order=e,this._controlBar=null,this._rangeControl=new fi,this._video=null,this._wasPaused=!1,this._currentTime=0,this._duration=0,this._playPromise=null}init(t,e){var i;const s=null===(i=t.mesh)||void 0===i?void 0:i.getTexture(),n=this.element,r=this._rangeControl,o=e.className.UNAVAILABLE;s&&s.isVideo()?(n.classList.remove(o),n.classList.add(e.className.PROGRESS_ROOT),t.on(Ot.RESIZE,this._onResize),s.source.addEventListener(lt,this._onTimeUpdate),s.source.addEventListener(ct,this._onDurationChange),s.source.addEventListener(jt,this._onTimeUpdate),r.init(e.className),r.on(Mt,this._onHold),r.on(Nt,this._onControl),r.on(Dt,this._onRelease),this._video=s,this._currentTime=s.source.currentTime,this._duration=s.source.duration,this._controlBar=e,r.updateStyle(this._currentTime/this._duration)):n.classList.add(o)}destroy(t){const e=this._video;t.off(Ot.RESIZE,this._onResize),e&&(e.source.removeEventListener(lt,this._onTimeUpdate),e.source.removeEventListener(ct,this._onDurationChange),e.source.removeEventListener(jt,this._onTimeUpdate)),this._rangeControl.destroy(),this._video=null,this._playPromise=null}}class yi extends gi{constructor({position:t=Ei.MAIN_LEFT,order:e=9999}={}){super({position:t,order:e}),this._onClick=()=>{const t=this._video;t&&(this._paused?t.source.play():t.source.pause())},this._onPlay=()=>{if(!this._controlBar)return;const t=this.element,e=this._controlBar.className;t.classList.add(e.PAUSE_BUTTON),t.classList.remove(e.PLAY_BUTTON),t.title="Pause Video",this._paused=!1},this._onPause=()=>{if(!this._controlBar)return;const t=this.element,e=this._controlBar.className;t.classList.add(e.PLAY_BUTTON),t.classList.remove(e.PAUSE_BUTTON),t.title="Play Video",this._paused=!0},this.element=document.createElement(pt),this._video=null,this._paused=!0,this._controlBar=null}init(t,e){var i;const s=this.element,n=null===(i=t.mesh)||void 0===i?void 0:i.getTexture(),r=e.className,o=r.UNAVAILABLE;if(!n||!n.isVideo())return void s.classList.add(o);s.classList.add(r.CONTROLS_BUTTON),s.classList.remove(o);const a=n.isPaused();this._video=n,this._paused=a,this._controlBar=e,a?this._onPause():this._onPlay(),s.addEventListener(J,this._onClick),n.source.addEventListener(rt,this._onPlay),n.source.addEventListener(ot,this._onPause)}destroy(){const t=this._video,e=this.element;t&&(e.className="",e.removeEventListener(J,this._onClick),t.source.removeEventListener(rt,this._onPlay),t.source.removeEventListener(ot,this._onPause),this._video=null,this._paused=!0,this._controlBar=null)}}class Ti extends gi{get element(){return this._rootEl}constructor({position:t=Ei.MAIN_RIGHT,order:e=9999}={}){super({position:t,order:e}),this._onResize=()=>{this._rangeControl.resize(),this._updateDisplay()},this._onClick=()=>{const t=this._video;t&&!this._rootEl.disabled&&(t.source.muted=!t.source.muted)},this._onVolumeChange=()=>{const t=this._buttonEl,e=this._video,i=this._controlBar;if(!e||!i)return;const s=i.className;e.source.muted||0===e.source.volume?(t.classList.add(s.MUTED_BUTTON),t.classList.remove(s.UNMUTED_BUTTON)):(t.classList.add(s.UNMUTED_BUTTON),t.classList.remove(s.MUTED_BUTTON)),this._updateDisplay()},this._onHold=t=>{const e=this._video,i=this._controlBar;if(!e||!i)return;const s=i.className;e.source.volume=t,this._rootEl.classList.add(s.FIXED),i.containerEl.classList.add(s.FIXED),this._updateDisplay()},this._onChange=t=>{const e=this._video;e&&(e.source.volume=t,e.source.muted=!(t>0),this._updateDisplay())},this._onRelease=()=>{const t=this._controlBar;if(!t)return;const e=t.className;this._rootEl.classList.remove(e.FIXED),t.containerEl.classList.remove(e.FIXED)},this._updateDisplay=()=>{const t=this._video,e=this._rootEl;if(!t)return;if(!t.hasAudio())return void(e.disabled=!0);e.disabled=!1;const i=t.source.muted?0:t.source.volume;this._rangeControl.updateStyle(i)},this._controlBar=null,this._rangeControl=new fi,this._createElements(),this._video=null}init(t,e){var i;const s=null===(i=t.mesh)||void 0===i?void 0:i.getTexture(),n=this._rootEl,r=this._buttonEl,o=this._rangeControl,a=e.className,h=a.UNAVAILABLE;s&&s.isVideo()?(n.classList.remove(h),n.classList.add(a.CONTROLS_BUTTON),n.classList.add(a.VOLUME_ROOT),r.classList.add(a.CONTROLS_BUTTON),s.source.muted?r.classList.add(a.MUTED_BUTTON):r.classList.add(a.UNMUTED_BUTTON),t.on(Ot.RESIZE,this._onResize),n.addEventListener(_t,this._onResize),r.addEventListener(J,this._onClick),s.source.addEventListener(ht,this._onVolumeChange),s.source.addEventListener(at,this._updateDisplay),s.source.addEventListener(ut,this._updateDisplay),o.init(a),o.on(Mt,this._onHold),o.on(Nt,this._onChange),o.on(Dt,this._onRelease),this._controlBar=e,this._video=s,this._updateDisplay()):n.classList.add(h)}destroy(t){const e=this._video,i=this._buttonEl,s=this._rootEl;s.className="",i.className="",t.off(Ot.RESIZE,this._onResize),s.removeEventListener(_t,this._onResize),i.removeEventListener(J,this._onClick),e&&(e.source.removeEventListener(ht,this._onVolumeChange),e.source.removeEventListener(at,this._updateDisplay),e.source.removeEventListener(ut,this._updateDisplay)),this._controlBar=null,this._rangeControl.destroy(),this._video=null}_createElements(){const t=document.createElement(pt),e=document.createElement(mt);t.appendChild(this._rangeControl.rootEl),t.appendChild(e),t.title="Toggle Mute",this._rootEl=t,this._buttonEl=e}}class Ri extends gi{constructor({position:t=Ei.MAIN_RIGHT,order:e=9999}={}){super({position:t,order:e}),this._onClick=()=>{const t=this._targetEl;t&&(he()?this._exitFullscreen():this._requestFullscreen(t))},this._onFullscreenChange=()=>{const t=this.element,e=this._controlBar;if(!e)return;const i=e.className;he()?(t.classList.add(i.FULLSCREEN_EXIT_BUTTON),t.classList.remove(i.FULLSCREEN_BUTTON)):(t.classList.add(i.FULLSCREEN_BUTTON),t.classList.remove(i.FULLSCREEN_EXIT_BUTTON))},this.element=document.createElement(pt),this.element.title="Toggle Fullscreen",this._controlBar=null,this._targetEl=null}init(t,e){const i=this.element,s=e.className;this._fullscreenAvailable()?(i.classList.add(s.CONTROLS_BUTTON),i.classList.remove(s.UNAVAILABLE),i.addEventListener(J,this._onClick),this._addFullscreenHandlers(),he()?i.classList.add(s.FULLSCREEN_EXIT_BUTTON):i.classList.add(s.FULLSCREEN_BUTTON),this._controlBar=e,this._targetEl=t.rootEl):i.classList.add(s.UNAVAILABLE)}destroy(){const t=this.element;t.className="",t.removeEventListener(J,this._onClick),this._removeFullscreenHandlers(),this._controlBar=null,this._targetEl=null}_fullscreenAvailable(){return Rt.some((t=>!!document[t]))}_requestFullscreen(t){for(const e of Rt){const i=t[e];if(i)return void i.call(t)}}_exitFullscreen(){for(const t of Ct){const e=document[t];if(e)return void e.call(document)}}_addFullscreenHandlers(){Lt.forEach((t=>{document.addEventListener(t,this._onFullscreenChange)}))}_removeFullscreenHandlers(){Lt.forEach((t=>{document.removeEventListener(t,this._onFullscreenChange)}))}}class wi extends gi{constructor({position:t=Ei.MAIN_LEFT,order:e=9999}={}){super({position:t,order:e}),this._onTimeUpdate=()=>{const t=this._video;t&&(this._currentTime=t.source.currentTime,this._updateDisplay())},this._onDurationChange=()=>{const t=this._video;t&&(this._duration=t.source.duration,this._updateDisplay())},this._onCustomTimeChange=t=>{this._currentTime=t.detail.time,this._updateDisplay()},this.element=document.createElement(mt),this._video=null,this._currentTime=0,this._duration=0}init(t,e){var i;const s=null===(i=t.mesh)||void 0===i?void 0:i.getTexture(),n=this.element,r=e.className;s&&s.isVideo()?(n.classList.add(r.VIDEO_TIME_DISPLAY),n.classList.remove(r.UNAVAILABLE),s.source.addEventListener(lt,this._onTimeUpdate),s.source.addEventListener(ct,this._onDurationChange),s.source.addEventListener(jt,this._onCustomTimeChange),this._video=s,this._currentTime=s.source.currentTime,this._duration=s.source.duration,this._updateDisplay()):n.classList.add(r.UNAVAILABLE)}destroy(){const t=this._video;t&&(this.element.className="",t.source.removeEventListener(lt,this._onTimeUpdate),t.source.removeEventListener(ct,this._onDurationChange),t.source.removeEventListener(jt,this._onCustomTimeChange),this._video=null)}_updateDisplay(){const t=this._currentTime,e=Math.floor(t/60),i=Math.floor(t-60*e),s=i<10?`0${i}`:i,n=this._duration,r=Math.floor(n/60),o=Math.floor(n-60*r),a=o<10?`0${o}`:o;this.element.innerText=`${e}:${s} / ${r}:${a}`}}class Ci extends gi{constructor({resetCamera:t=!0,position:e=Ei.TOP_RIGHT,order:i=9999}={}){super({position:e,order:i}),this._onClick=()=>{const t=this._viewer,e=this.resetCamera;if(!t||!e)return;const{yaw:i=t.initialYaw,pitch:s=t.initialPitch,zoom:n=t.initialZoom,duration:r=500}=re(e);t.camera.animateTo({yaw:i,pitch:s,zoom:n,duration:r})},this._updatePie=({target:t})=>{const e=this._piePathEl,i=this._rangeCircleEl,s=t.camera,n=s.getHorizontalFov(),r=s.getYawRange(s.zoom),o=.5*n,a=24*Math.PI,h=a*n/360,l=a*(s.yaw+o+90)/360;if(e.setAttribute("stroke-dasharray",`${h} ${a-h}`),e.setAttribute("stroke-dashoffset",`${l}`),isFinite(r.min)&&isFinite(r.max)){const t=45*Math.PI,e=(se(r.min,-180,180)-o)/360,s=(se(r.max,-180,180)+o)/360,n=t*Math.abs(s-e),a=-t*(e-.25);i.setAttribute("stroke-dasharray",`${n} ${t-n}`),i.setAttribute("stroke-dashoffset",`${a}`)}else i.setAttribute("stroke-dasharray",""),i.setAttribute("stroke-dashoffset","")},this.element=document.createElement(mt),this.element.title="Reset view",this.resetCamera=t,this._createPieElements(),this._viewer=null}init(t,e){const i=this.element;t.initialized?this._updatePie({target:t}):t.once(Ot.READY,this._updatePie);const s=e.className.PIEVIEW_ROOT;i.classList.add(s),this.resetCamera&&i.addEventListener(J,this._onClick),t.on(Ot.VIEW_CHANGE,this._updatePie),this._viewer=t}destroy(t){const e=this.element;e.removeEventListener(J,this._onClick),e.className="",t.off(Ot.READY,this._updatePie),t.off(Ot.VIEW_CHANGE,this._updatePie),this._viewer=null}_createPieElements(){const t=this.element,e=document.createElementNS(Kt,"svg");e.setAttribute("viewBox","0 0 48 48"),e.setAttribute("width","100%"),e.setAttribute("height","100%");const i=document.createElementNS(Kt,"circle");i.setAttribute("stroke","currentColor"),i.setAttribute("fill","transparent"),i.setAttribute("cx","24"),i.setAttribute("cy","24"),i.setAttribute("r","12"),i.setAttribute("stroke-width","24"),e.appendChild(i);const s=document.createElementNS(Kt,"circle");s.setAttribute("stroke","currentColor"),s.setAttribute("fill","transparent"),s.setAttribute("cx","24"),s.setAttribute("cy","24"),s.setAttribute("r","22.5"),s.setAttribute("stroke-width","3"),e.appendChild(s),t.appendChild(e),this._piePathEl=i,this._rangeCircleEl=s}}class Li extends gi{constructor({position:t=Ei.MAIN_RIGHT,order:e=9999}={}){super({position:t,order:e}),this._onClick=()=>{const t=this._viewer;t&&t.vr.enter()},this.element=document.createElement(pt),this.element.title="Enter VR",this._viewer=null}init(t,e){const i=this.element,s=e.className;i.classList.add(s.UNAVAILABLE),i.classList.add(s.VR_BUTTON),i.classList.add(s.CONTROLS_BUTTON),t.vr.isAvailable().then((t=>{t&&i.classList.remove(s.UNAVAILABLE)})),i.addEventListener(J,this._onClick),this._viewer=t}destroy(){const t=this.element;t.className="",t.removeEventListener(J,this._onClick),this._viewer=null}}class xi extends gi{constructor({position:t=Ei.MAIN_RIGHT,order:e=9999}={}){super({position:t,order:e}),this._onClick=()=>{const t=this._viewer,e=this._controlBar;if(!t||!e)return;const i=t.control.gyro;i.enabled?i.disable():we.requestSensorPermission().then((t=>{t?i.enable():this.element.classList.add(e.className.UNAVAILABLE)}))},this._updateStyle=()=>{const t=this.element,e=this._viewer,i=this._controlBar;if(!e||!i)return;const s=e.control.gyro,n=i.className;s.enabled?(t.classList.add(n.GYRO_ENABLED),t.classList.remove(n.GYRO_DISABLED)):(t.classList.add(n.GYRO_DISABLED),t.classList.remove(n.GYRO_ENABLED))},this.element=document.createElement(mt),this.element.title="Toggle gyroscope control"}init(t,e){const i=this.element,s=e.className;i.addEventListener(J,this._onClick),i.classList.add(s.CONTROLS_BUTTON),i.classList.add(s.UNAVAILABLE);const n=()=>{i.classList.remove(s.UNAVAILABLE),t.control.gyro.on(Ut,this._updateStyle),t.control.gyro.on(Bt,this._updateStyle)};le()?n():we.isAvailable().then((t=>{t&&n()})),this._controlBar=e,this._viewer=t,this._updateStyle()}destroy(t){const e=this.element;t.control.gyro.off(Ut,this._updateStyle),t.control.gyro.off(Bt,this._updateStyle),e.removeEventListener(J,this._onClick),e.className="",this._controlBar=null,this._viewer=null}}class Oi{get enabled(){return!!this._targetEl}get hidden(){return this._controlBar.containerEl.classList.contains(this._hiddenClass)}get _hiddenClass(){return this._controlBar.className.HIDDEN}get _fixedClass(){return this._controlBar.className.FIXED}constructor(t,{initialDelay:e=3e3,delay:i=0,idleDelay:s=3e3}){this._onMouseEnter=()=>{this._isCursorInside=!0,this.show()},this._onMouseLeave=()=>{this._isCursorInside=!1,this._hideAfterDelay()},this._onMouseMove=()=>{this._isFullscreen&&this.showTemporaliy()},this._onHold=t=>{this._isGrabbing=!0,"mouse"===t.pointerType&&(this._isCursorInside=!0),window.addEventListener(k,this._onRelease),this.show()},this._onRelease=()=>{this._isGrabbing=!1,window.removeEventListener(k,this._onRelease),this._hideAfterDelay()},this._onVideoPlay=()=>{this._targetEl&&this._controlBar.containerEl.classList.remove(this._fixedClass)},this._onVideoPause=()=>{this._targetEl&&this._controlBar.containerEl.classList.add(this._fixedClass)},this._onFullscreenChange=()=>{this._isFullscreen=he(),this._isFullscreen&&this._hideAfterDelay()},this._controlBar=t,this._initialDelay=e,this._delay=i,this._idleDelay=s,this._timer=-1,this._isCursorInside=!1,this._isGrabbing=!1,this._isFullscreen=!1,this._video=null,this._targetEl=null}enable(t){var e;this._targetEl&&this.disable(t);const i=this._initialDelay,s=t.rootEl;this._targetEl=t.rootEl,this._timer=window.setTimeout((()=>{this.hide()}),i),s.addEventListener(z,this._onHold),s.addEventListener(K,this._onMouseEnter),s.addEventListener(V,this._onMouseMove),s.addEventListener(q,this._onMouseLeave),this._addFullscreenHandlers();const n=null===(e=t.mesh)||void 0===e?void 0:e.getTexture();n&&n.isVideo()&&(n.isPaused()&&this._controlBar.containerEl.classList.add(this._fixedClass),n.source.addEventListener(rt,this._onVideoPlay),n.source.addEventListener(ot,this._onVideoPause),this._video=n)}disable(t){if(!this._targetEl)return;const e=this._controlBar,i=t.rootEl,s=this._video;i.removeEventListener(z,this._onHold),window.removeEventListener(k,this._onRelease),i.removeEventListener(K,this._onMouseEnter),i.removeEventListener(V,this._onMouseMove),i.removeEventListener(q,this._onMouseLeave),this._removeFullscreenHandlers(),window.clearTimeout(this._timer),e.containerEl.classList.remove(this._fixedClass),s&&(s.source.removeEventListener(rt,this._onVideoPlay),s.source.removeEventListener(ot,this._onVideoPause)),this._isCursorInside=!1,this._isGrabbing=!1,this._video=null,this._targetEl=null}show(){this._clearHideTimer(),this._controlBar.containerEl.classList.remove(this._hiddenClass)}showTemporaliy(){this.show(),this._hideAfterDelay(this._idleDelay)}hide(){this._clearHideTimer(),this._controlBar.containerEl.classList.add(this._hiddenClass)}_clearHideTimer(){this._timer&&(window.clearTimeout(this._timer),this._timer=-1)}_hideAfterDelay(t=this._delay){this._isGrabbing||!this._isFullscreen&&this._isCursorInside||(this._clearHideTimer(),t<=0?this.hide():this._timer=window.setTimeout((()=>{this.hide()}),t))}_addFullscreenHandlers(){Lt.forEach((t=>{document.addEventListener(t,this._onFullscreenChange)}))}_removeFullscreenHandlers(){Lt.forEach((t=>{document.removeEventListener(t,this._onFullscreenChange)}))}}class Ai{constructor(){this._onKeyDown=t=>{const e=this._video;if(!e)return;t.preventDefault(),t.stopPropagation();const i=e.source,s=null!=t.keyCode?yt[t.keyCode]:Tt[t.key];switch(s){case"LEFT":case"RIGHT":return this._changeVideoTime(i,"RIGHT"===s);case"UP":case"DOWN":return this._changeVideoVolume(i,"UP"===s)}(32===t.keyCode||" "===t.key)&&this._toggleVideo(e)}}enable(t,e){this._video=e,t.addEventListener(Z,this._onKeyDown,!0)}disable(t){this._video=null,t.removeEventListener(Z,this._onKeyDown,!0)}_changeVideoTime(t,e){const i=e?5:-5;t.currentTime+=i,t.dispatchEvent(new CustomEvent(jt,{detail:{time:t.currentTime}}))}_changeVideoVolume(t,e){const i=e?.1:-.1;t.muted?t.volume=ee(i,0,1):t.volume=ee(t.volume+i,0,1),t.volume>0?t.muted=!1:t.muted=!0}_toggleVideo(t){t.isPaused()?t.source.play():t.source.pause()}}class Ii{get rootEl(){return this._rootEl}get containerEl(){return this._containerEl}get backgroundEl(){return this._bgEl}get items(){return this._items}get customItems(){return this._customItems}constructor({autoHide:t,showBackground:e,clickToPlay:i=!0,keyboardControls:s=!0,progressBar:n=!0,playButton:r=!0,volumeButton:o=!0,fullscreenButton:a=!0,videoTime:h=!0,pieView:l=!0,vrButton:c=!0,gyroButton:u=!0,className:_={},customItems:d=[]}={}){var m;this._onStaticClick=({target:t,isTouch:e})=>{var i;const s=this._autoHider;if(e){if(!s.enabled)return;s.hidden?s.showTemporaliy():s.hide()}else{if(!this.clickToPlay)return;const e=null===(i=t.mesh)||void 0===i?void 0:i.getTexture();if(!e||!e.isVideo())return;e.isPaused()?e.source.play():e.source.pause()}},this._onNewSrcLoad=({target:t})=>{const e=this._items;this._updateBackground(t),this._updateAutoHide(t),this._updateKeyboardHandler(t),Object.keys(e).forEach((i=>{e[i].forEach((e=>{e.destroy(t,this),e.init(t,this)}))}))},this.autoHide=t,this.showBackground=e,this.clickToPlay=i,this.keyboardControls=s,this.progressBar=n,this.playButton=r,this.volumeButton=o,this.fullscreenButton=a,this.videoTime=h,this.pieView=l,this.vrButton=c,this.gyroButton=u,this.className=Object.assign(Object.assign({},Ii.DEFAULT_CLASS),_);const p=null!==(m=_.CONTROLS_ROOT)&&void 0!==m?m:Ii.DEFAULT_CLASS.CONTROLS_ROOT;this._rootEl=Qt(p),this._createPositionWrappers(),this._items=Object.keys(Ii.POSITION).reduce(((t,e)=>(t[Ii.POSITION[e]]=[],t)),{}),this._customItems=d,this._autoHider=new Oi(this,re(t)),this._videoControl=new Ai,d.forEach((t=>{this._items[t.position].push(t)}))}init(t){const e=t.rootEl,i=this._rootEl,s=this._createDefaultItems();this._updateBackground(t),this._updateAutoHide(t),this._updateKeyboardHandler(t),e.appendChild(i),this._addItem(t,s),this._addItem(t,this._customItems),t.on(Ot.PROJECTION_CHANGE,this._onNewSrcLoad),t.on(Ot.STATIC_CLICK,this._onStaticClick)}destroy(t){const e=t.rootEl,i=this._rootEl,s=this._items;i.parentElement===e&&e.removeChild(i),Object.keys(s).forEach((e=>{s[e].forEach((e=>{e.destroy(t,this)})),s[e]=[]})),this._clearItemElements(),this._autoHider.disable(t),this._videoControl.disable(e),t.off(Ot.PROJECTION_CHANGE,this._onNewSrcLoad),t.off(Ot.STATIC_CLICK,this._onStaticClick)}_addItem(t,e){for(const i of e){const e=this._items[i.position],s=this._wrapperEl[i.position],n=ne(e,(t=>t.order>i.order));if(n>=0){const t=e[n].element;e.splice(n,0,i),s.insertBefore(i.element,t)}else e.push(i),s.appendChild(i.element);i.init(t,this)}}_createPositionWrappers(){const t=Object.assign(Object.assign({},Ii.DEFAULT_CLASS),this.className),e=this._rootEl,i=Qt(t.CONTROLS_BG),s=Qt(t.CONTROLS_FLOAT_LEFT),n=Qt(t.CONTROLS_FLOAT_RIGHT);e.appendChild(s),e.appendChild(n);const r=Qt(t.CONTROLS_MAIN),o=Qt(t.CONTROLS_TOP),a=Qt(t.CONTROLS_BOTTOM),h=Qt(t.CONTROLS_MID),l=Qt(t.CONTROLS_LEFT),c=Qt(t.CONTROLS_RIGHT);h.appendChild(l),h.appendChild(c),r.appendChild(i),r.appendChild(o),r.appendChild(h),r.appendChild(a),e.appendChild(r),this._bgEl=i,this._containerEl=r,this._wrapperEl={[Ii.POSITION.MAIN_TOP]:o,[Ii.POSITION.MAIN_LEFT]:l,[Ii.POSITION.MAIN_RIGHT]:c,[Ii.POSITION.MAIN_BOTTOM]:a,[Ii.POSITION.TOP_LEFT]:s,[Ii.POSITION.TOP_RIGHT]:n}}_clearItemElements(){Object.keys(Ii.POSITION).map((t=>Ii.POSITION[t])).map((t=>this._wrapperEl[t])).forEach((t=>{for(;t.firstChild;)t.removeChild(t.firstChild)}))}_updateAutoHide(t){var e;const i=this.autoHide,s=this._autoHider;if(null!=i)i?s.enable(t):s.disable(t);else{const i=null===(e=t.mesh)||void 0===e?void 0:e.getTexture();i&&i.isVideo()?s.enable(t):s.disable(t)}}_updateBackground(t){var e,i;const s=this._bgEl,n=this.showBackground,r=null!==(e=this.className.HIDDEN)&&void 0!==e?e:Ii.DEFAULT_CLASS.HIDDEN;if(null!=n)n?s.classList.remove(r):s.classList.add(r);else{const e=null===(i=t.mesh)||void 0===i?void 0:i.getTexture();e&&e.isVideo()?s.classList.remove(r):s.classList.add(r)}}_updateKeyboardHandler(t){var e;const i=t.rootEl,s=this._videoControl,n=null===(e=t.mesh)||void 0===e?void 0:e.getTexture();this.keyboardControls&&n&&n.isVideo()?s.enable(i,n):s.disable(i)}_createDefaultItems(){const t=[];return this.progressBar&&t.push(new bi(re(this.progressBar))),this.playButton&&t.push(new yi(re(this.playButton))),this.volumeButton&&t.push(new Ti(re(this.volumeButton))),this.gyroButton&&t.push(new xi(re(this.gyroButton))),this.vrButton&&t.push(new Li(re(this.vrButton))),this.fullscreenButton&&t.push(new Ri(re(this.fullscreenButton))),this.videoTime&&t.push(new wi(re(this.videoTime))),this.pieView&&t.push(new Ci(re(this.pieView))),t}}Ii.DEFAULT_CLASS=vi,Ii.POSITION=Ei;class Si{constructor({src:t,video:e=!1}){this.src=t,this.video=e}updateCamera(t){t.resetRange()}updateControl(t){t.ignoreZoomScale=!1}}class Pi{constructor(){this.needsUpdate=!0}destroy(t){}}class Mi extends Pi{constructor(t,e,i){super(),this.texture=e,this._webglTexture=t.createWebGLCubeTexture(e,e.width),this._cubemapOrder=i}destroy(t){this.texture.destroy(),t.deleteTexture(this._webglTexture)}update(t,e,i){const s=this.texture;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.uniform1i(e,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_CUBE_MAP,this._webglTexture);ae(s.sources,this._cubemapOrder).forEach(((e,s)=>{i?t.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,0,0,t.RGBA,t.UNSIGNED_BYTE,e):t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e)})),s.isVideo()||(this.needsUpdate=!1)}}class Ni{get size(){return this._size}constructor(t,e){var i;this.texture=t,this._renderingOrder=ae(!(i=6)||i<=0?[]:Array.apply(0,Array(i)).map(((t,e)=>e)),e);const s=document.createElement("canvas");this._calcRenderingSize(),s.width=this._size,s.height=this._size,this._canvas=s,this._ctx=s.getContext("2d")}destroy(){const t=this._canvas;t.width=1,t.height=1,this._canvas=null}draw(t,e){const i=this._size,s=this.texture;let n=0;for(let r=0;r=0;t--)for(let e=0;e<3;e++){const n=[e*i,.5*t,(e+1)*i,.5*t,(e+1)*i,.5*(t+1),e*i,.5*(t+1)];s.push(n)}e&&e.forEach(((t,e)=>{if(t===Xt.ZERO)return;const i=s[e];let n;n=t===Xt.CW_90?[1,2,3,0]:t===Xt.CCW_90?[3,0,1,2]:[2,3,0,1];const r=Array(i.length);for(let t=0;tt.concat(e)),[]))}}class ki extends Pi{constructor(t,e){super(),this.texture=e,this._webglTexture=t.createWebGLTexture(e)}destroy(t){this.texture.destroy(),t.deleteTexture(this._webglTexture)}update(t,e,i){const s=this.texture,n=s.isVideo();t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.uniform1i(e,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this._webglTexture),!n&&i?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,s.source):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,s.source),n||(this.needsUpdate=!1)}}var Gi="#define GLSLIFY 1\nattribute vec3 position;attribute vec2 uv;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;varying highp vec2 vUV;void main(){vUV=uv;gl_Position=uPMatrix*uMVMatrix*vec4(position,1.0);}",Hi="#define GLSLIFY 1\nuniform sampler2D uTexture;varying highp vec2 vUV;void main(){gl_FragColor=texture2D(uTexture,vUV.st);}";class Yi extends zi{constructor(t){const e=[],i=[],s=[],n=[-.5,.5],r=1/60,o=t*r;for(let a=0;a<2;a++){const h=n[a];for(let n=0;n<=60;n++){const l=n*o+Math.PI-.5*t,c=Math.cos(l),u=Math.sin(l),_=n*r,d=a;if(s.push(_,d),e.push(c,h,u),0===a&&n<60){const t=n,e=t+60+1;i.push(t,e,t+1,e,e+1,t+1)}}}super(e,i,s)}}class Wi extends zi{constructor(){const t=60,e=-.5*Math.PI,i=[],s=[],n=[];let r,o;for(r=0;r<=60;r++){const a=(r/60-.5)*Math.PI,h=Math.sin(a),l=Math.cos(a);for(o=0;o<=t;o++){const a=2*(o/t-.5)*Math.PI+e,c=Math.sin(a),u=Math.cos(a)*l,_=h,d=c*l,m=o/t,p=r/60;if(i.push(m,p),s.push(u,_,d),o!==t&&60!==r){const e=61*r+o,i=e+t+1;n.push(e,e+1,i,i,e+1,i+1)}}}super(s,n,i)}}class Xi extends Pi{constructor(t){super(),this.val=t}update(t,e){t.uniform1f(e,this.val),this.needsUpdate=!1}}class ji extends zi{constructor(t=2,e=2,i=-1){const s=.5*t,n=.5*e;super([-s,-n,i,s,-n,i,-s,n,i,s,n,i],[0,1,2,2,1,3],[0,0,1,0,0,1,1,1])}}class Ki extends Pi{constructor(t){super(),this.val=t}update(t,e){t.uniform4fv(e,this.val.reduce(((t,e)=>[...t,...e]),[])),this.needsUpdate=!1}}class qi extends Si{constructor(t){super(t),this._mode=t.mode}createMesh(t,e){let i,s;if(this._mode===qi.MODE.LEFT_RIGHT)i=[.5,1,0,0],s=[.5,1,.5,0];else i=[1,.5,0,0],s=[1,.5,0,.5];const n={uTexture:new ki(t,e),uEye:new Xi(0),uTexScaleOffset:new Ki([i,s])},r=new Wi,o=new Bi(t,"#define GLSLIFY 1\nattribute vec3 position;attribute vec2 uv;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;uniform vec4 uTexScaleOffset[2];uniform float uEye;varying highp vec2 vUV;void main(){vec4 scaleOffset=uTexScaleOffset[int(uEye)];vUV=uv.xy*scaleOffset.xy+scaleOffset.zw;gl_Position=uPMatrix*uMVMatrix*vec4(position,1.0);}",Hi,n),a=t.createVAO(r,o);return new Ui(a,o)}}qi.MODE={LEFT_RIGHT:"left_right",TOP_BOTTOM:"top_bottom"};var Zi={__proto__:null,default:di,Autoplay:oi,AutoResizer:ri,Camera:me,CameraAnimation:de,Motion:_e,Object3D:mi,View360Error:D,WebGLRenderer:_i,XRManager:ai,PanoControl:Ce,RotateControl:Ee,ZoomControl:ye,GyroControl:we,ControlBar:Ii,ControlBarItem:gi,FullscreenButton:Ri,PieView:Ci,PlayButton:yi,ProgressBar:bi,VideoTime:wi,VolumeControl:Ti,LoadingSpinner:pi,Projection:Si,CubemapProjection:class extends Si{constructor(t){super(t);const{cubemapOrder:e="RLUDFB",cubemapFlipX:i=!1}=t;this._cubemapOrder=e,this._cubemapFlipX=i}createMesh(t,e){const i=this._cubemapOrder,s=this._cubemapFlipX,n={uTexture:e.isCube()?new Mi(t,e,i):new Di(t,e,i)},r=new Vi({order:i}),o=new Bi(t,"#define GLSLIFY 1\nattribute vec3 position;attribute vec2 uv;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;varying highp vec3 vPos;void main(){vPos=position;gl_Position=uPMatrix*uMVMatrix*vec4(position,1.0);}","#define GLSLIFY 1\nuniform samplerCube uTexture;varying highp vec3 vPos;void main(){gl_FragColor=textureCube(uTexture,vec3(vPos.x,vPos.y,-vPos.z));}",n),a=t.createVAO(r,o),h=new Ui(a,o);return s&&(h.scale[0]=-1),h.updateMatrix(),h}},CubestripProjection:class extends Si{constructor(t){super(t);const{cubemapOrder:e="RLUDFB",cubemapFlipX:i=!1}=t;this._cubemapOrder=e,this._cubemapFlipX=i}createMesh(t,e){const i=this._cubemapOrder,s=this._cubemapFlipX,n={uTexture:new ki(t,e)},r=new Vi({order:i}),o=new Bi(t,Gi,Hi,n),a=t.createVAO(r,o),h=new Ui(a,o);return s&&(h.scale[0]=-1),h.updateMatrix(),h}},CylindricalProjection:class extends Si{constructor(t){super(t);const{partial:e=!1}=t;this._partial=e,this._aspect=1,this._halfHeight=0,this._mesh=null}createMesh(t,e){if(this._mesh)return this._mesh;const i=this._partial,{width:s,height:n}=e,r=s/n,o=180/r,a=i?1:2*Math.tan(o*zt),h=i?r:2*Math.PI,l=new Yi(h),c=new Bi(t,Gi,Hi,{uTexture:new ki(t,e)}),u=t.createVAO(l,c),_=new Ui(u,c);return _.scale[1]=a,T(_.rotation),C(_.rotation,_.rotation,-Math.PI/2),_.updateMatrix(),this._aspect=r,this._halfHeight=.5*a,this._mesh=_,_}updateCamera(t){super.updateCamera(t);const e=this._mesh,i=this._aspect,s=this._halfHeight;if(!e)return;if(this._partial){const e=.5*i*Vt;t.restrictYawRange(-e,e)}const n=Math.atan2(s,1)*Vt,r=Math.tan(t.fov*zt*.5)/(s*t.aspect);t.restrictPitchRange(-n,n),t.restrictZoomRange(r,1/0),t.restrictRenderHeight(2*s)}},EquiangularProjection:class extends Si{createMesh(t,e){const i={uTexture:new ki(t,e)},s=new Vi({order:"LFRDBU",rotateUV:[Xt.ZERO,Xt.ZERO,Xt.ZERO,Xt.CW_90,Xt.CCW_90,Xt.CW_90]}),n=new Bi(t,Gi,"#define PI 3.14159265359\nprecision mediump float;\n#define GLSLIFY 1\nuniform sampler2D uTexture;varying highp vec2 vUV;const vec2 OPERATE_COORDS_RANGE=vec2(-1.0,1.0);const vec2 TEXTURE_COORDS_RANGE=vec2(0.0,1.0);const float ONE_THIRD=1.0/3.0;const float EAC_CONST=2.0/PI;float scale(vec2 domainRange,vec2 targetRange,float val){float unit=1.0/(domainRange[1]-domainRange[0]);return targetRange[0]+(targetRange[1]-targetRange[0])*(val-domainRange[0])*unit;}void main(void){float transformedCoordX;float transformedCoordY;float texRangeXStart=floor(vUV.s*3.)*ONE_THIRD;float texRangeYStart=floor(vUV.t*2.)*0.5;vec2 orgTextureRangeX=vec2(texRangeXStart,texRangeXStart+ONE_THIRD);vec2 orgTextureRangeY=vec2(texRangeYStart,texRangeYStart+0.5);float px=scale(orgTextureRangeX,OPERATE_COORDS_RANGE,vUV.s);float py=scale(orgTextureRangeY,OPERATE_COORDS_RANGE,vUV.t);float qu=EAC_CONST*atan(px)+0.5;float qv=EAC_CONST*atan(py)+0.5;transformedCoordX=scale(TEXTURE_COORDS_RANGE,orgTextureRangeX,qu);transformedCoordY=scale(TEXTURE_COORDS_RANGE,orgTextureRangeY,qv);gl_FragColor=texture2D(uTexture,vec2(transformedCoordX,transformedCoordY));}",i),r=t.createVAO(s,n);return new Ui(r,n)}},EquirectProjection:class extends Si{constructor(t){super(t)}createMesh(t,e){const i={uTexture:new ki(t,e)},s=new Wi,n=new Bi(t,Gi,Hi,i),r=t.createVAO(s,n);return new Ui(r,n)}},LittlePlanetProjection:class extends Si{constructor(t){super(t)}createMesh(t,e){e.wrapS=WebGLRenderingContext.REPEAT,e.wrapT=WebGLRenderingContext.REPEAT;const i={uTexture:new ki(t,e),uYaw:new Xi(0),uPitch:new Xi(.5),uZoom:new Xi(1)},s=new ji,n=new Bi(t,"#define GLSLIFY 1\nattribute vec3 position;attribute vec2 uv;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;varying highp vec2 vUV;void main(){vUV=uv;gl_Position=vec4(position,1.0);}","precision mediump float;\n#define GLSLIFY 1\nuniform sampler2D uTexture;uniform float uYaw;uniform float uPitch;uniform float uZoom;varying highp vec2 vUV;const float PI=3.1415926536;const float PI_2=PI*0.5;vec2 toStereographicUV(in vec2 uv,in vec2 center){float R=1.*uZoom;vec2 texLatLon=(uv*2.-1.)*vec2(PI,PI_2);vec2 central=(center*2.-1.)*vec2(PI,PI_2)+vec2(PI,0);float x=texLatLon.x;float y=texLatLon.y;float rou=sqrt(x*x+y*y);float c=2.0*atan(rou,R*0.5);float sin_c=sin(c);float cos_c=cos(c);float sin_cy=sin(central.y);float cos_cy=cos(central.y);float lat=asin(cos_c*sin_cy+(y*sin_c*cos_cy)/rou);float lon=central.x+atan(x*sin_c,rou*cos_cy*cos_c-y*sin_cy*sin_c);float u=(lon/PI+1.0)*0.5;float v=(lat/PI_2+1.0)*0.5;return vec2(u,v);}void main(){vec2 central=vec2(uYaw,uPitch);vec2 uv=toStereographicUV(vUV,central);gl_FragColor=texture2D(uTexture,uv);}",i),r=t.createVAO(s,n),o=new Ui(r,n);return o.on(Pt,(({camera:t})=>{const e=o.program.uniforms;e.uYaw.val=t.yaw/360,e.uPitch.val=t.pitch/180+.5,e.uZoom.val=t.zoom,e.uYaw.needsUpdate=!0,e.uPitch.needsUpdate=!0,e.uZoom.needsUpdate=!0})),o}updateControl(t){t.ignoreZoomScale=!0}},StereoEquiProjection:qi,Hotspot:hi,HotspotRenderer:li,ERROR_CODES:U,DEFAULT_CLASS:xt,EVENTS:Ot,EASING:At,getValidProps:t=>Object.keys(t).reduce(((e,i)=>(null!=t[i]&&(e[i]=t[i]),e)),{}),VIEW360_METHODS:["destroy","init","load","resize","addPlugins","removePlugins","renderFrame","on","hasOn","once","off","trigger"],withMethods:(t,e)=>{[o.prototype,di.prototype].forEach((i=>{Object.getOwnPropertyNames(i).filter((t=>"_"!==t.charAt(0)&&"constructor"!==t)).forEach((s=>{const n=Object.getOwnPropertyDescriptor(i,s);if(n.value)Object.defineProperty(t,s,{value:function(...t){return n.value.call(this[e],...t)}});else{const i={};n.get&&(i.get=function(){var t;return this[e]&&(null===(t=n.get)||void 0===t?void 0:t.call(this[e]))}),n.set&&(i.set=function(...t){var i;return null===(i=n.set)||void 0===i?void 0:i.call(this[e],...t)}),Object.defineProperty(t,s,i)}}))}))}};return((t,...e)=>{e.forEach((e=>{Object.keys(e).forEach((i=>{const s=e[i];Array.isArray(t[i])&&Array.isArray(s)?t[i]=[...t[i],...s]:t[i]=s}))}))})(di,Zi),di})); //# sourceMappingURL=view360.pkgd.min.js.map