{"version":3,"names":[],"mappings":"","sources":["scripts/scriptsCommonExtended.js"],"sourcesContent":["/**\n * @license\n * Video.js 7.8.2 \n * Copyright Brightcove, Inc. \n * Available under Apache License Version 2.0\n * \n *\n * Includes vtt.js \n * Available under Apache License Version 2.0\n * \n */\n!function(e,t){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=t(require(\"global/window\"),require(\"global/document\")):\"function\"==typeof define&&define.amd?define([\"global/window\",\"global/document\"],t):(e=e||self).videojs=t(e.window,e.document)}(this,function(y,h){\"use strict\";y=y&&Object.prototype.hasOwnProperty.call(y,\"default\")?y.default:y,h=h&&Object.prototype.hasOwnProperty.call(h,\"default\")?h.default:h;var d=\"7.8.2\",l=[],e=function(o,u){return function(e,t,i){var n=u.levels[t],r=new RegExp(\"^(\"+n+\")$\");if(\"log\"!==e&&i.unshift(e.toUpperCase()+\":\"),i.unshift(o+\":\"),l){l.push([].concat(i));var s=l.length-1e3;l.splice(0,0',i=n.firstChild,n.setAttribute(\"style\",\"display:none; position:absolute;\"),h.body.appendChild(n));for(var s={},a=0;ax',e=t.firstChild.href}return e}function Ut(e){if(\"string\"==typeof e){var t=/^(\\/?)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?)(\\.([^\\.\\/\\?]+)))(?:[\\/]*|[\\?].*)$/.exec(e);if(t)return t.pop().toLowerCase()}return\"\"}function Mt(e,t){void 0===t&&(t=y.location);var i=Nt(e);return(\":\"===i.protocol?t.protocol:i.protocol)+i.host!==t.protocol+t.host}var Bt=function(n){function e(e){var t;void 0===e&&(e=[]);for(var i=e.length-1;0<=i;i--)if(e[i].enabled){Ot(e,e[i]);break}return(t=n.call(this,e)||this).changing_=!1,t}He(e,n);var t=e.prototype;return t.addTrack=function(e){var t=this;e.enabled&&Ot(this,e),n.prototype.addTrack.call(this,e),e.addEventListener&&(e.enabledChange_=function(){t.changing_||(t.changing_=!0,Ot(t,e),t.changing_=!1,t.trigger(\"change\"))},e.addEventListener(\"enabledchange\",e.enabledChange_))},t.removeTrack=function(e){n.prototype.removeTrack.call(this,e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener(\"enabledchange\",e.enabledChange_),e.enabledChange_=null)},e}(Pt),jt=function(n){function e(e){var t;void 0===e&&(e=[]);for(var i=e.length-1;0<=i;i--)if(e[i].selected){Dt(e,e[i]);break}return(t=n.call(this,e)||this).changing_=!1,Object.defineProperty(Ue(t),\"selectedIndex\",{get:function(){for(var e=0;e\n * Copyright (c) 2014 David Björklund\n * Available under the MIT license\n * \n */,$t=Object.prototype.toString;var Qt=function(e){var r={};return e&&e.trim().split(\"\\n\").forEach(function(e){var t=e.indexOf(\":\"),i=e.slice(0,t).trim().toLowerCase(),n=e.slice(t+1).trim();\"undefined\"==typeof r[i]?r[i]=n:Array.isArray(r[i])?r[i].push(n):r[i]=[r[i],n]}),r},Jt=ti,Zt=ti;function ei(e,t,i){var n=e;return Yt(t)?(i=t,\"string\"==typeof e&&(n={uri:e})):n=r({},t,{uri:e}),n.callback=i,n}function ti(e,t,i){return ii(t=ei(e,t,i))}function ii(n){if(\"undefined\"==typeof n.callback)throw new Error(\"callback argument missing\");var r=!1,s=function(e,t,i){r||(r=!0,n.callback(e,t,i))};function t(e){return clearTimeout(o),e instanceof Error||(e=new Error(\"\"+(e||\"Unknown XMLHttpRequest Error\"))),e.statusCode=0,s(e,m)}function e(){if(!a){var e;clearTimeout(o),e=n.useXDR&&void 0===u.status?200:1223===u.status?204:u.status;var t=m,i=null;return 0!==e?(t={body:function(){var e=void 0;if(e=u.response?u.response:u.responseText||function(e){try{if(\"document\"===e.responseType)return e.responseXML;var t=e.responseXML&&\"parsererror\"===e.responseXML.documentElement.nodeName;if(\"\"===e.responseType&&!t)return e.responseXML}catch(e){}return null}(u),f)try{e=JSON.parse(e)}catch(e){}return e}(),statusCode:e,method:c,headers:{},url:l,rawRequest:u},u.getAllResponseHeaders&&(t.headers=Qt(u.getAllResponseHeaders()))):i=new Error(\"Internal XMLHttpRequest Error\"),s(i,t,t.body)}}var i,a,o,u=n.xhr||null,l=(u=u||(n.cors||n.useXDR?new ti.XDomainRequest:new ti.XMLHttpRequest)).url=n.uri||n.url,c=u.method=n.method||\"GET\",h=n.body||n.data,d=u.headers=n.headers||{},p=!!n.sync,f=!1,m={body:void 0,headers:{},statusCode:0,method:c,url:l,rawRequest:u};if(\"json\"in n&&!1!==n.json&&(f=!0,d.accept||d.Accept||(d.Accept=\"application/json\"),\"GET\"!==c&&\"HEAD\"!==c&&(d[\"content-type\"]||d[\"Content-Type\"]||(d[\"Content-Type\"]=\"application/json\"),h=JSON.stringify(!0===n.json?h:n.json))),u.onreadystatechange=function(){4===u.readyState&&setTimeout(e,0)},u.onload=e,u.onerror=t,u.onprogress=function(){},u.onabort=function(){a=!0},u.ontimeout=t,u.open(c,l,!p,n.username,n.password),p||(u.withCredentials=!!n.withCredentials),!p&&0=e?t.push(r):r.startTime===r.endTime&&r.startTime<=e&&r.startTime+.5>=e&&t.push(r)}if(o=!1,t.length!==this.activeCues_.length)o=!0;else for(var s=0;s]*>?)?/);return e=t[1]?t[1]:t[2],i=i.substr(e.length),e}function t(e,t){var i=bi[e];if(!i)return null;var n=s.document.createElement(i),r=Si[e];return r&&t&&(n[r]=t.trim()),n}for(var n,r,a,o,u=s.document.createElement(\"div\"),l=u,c=[];null!==(n=e());)if(\"<\"!==n[0])l.appendChild(s.document.createTextNode((r=n,_i.innerHTML=r,r=_i.textContent,_i.textContent=\"\",r)));else{if(\"/\"===n[1]){c.length&&c[c.length-1]===n.substr(2).replace(\">\",\"\")&&(c.pop(),l=l.parentNode);continue}var h,d=mi(n.substr(1,n.length-2));if(d){h=s.document.createProcessingInstruction(\"timestamp\",d),l.appendChild(h);continue}var p=n.match(/^<([^.\\s/0-9>]+)(\\.[^\\s\\\\>]+)?([^>\\\\]+)?(\\\\?)>?$/);if(!p)continue;if(!(h=t(p[1],p[3])))continue;if(a=l,ki[(o=h).localName]&&ki[o.localName]!==a.localName)continue;if(p[2]){var f=p[2].split(\".\");f.forEach(function(e){var t=/^bg_/.test(e),i=t?e.slice(3):e;if(Ti.hasOwnProperty(i)){var n=t?\"background-color\":\"color\",r=Ti[i];h.style[n]=r}}),h.className=f.join(\" \")}c.push(p[1]),l.appendChild(h),l=h}return u}var wi=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function Ei(e){for(var t=0;t=i[0]&&e<=i[1])return!0}return!1}function xi(){}function Ai(e,t,i){xi.call(this),this.cue=t,this.cueDiv=Ci(e,t.text);var n={color:\"rgba(255, 255, 255, 1)\",backgroundColor:\"rgba(0, 0, 0, 0.8)\",position:\"relative\",left:0,right:0,top:0,bottom:0,display:\"inline\",writingMode:\"\"===t.vertical?\"horizontal-tb\":\"lr\"===t.vertical?\"vertical-lr\":\"vertical-rl\",unicodeBidi:\"plaintext\"};this.applyStyles(n,this.cueDiv),this.div=e.document.createElement(\"div\"),n={direction:function(e){var t=[],i=\"\";if(!e||!e.childNodes)return\"ltr\";function r(e,t){for(var i=t.childNodes.length-1;0<=i;i--)e.push(t.childNodes[i])}function s(e){if(!e||!e.length)return null;var t=e.pop(),i=t.textContent||t.innerText;if(i){var n=i.match(/^.*(\\n|\\r)/);return n?n[e.length=0]:i}return\"ruby\"===t.tagName?s(e):t.childNodes?(r(e,t),s(e)):void 0}for(r(t,e);i=s(t);)for(var n=0;nh&&(c=c<0?-1:1,c*=Math.ceil(h/l)*l),r<0&&(c+=\"\"===n.vertical?o.height:o.width,s=s.reverse()),i.move(d,c)}else{var p=i.lineHeight/o.height*100;switch(n.lineAlign){case\"center\":r-=p/2;break;case\"end\":r-=p}switch(n.vertical){case\"\":t.applyStyles({top:t.formatStyle(r,\"%\")});break;case\"rl\":t.applyStyles({left:t.formatStyle(r,\"%\")});break;case\"lr\":t.applyStyles({right:t.formatStyle(r,\"%\")})}s=[\"+y\",\"-x\",\"+x\",\"-y\"],i=new Ii(t)}var f=function(e,t){for(var i,n=new Ii(e),r=1,s=0;se.left&&this.tope.top},Ii.prototype.overlapsAny=function(e){for(var t=0;t=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},Ii.prototype.overlapsOppositeAxis=function(e,t){switch(t){case\"+x\":return this.lefte.right;case\"+y\":return this.tope.bottom}},Ii.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},Ii.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},Ii.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,i=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,n=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||n,height:e.height||t,bottom:e.bottom||n+(e.height||t),width:e.width||i}},Li.StringDecoder=function(){return{decode:function(e){if(!e)return\"\";if(\"string\"!=typeof e)throw new Error(\"Error - expected string data.\");return decodeURIComponent(encodeURIComponent(e))}}},Li.convertCueToDOMTree=function(e,t){return e&&t?Ci(e,t):null};Li.processCues=function(n,r,e){if(!n||!r||!e)return null;for(;e.firstChild;)e.removeChild(e.firstChild);var s=n.document.createElement(\"div\");if(s.style.position=\"absolute\",s.style.left=\"0\",s.style.right=\"0\",s.style.top=\"0\",s.style.bottom=\"0\",s.style.margin=\"1.5%\",e.appendChild(s),function(e){for(var t=0;t',className:this.buildCSSClass(),tabIndex:0},t),\"button\"===e&&p.error(\"Creating a ClickableComponent with an HTML element of \"+e+\" is not supported; use a Button instead.\"),i=m({role:\"button\"},i),this.tabIndex_=t.tabIndex;var n=r.prototype.createEl.call(this,e,t,i);return this.createControlTextEl(n),n},t.dispose=function(){this.controlTextEl_=null,r.prototype.dispose.call(this)},t.createControlTextEl=function(e){return this.controlTextEl_=S(\"span\",{className:\"vjs-control-text\"},{\"aria-live\":\"polite\"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_},t.controlText=function(e,t){if(void 0===t&&(t=this.el()),void 0===e)return this.controlText_||\"Need Text\";var i=this.localize(e);this.controlText_=e,k(this.controlTextEl_,i),this.nonIconControl||t.setAttribute(\"title\",i)},t.buildCSSClass=function(){return\"vjs-control vjs-button \"+r.prototype.buildCSSClass.call(this)},t.enable=function(){this.enabled_||(this.enabled_=!0,this.removeClass(\"vjs-disabled\"),this.el_.setAttribute(\"aria-disabled\",\"false\"),\"undefined\"!=typeof this.tabIndex_&&this.el_.setAttribute(\"tabIndex\",this.tabIndex_),this.on([\"tap\",\"click\"],this.handleClick),this.on(\"keydown\",this.handleKeyDown))},t.disable=function(){this.enabled_=!1,this.addClass(\"vjs-disabled\"),this.el_.setAttribute(\"aria-disabled\",\"true\"),\"undefined\"!=typeof this.tabIndex_&&this.el_.removeAttribute(\"tabIndex\"),this.off(\"mouseover\",this.handleMouseOver),this.off(\"mouseout\",this.handleMouseOut),this.off([\"tap\",\"click\"],this.handleClick),this.off(\"keydown\",this.handleKeyDown)},t.handleClick=function(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)},t.handleKeyDown=function(e){xt.isEventKey(e,\"Space\")||xt.isEventKey(e,\"Enter\")?(e.preventDefault(),e.stopPropagation(),this.trigger(\"click\")):r.prototype.handleKeyDown.call(this,e)},e}(Re);Re.registerComponent(\"ClickableComponent\",rn);var sn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).update(),e.on(\"posterchange\",ge(Ue(i),i.update)),i}He(e,n);var t=e.prototype;return t.dispose=function(){this.player().off(\"posterchange\",this.update),n.prototype.dispose.call(this)},t.createEl=function(){return S(\"div\",{className:\"vjs-poster\",tabIndex:-1})},t.update=function(e){var t=this.player().poster();this.setSrc(t),t?this.show():this.hide()},t.setSrc=function(e){var t=\"\";e&&(t='url(\"'+e+'\")'),this.el_.style.backgroundImage=t},t.handleClick=function(e){if(this.player_.controls()){var t=this.player_.usingPlugin(\"eme\")&&this.player_.eme.sessions&&0',className:this.buildCSSClass()},t),i=m({type:\"button\"},i);var n=Re.prototype.createEl.call(this,\"button\",t,i);return this.createControlTextEl(n),n},i.addChild=function(e,t){void 0===t&&(t={});var i=this.constructor.name;return p.warn(\"Adding an actionable (user controllable) child to a Button (\"+i+\") is not supported; use a ClickableComponent instead.\"),Re.prototype.addChild.call(this,e,t)},i.enable=function(){t.prototype.enable.call(this),this.el_.removeAttribute(\"disabled\")},i.disable=function(){t.prototype.disable.call(this),this.el_.setAttribute(\"disabled\",\"disabled\")},i.handleKeyDown=function(e){xt.isEventKey(e,\"Space\")||xt.isEventKey(e,\"Enter\")?e.stopPropagation():t.prototype.handleKeyDown.call(this,e)},e}(rn);Re.registerComponent(\"Button\",dn);var pn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).mouseused_=!1,i.on(\"mousedown\",i.handleMouseDown),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-big-play-button\"},t.handleClick=function(e){var t=this.player_.play();if(this.mouseused_&&e.clientX&&e.clientY){var i=this.player_.usingPlugin(\"eme\")&&this.player_.eme.sessions&&0'+this.localize(this.labelText_)+\" \"});return this.contentEl_=S(\"span\",{className:e+\"-display\"},{\"aria-live\":\"off\",role:\"presentation\"}),t.appendChild(this.contentEl_),t},t.dispose=function(){this.contentEl_=null,this.textNode_=null,n.prototype.dispose.call(this)},t.updateTextNode_=function(e){var t=this;void 0===e&&(e=0),e=yn(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestAnimationFrame(function(){if(t.contentEl_){var e=t.textNode_;t.textNode_=h.createTextNode(t.formattedTime_),t.textNode_&&(e?t.contentEl_.replaceChild(t.textNode_,e):t.contentEl_.appendChild(t.textNode_))}}))},t.updateContent=function(e){},e}(Re);_n.prototype.labelText_=\"Time\",_n.prototype.controlText_=\"Time\",Re.registerComponent(\"TimeDisplay\",_n);var bn=function(e){function t(){return e.apply(this,arguments)||this}He(t,e);var i=t.prototype;return i.buildCSSClass=function(){return\"vjs-current-time\"},i.updateContent=function(e){var t;t=this.player_.ended()?this.player_.duration():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)},t}(_n);bn.prototype.labelText_=\"Current Time\",bn.prototype.controlText_=\"Current Time\",Re.registerComponent(\"CurrentTimeDisplay\",bn);var Tn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).on(e,\"durationchange\",i.updateContent),i.on(e,\"loadstart\",i.updateContent),i.on(e,\"loadedmetadata\",i.updateContent),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-duration\"},t.updateContent=function(e){var t=this.player_.duration();this.updateTextNode_(t)},e}(_n);Tn.prototype.labelText_=\"Duration\",Tn.prototype.controlText_=\"Duration\",Re.registerComponent(\"DurationDisplay\",Tn);var Sn=function(e){function t(){return e.apply(this,arguments)||this}return He(t,e),t.prototype.createEl=function(){return e.prototype.createEl.call(this,\"div\",{className:\"vjs-time-control vjs-time-divider\",innerHTML:\"
/
\"},{\"aria-hidden\":!0})},t}(Re);Re.registerComponent(\"TimeDivider\",Sn);var kn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).on(e,\"durationchange\",i.updateContent),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-remaining-time\"},t.createEl=function(){var e=n.prototype.createEl.call(this);return e.insertBefore(S(\"span\",{},{\"aria-hidden\":!0},\"-\"),this.contentEl_),e},t.updateContent=function(e){var t;\"number\"==typeof this.player_.duration()&&(t=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(t))},e}(_n);kn.prototype.labelText_=\"Remaining Time\",kn.prototype.controlText_=\"Remaining Time\",Re.registerComponent(\"RemainingTimeDisplay\",kn);var Cn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).updateShowing(),i.on(i.player(),\"durationchange\",i.updateShowing),i}He(e,n);var t=e.prototype;return t.createEl=function(){var e=n.prototype.createEl.call(this,\"div\",{className:\"vjs-live-control vjs-control\"});return this.contentEl_=S(\"div\",{className:\"vjs-live-display\",innerHTML:''+this.localize(\"Stream Type\")+\" \"+this.localize(\"LIVE\")},{\"aria-live\":\"off\"}),e.appendChild(this.contentEl_),e},t.dispose=function(){this.contentEl_=null,n.prototype.dispose.call(this)},t.updateShowing=function(e){this.player().duration()===1/0?this.show():this.hide()},e}(Re);Re.registerComponent(\"LiveDisplay\",Cn);var wn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).updateLiveEdgeStatus(),i.player_.liveTracker&&i.on(i.player_.liveTracker,\"liveedgechange\",i.updateLiveEdgeStatus),i}He(e,n);var t=e.prototype;return t.createEl=function(){var e=n.prototype.createEl.call(this,\"button\",{className:\"vjs-seek-to-live-control vjs-control\"});return this.textEl_=S(\"span\",{className:\"vjs-seek-to-live-text\",innerHTML:this.localize(\"LIVE\")},{\"aria-hidden\":\"true\"}),e.appendChild(this.textEl_),e},t.updateLiveEdgeStatus=function(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute(\"aria-disabled\",!0),this.addClass(\"vjs-at-live-edge\"),this.controlText(\"Seek to live, currently playing live\")):(this.setAttribute(\"aria-disabled\",!1),this.removeClass(\"vjs-at-live-edge\"),this.controlText(\"Seek to live, currently behind live\"))},t.handleClick=function(){this.player_.liveTracker.seekToLiveEdge()},t.dispose=function(){this.player_.liveTracker&&this.off(this.player_.liveTracker,\"liveedgechange\",this.updateLiveEdgeStatus),this.textEl_=null,n.prototype.dispose.call(this)},e}(dn);wn.prototype.controlText_=\"Seek to live, currently playing live\",Re.registerComponent(\"SeekToLive\",wn);function En(e,t,i){return e=Number(e),Math.min(i,Math.max(t,isNaN(e)?t:e))}var xn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).bar=i.getChild(i.options_.barName),i.vertical(!!i.options_.vertical),i.enable(),i}He(e,n);var t=e.prototype;return t.enabled=function(){return this.enabled_},t.enable=function(){this.enabled()||(this.on(\"mousedown\",this.handleMouseDown),this.on(\"touchstart\",this.handleMouseDown),this.on(\"keydown\",this.handleKeyDown),this.on(\"click\",this.handleClick),this.on(this.player_,\"controlsvisible\",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass(\"disabled\"),this.setAttribute(\"tabindex\",0),this.enabled_=!0)},t.disable=function(){if(this.enabled()){var e=this.bar.el_.ownerDocument;this.off(\"mousedown\",this.handleMouseDown),this.off(\"touchstart\",this.handleMouseDown),this.off(\"keydown\",this.handleKeyDown),this.off(\"click\",this.handleClick),this.off(this.player_,\"controlsvisible\",this.update),this.off(e,\"mousemove\",this.handleMouseMove),this.off(e,\"mouseup\",this.handleMouseUp),this.off(e,\"touchmove\",this.handleMouseMove),this.off(e,\"touchend\",this.handleMouseUp),this.removeAttribute(\"tabindex\"),this.addClass(\"disabled\"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}},t.createEl=function(e,t,i){return void 0===t&&(t={}),void 0===i&&(i={}),t.className=t.className+\" vjs-slider\",t=m({tabIndex:0},t),i=m({role:\"slider\",\"aria-valuenow\":0,\"aria-valuemin\":0,\"aria-valuemax\":100,tabIndex:0},i),n.prototype.createEl.call(this,e,t,i)},t.handleMouseDown=function(e){var t=this.bar.el_.ownerDocument;\"mousedown\"===e.type&&e.preventDefault(),\"touchstart\"!==e.type||Je||e.preventDefault(),N(),this.addClass(\"vjs-sliding\"),this.trigger(\"slideractive\"),this.on(t,\"mousemove\",this.handleMouseMove),this.on(t,\"mouseup\",this.handleMouseUp),this.on(t,\"touchmove\",this.handleMouseMove),this.on(t,\"touchend\",this.handleMouseUp),this.handleMouseMove(e)},t.handleMouseMove=function(e){},t.handleMouseUp=function(){var e=this.bar.el_.ownerDocument;R(),this.removeClass(\"vjs-sliding\"),this.trigger(\"sliderinactive\"),this.off(e,\"mousemove\",this.handleMouseMove),this.off(e,\"mouseup\",this.handleMouseUp),this.off(e,\"touchmove\",this.handleMouseMove),this.off(e,\"touchend\",this.handleMouseUp),this.update()},t.update=function(){var t=this;if(this.el_&&this.bar){var i=this.getProgress();return i===this.progress_||(this.progress_=i,this.requestAnimationFrame(function(){var e=t.vertical()?\"height\":\"width\";t.bar.el().style[e]=(100*i).toFixed(2)+\"%\"})),i}},t.getProgress=function(){return Number(En(this.getPercent(),0,1).toFixed(4))},t.calculateDistance=function(e){var t=B(this.el_,e);return this.vertical()?t.y:t.x},t.handleKeyDown=function(e){xt.isEventKey(e,\"Left\")||xt.isEventKey(e,\"Down\")?(e.preventDefault(),e.stopPropagation(),this.stepBack()):xt.isEventKey(e,\"Right\")||xt.isEventKey(e,\"Up\")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):n.prototype.handleKeyDown.call(this,e)},t.handleClick=function(e){e.stopPropagation(),e.preventDefault()},t.vertical=function(e){if(void 0===e)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass(\"vjs-slider-vertical\"):this.addClass(\"vjs-slider-horizontal\")},e}(Re);Re.registerComponent(\"Slider\",xn);function An(e,t){return En(e/t*100,0,100).toFixed(2)+\"%\"}var In=function(r){function e(e,t){var i;return(i=r.call(this,e,t)||this).partEls_=[],i.on(e,\"progress\",i.update),i}He(e,r);var t=e.prototype;return t.createEl=function(){var e=r.prototype.createEl.call(this,\"div\",{className:\"vjs-load-progress\"}),t=S(\"span\",{className:\"vjs-control-text\"}),i=S(\"span\",{textContent:this.localize(\"Loaded\")}),n=h.createTextNode(\": \");return this.percentageEl_=S(\"span\",{className:\"vjs-control-text-loaded-percentage\",textContent:\"0%\"}),e.appendChild(t),t.appendChild(i),t.appendChild(n),t.appendChild(this.percentageEl_),e},t.dispose=function(){this.partEls_=null,this.percentageEl_=null,r.prototype.dispose.call(this)},t.update=function(e){var h=this;this.requestAnimationFrame(function(){var e=h.player_.liveTracker,t=h.player_.buffered(),i=e&&e.isLive()?e.seekableEnd():h.player_.duration(),n=h.player_.bufferedEnd(),r=h.partEls_,s=An(n,i);h.percent_!==s&&(h.el_.style.width=s,k(h.percentageEl_,s),h.percent_=s);for(var a=0;at.length;c--)h.el_.removeChild(r[c-1]);r.length=t.length})},e}(Re);Re.registerComponent(\"LoadProgressBar\",In);var Pn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).update=ve(ge(Ue(i),i.update),30),i}He(e,n);var t=e.prototype;return t.createEl=function(){return n.prototype.createEl.call(this,\"div\",{className:\"vjs-time-tooltip\"},{\"aria-hidden\":\"true\"})},t.update=function(e,t,i){var n=U(this.el_),r=U(this.player_.el()),s=e.width*t;if(r&&n){var a=e.left-r.left+s,o=e.width-s+(r.right-e.right),u=n.width/2;an.width&&(u=n.width),this.el_.style.right=\"-\"+u+\"px\",this.write(i)}},t.write=function(e){k(this.el_,e)},t.updateTime=function(r,s,a,o){var u=this;this.rafId_&&this.cancelAnimationFrame(this.rafId_),this.rafId_=this.requestAnimationFrame(function(){var e,t=u.player_.duration();if(u.player_.liveTracker&&u.player_.liveTracker.isLive()){var i=u.player_.liveTracker.liveWindow(),n=i-s*i;e=(n<1?\"\":\"-\")+yn(n,i)}else e=yn(a,t);u.update(r,s,e),o&&o()})},e}(Re);Re.registerComponent(\"TimeTooltip\",Pn);var Ln=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).update=ve(ge(Ue(i),i.update),30),i}He(e,n);var t=e.prototype;return t.createEl=function(){return n.prototype.createEl.call(this,\"div\",{className:\"vjs-play-progress vjs-slider-bar\"},{\"aria-hidden\":\"true\"})},t.update=function(e,t){var i=this.getChild(\"timeTooltip\");if(i){var n=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();i.updateTime(e,t,n)}},e}(Re);Ln.prototype.options_={children:[]},at||Xe||Ln.prototype.options_.children.push(\"timeTooltip\"),Re.registerComponent(\"PlayProgressBar\",Ln);var On=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).update=ve(ge(Ue(i),i.update),30),i}He(e,n);var t=e.prototype;return t.createEl=function(){return n.prototype.createEl.call(this,\"div\",{className:\"vjs-mouse-display\"})},t.update=function(e,t){var i=this,n=t*this.player_.duration();this.getChild(\"timeTooltip\").updateTime(e,t,n,function(){i.el_.style.left=e.width*t+\"px\"})},e}(Re);On.prototype.options_={children:[\"timeTooltip\"]},Re.registerComponent(\"MouseTimeDisplay\",On);var Dn=function(s){function e(e,t){var i;return(i=s.call(this,e,t)||this).setEventHandlers_(),i}He(e,s);var t=e.prototype;return t.setEventHandlers_=function(){this.update_=ge(this,this.update),this.update=ve(this.update_,30),this.on(this.player_,[\"ended\",\"durationchange\",\"timeupdate\"],this.update),this.player_.liveTracker&&this.on(this.player_.liveTracker,\"liveedgechange\",this.update),this.updateInterval=null,this.on(this.player_,[\"playing\"],this.enableInterval_),this.on(this.player_,[\"ended\",\"pause\",\"waiting\"],this.disableInterval_),\"hidden\"in h&&\"visibilityState\"in h&&this.on(h,\"visibilitychange\",this.toggleVisibility_)},t.toggleVisibility_=function(e){h.hidden?this.disableInterval_(e):(this.enableInterval_(),this.update())},t.enableInterval_=function(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,30))},t.disableInterval_=function(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&\"ended\"!==e.type||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)},t.createEl=function(){return s.prototype.createEl.call(this,\"div\",{className:\"vjs-progress-holder\"},{\"aria-label\":this.localize(\"Progress Bar\")})},t.update=function(e){var n=this,r=s.prototype.update.call(this);return this.requestAnimationFrame(function(){var e=n.player_.ended()?n.player_.duration():n.getCurrentTime_(),t=n.player_.liveTracker,i=n.player_.duration();t&&t.isLive()&&(i=n.player_.liveTracker.liveCurrentTime()),n.percent_!==r&&(n.el_.setAttribute(\"aria-valuenow\",(100*r).toFixed(2)),n.percent_=r),n.currentTime_===e&&n.duration_===i||(n.el_.setAttribute(\"aria-valuetext\",n.localize(\"progress bar timing: currentTime={1} duration={2}\",[yn(e,i),yn(i,i)],\"{1} of {2}\")),n.currentTime_=e,n.duration_=i),n.bar&&n.bar.update(U(n.el()),n.getProgress())}),r},t.getCurrentTime_=function(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()},t.getPercent=function(){var e,t=this.getCurrentTime_(),i=this.player_.liveTracker;return i&&i.isLive()?(e=(t-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(e=1)):e=t/this.player_.duration(),e},t.handleMouseDown=function(e){W(e)&&(e.stopPropagation(),this.player_.scrubbing(!0),this.videoWasPlaying=!this.player_.paused(),this.player_.pause(),s.prototype.handleMouseDown.call(this,e))},t.handleMouseMove=function(e){if(W(e)){var t,i=this.calculateDistance(e),n=this.player_.liveTracker;if(n&&n.isLive()){if(.99<=i)return void n.seekToLiveEdge();var r=n.seekableStart(),s=n.liveCurrentTime();if(s<=(t=r+i*n.liveWindow())&&(t=s),t<=r&&(t=r+.1),t===1/0)return}else(t=i*this.player_.duration())===this.player_.duration()&&(t-=.1);this.player_.currentTime(t)}},t.enable=function(){s.prototype.enable.call(this);var e=this.getChild(\"mouseTimeDisplay\");e&&e.show()},t.disable=function(){s.prototype.disable.call(this);var e=this.getChild(\"mouseTimeDisplay\");e&&e.hide()},t.handleMouseUp=function(e){s.prototype.handleMouseUp.call(this,e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.player_.trigger({type:\"timeupdate\",target:this,manuallyTriggered:!0}),this.videoWasPlaying?kt(this.player_.play()):this.update_()},t.stepForward=function(){this.player_.currentTime(this.player_.currentTime()+5)},t.stepBack=function(){this.player_.currentTime(this.player_.currentTime()-5)},t.handleAction=function(e){this.player_.paused()?this.player_.play():this.player_.pause()},t.handleKeyDown=function(e){if(xt.isEventKey(e,\"Space\")||xt.isEventKey(e,\"Enter\"))e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(xt.isEventKey(e,\"Home\"))e.preventDefault(),e.stopPropagation(),this.player_.currentTime(0);else if(xt.isEventKey(e,\"End\"))e.preventDefault(),e.stopPropagation(),this.player_.currentTime(this.player_.duration());else if(/^[0-9]$/.test(xt(e))){e.preventDefault(),e.stopPropagation();var t=10*(xt.codes[xt(e)]-xt.codes[0])/100;this.player_.currentTime(this.player_.duration()*t)}else xt.isEventKey(e,\"PgDn\")?(e.preventDefault(),e.stopPropagation(),this.player_.currentTime(this.player_.currentTime()-60)):xt.isEventKey(e,\"PgUp\")?(e.preventDefault(),e.stopPropagation(),this.player_.currentTime(this.player_.currentTime()+60)):s.prototype.handleKeyDown.call(this,e)},t.dispose=function(){this.disableInterval_(),this.off(this.player_,[\"ended\",\"durationchange\",\"timeupdate\"],this.update),this.player_.liveTracker&&this.on(this.player_.liveTracker,\"liveedgechange\",this.update),this.off(this.player_,[\"playing\"],this.enableInterval_),this.off(this.player_,[\"ended\",\"pause\",\"waiting\"],this.disableInterval_),\"hidden\"in h&&\"visibilityState\"in h&&this.off(h,\"visibilitychange\",this.toggleVisibility_),s.prototype.dispose.call(this)},e}(xn);Dn.prototype.options_={children:[\"loadProgressBar\",\"playProgressBar\"],barName:\"playProgressBar\"},at||Xe||Dn.prototype.options_.children.splice(1,0,\"mouseTimeDisplay\"),Re.registerComponent(\"SeekBar\",Dn);var Nn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).handleMouseMove=ve(ge(Ue(i),i.handleMouseMove),30),i.throttledHandleMouseSeek=ve(ge(Ue(i),i.handleMouseSeek),30),i.enable(),i}He(e,n);var t=e.prototype;return t.createEl=function(){return n.prototype.createEl.call(this,\"div\",{className:\"vjs-progress-control vjs-control\"})},t.handleMouseMove=function(e){var t=this.getChild(\"seekBar\");if(t){var i=t.getChild(\"playProgressBar\"),n=t.getChild(\"mouseTimeDisplay\");if(i||n){var r=t.el(),s=U(r),a=B(r,e).x;a=En(0,1,a),n&&n.update(s,a),i&&i.update(s,t.getProgress())}}},t.handleMouseSeek=function(e){var t=this.getChild(\"seekBar\");t&&t.handleMouseMove(e)},t.enabled=function(){return this.enabled_},t.disable=function(){this.children().forEach(function(e){return e.disable&&e.disable()}),this.enabled()&&(this.off([\"mousedown\",\"touchstart\"],this.handleMouseDown),this.off(this.el_,\"mousemove\",this.handleMouseMove),this.handleMouseUp(),this.addClass(\"disabled\"),this.enabled_=!1)},t.enable=function(){this.children().forEach(function(e){return e.enable&&e.enable()}),this.enabled()||(this.on([\"mousedown\",\"touchstart\"],this.handleMouseDown),this.on(this.el_,\"mousemove\",this.handleMouseMove),this.removeClass(\"disabled\"),this.enabled_=!0)},t.handleMouseDown=function(e){var t=this.el_.ownerDocument,i=this.getChild(\"seekBar\");i&&i.handleMouseDown(e),this.on(t,\"mousemove\",this.throttledHandleMouseSeek),this.on(t,\"touchmove\",this.throttledHandleMouseSeek),this.on(t,\"mouseup\",this.handleMouseUp),this.on(t,\"touchend\",this.handleMouseUp)},t.handleMouseUp=function(e){var t=this.el_.ownerDocument,i=this.getChild(\"seekBar\");i&&i.handleMouseUp(e),this.off(t,\"mousemove\",this.throttledHandleMouseSeek),this.off(t,\"touchmove\",this.throttledHandleMouseSeek),this.off(t,\"mouseup\",this.handleMouseUp),this.off(t,\"touchend\",this.handleMouseUp)},e}(Re);Nn.prototype.options_={children:[\"seekBar\"]},Re.registerComponent(\"ProgressControl\",Nn);var Rn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).on(e,[\"enterpictureinpicture\",\"leavepictureinpicture\"],i.handlePictureInPictureChange),h.pictureInPictureEnabled||i.disable(),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-picture-in-picture-control \"+n.prototype.buildCSSClass.call(this)},t.handlePictureInPictureChange=function(e){this.player_.isInPictureInPicture()?this.controlText(\"Exit Picture-in-Picture\"):this.controlText(\"Picture-in-Picture\")},t.handleClick=function(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()},e}(dn);Rn.prototype.controlText_=\"Picture-in-Picture\",Re.registerComponent(\"PictureInPictureToggle\",Rn);var Un=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).on(e,\"fullscreenchange\",i.handleFullscreenChange),!1===h[e.fsApi_.fullscreenEnabled]&&i.disable(),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-fullscreen-control \"+n.prototype.buildCSSClass.call(this)},t.handleFullscreenChange=function(e){this.player_.isFullscreen()?this.controlText(\"Non-Fullscreen\"):this.controlText(\"Fullscreen\")},t.handleClick=function(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()},e}(dn);Un.prototype.controlText_=\"Fullscreen\",Re.registerComponent(\"FullscreenToggle\",Un);var Mn=function(e){function t(){return e.apply(this,arguments)||this}return He(t,e),t.prototype.createEl=function(){return e.prototype.createEl.call(this,\"div\",{className:\"vjs-volume-level\",innerHTML:''})},t}(Re);Re.registerComponent(\"VolumeLevel\",Mn);var Bn=function(n){function e(e,t){var i;return(i=n.call(this,e,t)||this).on(\"slideractive\",i.updateLastVolume_),i.on(e,\"volumechange\",i.updateARIAAttributes),e.ready(function(){return i.updateARIAAttributes()}),i}He(e,n);var t=e.prototype;return t.createEl=function(){return n.prototype.createEl.call(this,\"div\",{className:\"vjs-volume-bar vjs-slider-bar\"},{\"aria-label\":this.localize(\"Volume Level\"),\"aria-live\":\"polite\"})},t.handleMouseDown=function(e){W(e)&&n.prototype.handleMouseDown.call(this,e)},t.handleMouseMove=function(e){W(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))},t.checkMuted=function(){this.player_.muted()&&this.player_.muted(!1)},t.getPercent=function(){return this.player_.muted()?0:this.player_.volume()},t.stepForward=function(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)},t.stepBack=function(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)},t.updateARIAAttributes=function(e){var t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute(\"aria-valuenow\",t),this.el_.setAttribute(\"aria-valuetext\",t+\"%\")},t.volumeAsPercentage_=function(){return Math.round(100*this.player_.volume())},t.updateLastVolume_=function(){var e=this,t=this.player_.volume();this.one(\"sliderinactive\",function(){0===e.player_.volume()&&e.player_.lastVolume_(t)})},e}(xn);Bn.prototype.options_={children:[\"volumeLevel\"],barName:\"volumeLevel\"},Bn.prototype.playerEvent=\"volumechange\",Re.registerComponent(\"VolumeBar\",Bn);var jn=function(n){function e(e,t){var i;return void 0===t&&(t={}),t.vertical=t.vertical||!1,\"undefined\"!=typeof t.volumeBar&&!u(t.volumeBar)||(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),i=n.call(this,e,t)||this,function(e,t){t.tech_&&!t.tech_.featuresVolumeControl&&e.addClass(\"vjs-hidden\"),e.on(t,\"loadstart\",function(){t.tech_.featuresVolumeControl?e.removeClass(\"vjs-hidden\"):e.addClass(\"vjs-hidden\")})}(Ue(i),e),i.throttledHandleMouseMove=ve(ge(Ue(i),i.handleMouseMove),30),i.on(\"mousedown\",i.handleMouseDown),i.on(\"touchstart\",i.handleMouseDown),i.on(i.volumeBar,[\"focus\",\"slideractive\"],function(){i.volumeBar.addClass(\"vjs-slider-active\"),i.addClass(\"vjs-slider-active\"),i.trigger(\"slideractive\")}),i.on(i.volumeBar,[\"blur\",\"sliderinactive\"],function(){i.volumeBar.removeClass(\"vjs-slider-active\"),i.removeClass(\"vjs-slider-active\"),i.trigger(\"sliderinactive\")}),i}He(e,n);var t=e.prototype;return t.createEl=function(){var e=\"vjs-volume-horizontal\";return this.options_.vertical&&(e=\"vjs-volume-vertical\"),n.prototype.createEl.call(this,\"div\",{className:\"vjs-volume-control vjs-control \"+e})},t.handleMouseDown=function(e){var t=this.el_.ownerDocument;this.on(t,\"mousemove\",this.throttledHandleMouseMove),this.on(t,\"touchmove\",this.throttledHandleMouseMove),this.on(t,\"mouseup\",this.handleMouseUp),this.on(t,\"touchend\",this.handleMouseUp)},t.handleMouseUp=function(e){var t=this.el_.ownerDocument;this.off(t,\"mousemove\",this.throttledHandleMouseMove),this.off(t,\"touchmove\",this.throttledHandleMouseMove),this.off(t,\"mouseup\",this.handleMouseUp),this.off(t,\"touchend\",this.handleMouseUp)},t.handleMouseMove=function(e){this.volumeBar.handleMouseMove(e)},e}(Re);jn.prototype.options_={children:[\"volumeBar\"]},Re.registerComponent(\"VolumeControl\",jn);var Fn=function(n){function e(e,t){var i;return i=n.call(this,e,t)||this,function(e,t){t.tech_&&!t.tech_.featuresMuteControl&&e.addClass(\"vjs-hidden\"),e.on(t,\"loadstart\",function(){t.tech_.featuresMuteControl?e.removeClass(\"vjs-hidden\"):e.addClass(\"vjs-hidden\")})}(Ue(i),e),i.on(e,[\"loadstart\",\"volumechange\"],i.update),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-mute-control \"+n.prototype.buildCSSClass.call(this)},t.handleClick=function(e){var t=this.player_.volume(),i=this.player_.lastVolume_();if(0===t){var n=i<.1?.1:i;this.player_.volume(n),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())},t.update=function(e){this.updateIcon_(),this.updateControlText_()},t.updateIcon_=function(){var e=this.player_.volume(),t=3;at&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),0===e||this.player_.muted()?t=0:e<.33?t=1:e<.67&&(t=2);for(var i=0;i<4;i++)x(this.el_,\"vjs-vol-\"+i);E(this.el_,\"vjs-vol-\"+t)},t.updateControlText_=function(){var e=this.player_.muted()||0===this.player_.volume()?\"Unmute\":\"Mute\";this.controlText()!==e&&this.controlText(e)},e}(dn);Fn.prototype.controlText_=\"Mute\",Re.registerComponent(\"MuteToggle\",Fn);var Hn=function(n){function e(e,t){var i;return void 0===t&&(t={}),\"undefined\"!=typeof t.inline?t.inline=t.inline:t.inline=!0,\"undefined\"!=typeof t.volumeControl&&!u(t.volumeControl)||(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),(i=n.call(this,e,t)||this).on(e,[\"loadstart\"],i.volumePanelState_),i.on(i.muteToggle,\"keyup\",i.handleKeyPress),i.on(i.volumeControl,\"keyup\",i.handleVolumeControlKeyUp),i.on(\"keydown\",i.handleKeyPress),i.on(\"mouseover\",i.handleMouseOver),i.on(\"mouseout\",i.handleMouseOut),i.on(i.volumeControl,[\"slideractive\"],i.sliderActive_),i.on(i.volumeControl,[\"sliderinactive\"],i.sliderInactive_),i}He(e,n);var t=e.prototype;return t.sliderActive_=function(){this.addClass(\"vjs-slider-active\")},t.sliderInactive_=function(){this.removeClass(\"vjs-slider-active\")},t.volumePanelState_=function(){this.volumeControl.hasClass(\"vjs-hidden\")&&this.muteToggle.hasClass(\"vjs-hidden\")&&this.addClass(\"vjs-hidden\"),this.volumeControl.hasClass(\"vjs-hidden\")&&!this.muteToggle.hasClass(\"vjs-hidden\")&&this.addClass(\"vjs-mute-toggle-only\")},t.createEl=function(){var e=\"vjs-volume-panel-horizontal\";return this.options_.inline||(e=\"vjs-volume-panel-vertical\"),n.prototype.createEl.call(this,\"div\",{className:\"vjs-volume-panel vjs-control \"+e})},t.dispose=function(){this.handleMouseOut(),n.prototype.dispose.call(this)},t.handleVolumeControlKeyUp=function(e){xt.isEventKey(e,\"Esc\")&&this.muteToggle.focus()},t.handleMouseOver=function(e){this.addClass(\"vjs-hover\"),he(h,\"keyup\",ge(this,this.handleKeyPress))},t.handleMouseOut=function(e){this.removeClass(\"vjs-hover\"),de(h,\"keyup\",ge(this,this.handleKeyPress))},t.handleKeyPress=function(e){xt.isEventKey(e,\"Esc\")&&this.handleMouseOut()},e}(Re);Hn.prototype.options_={children:[\"muteToggle\",\"volumeControl\"]},Re.registerComponent(\"VolumePanel\",Hn);var Vn=function(n){function e(e,t){var i;return i=n.call(this,e,t)||this,t&&(i.menuButton_=t.menuButton),i.focusedChild_=-1,i.on(\"keydown\",i.handleKeyDown),i.boundHandleBlur_=ge(Ue(i),i.handleBlur),i.boundHandleTapClick_=ge(Ue(i),i.handleTapClick),i}He(e,n);var t=e.prototype;return t.addEventListenerForItem=function(e){e instanceof Re&&(this.on(e,\"blur\",this.boundHandleBlur_),this.on(e,[\"tap\",\"click\"],this.boundHandleTapClick_))},t.removeEventListenerForItem=function(e){e instanceof Re&&(this.off(e,\"blur\",this.boundHandleBlur_),this.off(e,[\"tap\",\"click\"],this.boundHandleTapClick_))},t.removeChild=function(e){\"string\"==typeof e&&(e=this.getChild(e)),this.removeEventListenerForItem(e),n.prototype.removeChild.call(this,e)},t.addItem=function(e){var t=this.addChild(e);t&&this.addEventListenerForItem(t)},t.createEl=function(){var e=this.options_.contentElType||\"ul\";this.contentEl_=S(e,{className:\"vjs-menu-content\"}),this.contentEl_.setAttribute(\"role\",\"menu\");var t=n.prototype.createEl.call(this,\"div\",{append:this.contentEl_,className:\"vjs-menu\"});return t.appendChild(this.contentEl_),he(t,\"click\",function(e){e.preventDefault(),e.stopImmediatePropagation()}),t},t.dispose=function(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,n.prototype.dispose.call(this)},t.handleBlur=function(e){var t=e.relatedTarget||h.activeElement;if(!this.children().some(function(e){return e.el()===t})){var i=this.menuButton_;i&&i.buttonPressed_&&t!==i.el().firstChild&&i.unpressButton()}},t.handleTapClick=function(t){if(this.menuButton_){this.menuButton_.unpressButton();var e=this.children();if(!Array.isArray(e))return;var i=e.filter(function(e){return e.el()===t.target})[0];if(!i)return;\"CaptionSettingsMenuItem\"!==i.name()&&this.menuButton_.focus()}},t.handleKeyDown=function(e){xt.isEventKey(e,\"Left\")||xt.isEventKey(e,\"Down\")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(xt.isEventKey(e,\"Right\")||xt.isEventKey(e,\"Up\"))&&(e.preventDefault(),e.stopPropagation(),this.stepBack())},t.stepForward=function(){var e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_+1),this.focus(e)},t.stepBack=function(){var e=0;void 0!==this.focusedChild_&&(e=this.focusedChild_-1),this.focus(e)},t.focus=function(e){void 0===e&&(e=0);var t=this.children().slice();t.length&&t[0].className&&/vjs-menu-title/.test(t[0].className)&&t.shift(),0=t.length&&(e=t.length-1),t[this.focusedChild_=e].el_.focus())},e}(Re);Re.registerComponent(\"Menu\",Vn);var qn=function(r){function e(e,t){var i;void 0===t&&(t={}),(i=r.call(this,e,t)||this).menuButton_=new dn(e,t),i.menuButton_.controlText(i.controlText_),i.menuButton_.el_.setAttribute(\"aria-haspopup\",\"true\");var n=dn.prototype.buildCSSClass();return i.menuButton_.el_.className=i.buildCSSClass()+\" \"+n,i.menuButton_.removeClass(\"vjs-control\"),i.addChild(i.menuButton_),i.update(),i.enabled_=!0,i.on(i.menuButton_,\"tap\",i.handleClick),i.on(i.menuButton_,\"click\",i.handleClick),i.on(i.menuButton_,\"keydown\",i.handleKeyDown),i.on(i.menuButton_,\"mouseenter\",function(){i.addClass(\"vjs-hover\"),i.menu.show(),he(h,\"keyup\",ge(Ue(i),i.handleMenuKeyUp))}),i.on(\"mouseleave\",i.handleMouseLeave),i.on(\"keydown\",i.handleSubmenuKeyDown),i}He(e,r);var t=e.prototype;return t.update=function(){var e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute(\"aria-expanded\",\"false\"),this.items&&this.items.length<=this.hideThreshold_?this.hide():this.show()},t.createMenu=function(){var e=new Vn(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){var t=S(\"li\",{className:\"vjs-menu-title\",innerHTML:De(this.options_.title),tabIndex:-1});this.hideThreshold_+=1;var i=new Re(this.player_,{el:t});e.addItem(i)}if(this.items=this.createItems(),this.items)for(var n=0;n'+this.localize(this.options_.label)+\"\",tabIndex:-1},t),i)},t.handleKeyDown=function(t){zn.some(function(e){return xt.isEventKey(t,e)})||n.prototype.handleKeyDown.call(this,t)},t.handleClick=function(e){this.selected(!0)},t.selected=function(e){this.selectable&&(e?(this.addClass(\"vjs-selected\"),this.el_.setAttribute(\"aria-checked\",\"true\"),this.controlText(\", selected\"),this.isSelected_=!0):(this.removeClass(\"vjs-selected\"),this.el_.setAttribute(\"aria-checked\",\"false\"),this.controlText(\"\"),this.isSelected_=!1))},e}(rn);Re.registerComponent(\"MenuItem\",Gn);var Xn=function(u){function e(e,t){var n,i=t.track,r=e.textTracks();t.label=i.label||i.language||\"Unknown\",t.selected=\"showing\"===i.mode,(n=u.call(this,e,t)||this).track=i,n.kinds=(t.kinds||[t.kind||n.track.kind]).filter(Boolean);function s(){for(var e=arguments.length,t=new Array(e),i=0;i\\n '+this.localize(\"Captions\")+\"\\n \"),n+=\"\",r.prototype.createEl.call(this,e,m({innerHTML:n},t),i)},e}(Xn);Re.registerComponent(\"SubsCapsMenuItem\",ir);var nr=function(n){function e(e,t){var i;return void 0===t&&(t={}),(i=n.call(this,e,t)||this).label_=\"subtitles\",-1<[\"en\",\"en-us\",\"en-ca\",\"fr-ca\"].indexOf(i.player_.language_)&&(i.label_=\"captions\"),i.menuButton_.controlText(De(i.label_)),i}He(e,n);var t=e.prototype;return t.buildCSSClass=function(){return\"vjs-subs-caps-button \"+n.prototype.buildCSSClass.call(this)},t.buildWrapperCSSClass=function(){return\"vjs-subs-caps-button \"+n.prototype.buildWrapperCSSClass.call(this)},t.createItems=function(){var e=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild(\"textTrackSettings\")||(e.push(new er(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=n.prototype.createItems.call(this,e,ir)},e}(Yn);nr.prototype.kinds_=[\"captions\",\"subtitles\"],nr.prototype.controlText_=\"Subtitles\",Re.registerComponent(\"SubsCapsButton\",nr);var rr=function(a){function e(e,t){var n,i=t.track,r=e.audioTracks();t.label=i.label||i.language||\"Unknown\",t.selected=i.enabled,(n=a.call(this,e,t)||this).track=i,n.addClass(\"vjs-\"+i.kind+\"-menu-item\");function s(){for(var e=arguments.length,t=new Array(e),i=0;i\\n '+this.localize(\"Descriptions\")+\"\\n \"),n+=\"\",a.prototype.createEl.call(this,e,m({innerHTML:n},t),i)},t.handleClick=function(e){var t=this.player_.audioTracks();a.prototype.handleClick.call(this,e);for(var i=0;it){n=i[r];break}this.player().playbackRate(n)},t.playbackRates=function(){return this.options_.playbackRates||this.options_.playerOptions&&this.options_.playerOptions.playbackRates},t.playbackRateSupported=function(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&0 select\",id:\"captions-background-color-%s\",label:\"Color\",options:[pr,_r,yr,gr,fr,br,vr,mr]},backgroundOpacity:{selector:\".vjs-bg-opacity > select\",id:\"captions-background-opacity-%s\",label:\"Transparency\",options:[Tr,Sr,kr]},color:{selector:\".vjs-fg-color > select\",id:\"captions-foreground-color-%s\",label:\"Color\",options:[_r,pr,yr,gr,fr,br,vr,mr]},edgeStyle:{selector:\".vjs-edge-style > select\",id:\"%s\",label:\"Text Edge Style\",options:[[\"none\",\"None\"],[\"raised\",\"Raised\"],[\"depressed\",\"Depressed\"],[\"uniform\",\"Uniform\"],[\"dropshadow\",\"Dropshadow\"]]},fontFamily:{selector:\".vjs-font-family > select\",id:\"captions-font-family-%s\",label:\"Font Family\",options:[[\"proportionalSansSerif\",\"Proportional Sans-Serif\"],[\"monospaceSansSerif\",\"Monospace Sans-Serif\"],[\"proportionalSerif\",\"Proportional Serif\"],[\"monospaceSerif\",\"Monospace Serif\"],[\"casual\",\"Casual\"],[\"script\",\"Script\"],[\"small-caps\",\"Small Caps\"]]},fontPercent:{selector:\".vjs-font-percent > select\",id:\"captions-font-size-%s\",label:\"Font Size\",options:[[\"0.50\",\"50%\"],[\"0.75\",\"75%\"],[\"1.00\",\"100%\"],[\"1.25\",\"125%\"],[\"1.50\",\"150%\"],[\"1.75\",\"175%\"],[\"2.00\",\"200%\"],[\"3.00\",\"300%\"],[\"4.00\",\"400%\"]],default:2,parser:function(e){return\"1.00\"===e?null:Number(e)}},textOpacity:{selector:\".vjs-text-opacity > select\",id:\"captions-foreground-opacity-%s\",label:\"Transparency\",options:[Tr,Sr]},windowColor:{selector:\".vjs-window-color > select\",id:\"captions-window-color-%s\",label:\"Color\"},windowOpacity:{selector:\".vjs-window-opacity > select\",id:\"captions-window-opacity-%s\",label:\"Transparency\",options:[kr,Sr,Tr]}};function wr(e,t){if(t&&(e=t(e)),e&&\"none\"!==e)return e}Cr.windowColor.options=Cr.backgroundColor.options;var Er=function(n){function e(e,t){var i;return t.temporary=!1,(i=n.call(this,e,t)||this).updateDisplay=ge(Ue(i),i.updateDisplay),i.fill(),i.hasBeenOpened_=i.hasBeenFilled_=!0,i.endDialog=S(\"p\",{className:\"vjs-control-text\",textContent:i.localize(\"End of dialog window.\")}),i.el().appendChild(i.endDialog),i.setDefaults(),void 0===t.persistTextTrackSettings&&(i.options_.persistTextTrackSettings=i.options_.playerOptions.persistTextTrackSettings),i.on(i.$(\".vjs-done-button\"),\"click\",function(){i.saveSettings(),i.close()}),i.on(i.$(\".vjs-default-button\"),\"click\",function(){i.setDefaults(),i.updateDisplay()}),a(Cr,function(e){i.on(i.$(e.selector),\"change\",i.updateDisplay)}),i.options_.persistTextTrackSettings&&i.restoreSettings(),i}He(e,n);var t=e.prototype;return t.dispose=function(){this.endDialog=null,n.prototype.dispose.call(this)},t.createElSelect_=function(e,t,i){var n=this;void 0===t&&(t=\"\"),void 0===i&&(i=\"label\");var r=Cr[e],s=r.id.replace(\"%s\",this.id_),a=[t,s].join(\" \").trim();return[\"<\"+i+' id=\"'+s+'\" class=\"'+(\"label\"===i?\"vjs-label\":\"\")+'\">',this.localize(r.label),\"\",'\").join(\"\")},t.createElFgColor_=function(){var e=\"captions-text-legend-\"+this.id_;return['
','',this.localize(\"Text\"),\"\",this.createElSelect_(\"color\",e),'',this.createElSelect_(\"textOpacity\",e),\"\",\"
\"].join(\"\")},t.createElBgColor_=function(){var e=\"captions-background-\"+this.id_;return['
','',this.localize(\"Background\"),\"\",this.createElSelect_(\"backgroundColor\",e),'',this.createElSelect_(\"backgroundOpacity\",e),\"\",\"
\"].join(\"\")},t.createElWinColor_=function(){var e=\"captions-window-\"+this.id_;return['
','',this.localize(\"Window\"),\"\",this.createElSelect_(\"windowColor\",e),'',this.createElSelect_(\"windowOpacity\",e),\"\",\"
\"].join(\"\")},t.createElColors_=function(){return S(\"div\",{className:\"vjs-track-settings-colors\",innerHTML:[this.createElFgColor_(),this.createElBgColor_(),this.createElWinColor_()].join(\"\")})},t.createElFont_=function(){return S(\"div\",{className:\"vjs-track-settings-font\",innerHTML:['
',this.createElSelect_(\"fontPercent\",\"\",\"legend\"),\"
\",'
',this.createElSelect_(\"edgeStyle\",\"\",\"legend\"),\"
\",'
',this.createElSelect_(\"fontFamily\",\"\",\"legend\"),\"
\"].join(\"\")})},t.createElControls_=function(){var e=this.localize(\"restore all settings to the default values\");return S(\"div\",{className:\"vjs-track-settings-controls\",innerHTML:['\",'\"].join(\"\")})},t.content=function(){return[this.createElColors_(),this.createElFont_(),this.createElControls_()]},t.label=function(){return this.localize(\"Caption Settings Dialog\")},t.description=function(){return this.localize(\"Beginning of dialog window. Escape will cancel and close the window.\")},t.buildCSSClass=function(){return n.prototype.buildCSSClass.call(this)+\" vjs-text-track-settings\"},t.getValues=function(){var r=this;return function(i,n,e){return void 0===e&&(e=0),s(i).reduce(function(e,t){return n(e,i[t],t)},e)}(Cr,function(e,t,i){var n=function(e,t){return wr(e.options[e.options.selectedIndex].value,t)}(r.$(t.selector),t.parser);return void 0!==n&&(e[i]=n),e},{})},t.setValues=function(i){var n=this;a(Cr,function(e,t){!function(e,t,i){if(t)for(var n=0;nthis.options_.liveTolerance;this.timeupdateSeen_&&n!==1/0||(s=!1),s!==this.behindLiveEdge_&&(this.behindLiveEdge_=s,this.trigger(\"liveedgechange\"))}},t.handleDurationchange=function(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass(\"vjs-liveui\"),this.startTracking()):(this.player_.removeClass(\"vjs-liveui\"),this.stopTracking())},t.startTracking=function(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLive_,30),this.trackLive_(),this.on(this.player_,[\"play\",\"pause\"],this.trackLive_),this.timeupdateSeen_?this.on(this.player_,\"seeked\",this.handleSeeked):(this.one(this.player_,\"play\",this.handlePlay),this.one(this.player_,\"timeupdate\",this.handleFirstTimeupdate)))},t.handleFirstTimeupdate=function(){this.timeupdateSeen_=!0,this.on(this.player_,\"seeked\",this.handleSeeked)},t.handleSeeked=function(){var e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=!this.skipNextSeeked_&&2\":switch(u){case xs:i.setTagName(e.slice(t,o));case Os:case Ds:case Ns:break;case Ls:case As:\"/\"===(c=e.slice(t,o)).slice(-1)&&(i.closed=!0,c=c.slice(0,-1));case Is:u===Is&&(c=a),u==Ls?(s.warning('attribute \"'+c+'\" missed quot(\")!!'),i.add(a,c.replace(/&#?\\w+;/g,r),t)):(\"http://www.w3.org/1999/xhtml\"===n[\"\"]&&c.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute \"'+c+'\" missed value!! \"'+c+'\" instead!!'),i.add(c,c,t));break;case Ps:throw new Error(\"attribute value missed!!\")}return o;case\"€\":l=\" \";default:if(l<=\" \")switch(u){case xs:i.setTagName(e.slice(t,o)),u=Ds;break;case As:a=e.slice(t,o),u=Is;break;case Ls:var c=e.slice(t,o).replace(/&#?\\w+;/g,r);s.warning('attribute \"'+c+'\" missed quot(\")!!'),i.add(a,c,t);case Os:u=Ds}else switch(u){case Is:i.tagName;\"http://www.w3.org/1999/xhtml\"===n[\"\"]&&a.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute \"'+a+'\" missed value!! \"'+a+'\" instead2!!'),i.add(a,a,t),t=o,u=As;break;case Os:s.warning('attribute space is required\"'+a+'\"!!');case Ds:u=As,t=o;break;case Ps:u=Ls,t=o;break;case Ns:throw new Error(\"elements closed character '/' and '>' must be connected to\")}}o++}}function Bs(e,t,i){for(var n=e.tagName,r=null,s=e.length;s--;){var a=e[s],o=a.qName,u=a.value;if(0<(d=o.indexOf(\":\")))var l=a.prefix=o.slice(0,d),c=o.slice(d+1),h=\"xmlns\"===l&&c;else l=null,h=\"xmlns\"===(c=o)&&\"\";a.localName=c,!1!==h&&(null==r&&(r={},Hs(i,i={})),i[h]=r[h]=u,a.uri=\"http://www.w3.org/2000/xmlns/\",t.startPrefixMapping(h,u))}for(s=e.length;s--;){(l=(a=e[s]).prefix)&&(\"xml\"===l&&(a.uri=\"http://www.w3.org/XML/1998/namespace\"),\"xmlns\"!==l&&(a.uri=i[l||\"\"]))}var d;c=0<(d=n.indexOf(\":\"))?(l=e.prefix=n.slice(0,d),e.localName=n.slice(d+1)):(l=null,e.localName=n);var p=e.uri=i[l||\"\"];if(t.startElement(p,c,n,e),!e.closed)return e.currentNSMap=i,e.localNSMap=r,!0;if(t.endElement(p,c,n),r)for(l in r)t.endPrefixMapping(l)}function js(e,t,i,n,r){if(/^(?:script|textarea)$/i.test(i)){var s=e.indexOf(\"\",t),a=e.substring(t+1,s);if(/[&<]/.test(a))return/^script$/i.test(i)||(a=a.replace(/&#?\\w+;/g,n)),r.characters(a,0,a.length),s}return t+1}function Fs(e,t,i,n){var r=n[i];return null==r&&((r=e.lastIndexOf(\"\"))\",t+9);return i.startCDATA(),i.characters(e,t+9,r-t-9),i.endCDATA(),r+3}var s=function(e,t){var i,n=[],r=/'[^']+'|\"[^\"]+\"|[^\\s<>\\/=]+=?|(\\/?\\s*>|<)/g;r.lastIndex=t,r.exec(e);for(;i=r.exec(e);)if(n.push(i),i[1])return n}(e,t),a=s.length;if(1\",t);if(n){var r=e.substring(t,n).match(/^<\\?(\\S*)\\s*([\\s\\S]*?)\\s*$/);if(r){r[0].length;return i.processingInstruction(r[1],r[2]),n+2}return-1}return-1}function Ws(e){}function zs(e,t){return e.__proto__=t,e}Rs.prototype={parse:function(e,t,i){var n=this.domBuilder;n.startDocument(),Hs(t,t={}),function(i,e,n,r,s){function a(e){var t=e.slice(1,-1);return t in n?n[t]:\"#\"===t.charAt(0)?function(e){if(65535>10),i=56320+(1023&e);return String.fromCharCode(t,i)}return String.fromCharCode(e)}(parseInt(t.substr(1).replace(\"x\",\"0x\"))):(s.error(\"entity not found:\"+e),e)}function t(e){if(f\",m+3),_=i.substring(m+2,y),b=d.pop();y<0?(_=i.substring(m+2).replace(/[\\s<].*/,\"\"),s.error(\"end tag name: \"+_+\" is not complete:\"+b.tagName),y=m+1+_.length):_.match(/\\s\"==e&&\">\")||\"&\"==e&&\"&\"||'\"'==e&&\""\"||\"&#\"+e.charCodeAt()+\";\"}function wa(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(wa(e,t))return!0}while(e=e.nextSibling)}function Ea(){}function xa(e,t,i){e&&e._inc++,\"http://www.w3.org/2000/xmlns/\"==i.namespaceURI&&delete t._nsMap[i.prefix?i.localName:\"\"]}function Aa(e,t,i){if(e&&e._inc){e._inc++;var n=t.childNodes;if(i)n[n.length++]=i;else{for(var r=t.firstChild,s=0;r;)r=(n[s++]=r).nextSibling;n.length=s}}}function Ia(e,t){var i=t.previousSibling,n=t.nextSibling;return i?i.nextSibling=n:e.firstChild=n,n?n.previousSibling=i:e.lastChild=i,Aa(e.ownerDocument,e),t}function Pa(e,t,i){var n=t.parentNode;if(n&&n.removeChild(t),t.nodeType===oa){var r=t.firstChild;if(null==r)return t;var s=t.lastChild}else r=s=t;var a=i?i.previousSibling:e.lastChild;for(r.previousSibling=a,s.nextSibling=i,a?a.nextSibling=r:e.firstChild=r,null==i?e.lastChild=s:i.previousSibling=s;r.parentNode=e,r!==s&&(r=r.nextSibling););return Aa(e.ownerDocument||e,e),t.nodeType==oa&&(t.firstChild=t.lastChild=null),t}function La(){this._nsMap={}}function Oa(){}function Da(){}function Na(){}function Ra(){}function Ua(){}function Ma(){}function Ba(){}function ja(){}function Fa(){}function Ha(){}function Va(){}function qa(){}function Wa(e,t){var i=[],n=9==this.nodeType?this.documentElement:this,r=n.prefix,s=n.namespaceURI;if(s&&null==r&&null==(r=n.lookupPrefix(s)))var a=[{namespace:s,prefix:null}];return Ga(this,i,e,t,a),i.join(\"\")}function za(e,t,i){var n=e.prefix||\"\",r=e.namespaceURI;if(!n&&!r)return!1;if(\"xml\"===n&&\"http://www.w3.org/XML/1998/namespace\"===r||\"http://www.w3.org/2000/xmlns/\"==r)return!1;for(var s=i.length;s--;){var a=i[s];if(a.prefix==n)return a.namespace!=r}return!0}function Ga(e,t,i,n,r){if(n){if(!(e=n(e)))return;if(\"string\"==typeof e)return void t.push(e)}switch(e.nodeType){case Qs:r=r||[];var s=e.attributes,a=s.length,o=e.firstChild,u=e.tagName;i=Ys===e.namespaceURI||i,t.push(\"<\",u);for(var l=0;l\"),i&&/^script$/i.test(u))for(;o;)o.data?t.push(o.data):Ga(o,t,i,n,r),o=o.nextSibling;else for(;o;)Ga(o,t,i,n,r),o=o.nextSibling;t.push(\"\")}else t.push(\"/>\");return;case sa:case oa:for(o=e.firstChild;o;)Ga(o,t,i,n,r),o=o.nextSibling;return;case Js:return t.push(\" \",e.name,'=\"',e.value.replace(/[<&\"]/g,Ca),'\"');case Zs:return t.push(e.data.replace(/[<&]/g,Ca));case ea:return t.push(\"\");case ra:return t.push(\"\\x3c!--\",e.data,\"--\\x3e\");case aa:var f=e.publicId,m=e.systemId;if(t.push(\"');else if(m&&\".\"!=m)t.push(' SYSTEM \"',m,'\">');else{var g=e.internalSubset;g&&t.push(\" [\",g,\"]\"),t.push(\">\")}return;case na:return t.push(\"\");case ta:return t.push(\"&\",e.nodeName,\";\");default:t.push(\"??\",e.nodeName)}}function Xa(e,t,i){e[t]=i}fa.prototype=Error.prototype,Xs(la,fa),ma.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var i=[],n=0;nt.attributes.bandwidth||(e[r]={language:n,autoselect:!0,default:\"main\"===i,playlists:no([function(e){var t,i=e.attributes,n=e.segments,r=e.sidx,s={attributes:(t={NAME:i.id,BANDWIDTH:i.bandwidth,CODECS:i.codecs},t[\"PROGRAM-ID\"]=1,t),uri:\"\",endList:\"static\"===(i.type||\"static\"),timeline:i.periodIndex,resolvedUri:\"\",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1};return i.contentProtection&&(s.contentProtection=i.contentProtection),r&&(s.sidx=r),s}(t)],a),uri:\"\"},\"undefined\"==typeof o&&\"main\"===i&&((o=t).default=!0)),e},{});o||(t[Object.keys(t)[0]].default=!0);return t}(h,t)),d.length&&(p.mediaGroups.SUBTITLES.subs=function(e,n){return void 0===n&&(n={}),e.reduce(function(e,t){var i=t.attributes.lang||\"text\";return e[i]||(e[i]={language:i,default:!1,autoselect:!1,playlists:no([function(e){var t,i=e.attributes,n=e.segments;return\"undefined\"==typeof n&&(n=[{uri:i.baseUrl,timeline:i.periodIndex,resolvedUri:i.baseUrl||\"\",duration:i.sourceDuration,number:0}],i.duration=i.sourceDuration),{attributes:(t={NAME:i.id,BANDWIDTH:i.bandwidth},t[\"PROGRAM-ID\"]=1,t),uri:\"\",endList:\"static\"===(i.type||\"static\"),timeline:i.periodIndex,resolvedUri:i.baseUrl||\"\",targetDuration:i.duration,segments:n,mediaSequence:n.length?n[0].number:1}}(t)],n),uri:\"\"}),e},{})}(d,t)),p}function ao(e,t){for(var i,n,r,s,a,o,u,l,c,h,d,p,f=e.type,m=void 0===f?\"static\":f,g=e.minimumUpdatePeriod,v=void 0===g?0:g,y=e.media,_=void 0===y?\"\":y,b=e.sourceDuration,T=e.timescale,S=void 0===T?1:T,k=e.startNumber,C=void 0===k?1:k,w=e.periodIndex,E=[],x=-1,A=0;A>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}function wo(e){var t=\"\";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),t+=String.fromCharCode(e[2]),t+=String.fromCharCode(e[3])}var Eo,xo,Ao,Io,Po,Lo,Oo,Do={DOMImplementation:Sa,XMLSerializer:qa},No=t(function(e,t){function i(e){this.options=e||{locator:{}}}function l(){this.cdata=!1}function c(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function h(e){if(e)return\"\\n@\"+(e.systemId||\"\")+\"#[line:\"+e.lineNumber+\",col:\"+e.columnNumber+\"]\"}function r(e,t,i){return\"string\"==typeof e?e.substr(t,i):e.length>=t+i||t?new java.lang.String(e,t,i)+\"\":e}function d(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}i.prototype.parseFromString=function(e,t){var i=this.options,n=new p,r=i.domBuilder||new l,s=i.errorHandler,a=i.locator,o=i.xmlns||{},u={lt:\"<\",gt:\">\",amp:\"&\",quot:'\"',apos:\"'\"};return a&&r.setDocumentLocator(a),n.errorHandler=function(n,e,r){if(!n){if(e instanceof l)return e;n=e}var s={},a=n instanceof Function;function t(t){var i=n[t];!i&&a&&(i=2==n.length?function(e){n(t,e)}:n),s[t]=i&&function(e){i(\"[xmldom \"+t+\"]\\t\"+e+h(r))}||function(){}}return r=r||{},t(\"warning\"),t(\"error\"),t(\"fatalError\"),s}(s,r,a),n.domBuilder=i.domBuilder||r,/\\/x?html?$/.test(t)&&(u.nbsp=\" \",u.copy=\"©\",o[\"\"]=\"http://www.w3.org/1999/xhtml\"),o.xml=o.xml||\"http://www.w3.org/XML/1998/namespace\",e?n.parse(e,o,u):n.errorHandler.error(\"invalid doc source\"),r.doc},l.prototype={startDocument:function(){this.doc=(new n).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,i,n){var r=this.doc,s=r.createElementNS(e,i||t),a=n.length;d(this,s),this.currentElement=s,this.locator&&c(this.locator,s);for(var o=0;o>>0},Xo=function(e){return(\"00\"+e.toString(16)).slice(-2)},Ko=Go,Yo={avc1:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{dataReferenceIndex:t.getUint16(6),width:t.getUint16(24),height:t.getUint16(26),horizresolution:t.getUint16(28)+t.getUint16(30)/16,vertresolution:t.getUint16(32)+t.getUint16(34)/16,frameCount:t.getUint16(40),depth:t.getUint16(74),config:Eo(e.subarray(78,e.byteLength))}},avcC:function(e){var t,i,n,r,s=new DataView(e.buffer,e.byteOffset,e.byteLength),a={configurationVersion:e[0],avcProfileIndication:e[1],profileCompatibility:e[2],avcLevelIndication:e[3],lengthSizeMinusOne:3&e[4],sps:[],pps:[]},o=31&e[5];for(n=6,r=0;r>>2&63,bufferSize:e[13]<<16|e[14]<<8|e[15],maxBitrate:e[16]<<24|e[17]<<16|e[18]<<8|e[19],avgBitrate:e[20]<<24|e[21]<<16|e[22]<<8|e[23],decoderConfigDescriptor:{tag:e[24],length:e[25],audioObjectType:e[26]>>>3&31,samplingFrequencyIndex:(7&e[26])<<1|e[27]>>>7&1,channelConfiguration:e[27]>>>3&15}}}},ftyp:function(e){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i={majorBrand:wo(e.subarray(0,4)),minorVersion:t.getUint32(4),compatibleBrands:[]},n=8;nMALFORMED DATA\");else switch(31&e[t]){case 1:r.push(\"slice_layer_without_partitioning_rbsp\");break;case 5:r.push(\"slice_layer_without_partitioning_rbsp_idr\");break;case 6:r.push(\"sei_rbsp\");break;case 7:r.push(\"seq_parameter_set_rbsp\");break;case 8:r.push(\"pic_parameter_set_rbsp\");break;case 9:r.push(\"access_unit_delimiter_rbsp\");break;default:r.push(\"UNKNOWN NAL - \"+e[t]&31)}return r}(e)}},mdhd:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n=4,r={version:i.getUint8(0),flags:new Uint8Array(e.subarray(1,4)),language:\"\"};return 1===r.version?(n+=4,r.creationTime=ko(i.getUint32(n)),n+=8,r.modificationTime=ko(i.getUint32(n)),n+=4,r.timescale=i.getUint32(n),n+=8):(r.creationTime=ko(i.getUint32(n)),n+=4,r.modificationTime=ko(i.getUint32(n)),n+=4,r.timescale=i.getUint32(n),n+=4),r.duration=i.getUint32(n),n+=4,t=i.getUint16(n),r.language+=String.fromCharCode(96+(t>>10)),r.language+=String.fromCharCode(96+((992&t)>>5)),r.language+=String.fromCharCode(96+(31&t)),r},mdia:function(e){return{boxes:Eo(e)}},mfhd:function(e){return{version:e[0],flags:new Uint8Array(e.subarray(1,4)),sequenceNumber:e[4]<<24|e[5]<<16|e[6]<<8|e[7]}},minf:function(e){return{boxes:Eo(e)}},mp4a:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),i={dataReferenceIndex:t.getUint16(6),channelcount:t.getUint16(16),samplesize:t.getUint16(18),samplerate:t.getUint16(24)+t.getUint16(26)/65536};return 28>4,isDependedOn:(12&e[t])>>2,hasRedundancy:3&e[t]});return i},sidx:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8),earliestPresentationTime:i.getUint32(12),firstOffset:i.getUint32(16)},r=i.getUint16(22);for(t=24;r;t+=12,r--)n.references.push({referenceType:(128&e[t])>>>7,referencedSize:2147483647&i.getUint32(t),subsegmentDuration:i.getUint32(t+4),startsWithSap:!!(128&e[t+8]),sapType:(112&e[t+8])>>>4,sapDeltaTime:268435455&i.getUint32(t+8)});return n},smhd:function(e){return{version:e[0],flags:new Uint8Array(e.subarray(1,4)),balance:e[4]+e[5]/256}},stbl:function(e){return{boxes:Eo(e)}},stco:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),chunkOffsets:[]},r=i.getUint32(4);for(t=8;r;t+=4,r--)n.chunkOffsets.push(i.getUint32(t));return n},stsc:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n=i.getUint32(4),r={version:e[0],flags:new Uint8Array(e.subarray(1,4)),sampleToChunks:[]};for(t=8;n;t+=12,n--)r.sampleToChunks.push({firstChunk:i.getUint32(t),samplesPerChunk:i.getUint32(t+4),sampleDescriptionIndex:i.getUint32(t+8)});return r},stsd:function(e){return{version:e[0],flags:new Uint8Array(e.subarray(1,4)),sampleDescriptions:Eo(e.subarray(8))}},stsz:function(e){var t,i=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),sampleSize:i.getUint32(4),entries:[]};for(t=12;t>6,sampleHasRedundancy:(48&e[21])>>4,samplePaddingValue:(14&e[21])>>1,sampleIsDifferenceSample:!!(1&e[21]),sampleDegradationPriority:t.getUint16(22)}},trun:function(e){var t,i={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=1&i.flags[2],s=4&i.flags[2],a=1&i.flags[1],o=2&i.flags[1],u=4&i.flags[1],l=8&i.flags[1],c=n.getUint32(4),h=8;for(r&&(i.dataOffset=n.getInt32(h),h+=4),s&&c&&(t={flags:Co(e.subarray(h,h+4))},h+=4,a&&(t.duration=n.getUint32(h),h+=4),o&&(t.size=n.getUint32(h),h+=4),l&&(t.compositionTimeOffset=n.getUint32(h),h+=4),i.samples.push(t),c--);c--;)t={},a&&(t.duration=n.getUint32(h),h+=4),o&&(t.size=n.getUint32(h),h+=4),u&&(t.flags=Co(e.subarray(h,h+4)),h+=4),l&&(t.compositionTimeOffset=n.getUint32(h),h+=4),i.samples.push(t);return i},\"url \":function(e){return{version:e[0],flags:new Uint8Array(e.subarray(1,4))}},vmhd:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{version:e[0],flags:new Uint8Array(e.subarray(1,4)),graphicsmode:t.getUint16(4),opcolor:new Uint16Array([t.getUint16(6),t.getUint16(8),t.getUint16(10)])}}},$o={inspect:Eo=function(e){for(var t,i,n,r,s,a=0,o=[],u=new ArrayBuffer(e.length),l=new Uint8Array(u),c=0;c\":t+\"<\\n\"+n.map(function(e){return s+\" \"+e}).join(\"\\n\")+\"\\n\"+s+\" >\":t+\"<>\"}return t+JSON.stringify(i,null,2).split(\"\\n\").map(function(e,t){return 0===t?e:s+\" \"+e}).join(\"\\n\")}).join(\"\\n\")+(r.boxes?\"\\n\"+xo(r.boxes,t+1):\"\")}).join(\"\\n\")},parseType:wo,findBox:function e(t,i){var n,r,s,a,o,u=[];if(!i.length)return null;for(n=0;n>>2&63).replace(/^0/,\"\")):n.codec=\"mp4a.40.2\"))}var h=$o.findBox(e,[\"mdia\",\"mdhd\"])[0];if(h&&r){var d=0===i?12:20;n.timescale=Qo(h[d]<<24|h[1+d]<<16|h[2+d]<<8|h[3+d])}p.push(n)}),p};function Zo(){this.init=function(){var s={};this.on=function(e,t){s[e]||(s[e]=[]),s[e]=s[e].concat(t)},this.off=function(e,t){var i;return!!s[e]&&(i=s[e].indexOf(t),s[e]=s[e].slice(),s[e].splice(i,1),-1>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_=\"popOn\";else if(t===this.END_OF_CAPTION_)this.mode_=\"popOn\",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)\"popOn\"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=lu();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=lu();else if(t===this.RESUME_DIRECT_CAPTIONING_)\"paintOn\"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=lu()),this.mode_=\"paintOn\",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))s=uu((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isExtCharacter(n,r))\"popOn\"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),s=uu((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts,\" \"),this.column_++,14==(14&r)&&this.addFormatting(e.pts,[\"i\"]),1==(1&r)&&this.addFormatting(e.pts,[\"u\"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var a=hu.indexOf(7968&t);\"rollUp\"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(e.pts,a)),a!==this.row_&&(this.clearFormatting(e.pts),this.row_=a),1&r&&-1===this.formatting_.indexOf(\"u\")&&this.addFormatting(e.pts,[\"u\"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,[\"i\"])}else this.isNormalChar(n)&&(0===r&&(r=null),s=uu(n),s+=uu(r),this[this.mode_](e.pts,s),this.column_+=s.length)}else this.lastControlCode_=null}};du.prototype=new ou,du.prototype.flushDisplayed=function(e){var t=this.displayed_.map(function(e){try{return e.trim()}catch(e){return\"\"}}).join(\"\\n\").replace(/^\\n+|\\n+$/g,\"\");t.length&&this.trigger(\"data\",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},du.prototype.reset=function(){this.mode_=\"popOn\",this.topRow_=0,this.startPts_=0,this.displayed_=lu(),this.nonDisplayed_=lu(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},du.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},du.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&48<=t&&t<=63},du.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&32<=t&&t<=63},du.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&32<=t&&t<=47},du.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&33<=t&&t<=35},du.prototype.isPAC=function(e,t){return e>=this.BASE_&&e\"},\"\");this[this.mode_](e,i)},du.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce(function(e,t){return e+\"\"},\"\");this.formatting_=[],this[this.mode_](e,t)}},du.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},du.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i},du.prototype.shiftRowsUp_=function(){var e;for(e=0;e>>4&&(t+=e[4]+1),t}function wu(e){switch(e){case 5:return\"slice_layer_without_partitioning_rbsp_idr\";case 6:return\"sei_rbsp\";case 7:return\"seq_parameter_set_rbsp\";case 8:return\"pic_parameter_set_rbsp\";case 9:return\"access_unit_delimiter_rbsp\";default:return null}}function Eu(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]}var xu,Au,Iu,Pu,Lu={parseType:function(e,t){var i=Su(e);return 0===i?\"pat\":i===t?\"pmt\":t?\"pes\":null},parsePat:function(e){var t=ku(e),i=4+Cu(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},parsePmt:function(e){var t={},i=ku(e),n=4+Cu(e);if(i&&(n+=e[n]+1),1&e[n+5]){var r;r=3+((15&e[n+1])<<8|e[n+2])-4;for(var s=12+((15&e[n+10])<<8|e[n+11]);s=e.byteLength)return null;var i,n=null;return 192&(i=e[t+7])&&((n={}).pts=(14&e[t+9])<<27|(255&e[t+10])<<20|(254&e[t+11])<<12|(255&e[t+12])<<5|(254&e[t+13])>>>3,n.pts*=4,n.pts+=(6&e[t+13])>>>1,n.dts=n.pts,64&i&&(n.dts=(14&e[t+14])<<27|(255&e[t+15])<<20|(254&e[t+16])<<12|(255&e[t+17])<<5|(254&e[t+18])>>>3,n.dts*=4,n.dts+=(6&e[t+18])>>>1)),n},videoPacketContainsKeyFrame:function(e){for(var t=4+Cu(e),i=e.subarray(t),n=0,r=0,s=!1;r>4?20+i:10+i},parseAdtsSize:function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i},parseType:function(e,t){return e[t]===\"I\".charCodeAt(0)&&e[t+1]===\"D\".charCodeAt(0)&&e[t+2]===\"3\".charCodeAt(0)?\"timed-metadata\":!0&e[t]&&240==(240&e[t+1])?\"audio\":null},parseSampleRate:function(e){for(var t=0;t+5>>2];t++}return null},parseAacTimestamp:function(e){var t,i,n;t=10,64&e[5]&&(t+=4,t+=Eu(e.subarray(10,14)));do{if((i=Eu(e.subarray(t+4,t+8)))<1)return null;if(\"PRIV\"===String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3])){n=e.subarray(t+10,t+i+10);for(var r=0;r>>2;return a*=4,a+=3&s[7]}}t+=10,t+=i}while(te.length){i=!0;break}null===s&&(t=e.subarray(o,o+a),s=Uu.aac.parseAacTimestamp(t)),o+=a;break;case\"audio\":if(e.length-o<7){i=!0;break}if((a=Uu.aac.parseAdtsSize(e,o))>e.length){i=!0;break}null===r&&(t=e.subarray(o,o+a),r=Uu.aac.parseSampleRate(t)),n++,o+=a;break;default:o++}if(i)return null}if(null===r||null===s)return null;var u=Fu/r;return{audio:[{type:\"audio\",dts:s,pts:s},{type:\"audio\",dts:s+1024*n*u,pts:s+1024*n*u}]}}(e):ju(e))&&(i.audio||i.video)?(function(e,t){if(e.audio&&e.audio.length){var i=t;\"undefined\"==typeof i&&(i=e.audio[0].dts),e.audio.forEach(function(e){e.dts=Ru(e.dts,i),e.pts=Ru(e.pts,i),e.dtsTime=e.dts/Fu,e.ptsTime=e.pts/Fu})}if(e.video&&e.video.length){var n=t;if(\"undefined\"==typeof n&&(n=e.video[0].dts),e.video.forEach(function(e){e.dts=Ru(e.dts,n),e.pts=Ru(e.pts,n),e.dtsTime=e.dts/Fu,e.ptsTime=e.pts/Fu}),e.firstKeyFrame){var r=e.firstKeyFrame;r.dts=Ru(r.dts,n),r.pts=Ru(r.pts,n),r.dtsTime=r.dts/Fu,r.ptsTime=r.dts/Fu}}}(i,t),i):null};function qu(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}var Wu=function(e,t,i){return t&&zu(e.prototype,t),i&&zu(e,i),e};function zu(e,t){for(var i=0;i>>24]^_[u>>16&255]^b[l>>8&255]^T[255&c]^a[g],d=y[u>>>24]^_[l>>16&255]^b[c>>8&255]^T[255&o]^a[g+1],p=y[l>>>24]^_[c>>16&255]^b[o>>8&255]^T[255&u]^a[g+2],c=y[c>>>24]^_[o>>16&255]^b[u>>8&255]^T[255&l]^a[g+3],g+=4,o=h,u=d,l=p;for(m=0;m<4;m++)r[(3&-m)+s]=S[o>>>24]<<24^S[u>>16&255]<<16^S[l>>8&255]<<8^S[255&c]^a[g++],h=o,o=u,u=l,l=c,c=h},Ku);function Ku(e){qu(this,Ku),Gu=Gu||function(){var e=[[[],[],[],[],[]],[[],[],[],[],[]]],t=e[0],i=e[1],n=t[4],r=i[4],s=void 0,a=void 0,o=void 0,u=[],l=[],c=void 0,h=void 0,d=void 0,p=void 0,f=void 0;for(s=0;s<256;s++)l[(u[s]=s<<1^283*(s>>7))^s]=s;for(a=o=0;!n[a];a^=c||1,o=l[o]||1)for(d=(d=o^o<<1^o<<2^o<<3^o<<4)>>8^255&d^99,f=16843009*u[h=u[c=u[r[n[a]=d]=a]]]^65537*h^257*c^16843008*a,p=257*u[d]^16843008*d,s=0;s<4;s++)t[s][a]=p=p<<24^p>>>8,i[s][d]=f=f<<24^f>>>8;for(s=0;s<5;s++)t[s]=t[s].slice(0),i[s]=i[s].slice(0);return e}(),this._tables=[[Gu[0][0].slice(),Gu[0][1].slice(),Gu[0][2].slice(),Gu[0][3].slice(),Gu[0][4].slice()],[Gu[1][0].slice(),Gu[1][1].slice(),Gu[1][2].slice(),Gu[1][3].slice(),Gu[1][4].slice()]];var t=void 0,i=void 0,n=void 0,r=void 0,s=void 0,a=this._tables[0][4],o=this._tables[1],u=e.length,l=1;if(4!==u&&6!==u&&8!==u)throw new Error(\"Invalid aes key size\");for(r=e.slice(0),s=[],this._key=[r,s],t=u;t<4*u+28;t++)n=r[t-1],(t%u==0||8===u&&t%u==4)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],t%u==0&&(n=n<<8^n>>>24^l<<24,l=l<<1^283*(l>>7))),r[t]=r[t-u]^n;for(i=0;t;i++,t--)n=r[3&i?t:t-4],s[i]=t<=4||i<4?n:o[0][a[n>>>24]]^o[1][a[n>>16&255]]^o[2][a[n>>8&255]]^o[3][a[255&n]]}var Yu=($u.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},$u.prototype.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e].splice(i,1),-1>8|e>>>24}function tl(e,t,i){var n=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),r=new Xu(Array.prototype.slice.call(t)),s=new Uint8Array(e.byteLength),a=new Int32Array(s.buffer),o=void 0,u=void 0,l=void 0,c=void 0,h=void 0,d=void 0,p=void 0,f=void 0,m=void 0;for(o=i[0],u=i[1],l=i[2],c=i[3],m=0;mDate.now()}function Pl(e){return e.excludeUntil&&e.excludeUntil===1/0}function Ll(e){var t=Il(e);return!e.disabled&&!t}function Ol(e,t){return t.attributes&&t.attributes[e]}function Dl(e,t){if(1===e.playlists.length)return!0;var i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter(function(e){return!!Ll(e)&&(e.attributes.BANDWIDTH||0)i+.25*s.duration)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:i-n.duration,type:n.videoTimingInfo?\"accurate\":\"estimate\"}}(n,t);if(!s)return r({message:\"valid programTime was not found\"});if(\"estimate\"===s.type)return r({message:\"Accurate programTime could not be determined. Please seek to e.seekTime and try again\",seekTime:s.estimatedStart});var a={mediaSeconds:n},o=function(e,t){if(!t.dateTimeObject)return null;var i=t.videoTimingInfo.transmuxerPrependedSeconds,n=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*n)}(n,s.segment);return o&&(a.programDateTime=o.toISOString()),r(null,a)}function ql(e){var t=e.programTime,i=e.playlist,n=e.retryCount,r=void 0===n?2:n,s=e.seekTo,a=e.pauseAfterSeek,o=void 0===a||a,u=e.tech,l=e.callback;if(!l)throw new Error(\"seekToProgramTime: callback must be provided\");if(\"undefined\"==typeof t||!i||!s)return l({message:\"seekToProgramTime: programTime, seekTo and playlist must be provided\"});if(!i.endList&&!u.hasStarted_)return l({message:\"player must be playing a live stream to start buffering\"});if(!function(e){if(!e.segments||0===e.segments.length)return!1;for(var t=0;t \"+e.end(i));return t.join(\", \")}function Kl(e){for(var t=[],i=0;i=e&&i.removeCue(r)}function $l(e){return isNaN(e)||Math.abs(e)===1/0?Number.MAX_VALUE:e}function Ql(e,t,i){var n=y.WebKitDataCue||y.VTTCue;if(t&&t.forEach(function(e){var t=e.stream;this.inbandTextTracks_[t].addCue(new n(e.startTime+this.timestampOffset,e.endTime+this.timestampOffset,e.text))},e),i){var r=$l(e.mediaSource_.duration);if(i.forEach(function(e){var i=e.cueTime+this.timestampOffset;!(\"number\"!=typeof i||y.isNaN(i)||i<0)&&i<1/0&&e.frames.forEach(function(e){var t=new n(i,i,e.value||e.url||e.data||\"\");t.frame=e,t.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return as.log.warn(\"cue.frame.id is deprecated. Use cue.value.key instead.\"),e.value.key}},value:{get:function(){return as.log.warn(\"cue.frame.value is deprecated. Use cue.value.data instead.\"),e.value.data}},privateData:{get:function(){return as.log.warn(\"cue.frame.privateData is deprecated. Use cue.value.data instead.\"),e.value.data}}})}(t),this.metadataTrack_.addCue(t)},this)},e),e.metadataTrack_&&e.metadataTrack_.cues&&e.metadataTrack_.cues.length){for(var s=e.metadataTrack_.cues,a=[],o=0;o>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},m=function(e){return l(S.hdlr,A[e])},f=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(t[12]=e.samplerate>>>24&255,t[13]=e.samplerate>>>16&255,t[14]=e.samplerate>>>8&255,t[15]=255&e.samplerate),l(S.mdhd,t)},p=function(e){return l(S.mdia,f(e),m(e.type),n(e))},s=function(e){return l(S.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},n=function(e){return l(S.minf,\"video\"===e.type?l(S.vmhd,I):l(S.smhd,P),t(),v(e))},a=function(e,t){for(var i=[],n=t.length;n--;)i[n]=_(t[n]);return l.apply(null,[S.moof,s(e)].concat(i))},o=function(e){for(var t=e.length,i=[];t--;)i[t]=h(e[t]);return l.apply(null,[S.moov,c(4294967295)].concat(i).concat(u(e)))},u=function(e){for(var t=e.length,i=[];t--;)i[t]=b(e[t]);return l.apply(null,[S.mvex].concat(i))},c=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return l(S.mvhd,t)},g=function(e){var t,i,n=e.samples||[],r=new Uint8Array(4+n.length);for(i=0;i>>8),s.push(255&n[t].byteLength),s=s.concat(Array.prototype.slice.call(n[t]));for(t=0;t>>8),a.push(255&r[t].byteLength),a=a.concat(Array.prototype.slice.call(r[t]));if(i=[S.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(S.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([n.length],s,[r.length],a))),l(S.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var o=e.sarRatio[0],u=e.sarRatio[1];i.push(l(S.pasp,new Uint8Array([(4278190080&o)>>24,(16711680&o)>>16,(65280&o)>>8,255&o,(4278190080&u)>>24,(16711680&u)>>16,(65280&u)>>8,255&u])))}return l.apply(null,i)},M=function(e){return l(S.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),i(e))},d=function(e){var t=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return l(S.tkhd,t)},_=function(e){var t,i,n,r,s,a;return t=l(S.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),s=Math.floor(e.baseMediaDecodeTime/(1+V)),a=Math.floor(e.baseMediaDecodeTime%(1+V)),i=l(S.tfdt,new Uint8Array([1,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a])),92,\"audio\"===e.type?(n=T(e,92),l(S.traf,t,i,n)):(r=g(e),n=T(e,r.length+92),l(S.traf,t,i,n,r))},h=function(e){return e.duration=e.duration||4294967295,l(S.trak,d(e),p(e))},b=function(e){var t=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return\"video\"!==e.type&&(t[t.length-1]=0),l(S.trex,t)},F=function(e,t){var i=0,n=0,r=0,s=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(n=2),void 0!==e[0].flags&&(r=4),void 0!==e[0].compositionTimeOffset&&(s=8)),[0,0,i|n|r|s,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},j=function(e,t){var i,n,r,s;for(t+=20+16*(n=e.samples||[]).length,i=F(n,t),s=0;s>>24,(16711680&r.duration)>>>16,(65280&r.duration)>>>8,255&r.duration,(4278190080&r.size)>>>24,(16711680&r.size)>>>16,(65280&r.size)>>>8,255&r.size,r.flags.isLeading<<2|r.flags.dependsOn,r.flags.isDependedOn<<6|r.flags.hasRedundancy<<4|r.flags.paddingValue<<1|r.flags.isNonSyncSample,61440&r.flags.degradationPriority,15&r.flags.degradationPriority,(4278190080&r.compositionTimeOffset)>>>24,(16711680&r.compositionTimeOffset)>>>16,(65280&r.compositionTimeOffset)>>>8,255&r.compositionTimeOffset]);return l(S.trun,new Uint8Array(i))},B=function(e,t){var i,n,r,s;for(t+=20+8*(n=e.samples||[]).length,i=F(n,t),s=0;s>>24,(16711680&r.duration)>>>16,(65280&r.duration)>>>8,255&r.duration,(4278190080&r.size)>>>24,(16711680&r.size)>>>16,(65280&r.size)>>>8,255&r.size]);return l(S.trun,new Uint8Array(i))},T=function(e,t){return\"audio\"===e.type?B(e,t):j(e,t)};r=function(){return l(S.ftyp,k,C,k,w)};function q(e,t){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i}function W(e){for(var t=[];e--;)t.push(0);return t}function z(){z.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new Ie(0,0),new Ie(0,1),new Ie(1,0),new Ie(1,1)],this.reset(),this.ccStreams_.forEach(function(e){e.on(\"data\",this.trigger.bind(this,\"data\")),e.on(\"partialdone\",this.trigger.bind(this,\"partialdone\")),e.on(\"done\",this.trigger.bind(this,\"done\"))},this)}var G,X,K,Y,$,Q=function(e){return l(S.mdat,e)},J=a,Z=function(e){var t,i=r(),n=o(e);return(t=new Uint8Array(i.byteLength+n.byteLength)).set(i),t.set(n,i.byteLength),t},ee=function(e){var t,i,n=[],r=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,t=n.byteLength=0;t=i?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)}))},me=function(e){var t,i,n=[];for(t=0;t>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_=\"popOn\";else if(t===this.END_OF_CAPTION_)this.mode_=\"popOn\",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)\"popOn\"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=Ee();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ee();else if(t===this.RESUME_DIRECT_CAPTIONING_)\"paintOn\"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=Ee()),this.mode_=\"paintOn\",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))s=we((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isExtCharacter(n,r))\"popOn\"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),s=we((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts,\" \"),this.column_++,14==(14&r)&&this.addFormatting(e.pts,[\"i\"]),1==(1&r)&&this.addFormatting(e.pts,[\"u\"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var a=Ae.indexOf(7968&t);\"rollUp\"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(e.pts,a)),a!==this.row_&&(this.clearFormatting(e.pts),this.row_=a),1&r&&-1===this.formatting_.indexOf(\"u\")&&this.addFormatting(e.pts,[\"u\"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,[\"i\"])}else this.isNormalChar(n)&&(0===r&&(r=null),s=we(n),s+=we(r),this[this.mode_](e.pts,s),this.column_+=s.length)}else this.lastControlCode_=null}};Ie.prototype=new H,Ie.prototype.flushDisplayed=function(e){var t=this.displayed_.map(function(e){try{return e.trim()}catch(e){return\"\"}}).join(\"\\n\").replace(/^\\n+|\\n+$/g,\"\");t.length&&this.trigger(\"data\",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},Ie.prototype.reset=function(){this.mode_=\"popOn\",this.topRow_=0,this.startPts_=0,this.displayed_=Ee(),this.nonDisplayed_=Ee(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},Ie.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},Ie.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&48<=t&&t<=63},Ie.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&32<=t&&t<=63},Ie.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&32<=t&&t<=47},Ie.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&33<=t&&t<=35},Ie.prototype.isPAC=function(e,t){return e>=this.BASE_&&e\"},\"\");this[this.mode_](e,i)},Ie.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce(function(e,t){return e+\"\"},\"\");this.formatting_=[],this[this.mode_](e,t)}},Ie.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},Ie.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i},Ie.prototype.shiftRowsUp_=function(){var e;for(e=0;e>>2;o*=4,o+=3&a[7],r.timeStamp=o,void 0===t.pts&&void 0===t.dts&&(t.pts=r.timeStamp,t.dts=r.timeStamp),this.trigger(\"timestamp\",r)}t.frames.push(r),i+=10,i+=n}while(i>>4&&(i+=e[i]+1),0===t.pid)t.type=\"pat\",n(e.subarray(i),t),this.trigger(\"data\",t);else if(t.pid===this.pmtPid)for(t.type=\"pmt\",n(e.subarray(i),t),this.trigger(\"data\",t);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,i,t]):this.processPes_(e,i,t)},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=De.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=De.ADTS_STREAM_TYPE:i.streamType=this.programMapTable[\"timed-metadata\"][i.pid],i.type=\"pes\",i.data=e.subarray(t),this.trigger(\"data\",i)}}).prototype=new H,He.STREAM_TYPES={h264:27,adts:15},(Ve=function(){function n(e,t,i){var n,r,s=new Uint8Array(e.size),a={type:t},o=0,u=0;if(e.data.length&&!(e.size<9)){for(a.trackId=e.data[0].pid,o=0;o>>3,t.pts*=4,t.pts+=(6&e[13])>>>1,t.dts=t.pts,64&i&&(t.dts=(14&e[14])<<27|(255&e[15])<<20|(254&e[16])<<12|(255&e[17])<<5|(254&e[18])>>>3,t.dts*=4,t.dts+=(6&e[18])>>>1)),t.data=e.subarray(9+e[8])}(s,a),n=\"video\"===t||a.packetLength<=e.size,(i||n)&&(e.size=0,e.data.length=0),n&&l.trigger(\"data\",a)}}var t,l=this,r={data:[],size:0},s={data:[],size:0},a={data:[],size:0};Ve.prototype.init.call(this),this.push=function(i){({pat:function(){},pes:function(){var e,t;switch(i.streamType){case De.H264_STREAM_TYPE:case De.H264_STREAM_TYPE:e=r,t=\"video\";break;case De.ADTS_STREAM_TYPE:e=s,t=\"audio\";break;case De.METADATA_STREAM_TYPE:e=a,t=\"timed-metadata\";break;default:return}i.payloadUnitStartIndicator&&n(e,t,!0),e.data.push(i),e.size+=i.data.byteLength},pmt:function(){var e={type:\"metadata\",tracks:[]};null!==(t=i.programMapTable).video&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:\"avc\",type:\"video\"}),null!==t.audio&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:\"adts\",type:\"audio\"}),l.trigger(\"data\",e)}})[i.type]()},this.reset=function(){r.size=0,r.data.length=0,s.size=0,s.data.length=0,this.trigger(\"reset\")},this.flushStreams_=function(){n(r,\"video\"),n(s,\"audio\"),n(a,\"timed-metadata\")},this.flush=function(){this.flushStreams_(),this.trigger(\"done\")}}).prototype=new H;var ze={PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:Fe,TransportParseStream:He,ElementaryStream:Ve,TimestampRolloverStream:We,CaptionStream:Oe.CaptionStream,Cea608Stream:Oe.Cea608Stream,MetadataStream:qe};for(var Ge in De)De.hasOwnProperty(Ge)&&(ze[Ge]=De[Ge]);var Xe,Ke=ze,Ye=le,$e=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(Xe=function(u){var l,c=0;Xe.prototype.init.call(this),this.push=function(e){var t,i,n,r,s,a,o=0;if(u||(c=0),\"audio\"===e.type)for(l?(r=l,(l=new Uint8Array(r.byteLength+e.data.byteLength)).set(r),l.set(e.data,r.byteLength)):l=e.data;o+5>5,a=(s=1024*(1+(3&l[o+6])))*Ye/$e[(60&l[o+2])>>>2],n=o+t,l.byteLength>>6&3),channelcount:(1&l[o+2])<<2|(192&l[o+3])>>>6,samplerate:$e[(60&l[o+2])>>>2],samplingfrequencyindex:(60&l[o+2])>>>2,samplesize:16,data:l.subarray(o+7+i,n)}),c++,l.byteLength===n)return void(l=void 0);l=l.subarray(n)}else o++},this.flush=function(){c=0,this.trigger(\"done\")},this.reset=function(){l=void 0,this.trigger(\"reset\")},this.endTimeline=function(){l=void 0,this.trigger(\"endedtimeline\")}}).prototype=new H;var Qe,Je,Ze,et=Xe,tt=function(n){var r=n.byteLength,s=0,a=0;this.length=function(){return 8*r},this.bitsAvailable=function(){return 8*r+a},this.loadWord=function(){var e=n.byteLength-r,t=new Uint8Array(4),i=Math.min(4,r);if(0===i)throw new Error(\"no bytes available\");t.set(n.subarray(e,e+i)),s=new DataView(t.buffer).getUint32(0),a=8*i,r-=i},this.skipBits=function(e){var t;e>>32-t;return 0<(a-=t)?s<<=t:0>>e))return s<<=e,a-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(Je=function(){var n,r,s=0;Je.prototype.init.call(this),this.push=function(e){for(var t,i=(r=r?((t=new Uint8Array(r.byteLength+e.data.byteLength)).set(r),t.set(e.data,r.byteLength),t):e.data).byteLength;s>4?20+i:10+i},at=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(it=function(){var o=new Uint8Array,u=0;it.prototype.init.call(this),this.setTimestamp=function(e){u=e},this.push=function(e){var t,i,n,r,s=0,a=0;for(o.length?(r=o.length,(o=new Uint8Array(e.byteLength+r)).set(o.subarray(0,r)),o.set(e,r)):o=e;3<=o.length-a;)if(o[a]!==\"I\".charCodeAt(0)||o[a+1]!==\"D\".charCodeAt(0)||o[a+2]!==\"3\".charCodeAt(0))if(255!=(255&o[a])||240!=(240&o[a+1]))a++;else{if(o.length-a<7)break;if(a+(s=at(o,a))>o.length)break;n={type:\"audio\",data:o.subarray(a,a+s),pts:u,dts:u},this.trigger(\"data\",n),a+=s}else{if(o.length-a<10)break;if(a+(s=st(o,a))>o.length)break;i={type:\"timed-metadata\",data:o.subarray(a,a+s)},this.trigger(\"data\",i),a+=s}t=o.length-a,o=0n.pts?t++:(i++,s-=r.byteLength,a-=r.nalCount,o-=r.duration);return 0===i?e:i===e.length?null:((u=e.slice(i)).byteLength=s,u.duration=o,u.nalCount=a,u.pts=u[0].pts,u.dts=u[0].dts,u)},this.alignGopsAtEnd_=function(e){var t,i,n,r,s,a,o;for(t=f.length-1,i=e.length-1,s=null,a=!1;0<=t&&0<=i;){if(n=f[t],r=e[i],n.pts===r.pts){a=!0;break}n.pts>r.pts?t--:(t===f.length-1&&(s=i),i--)}if(!a&&null===s)return null;if(0===(o=a?i:s))return e;var u=e.slice(o),l=u.reduce(function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e},{byteLength:0,duration:0,nalCount:0});return u.byteLength=l.byteLength,u.duration=l.duration,u.nalCount=l.nalCount,u.pts=u[0].pts,u.dts=u[0].dts,u},this.alignGopsWith=function(e){f=e}}).prototype=new H,(dt=function(e,t){this.numberOfTracks=0,this.metadataStream=t,\"undefined\"!=typeof(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,\"boolean\"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,dt.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,\"video\"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void(\"audio\"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))}}).prototype=new H,dt.prototype.flush=function(e){var t,i,n,r,s=0,a={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger(\"done\"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,yt.forEach(function(e){a.info[e]=this.videoTrack[e]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,vt.forEach(function(e){a.info[e]=this.audioTrack[e]},this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type=\"combined\",this.emittedTracks+=this.pendingTracks.length,n=Z(this.pendingTracks),a.initSegment=new Uint8Array(n.byteLength),a.initSegment.set(n),a.data=new Uint8Array(this.pendingBytes),r=0;r=this.numberOfTracks&&(this.trigger(\"done\"),this.emittedTracks=0)},dt.prototype.setRemux=function(e){this.remuxTracks=e},(ht=function(n){var r,s,a=this,i=!0;ht.prototype.init.call(this),n=n||{},this.baseMediaDecodeTime=n.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var t={};(this.transmuxPipeline_=t).type=\"aac\",t.metadataStream=new Ke.MetadataStream,t.aacStream=new pt,t.audioTimestampRolloverStream=new Ke.TimestampRolloverStream(\"audio\"),t.timedMetadataTimestampRolloverStream=new Ke.TimestampRolloverStream(\"timed-metadata\"),t.adtsStream=new et,t.coalesceStream=new dt(n,t.metadataStream),t.headOfPipeline=t.aacStream,t.aacStream.pipe(t.audioTimestampRolloverStream).pipe(t.adtsStream),t.aacStream.pipe(t.timedMetadataTimestampRolloverStream).pipe(t.metadataStream).pipe(t.coalesceStream),t.metadataStream.on(\"timestamp\",function(e){t.aacStream.setTimestamp(e.timeStamp)}),t.aacStream.on(\"data\",function(e){\"timed-metadata\"!==e.type||t.audioSegmentStream||(s=s||{timelineStartInfo:{baseMediaDecodeTime:a.baseMediaDecodeTime},codec:\"adts\",type:\"audio\"},t.coalesceStream.numberOfTracks++,t.audioSegmentStream=new ct(s,n),t.audioSegmentStream.on(\"timingInfo\",a.trigger.bind(a,\"audioTimingInfo\")),t.adtsStream.pipe(t.audioSegmentStream).pipe(t.coalesceStream)),a.trigger(\"trackinfo\",{hasAudio:!!s,hasVideo:!!r})}),t.coalesceStream.on(\"data\",this.trigger.bind(this,\"data\")),t.coalesceStream.on(\"done\",this.trigger.bind(this,\"done\"))},this.setupTsPipeline=function(){var i={};(this.transmuxPipeline_=i).type=\"ts\",i.metadataStream=new Ke.MetadataStream,i.packetStream=new Ke.TransportPacketStream,i.parseStream=new Ke.TransportParseStream,i.elementaryStream=new Ke.ElementaryStream,i.timestampRolloverStream=new Ke.TimestampRolloverStream,i.adtsStream=new et,i.h264Stream=new ft,i.captionStream=new Ke.CaptionStream,i.coalesceStream=new dt(n,i.metadataStream),i.headOfPipeline=i.packetStream,i.packetStream.pipe(i.parseStream).pipe(i.elementaryStream).pipe(i.timestampRolloverStream),i.timestampRolloverStream.pipe(i.h264Stream),i.timestampRolloverStream.pipe(i.adtsStream),i.timestampRolloverStream.pipe(i.metadataStream).pipe(i.coalesceStream),i.h264Stream.pipe(i.captionStream).pipe(i.coalesceStream),i.elementaryStream.on(\"data\",function(e){var t;if(\"metadata\"===e.type){for(t=e.tracks.length;t--;)r||\"video\"!==e.tracks[t].type?s||\"audio\"!==e.tracks[t].type||((s=e.tracks[t]).timelineStartInfo.baseMediaDecodeTime=a.baseMediaDecodeTime):(r=e.tracks[t]).timelineStartInfo.baseMediaDecodeTime=a.baseMediaDecodeTime;r&&!i.videoSegmentStream&&(i.coalesceStream.numberOfTracks++,i.videoSegmentStream=new lt(r,n),i.videoSegmentStream.on(\"timelineStartInfo\",function(e){s&&(s.timelineStartInfo=e,i.audioSegmentStream.setEarliestDts(e.dts))}),i.videoSegmentStream.on(\"processedGopsInfo\",a.trigger.bind(a,\"gopInfo\")),i.videoSegmentStream.on(\"segmentTimingInfo\",a.trigger.bind(a,\"videoSegmentTimingInfo\")),i.videoSegmentStream.on(\"baseMediaDecodeTime\",function(e){s&&i.audioSegmentStream.setVideoBaseMediaDecodeTime(e)}),i.videoSegmentStream.on(\"timingInfo\",a.trigger.bind(a,\"videoTimingInfo\")),i.h264Stream.pipe(i.videoSegmentStream).pipe(i.coalesceStream)),s&&!i.audioSegmentStream&&(i.coalesceStream.numberOfTracks++,i.audioSegmentStream=new ct(s,n),i.audioSegmentStream.on(\"timingInfo\",a.trigger.bind(a,\"audioTimingInfo\")),i.adtsStream.pipe(i.audioSegmentStream).pipe(i.coalesceStream)),a.trigger(\"trackinfo\",{hasAudio:!!s,hasVideo:!!r})}}),i.coalesceStream.on(\"data\",this.trigger.bind(this,\"data\")),i.coalesceStream.on(\"id3Frame\",function(e){e.dispatchType=i.metadataStream.dispatchType,a.trigger(\"id3Frame\",e)}),i.coalesceStream.on(\"caption\",this.trigger.bind(this,\"caption\")),i.coalesceStream.on(\"done\",this.trigger.bind(this,\"done\"))},this.setBaseMediaDecodeTime=function(e){var t=this.transmuxPipeline_;n.keepOriginalTimestamps||(this.baseMediaDecodeTime=e),s&&(s.timelineStartInfo.dts=void 0,s.timelineStartInfo.pts=void 0,ye(s),n.keepOriginalTimestamps||(s.timelineStartInfo.baseMediaDecodeTime=e),t.audioTimestampRolloverStream&&t.audioTimestampRolloverStream.discontinuity()),r&&(t.videoSegmentStream&&(t.videoSegmentStream.gopCache_=[]),r.timelineStartInfo.dts=void 0,r.timelineStartInfo.pts=void 0,ye(r),t.captionStream.reset(),n.keepOriginalTimestamps||(r.timelineStartInfo.baseMediaDecodeTime=e)),t.timestampRolloverStream&&t.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){s&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(e){var t=this.transmuxPipeline_;n.remux=e,t&&t.coalesceStream&&t.coalesceStream.setRemux(e)},this.alignGopsWith=function(e){r&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.push=function(e){if(i){var t=mt(e);t&&\"aac\"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||\"ts\"===this.transmuxPipeline_.type||this.setupTsPipeline(),i=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){i=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new H;var _t={Transmuxer:ht,VideoSegmentStream:lt,AudioSegmentStream:ct,AUDIO_PROPERTIES:vt,VIDEO_PROPERTIES:yt,generateVideoSegmentTimingInfo:ut};function bt(e,t){for(var i=0;in);r++);return e.slice(r)}(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:\"push\",data:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength},[e.buffer]),this.transmuxer_.postMessage({action:\"flush\"})}},{key:\"appendGopInfo_\",value:function(e){this.gopBuffer_=function(e,t,i){if(!t.length)return e;if(i)return t.slice();for(var n=t[0].pts,r=0;r=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,e.data.gopInfo,this.safeAppend_)}},{key:\"remove\",value:function(e,t){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(e,t),this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil(9e4*(t-n)),s=Math.ceil(9e4*(i-n)),a=e.slice(),o=e.length;o--&&!(e[o].pts<=s););if(-1===o)return a;for(var u=o+1;u--&&!(e[u].pts<=r););return u=Math.max(u,0),a.splice(u,o-u+1),a}(this.gopBuffer_,e,t,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(e,t)),Yl(e,t,this.metadataTrack_),this.inbandTextTracks_)for(var i in this.inbandTextTracks_)Yl(e,t,this.inbandTextTracks_[i])}},{key:\"processPendingSegments_\",value:function(){var e={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length)return this.trigger(\"updateend\"),void(this.bufferUpdating_=!1);e=this.pendingBuffers_.reduce(function(e,t){var i=t.type,n=t.data,r=t.initSegment;return e[i].segments.push(n),e[i].bytes+=n.byteLength,e[i].initSegment=r,t.captions&&(e.captions=e.captions.concat(t.captions)),t.info&&(e[i].info=t.info),t.metadata&&(e.metadata=e.metadata.concat(t.metadata)),e},e),this.videoBuffer_||this.audioBuffer_||(0===e.video.bytes&&(this.videoCodec_=null),0===e.audio.bytes&&(this.audioCodec_=null),this.createRealSourceBuffers_()),e.audio.info&&this.mediaSource_.trigger({type:\"audioinfo\",info:e.audio.info}),e.video.info&&this.mediaSource_.trigger({type:\"videoinfo\",info:e.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(e.audio.segments.unshift(e.audio.initSegment),e.audio.bytes+=e.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var t=!1;this.videoBuffer_&&e.video.bytes?(e.video.segments.unshift(e.video.initSegment),e.video.bytes+=e.video.initSegment.byteLength,this.concatAndAppendSegments_(e.video,this.videoBuffer_)):!this.videoBuffer_||!this.audioDisabled_&&this.audioBuffer_||(t=!0),Ql(this,e.captions,e.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(e.audio,this.audioBuffer_),this.pendingBuffers_.length=0,t&&this.trigger(\"updateend\"),this.bufferUpdating_=!1}},{key:\"concatAndAppendSegments_\",value:function(e,t){var i=0,n=void 0;if(e.bytes){n=new Uint8Array(e.bytes),e.segments.forEach(function(e){n.set(e,i),i+=e.byteLength});try{t.updating=!0,t.appendBuffer(n)}catch(e){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:\"APPEND_BUFFER_ERR\",message:e.message,originalError:e})}}}},{key:\"abort\",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:\"reset\"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}},{key:\"dispose\",value:function(){this.transmuxer_&&this.transmuxer_.terminate(),this.trigger(\"dispose\"),this.off()}}]),Ec);function Ec(e,t){al(this,Ec);var i=cl(this,(Ec.__proto__||Object.getPrototypeOf(Ec)).call(this,as.EventTarget));i.timestampOffset_=0,i.pendingBuffers_=[],i.bufferUpdating_=!1,i.mediaSource_=e,i.codecs_=t,i.audioCodec_=null,i.videoCodec_=null,i.audioDisabled_=!1,i.appendAudioInitSegment_=!0,i.gopBuffer_=[],i.timeMapping_=0,i.safeAppend_=11<=as.browser.IE_VERSION;var n={remux:!1,alignGopsAtEnd:i.safeAppend_};return i.codecs_.forEach(function(e){Tc(e)?i.audioCodec_=e:Sc(e)&&(i.videoCodec_=e)}),i.transmuxer_=new kc,i.transmuxer_.postMessage({action:\"init\",options:n}),i.transmuxer_.onmessage=function(e){return\"data\"===e.data.action?i.data_(e):\"done\"===e.data.action?i.done_(e):\"gopInfo\"===e.data.action?i.appendGopInfo_(e):\"videoSegmentTimingInfo\"===e.data.action?i.videoSegmentTimingInfo_(e.data.videoSegmentTimingInfo):void 0},Object.defineProperty(i,\"timestampOffset\",{get:function(){return this.timestampOffset_},set:function(e){\"number\"==typeof e&&0<=e&&(this.timestampOffset_=e,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:\"setTimestampOffset\",timestampOffset:e}))}}),Object.defineProperty(i,\"appendWindowStart\",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(e){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=e),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=e)}}),Object.defineProperty(i,\"updating\",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(i,\"buffered\",{get:function(){return function(e,t,i){var n=null,r=null,s=0,a=[],o=[];if(!e&&!t)return as.createTimeRange();if(!e)return t.buffered;if(!t)return e.buffered;if(i)return e.buffered;if(0===e.buffered.length&&0===t.buffered.length)return as.createTimeRange();for(var u=e.buffered,l=t.buffered,c=u.length;c--;)a.push({time:u.start(c),type:\"start\"}),a.push({time:u.end(c),type:\"end\"});for(c=l.length;c--;)a.push({time:l.start(c),type:\"start\"}),a.push({time:l.end(c),type:\"end\"});for(a.sort(function(e,t){return e.time-t.time}),c=0;cthis.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=t)}},{key:\"addSourceBuffer\",value:function(e){var t=void 0,i=bc(e);if(/^(video|audio)\\/mp2t$/i.test(i.type)){var n=[];i.parameters&&i.parameters.codecs&&(n=i.parameters.codecs.split(\",\"),n=(n=gc(n)).filter(function(e){return Tc(e)||Sc(e)})),0===n.length&&(n=[\"avc1.4d400d\",\"mp4a.40.2\"]),t=new wc(this,n),0!==this.sourceBuffers.length&&(this.sourceBuffers[0].createRealSourceBuffers_(),t.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else t=this.nativeMediaSource_.addSourceBuffer(e);return this.sourceBuffers.push(t),t}},{key:\"dispose\",value:function(){this.trigger(\"dispose\"),this.off(),this.sourceBuffers.forEach(function(e){e.dispose&&e.dispose()}),this.sourceBuffers.length=0}}]),Ac);function Ac(){al(this,Ac);var s=cl(this,(Ac.__proto__||Object.getPrototypeOf(Ac)).call(this)),e=void 0;for(e in s.nativeMediaSource_=new y.MediaSource,s.nativeMediaSource_)e in Ac.prototype||\"function\"!=typeof s.nativeMediaSource_[e]||(s[e]=s.nativeMediaSource_[e].bind(s.nativeMediaSource_));return s.duration_=NaN,Object.defineProperty(s,\"duration\",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(e){(this.duration_=e)===1/0||(this.nativeMediaSource_.duration=e)}}),Object.defineProperty(s,\"seekable\",{get:function(){return this.duration_===1/0?as.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(s,\"readyState\",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(s,\"activeSourceBuffers\",{get:function(){return this.activeSourceBuffers_}}),s.sourceBuffers=[],s.activeSourceBuffers_=[],s.updateActiveSourceBuffers_=function(){if(s.activeSourceBuffers_.length=0,1===s.sourceBuffers.length){var e=s.sourceBuffers[0];return e.appendAudioInitSegment_=!0,e.audioDisabled_=!e.audioCodec_,void s.activeSourceBuffers_.push(e)}for(var i=!1,n=!0,t=0;t\"):function(){}}function Vc(){}var qc=(ol(Wc,[{key:\"createSourceBuffer_\",value:function(e,t){var i=this;this.sourceBuffer_=this.mediaSource.addSourceBuffer(e),this.logger_(\"created SourceBuffer\"),t&&(t.trigger(\"sourcebufferadded\"),this.mediaSource.sourceBuffers.length<2)?t.on(\"sourcebufferadded\",function(){i.start_()}):this.start_()}},{key:\"start_\",value:function(){var t=this;this.started_=!0,this.onUpdateendCallback_=function(){var e=t.pendingCallback_;t.pendingCallback_=null,t.sourceBuffer_.removing=!1,t.logger_(\"buffered [\"+Xl(t.buffered())+\"]\"),e&&e(),t.runCallback_()},this.sourceBuffer_.addEventListener(\"updateend\",this.onUpdateendCallback_),this.runCallback_()}},{key:\"abort\",value:function(e){var t=this;this.processedAppend_&&this.queueCallback_(function(){t.sourceBuffer_.abort()},e)}},{key:\"appendBuffer\",value:function(e,t){var i=this;this.processedAppend_=!0,this.queueCallback_(function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.addEventListener(\"videoSegmentTimingInfo\",e.videoSegmentTimingInfoCallback),i.sourceBuffer_.appendBuffer(e.bytes)},function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.removeEventListener(\"videoSegmentTimingInfo\",e.videoSegmentTimingInfoCallback),t()})}},{key:\"buffered\",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:as.createTimeRanges()}},{key:\"remove\",value:function(e,t,i){var n=this,r=2 \"+t+\"]\"),n.sourceBuffer_.removing=!0,n.sourceBuffer_.remove(e,t)},r)}},{key:\"updating\",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==Vc}},{key:\"timestampOffset\",value:function(e){var t=this;return\"undefined\"!=typeof e&&(this.queueCallback_(function(){t.sourceBuffer_.timestampOffset=e,t.runCallback_()}),this.timestampOffset_=e),this.timestampOffset_}},{key:\"queueCallback_\",value:function(e,t){this.callbacks_.push([e.bind(this),t]),this.runCallback_()}},{key:\"runCallback_\",value:function(){var e=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(e=this.callbacks_.shift(),this.pendingCallback_=e[1],e[0]())}},{key:\"dispose\",value:function(){function e(){t.sourceBuffer_&&\"open\"===t.mediaSource.readyState&&t.sourceBuffer_.abort(),t.sourceBuffer_.removeEventListener(\"updateend\",e)}var t=this;this.sourceBuffer_.removeEventListener(\"updateend\",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener(\"updateend\",e):e()}}]),Wc);function Wc(e,t,i,n){al(this,Wc),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=e,this.processedAppend_=!1,this.type_=i,this.mimeType_=t,this.logger_=Hc(\"SourceUpdater[\"+i+\"][\"+t+\"]\"),\"closed\"===e.readyState?e.addEventListener(\"sourceopen\",this.createSourceBuffer_.bind(this,t,n)):this.createSourceBuffer_(t,n)}function zc(e){e.forEach(function(e){e.abort()})}function Gc(e,t){return t.timedout?{status:t.status,message:\"HLS request timed-out at URL: \"+t.uri,code:ih,xhr:t}:t.aborted?{status:t.status,message:\"HLS request aborted at URL: \"+t.uri,code:nh,xhr:t}:e?{status:t.status,message:\"HLS request errored at URL: \"+t.uri,code:th,xhr:t}:null}function Xc(i,n,r){var s=0,a=!1;return function(e,t){if(!a)return e?(a=!0,zc(i),r(e,t)):(s+=1)===i.length?(t.endOfAllRequests=Date.now(),t.encryptedBytes?function(n,r,s){n.addEventListener(\"message\",function e(t){if(t.data.source===r.requestId){n.removeEventListener(\"message\",e);var i=t.data.decrypted;return r.bytes=new Uint8Array(i.bytes,i.byteOffset,i.byteLength),s(null,r)}});var e=void 0;e=r.key.bytes.slice?r.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(r.key.bytes)),n.postMessage(Bl({source:r.requestId,encrypted:r.encryptedBytes,key:e,iv:r.key.iv}),[r.encryptedBytes.buffer,e.buffer])}(n,t,r):r(null,t)):void 0}}function Kc(t,i){return function(e){return t.stats=as.mergeOptions(t.stats,function(e){var t=e.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return i.bytesReceived=e.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i}(e)),!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()),i(e,t)}}function Yc(e,t,i,n,r,s,a){var o=[],u=Xc(o,i,a);if(r.key&&!r.key.bytes){var l=e(as.mergeOptions(t,{uri:r.key.resolvedUri,responseType:\"arraybuffer\"}),function(s,a){return function(e,t){var i=t.response,n=Gc(e,t);if(n)return a(n,s);if(16!==i.byteLength)return a({status:t.status,message:\"Invalid HLS key at URL: \"+t.uri,code:th,xhr:t},s);var r=new DataView(i);return s.key.bytes=new Uint32Array([r.getUint32(0),r.getUint32(4),r.getUint32(8),r.getUint32(12)]),a(null,s)}}(r,u));o.push(l)}if(r.map&&!r.map.bytes){var c=e(as.mergeOptions(t,{uri:r.map.resolvedUri,responseType:\"arraybuffer\",headers:Rl(r.map)}),function(r,s,a){return function(e,t){var i=t.response,n=Gc(e,t);return n?a(n,r):0===i.byteLength?a({status:t.status,message:\"Empty HLS segment content at URL: \"+t.uri,code:th,xhr:t},r):(r.map.bytes=new Uint8Array(t.response),s&&!s.isInitialized()&&s.init(),r.map.timescales=eu.timescale(r.map.bytes),r.map.videoTrackIds=eu.videoTrackIds(r.map.bytes),a(null,r))}}(r,n,u));o.push(c)}var h=e(as.mergeOptions(t,{uri:r.resolvedUri,responseType:\"arraybuffer\",headers:Rl(r)}),function(s,a,o){return function(e,t){var i=t.response,n=Gc(e,t),r=void 0;return n?o(n,s):0===i.byteLength?o({status:t.status,message:\"Empty HLS segment content at URL: \"+t.uri,code:th,xhr:t},s):(s.stats=function(e){return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}}(t),s.key?s.encryptedBytes=new Uint8Array(t.response):s.bytes=new Uint8Array(t.response),a&&s.map&&s.map.bytes&&(a.isInitialized()||a.init(),(r=a.parse(s.bytes,s.map.videoTrackIds,s.map.timescales))&&r.captions&&(s.captionStreams=r.captionStreams,s.fmp4Captions=r.captions)),o(null,s))}}(r,n,u));return h.addEventListener(\"progress\",Kc(r,s)),o.push(h),function(){return zc(o)}}function $c(e,t){var i;return e&&(i=y.getComputedStyle(e))?i[t]:\"\"}function Qc(e,n){var r=e.slice();e.sort(function(e,t){var i=n(e,t);return 0===i?r.indexOf(e)-r.indexOf(t):i})}function Jc(e,t){var i=void 0,n=void 0;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||y.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH),i-(n=n||y.Number.MAX_VALUE)}function Zc(e){return\"number\"==typeof e&&isFinite(e)}var eh={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1},th=2,ih=-101,nh=-102,rh=(ll(sh,as.EventTarget),ol(sh,[{key:\"resetStats_\",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:\"dispose\",value:function(){this.trigger(\"dispose\"),this.state=\"DISPOSED\",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset(),this.checkBufferTimeout_&&y.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off(\"syncinfoupdate\",this.triggerSyncInfoUpdate_),this.off()}},{key:\"abort\",value:function(){\"WAITING\"===this.state?(this.abort_(),this.state=\"READY\",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null)}},{key:\"abort_\",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:\"error\",value:function(e){return\"undefined\"!=typeof e&&(this.error_=e),this.pendingSegment_=null,this.error_}},{key:\"endOfStream\",value:function(){this.ended_=!0,this.pause(),this.trigger(\"ended\")}},{key:\"buffered_\",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():as.createTimeRanges()}},{key:\"initSegment\",value:function(e,t){var i=1 \"+(e.id||e.uri)+\"]\"),this.trigger(\"syncinfoupdate\"),\"INIT\"===this.state&&this.couldBeginLoading_())return this.init_();if(n&&n.uri===e.uri){var a=e.mediaSequence-n.mediaSequence;this.logger_(\"live window shift [\"+a+\"]\"),null!==this.mediaIndex&&(this.mediaIndex-=a),r&&(r.mediaIndex-=a,0<=r.mediaIndex&&(r.segment=e.segments[r.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(n,e)}else null!==this.mediaIndex&&this.resyncLoader()}}},{key:\"pause\",value:function(){this.checkBufferTimeout_&&(y.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:\"paused\",value:function(){return null===this.checkBufferTimeout_}},{key:\"mimeType\",value:function(e,t){this.mimeType_||(this.mimeType_=e,this.sourceBufferEmitter_=t,\"INIT\"===this.state&&this.couldBeginLoading_()&&this.init_())}},{key:\"resetEverything\",value:function(e){this.ended_=!1,this.resetLoader(),this.remove(0,1/0,e),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger(\"reseteverything\")}},{key:\"resetLoader\",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:\"resyncLoader\",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:\"remove\",value:function(e,t,i){if(t===1/0&&(t=this.duration_()),this.sourceUpdater_&&this.sourceUpdater_.remove(e,t,i),Yl(e,t,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var n in this.inbandTextTracks_)Yl(e,t,this.inbandTextTracks_[n])}},{key:\"monitorBuffer_\",value:function(){this.checkBufferTimeout_&&y.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=y.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:\"monitorBufferTick_\",value:function(){\"READY\"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&y.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=y.setTimeout(this.monitorBufferTick_.bind(this),500)}},{key:\"fillBuffer_\",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);e&&(this.isEndOfStream_(e.mediaIndex)?this.endOfStream():e.mediaIndex===this.playlist_.segments.length-1&&\"ended\"===this.mediaSource_.readyState&&!this.seeking_()||(e.timeline!==this.currentTimeline_&&(this.syncController_.reset(),e.timestampOffset=e.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(e)))}}},{key:\"isEndOfStream_\",value:function(e,t){return function(e,t,i){if(!e||!t)return!1;var n=i===e.segments.length;return e.endList&&\"open\"===t.readyState&&n}(1=this.goalBufferLength_())return null;if(!n&&1<=u)return null;if(null===s)return i=this.getSyncSegmentCandidate_(t),this.generateSegmentInfo_(t,i,null,!0);if(null!==i)return t.segments[i],o=a,this.generateSegmentInfo_(t,i+1,o,!1);if(this.fetchAtBuffer_){var l=tc.getMediaInfoForTime(t,a,s.segmentIndex,s.time);i=l.mediaIndex,o=l.startTime}else{var c=tc.getMediaInfoForTime(t,r,s.segmentIndex,s.time);i=c.mediaIndex,o=c.startTime}return this.generateSegmentInfo_(t,i,o,!1)}},{key:\"getSyncSegmentCandidate_\",value:function(e){var t=this;if(-1===this.currentTimeline_)return 0;var i=e.segments.map(function(e,t){return{timeline:e.timeline,segmentIndex:t}}).filter(function(e){return e.timeline===t.currentTimeline_});return i.length?i[Math.min(i.length-1,1)].segmentIndex:Math.max(e.segments.length-1,0)}},{key:\"generateSegmentInfo_\",value:function(e,t,i,n){if(t<0||t>=e.segments.length)return null;var r=e.segments[t];return{requestId:\"segment-loader-\"+Math.random(),uri:r.resolvedUri,mediaIndex:t,isSyncRequest:n,startOfSegment:i,playlist:e,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:r.timeline,duration:r.duration,segment:r}}},{key:\"abortRequestEarly_\",value:function(e){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return!1;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return!1;var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=tc.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),s=function(e,t,i){var n=2 \"+n+\"] in timeline [\"+c+\"]\"].join(\" \")}(t)),this.sourceUpdater_.appendBuffer({bytes:t.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,t.requestId)},this.handleUpdateEnd_.bind(this))}else this.state=\"READY\"}},{key:\"handleVideoSegmentTimingInfo_\",value:function(e,t){if(this.pendingSegment_&&e===this.pendingSegment_.requestId){var i=this.pendingSegment_.segment;i.videoTimingInfo||(i.videoTimingInfo={}),i.videoTimingInfo.transmuxerPrependedSeconds=t.videoSegmentTimingInfo.prependedContentDuration||0,i.videoTimingInfo.transmuxedPresentationStart=t.videoSegmentTimingInfo.start.presentation,i.videoTimingInfo.transmuxedPresentationEnd=t.videoSegmentTimingInfo.end.presentation,i.videoTimingInfo.baseMediaDecodeTime=t.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:\"handleUpdateEnd_\",value:function(){if(!this.pendingSegment_)return this.state=\"READY\",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_,t=e.segment,i=null!==this.mediaIndex;this.pendingSegment_=null,this.recordThroughput_(e),this.addSegmentMetadataCue_(e),this.state=\"READY\",this.mediaIndex=e.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=e.timeline,this.trigger(\"syncinfoupdate\"),t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration?this.resetEverything():(i&&this.trigger(\"bandwidthupdate\"),this.trigger(\"progress\"),this.isEndOfStream_(e.mediaIndex+1,e.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_())}},{key:\"recordThroughput_\",value:function(e){var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}},{key:\"addSegmentMetadataCue_\",value:function(e){if(this.segmentMetadataTrack_){var t=e.segment,i=t.start,n=t.end;if(Zc(i)&&Zc(n)){Yl(i,n,this.segmentMetadataTrack_);var r=y.WebKitDataCue||y.VTTCue,s={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},a=new r(i,n,JSON.stringify(s));a.value=s,this.segmentMetadataTrack_.addCue(a)}}}}]),sh);function sh(e){al(this,sh);var t=cl(this,(sh.__proto__||Object.getPrototypeOf(sh)).call(this));if(!e)throw new TypeError(\"Initialization settings are required\");if(\"function\"!=typeof e.currentTime)throw new TypeError(\"No currentTime getter specified\");if(!e.mediaSource)throw new TypeError(\"No MediaSource specified\");return t.bandwidth=e.bandwidth,t.throughput={rate:0,count:0},t.roundTrip=NaN,t.resetStats_(),t.mediaIndex=null,t.hasPlayed_=e.hasPlayed,t.currentTime_=e.currentTime,t.seekable_=e.seekable,t.seeking_=e.seeking,t.duration_=e.duration,t.mediaSource_=e.mediaSource,t.hls_=e.hls,t.loaderType_=e.loaderType,t.startingMedia_=void 0,t.segmentMetadataTrack_=e.segmentMetadataTrack,t.goalBufferLength_=e.goalBufferLength,t.sourceType_=e.sourceType,t.inbandTextTracks_=e.inbandTextTracks,t.state_=\"INIT\",t.checkBufferTimeout_=null,t.error_=void 0,t.currentTimeline_=-1,t.pendingSegment_=null,t.mimeType_=null,t.sourceUpdater_=null,t.xhrOptions_=null,t.activeInitSegmentId_=null,t.initSegments_={},t.cacheEncryptionKeys_=e.cacheEncryptionKeys,t.keyCache_={},\"main\"===t.loaderType_?t.captionParser_=new yu:t.captionParser_=null,t.decrypter_=e.decrypter,t.syncController_=e.syncController,t.syncPoint_={segmentIndex:0,time:0},t.triggerSyncInfoUpdate_=function(){return t.trigger(\"syncinfoupdate\")},t.syncController_.on(\"syncinfoupdate\",t.triggerSyncInfoUpdate_),t.mediaSource_.addEventListener(\"sourceopen\",function(){return t.ended_=!1}),t.fetchAtBuffer_=!1,t.logger_=Hc(\"SegmentLoader[\"+t.loaderType_+\"]\"),Object.defineProperty(t,\"state\",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+\" -> \"+e),this.state_=e)}}),t}function ah(e){return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))}var oh=new Uint8Array(\"\\n\\n\".split(\"\").map(function(e){return e.charCodeAt(0)})),uh=(ll(lh,rh),ol(lh,[{key:\"buffered_\",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return as.createTimeRanges();var e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return as.createTimeRanges([[t,i]])}},{key:\"initSegment\",value:function(e,t){var i=1=r.adStartTime&&t<=r.adEndTime)return r}return null}var hh=Vu,dh=[{name:\"VOD\",run:function(e,t,i,n,r){if(i===1/0)return null;return{time:0,segmentIndex:0}}},{name:\"ProgramDateTime\",run:function(e,t,i,n,r){if(!e.datetimeToDisplayTime)return null;var s=t.segments||[],a=null,o=null;r=r||0;for(var u=0;uo){var u=void 0;u=a<0?i.start-Cl(t,e.mediaIndex,r):i.end+Cl(t,e.mediaIndex+1,r),this.discontinuities[s]={time:u,accuracy:o}}}}},{key:\"dispose\",value:function(){this.trigger(\"dispose\"),this.off()}}]),fh);function fh(){al(this,fh);var e=cl(this,(fh.__proto__||Object.getPrototypeOf(fh)).call(this));return e.inspectCache_=void 0,e.timelines=[],e.discontinuities=[],e.datetimeToDisplayTime=null,e.logger_=Hc(\"SyncController\"),e}function mh(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)}function gh(e,t){(t.activePlaylistLoader=e).load()}function vh(t){[\"AUDIO\",\"SUBTITLES\",\"CLOSED-CAPTIONS\"].forEach(function(e){Th[e](e,t)});var i=t.mediaTypes,e=t.masterPlaylistLoader,n=t.tech,r=t.hls;[\"AUDIO\",\"SUBTITLES\"].forEach(function(e){i[e].activeGroup=function(s,a){return function(t){var e=a.masterPlaylistLoader,i=a.mediaTypes[s].groups,n=e.media();if(!n)return null;var r=null;return n.attributes[s]&&(r=i[n.attributes[s]]),r=r||i.main,\"undefined\"==typeof t?r:null===t?null:r.filter(function(e){return e.id===t.id})[0]||null}}(e,t),i[e].activeTrack=Sh[e](e,t),i[e].onGroupChanged=function(o,u){return function(){var e=u.segmentLoaders,t=e[o],i=e.main,n=u.mediaTypes[o],r=n.activeTrack(),s=n.activeGroup(r),a=n.activePlaylistLoader;mh(t,n),s&&(s.playlistLoader?(t.resyncLoader(),gh(s.playlistLoader,n)):a&&i.resetEverything())}}(e,t),i[e].onTrackChanged=function(o,u){return function(){var e=u.segmentLoaders,t=e[o],i=e.main,n=u.mediaTypes[o],r=n.activeTrack(),s=n.activeGroup(r),a=n.activePlaylistLoader;mh(t,n),s&&(s.playlistLoader?(a!==s.playlistLoader&&(t.track&&t.track(r),t.resetEverything()),gh(s.playlistLoader,n)):i.resetEverything())}}(e,t)});var s=i.AUDIO.activeGroup(),a=(s.filter(function(e){return e.default})[0]||s[0]).id;function o(){i.AUDIO.onTrackChanged(),n.trigger({type:\"usage\",name:\"hls-audio-change\"})}for(var u in i.AUDIO.tracks[a].enabled=!0,i.AUDIO.onTrackChanged(),e.on(\"mediachange\",function(){[\"AUDIO\",\"SUBTITLES\"].forEach(function(e){return i[e].onGroupChanged()})}),n.audioTracks().addEventListener(\"change\",o),n.remoteTextTracks().addEventListener(\"change\",i.SUBTITLES.onTrackChanged),r.on(\"dispose\",function(){n.audioTracks().removeEventListener(\"change\",o),n.remoteTextTracks().removeEventListener(\"change\",i.SUBTITLES.onTrackChanged)}),n.clearTracks(\"audio\"),i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])}var yh=new hc(\"./decrypter-worker.worker.js\",function(e,t){var i,c,g,n,r,u,a,s=this;i=function(e,t,i){return t&&o(e.prototype,t),i&&o(e,i),e},c=null,d.prototype.decrypt=function(e,t,i,n,r,s){var a=this._key[1],o=e^a[0],u=n^a[1],l=i^a[2],c=t^a[3],h=void 0,d=void 0,p=void 0,f=a.length/4-2,m=void 0,g=4,v=this._tables[1],y=v[0],_=v[1],b=v[2],T=v[3],S=v[4];for(m=0;m>>24]^_[u>>16&255]^b[l>>8&255]^T[255&c]^a[g],d=y[u>>>24]^_[l>>16&255]^b[c>>8&255]^T[255&o]^a[g+1],p=y[l>>>24]^_[c>>16&255]^b[o>>8&255]^T[255&u]^a[g+2],c=y[c>>>24]^_[o>>16&255]^b[u>>8&255]^T[255&l]^a[g+3],g+=4,o=h,u=d,l=p;for(m=0;m<4;m++)r[(3&-m)+s]=S[o>>>24]<<24^S[u>>16&255]<<16^S[l>>8&255]<<8^S[255&c]^a[g++],h=o,o=u,u=l,l=c,c=h},g=d,l.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},l.prototype.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e].splice(i,1),-1>2),r=new g(Array.prototype.slice.call(t)),s=new Uint8Array(e.byteLength),a=new Int32Array(s.buffer),o=void 0,u=void 0,l=void 0,c=void 0,h=void 0,d=void 0,p=void 0,f=void 0,m=void 0;for(o=i[0],u=i[1],l=i[2],c=i[3],m=0;m>7))^s]=s;for(a=o=0;!n[a];a^=c||1,o=l[o]||1)for(d=(d=o^o<<1^o<<2^o<<3^o<<4)>>8^255&d^99,f=16843009*u[h=u[c=u[r[n[a]=d]=a]]]^65537*h^257*c^16843008*a,p=257*u[d]^16843008*d,s=0;s<4;s++)t[s][a]=p=p<<24^p>>>8,i[s][d]=f=f<<24^f>>>8;for(s=0;s<5;s++)t[s]=t[s].slice(0),i[s]=i[s].slice(0);return e}(),this._tables=[[c[0][0].slice(),c[0][1].slice(),c[0][2].slice(),c[0][3].slice(),c[0][4].slice()],[c[1][0].slice(),c[1][1].slice(),c[1][2].slice(),c[1][3].slice(),c[1][4].slice()]];var t=void 0,i=void 0,n=void 0,r=void 0,s=void 0,a=this._tables[0][4],o=this._tables[1],u=e.length,l=1;if(4!==u&&6!==u&&8!==u)throw new Error(\"Invalid aes key size\");for(r=e.slice(0),s=[],this._key=[r,s],t=u;t<4*u+28;t++)n=r[t-1],(t%u==0||8===u&&t%u==4)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],t%u==0&&(n=n<<8^n>>>24^l<<24,l=l<<1^283*(l>>7))),r[t]=r[t-u]^n;for(i=0;t;i++,t--)n=r[3&i?t:t-4],s[i]=t<=4||i<4?n:o[0][a[n>>>24]]^o[1][a[n>>16&255]]^o[2][a[n>>8&255]]^o[3][a[255&n]]}function l(){h(this,l),this.listeners={}}function p(){h(this,p);var e=function(e,t){if(!e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return!t||\"object\"!=typeof t&&\"function\"!=typeof t?e:t}(this,r.call(this,n));return e.jobs=[],e.delay=1,e.timeout_=null,e}function v(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}function f(e,t,i,n){h(this,f);var r=f.STEP,s=new Int32Array(e.buffer),a=new Uint8Array(e.byteLength),o=0;for(this.asyncStream_=new u,this.asyncStream_.push(this.decryptChunk_(s.subarray(o,o+r),t,i,a)),o=r;or.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=as.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0) \"+n);try{t.mediaSource.duration=n}catch(e){as.log.warn(\"Failed to set media source duration\",e)}t.tech_.trigger(\"durationchange\"),t.mediaSource.removeEventListener(\"sourceopen\",e)}var t=this,i=this.mediaSource.duration,n=kh.Playlist.duration(this.masterPlaylistLoader_.media()),r=this.tech_.buffered();0=t.end(t.length-1)))return this.techWaiting_();5<=this.consecutiveUpdates&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}}},{key:\"cancelTimer_\",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_(\"cancelTimer_\"),clearTimeout(this.timer_)),this.timer_=null}},{key:\"fixesBadSeeks_\",value:function(){if(!this.tech_.seeking())return!1;var e=this.seekable(),t=this.tech_.currentTime(),i=void 0;return this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(i=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)&&(i=e.start(0)+.1),\"undefined\"!=typeof i&&(this.logger_(\"Trying to seek outside of seekable at time \"+t+\" with seekable range \"+Xl(e)+\". Seeking to \"+i+\".\"),this.tech_.setCurrentTime(i),!0)}},{key:\"waiting_\",value:function(){if(!this.techWaiting_()){var e=this.tech_.currentTime(),t=this.tech_.buffered(),i=zl(t,e);return i.length&&e+3<=i.end(0)?(this.cancelTimer_(),this.tech_.setCurrentTime(e),this.logger_(\"Stopped at \"+e+\" while inside a buffered region [\"+i.start(0)+\" -> \"+i.end(0)+\"]. Attempting to resume playback by seeking to the current time.\"),void this.tech_.trigger({type:\"usage\",name:\"hls-unknown-waiting\"})):void 0}}},{key:\"techWaiting_\",value:function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return!0;if(this.tech_.seeking()||null!==this.timer_)return!0;if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_(\"Fell out of live window at time \"+t+\". Seeking to live point (seekable end) \"+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:\"usage\",name:\"hls-live-resync\"}),!0}var n=this.tech_.buffered(),r=Gl(n,t);if(this.videoUnderflow_(r,n,t))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:\"usage\",name:\"hls-video-underflow\"}),!0;if(0i||e.height>n})).filter(function(e){return e.width===f[0].width&&e.height===f[0].height}),u=m[m.length-1],g=m.filter(function(e){return e.bandwidth===u.bandwidth})[0]);var v=g||p||l||a[0]||s[0];return v?v.playlist:null}(this.playlists.master,this.systemBandwidth,parseInt($c(this.tech_.el(),\"width\"),10)*e,parseInt($c(this.tech_.el(),\"height\"),10)*e,this.limitRenditionByPlayerDimensions)},INITIAL_PLAYLIST_SELECTOR:function(){var e=this.playlists.master.playlists.filter(tc.isEnabled);return Qc(e,function(e,t){return Jc(e,t)}),e.filter(function(e){return vc(e.attributes.CODECS).videoCodec})[0]||null},comparePlaylistBandwidth:Jc,comparePlaylistResolution:function(e,t){var i=void 0,n=void 0;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||y.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width),i===(n=n||y.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:Nl()};[\"GOAL_BUFFER_LENGTH\",\"MAX_GOAL_BUFFER_LENGTH\",\"GOAL_BUFFER_LENGTH_RATE\",\"BUFFER_LOW_WATER_LINE\",\"MAX_BUFFER_LOW_WATER_LINE\",\"BUFFER_LOW_WATER_LINE_RATE\",\"BANDWIDTH_VARIANCE\"].forEach(function(t){Object.defineProperty(Dh,t,{get:function(){return as.log.warn(\"using Hls.\"+t+\" is UNSAFE be sure you know what you are doing\"),eh[t]},set:function(e){as.log.warn(\"using Hls.\"+t+\" is UNSAFE be sure you know what you are doing\"),\"number\"!=typeof e||e<0?as.log.warn(\"value of Hls.\"+t+\" must be greater than or equal to 0\"):eh[t]=e}})});function Nh(e){return/^(audio|video|application)\\/(x-|vnd\\.apple\\.)?mpegurl/i.test(e)?\"hls\":/^application\\/dash\\+xml/i.test(e)?\"dash\":null}function Rh(e,t){for(var i=t.media(),n=-1,r=0;re.TEXTURE31){console.error(\"TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit\"),r.push(null,null);break}n||(n=e.getParameter(e.ACTIVE_TEXTURE)),e.activeTexture(c),r.push(e.getParameter(o),null);break;case e.ACTIVE_TEXTURE:n=e.getParameter(e.ACTIVE_TEXTURE),r.push(null);break;default:r.push(e.getParameter(o))}for(i(e),a=0;ae.TEXTURE31)break;e.activeTexture(c),e.bindTexture(e.TEXTURE_2D,s);break;case e.TEXTURE_BINDING_CUBE_MAP:var c;if((c=t[++a])e.TEXTURE31)break;e.activeTexture(c),e.bindTexture(e.TEXTURE_CUBE_MAP,s);break;case e.VIEWPORT:e.viewport(s[0],s[1],s[2],s[3]);break;case e.BLEND:case e.CULL_FACE:case e.DEPTH_TEST:case e.SCISSOR_TEST:case e.STENCIL_TEST:s?e.enable(o):e.disable(o);break;default:console.log(\"No GL restore behavior for 0x\"+o.toString(16))}n&&e.activeTexture(n)}}else i(e)},L=[\"attribute vec2 position;\",\"attribute vec3 texCoord;\",\"varying vec2 vTexCoord;\",\"uniform vec4 viewportOffsetScale[2];\",\"void main() {\",\" vec4 viewport = viewportOffsetScale[int(texCoord.z)];\",\" vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;\",\" gl_Position = vec4( position, 1.0, 1.0 );\",\"}\"].join(\"\\n\"),P=[\"precision mediump float;\",\"uniform sampler2D diffuse;\",\"varying vec2 vTexCoord;\",\"void main() {\",\" gl_FragColor = texture2D(diffuse, vTexCoord);\",\"}\"].join(\"\\n\");function C(e,t,i,r){this.gl=e,this.cardboardUI=t,this.bufferScale=i,this.dirtySubmitFrameBindings=r,this.ctxAttribs=e.getContextAttributes(),this.instanceExt=e.getExtension(\"ANGLE_instanced_arrays\"),this.meshWidth=20,this.meshHeight=20,this.bufferWidth=e.drawingBufferWidth,this.bufferHeight=e.drawingBufferHeight,this.realBindFramebuffer=e.bindFramebuffer,this.realEnable=e.enable,this.realDisable=e.disable,this.realColorMask=e.colorMask,this.realClearColor=e.clearColor,this.realViewport=e.viewport,s()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(e.canvas.__proto__,\"width\"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(e.canvas.__proto__,\"height\")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=A(e,L,P,this.attribs),this.uniforms=x(e,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.indexCount=0,this.renderTarget=e.createTexture(),this.framebuffer=e.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=e.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=e.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=e.createRenderbuffer()),this.patch(),this.onResize()}C.prototype.destroy=function(){var e=this.gl;this.unpatch(),e.deleteProgram(this.program),e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.indexBuffer),e.deleteTexture(this.renderTarget),e.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&e.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&e.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&e.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},C.prototype.onResize=function(){var e=this.gl,t=this,i=[e.RENDERBUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0];R(e,i,(function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.framebuffer),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.texImage2D(e.TEXTURE_2D,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,t.bufferWidth,t.bufferHeight,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.renderTarget,0),t.ctxAttribs.depth&&t.ctxAttribs.stencil?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t.depthStencilBuffer)):t.ctxAttribs.depth?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t.depthBuffer)):t.ctxAttribs.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,t.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.STENCIL_INDEX8,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.STENCIL_ATTACHMENT,e.RENDERBUFFER,t.stencilBuffer)),!e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE&&console.error(\"Framebuffer incomplete!\"),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),t.realClearColor.apply(e,t.clearColor)})),this.cardboardUI&&this.cardboardUI.onResize()},C.prototype.patch=function(){if(!this.isPatched){var e=this,t=this.gl.canvas,i=this.gl;s()||(t.width=v()*this.bufferScale,t.height=g()*this.bufferScale,Object.defineProperty(t,\"width\",{configurable:!0,enumerable:!0,get:function(){return e.bufferWidth},set:function(i){e.bufferWidth=i,e.realCanvasWidth.set.call(t,i),e.onResize()}}),Object.defineProperty(t,\"height\",{configurable:!0,enumerable:!0,get:function(){return e.bufferHeight},set:function(i){e.bufferHeight=i,e.realCanvasHeight.set.call(t,i),e.onResize()}})),this.lastBoundFramebuffer=i.getParameter(i.FRAMEBUFFER_BINDING),null==this.lastBoundFramebuffer&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(t,r){e.lastBoundFramebuffer=r||e.framebuffer,e.realBindFramebuffer.call(i,t,e.lastBoundFramebuffer)},this.cullFace=i.getParameter(i.CULL_FACE),this.depthTest=i.getParameter(i.DEPTH_TEST),this.blend=i.getParameter(i.BLEND),this.scissorTest=i.getParameter(i.SCISSOR_TEST),this.stencilTest=i.getParameter(i.STENCIL_TEST),i.enable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!0;break;case i.DEPTH_TEST:e.depthTest=!0;break;case i.BLEND:e.blend=!0;break;case i.SCISSOR_TEST:e.scissorTest=!0;break;case i.STENCIL_TEST:e.stencilTest=!0}e.realEnable.call(i,t)},i.disable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!1;break;case i.DEPTH_TEST:e.depthTest=!1;break;case i.BLEND:e.blend=!1;break;case i.SCISSOR_TEST:e.scissorTest=!1;break;case i.STENCIL_TEST:e.stencilTest=!1}e.realDisable.call(i,t)},this.colorMask=i.getParameter(i.COLOR_WRITEMASK),i.colorMask=function(t,r,n,a){e.colorMask[0]=t,e.colorMask[1]=r,e.colorMask[2]=n,e.colorMask[3]=a,e.realColorMask.call(i,t,r,n,a)},this.clearColor=i.getParameter(i.COLOR_CLEAR_VALUE),i.clearColor=function(t,r,n,a){e.clearColor[0]=t,e.clearColor[1]=r,e.clearColor[2]=n,e.clearColor[3]=a,e.realClearColor.call(i,t,r,n,a)},this.viewport=i.getParameter(i.VIEWPORT),i.viewport=function(t,r,n,a){e.viewport[0]=t,e.viewport[1]=r,e.viewport[2]=n,e.viewport[3]=a,e.realViewport.call(i,t,r,n,a)},this.isPatched=!0,_(t)}},C.prototype.unpatch=function(){if(this.isPatched){var e=this.gl,t=this.gl.canvas;s()||(Object.defineProperty(t,\"width\",this.realCanvasWidth),Object.defineProperty(t,\"height\",this.realCanvasHeight)),t.width=this.bufferWidth,t.height=this.bufferHeight,e.bindFramebuffer=this.realBindFramebuffer,e.enable=this.realEnable,e.disable=this.realDisable,e.colorMask=this.realColorMask,e.clearColor=this.realClearColor,e.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&e.bindFramebuffer(e.FRAMEBUFFER,null),this.isPatched=!1,setTimeout((function(){_(t)}),1)}},C.prototype.setTextureBounds=function(e,t){e||(e=[0,0,.5,1]),t||(t=[.5,0,.5,1]),this.viewportOffsetScale[0]=e[0],this.viewportOffsetScale[1]=e[1],this.viewportOffsetScale[2]=e[2],this.viewportOffsetScale[3]=e[3],this.viewportOffsetScale[4]=t[0],this.viewportOffsetScale[5]=t[1],this.viewportOffsetScale[6]=t[2],this.viewportOffsetScale[7]=t[3]},C.prototype.submitFrame=function(){var e=this.gl,t=this,i=[];if(this.dirtySubmitFrameBindings||i.push(e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING,e.ELEMENT_ARRAY_BUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0),R(e,i,(function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null);var i=0,r=0;t.instanceExt&&(i=e.getVertexAttrib(t.attribs.position,t.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE),r=e.getVertexAttrib(t.attribs.texCoord,t.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)),t.cullFace&&t.realDisable.call(e,e.CULL_FACE),t.depthTest&&t.realDisable.call(e,e.DEPTH_TEST),t.blend&&t.realDisable.call(e,e.BLEND),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realDisable.call(e,e.STENCIL_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),(t.ctxAttribs.alpha||s())&&(t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT)),e.useProgram(t.program),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.indexBuffer),e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.enableVertexAttribArray(t.attribs.position),e.enableVertexAttribArray(t.attribs.texCoord),e.vertexAttribPointer(t.attribs.position,2,e.FLOAT,!1,20,0),e.vertexAttribPointer(t.attribs.texCoord,3,e.FLOAT,!1,20,8),t.instanceExt&&(0!=i&&t.instanceExt.vertexAttribDivisorANGLE(t.attribs.position,0),0!=r&&t.instanceExt.vertexAttribDivisorANGLE(t.attribs.texCoord,0)),e.activeTexture(e.TEXTURE0),e.uniform1i(t.uniforms.diffuse,0),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.uniform4fv(t.uniforms.viewportOffsetScale,t.viewportOffsetScale),e.drawElements(e.TRIANGLES,t.indexCount,e.UNSIGNED_SHORT,0),t.cardboardUI&&t.cardboardUI.renderNoState(),t.realBindFramebuffer.call(t.gl,e.FRAMEBUFFER,t.framebuffer),t.ctxAttribs.preserveDrawingBuffer||(t.realClearColor.call(e,0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)),t.dirtySubmitFrameBindings||t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.cullFace&&t.realEnable.call(e,e.CULL_FACE),t.depthTest&&t.realEnable.call(e,e.DEPTH_TEST),t.blend&&t.realEnable.call(e,e.BLEND),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realEnable.call(e,e.STENCIL_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),!t.ctxAttribs.alpha&&t.ctxAttribs.preserveDrawingBuffer||t.realClearColor.apply(e,t.clearColor),t.instanceExt&&(0!=i&&t.instanceExt.vertexAttribDivisorANGLE(t.attribs.position,i),0!=r&&t.instanceExt.vertexAttribDivisorANGLE(t.attribs.texCoord,r))})),s()){var r=e.canvas;r.width==t.bufferWidth&&r.height==t.bufferHeight||(t.bufferWidth=r.width,t.bufferHeight=r.height,t.onResize())}},C.prototype.updateDeviceInfo=function(e){var t=this.gl,i=this,r=[t.ARRAY_BUFFER_BINDING,t.ELEMENT_ARRAY_BUFFER_BINDING];R(t,r,(function(t){var r=i.computeMeshVertices_(i.meshWidth,i.meshHeight,e);if(t.bindBuffer(t.ARRAY_BUFFER,i.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),!i.indexCount){var n=i.computeMeshIndices_(i.meshWidth,i.meshHeight);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW),i.indexCount=n.length}}))},C.prototype.computeMeshVertices_=function(e,t,i){for(var r=new Float32Array(2*e*t*5),n=i.getLeftEyeVisibleTanAngles(),a=i.getLeftEyeNoLensTanAngles(),s=i.getLeftEyeVisibleScreenRect(a),c=0,h=0;h<2;h++){for(var l=0;ln-42&&r.clientXi.clientHeight-42?e(r):r.clientX<42&&r.clientY<42&&t(r)},i.addEventListener(\"click\",this.listener,!1)},N.prototype.onResize=function(){var e=this.gl,t=this,i=[e.ARRAY_BUFFER_BINDING];R(e,i,(function(e){var i=[],r=e.drawingBufferWidth/2,n=Math.max(screen.width,screen.height)*window.devicePixelRatio,a=e.drawingBufferWidth/n*window.devicePixelRatio,o=4*a/2,s=42*a,c=28*a/2,h=14*a;function l(e,t){var n=(90-e)*O,a=Math.cos(n),o=Math.sin(n);i.push(.3125*a*c+r,.3125*o*c+c),i.push(t*a*c+r,t*o*c+c)}i.push(r-o,s),i.push(r-o,e.drawingBufferHeight),i.push(r+o,s),i.push(r+o,e.drawingBufferHeight),t.gearOffset=i.length/2;for(var u=0;u<=6;u++){var d=60*u;l(d,1),l(d+12,1),l(d+20,.75),l(d+40,.75),l(d+48,1)}function p(t,r){i.push(h+t,e.drawingBufferHeight-h-r)}t.gearVertexCount=i.length/2-t.gearOffset,t.arrowOffset=i.length/2;var f=o/Math.sin(45*O);p(0,c),p(c,0),p(c+f,f),p(f,c+f),p(f,c-f),p(0,c),p(c,2*c),p(c+f,2*c-f),p(f,c-f),p(0,c),p(f,c-o),p(28*a,c-o),p(f,c+o),p(28*a,c+o),t.arrowVertexCount=i.length/2-t.arrowOffset,e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(i),e.STATIC_DRAW)}))},N.prototype.render=function(){var e=this.gl,t=this,i=[e.CULL_FACE,e.DEPTH_TEST,e.BLEND,e.SCISSOR_TEST,e.STENCIL_TEST,e.COLOR_WRITEMASK,e.VIEWPORT,e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING];R(e,i,(function(e){e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.colorMask(!0,!0,!0,!0),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.renderNoState()}))},N.prototype.renderNoState=function(){var e,t,i,r,n,a,o,s,c,h,l=this.gl;l.useProgram(this.program),l.bindBuffer(l.ARRAY_BUFFER,this.vertexBuffer),l.enableVertexAttribArray(this.attribs.position),l.vertexAttribPointer(this.attribs.position,2,l.FLOAT,!1,8,0),l.uniform4f(this.uniforms.color,1,1,1,1),e=this.projMat,t=0,i=l.drawingBufferWidth,r=0,n=l.drawingBufferHeight,s=1/(t-i),c=1/(r-n),h=1/((a=.1)-(o=1024)),e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+i)*s,e[13]=(n+r)*c,e[14]=(o+a)*h,e[15]=1,l.uniformMatrix4fv(this.uniforms.projectionMat,!1,this.projMat),l.drawArrays(l.TRIANGLE_STRIP,0,4),l.drawArrays(l.TRIANGLE_STRIP,this.gearOffset,this.gearVertexCount),l.drawArrays(l.TRIANGLE_STRIP,this.arrowOffset,this.arrowVertexCount)},B.prototype.distortInverse=function(e){for(var t=0,i=1,r=e-this.distort(t);Math.abs(i-t)>1e-4;){var n=e-this.distort(i),a=i-n*((i-t)/(n-r));t=i,i=a,r=n}return i},B.prototype.distort=function(e){for(var t=e*e,i=0,r=0;r=1)return this.w=a,this.x=i,this.y=r,this.z=n,this;var s=Math.acos(o),c=Math.sqrt(1-o*o);if(Math.abs(c)<.001)return this.w=.5*(a+this.w),this.x=.5*(i+this.x),this.y=.5*(r+this.y),this.z=.5*(n+this.z),this;var h=Math.sin((1-t)*s)/c,l=Math.sin(t*s)/c;return this.w=a*h+this.w*l,this.x=i*h+this.x*l,this.y=r*h+this.y*l,this.z=n*h+this.z*l,this},setFromUnitVectors:function(e,t){return void 0===G&&(G=new z),(V=e.dot(t)+1)<1e-6?(V=0,Math.abs(e.x)>Math.abs(e.z)?G.set(-e.y,e.x,0):G.set(0,-e.z,e.y)):G.crossVectors(e,t),this.x=G.x,this.y=G.y,this.z=G.z,this.w=V,this.normalize(),this}};var j=new k({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),W=new k({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),X={CardboardV1:new q({id:\"CardboardV1\",label:\"Cardboard I/O 2014\",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new q({id:\"CardboardV2\",label:\"Cardboard I/O 2015\",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};function Y(e,t){this.viewer=X.CardboardV2,this.updateDeviceParams(e),this.distortion=new B(this.viewer.distortionCoefficients);for(var i=0;i=200&&i.status<=299?(r.dpdb=JSON.parse(i.response),r.recalculateDeviceParams_()):console.error(\"Error loading online DPDB!\")})),i.send()}}function J(e){this.xdpi=e.xdpi,this.ydpi=e.ydpi,this.bevelMm=e.bevelMm}function K(e,t){this.set(e,t)}function $(e,t){this.kFilter=e,this.isDebug=t,this.currentAccelMeasurement=new K,this.currentGyroMeasurement=new K,this.previousGyroMeasurement=new K,s()?this.filterQ=new H(-1,0,0,1):this.filterQ=new H(1,0,0,1),this.previousFilterQ=new H,this.previousFilterQ.copy(this.filterQ),this.accelQ=new H,this.isOrientationInitialized=!1,this.estimatedGravity=new z,this.measuredGravity=new z,this.gyroIntegralQ=new H}function ee(e,t){this.predictionTimeS=e,this.isDebug=t,this.previousQ=new H,this.previousTimestampS=null,this.deltaQ=new H,this.outQ=new H}function te(e,t,i,r){this.yawOnly=i,this.accelerometer=new z,this.gyroscope=new z,this.filter=new $(e,r),this.posePredictor=new ee(t,r),this.isFirefoxAndroid=l(),this.isIOS=s();var n=u();this.isDeviceMotionInRadians=!this.isIOS&&n&&n<66,this.isWithoutDeviceMotion=p()||d(),this.filterToWorldQ=new H,s()?this.filterToWorldQ.setFromAxisAngle(new z(1,0,0),Math.PI/2):this.filterToWorldQ.setFromAxisAngle(new z(1,0,0),-Math.PI/2),this.inverseWorldToScreenQ=new H,this.worldToScreenQ=new H,this.originalPoseAdjustQ=new H,this.originalPoseAdjustQ.setFromAxisAngle(new z(0,0,1),-window.orientation*Math.PI/180),this.setScreenTransform_(),m()&&this.filterToWorldQ.multiply(this.inverseWorldToScreenQ),this.resetQ=new H,this.orientationOut_=new Float32Array(4),this.start()}Z.prototype.getDeviceParams=function(){return this.deviceParams},Z.prototype.recalculateDeviceParams_=function(){var e=this.calcDeviceParams_();e?(this.deviceParams=e,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error(\"Failed to recalculate device parameters.\")},Z.prototype.calcDeviceParams_=function(){var e=this.dpdb;if(!e)return console.error(\"DPDB not available.\"),null;if(1!=e.format)return console.error(\"DPDB has unexpected format version.\"),null;if(!e.devices||!e.devices.length)return console.error(\"DPDB does not have a devices section.\"),null;var t=navigator.userAgent||navigator.vendor||window.opera,i=v(),r=g();if(!e.devices)return console.error(\"DPDB has no devices section.\"),null;for(var n=0;n1||this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},$.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var e=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,t=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,e);this.gyroIntegralQ.multiply(t),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(t);var i=new H;i.copy(this.filterQ),i.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(i),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var r,n=new H;n.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),n.inverse(),this.isDebug&&console.log(\"Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)\",U*((r=n).w>1?(console.warn(\"getQuaternionAngle: w > 1\"),0):2*Math.acos(r.w)),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1));var a=new H;a.copy(this.filterQ),a.multiply(n),this.filterQ.slerp(a,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},$.prototype.getOrientation=function(){return this.filterQ},$.prototype.accelToQuaternion_=function(e){var t=new z;t.copy(e),t.normalize();var i=new H;return i.setFromUnitVectors(new z(0,0,-1),t),i.inverse(),i},$.prototype.gyroToQuaternionDelta_=function(e,t){var i=new H,r=new z;return r.copy(e),r.normalize(),i.setFromAxisAngle(r,e.length()*t),i},ee.prototype.getPrediction=function(e,t,i){if(!this.previousTimestampS)return this.previousQ.copy(e),this.previousTimestampS=i,e;var r=new z;r.copy(t),r.normalize();var n=t.length();if(n<20*F)return this.isDebug&&console.log(\"Moving slowly, at %s deg/s: no prediction\",(U*n).toFixed(1)),this.outQ.copy(e),this.previousQ.copy(e),this.outQ;var a=n*this.predictionTimeS;return this.deltaQ.setFromAxisAngle(r,a),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(e),this.previousTimestampS=i,this.outQ},te.prototype.getPosition=function(){return null},te.prototype.getOrientation=function(){var e=void 0;if(this.isWithoutDeviceMotion&&this._deviceOrientationQ)return this.deviceOrientationFixQ=this.deviceOrientationFixQ||(i=(new H).setFromAxisAngle(new z(0,0,-1),0),r=new H,-90===window.orientation?r.setFromAxisAngle(new z(0,1,0),Math.PI/-2):r.setFromAxisAngle(new z(0,1,0),Math.PI/2),i.multiply(r)),this.deviceOrientationFilterToWorldQ=this.deviceOrientationFilterToWorldQ||((t=new H).setFromAxisAngle(new z(1,0,0),-Math.PI/2),t),e=this._deviceOrientationQ,(n=new H).copy(e),n.multiply(this.deviceOrientationFilterToWorldQ),n.multiply(this.resetQ),n.multiply(this.worldToScreenQ),n.multiplyQuaternions(this.deviceOrientationFixQ,n),this.yawOnly&&(n.x=0,n.z=0,n.normalize()),this.orientationOut_[0]=n.x,this.orientationOut_[1]=n.y,this.orientationOut_[2]=n.z,this.orientationOut_[3]=n.w,this.orientationOut_;var t,i,r,n,a=this.filter.getOrientation();return e=this.posePredictor.getPrediction(a,this.gyroscope,this.previousTimestampS),(n=new H).copy(this.filterToWorldQ),n.multiply(this.resetQ),n.multiply(e),n.multiply(this.worldToScreenQ),this.yawOnly&&(n.x=0,n.z=0,n.normalize()),this.orientationOut_[0]=n.x,this.orientationOut_[1]=n.y,this.orientationOut_[2]=n.z,this.orientationOut_[3]=n.w,this.orientationOut_},te.prototype.resetPose=function(){this.resetQ.copy(this.filter.getOrientation()),this.resetQ.x=0,this.resetQ.y=0,this.resetQ.z*=-1,this.resetQ.normalize(),m()&&this.resetQ.multiply(this.inverseWorldToScreenQ),this.resetQ.multiply(this.originalPoseAdjustQ)},te.prototype.onDeviceOrientation_=function(e){this._deviceOrientationQ=this._deviceOrientationQ||new H;var t=e.alpha,i=e.beta,r=e.gamma;t=(t||0)*Math.PI/180,i=(i||0)*Math.PI/180,r=(r||0)*Math.PI/180,this._deviceOrientationQ.setFromEulerYXZ(i,t,-r)},te.prototype.onDeviceMotion_=function(e){this.updateDeviceMotion_(e)},te.prototype.updateDeviceMotion_=function(e){var t=e.accelerationIncludingGravity,i=e.rotationRate,r=e.timeStamp/1e3,n=r-this.previousTimestampS;return n<0?(T(\"fusion-pose-sensor:invalid:non-monotonic\",\"Invalid timestamps detected: non-monotonic timestamp from devicemotion\"),void(this.previousTimestampS=r)):n<=.001||n>1?(T(\"fusion-pose-sensor:invalid:outside-threshold\",\"Invalid timestamps detected: Timestamp from devicemotion outside expected range.\"),void(this.previousTimestampS=r)):(this.accelerometer.set(-t.x,-t.y,-t.z),i&&(f()?this.gyroscope.set(-i.beta,i.alpha,i.gamma):this.gyroscope.set(i.alpha,i.beta,i.gamma),this.isDeviceMotionInRadians||this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addGyroMeasurement(this.gyroscope,r)),this.filter.addAccelMeasurement(this.accelerometer,r),void(this.previousTimestampS=r))},te.prototype.onOrientationChange_=function(e){this.setScreenTransform_()},te.prototype.onMessage_=function(e){var t=e.data;t&&t.type&&\"devicemotion\"===t.type.toLowerCase()&&this.updateDeviceMotion_(t.deviceMotionEvent)},te.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new z(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new z(0,0,1),Math.PI/2)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},te.prototype.start=function(){var e,t,i;this.onDeviceMotionCallback_=this.onDeviceMotion_.bind(this),this.onOrientationChangeCallback_=this.onOrientationChange_.bind(this),this.onMessageCallback_=this.onMessage_.bind(this),this.onDeviceOrientationCallback_=this.onDeviceOrientation_.bind(this),s()&&(e=window.self!==window.top,t=M(document.referrer),i=M(window.location.href),e&&t!==i)&&window.addEventListener(\"message\",this.onMessageCallback_),window.addEventListener(\"orientationchange\",this.onOrientationChangeCallback_),this.isWithoutDeviceMotion?window.addEventListener(\"deviceorientation\",this.onDeviceOrientationCallback_):window.addEventListener(\"devicemotion\",this.onDeviceMotionCallback_)},te.prototype.stop=function(){window.removeEventListener(\"devicemotion\",this.onDeviceMotionCallback_),window.removeEventListener(\"deviceorientation\",this.onDeviceOrientationCallback_),window.removeEventListener(\"orientationchange\",this.onOrientationChangeCallback_),window.removeEventListener(\"message\",this.onMessageCallback_)};var ie=new z(1,0,0),re=new z(0,0,1),ne=new H;ne.setFromAxisAngle(ie,-Math.PI/2),ne.multiply((new H).setFromAxisAngle(re,Math.PI/2));var ae=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.config=t,this.sensor=null,this.fusionSensor=null,this._out=new Float32Array(4),this.api=null,this.errors=[],this._sensorQ=new H,this._outQ=new H,this._onSensorRead=this._onSensorRead.bind(this),this._onSensorError=this._onSensorError.bind(this),this.init()}return n(e,[{key:\"init\",value:function(){var e=null;try{(e=new RelativeOrientationSensor({frequency:60,referenceFrame:\"screen\"})).addEventListener(\"error\",this._onSensorError)}catch(e){this.errors.push(e),\"SecurityError\"===e.name?(console.error(\"Cannot construct sensors due to the Feature Policy\"),console.warn('Attempting to fall back using \"devicemotion\"; however this will fail in the future without correct permissions.'),this.useDeviceMotion()):\"ReferenceError\"===e.name?this.useDeviceMotion():console.error(e)}e&&(this.api=\"sensor\",this.sensor=e,this.sensor.addEventListener(\"reading\",this._onSensorRead),this.sensor.start())}},{key:\"useDeviceMotion\",value:function(){this.api=\"devicemotion\",this.fusionSensor=new te(this.config.K_FILTER,this.config.PREDICTION_TIME_S,this.config.YAW_ONLY,this.config.DEBUG),this.sensor&&(this.sensor.removeEventListener(\"reading\",this._onSensorRead),this.sensor.removeEventListener(\"error\",this._onSensorError),this.sensor=null)}},{key:\"getOrientation\",value:function(){if(this.fusionSensor)return this.fusionSensor.getOrientation();if(!this.sensor||!this.sensor.quaternion)return this._out[0]=this._out[1]=this._out[2]=0,this._out[3]=1,this._out;var e=this.sensor.quaternion;this._sensorQ.set(e[0],e[1],e[2],e[3]);var t=this._outQ;return t.copy(ne),t.multiply(this._sensorQ),this.config.YAW_ONLY&&(t.x=t.z=0,t.normalize()),this._out[0]=t.x,this._out[1]=t.y,this._out[2]=t.z,this._out[3]=t.w,this._out}},{key:\"_onSensorError\",value:function(e){this.errors.push(e.error),\"NotAllowedError\"===e.error.name?console.error(\"Permission to access sensor was denied\"):\"NotReadableError\"===e.error.name?console.error(\"Sensor could not be read\"):console.error(e.error),this.useDeviceMotion()}},{key:\"_onSensorRead\",value:function(){}}]),e}();function oe(){this.loadIcon_();var e=document.createElement(\"div\");(a=e.style).position=\"fixed\",a.top=0,a.right=0,a.bottom=0,a.left=0,a.backgroundColor=\"gray\",a.fontFamily=\"sans-serif\",a.zIndex=1e6;var t=document.createElement(\"img\");t.src=this.icon,(a=t.style).marginLeft=\"25%\",a.marginTop=\"25%\",a.width=\"50%\",e.appendChild(t);var i=document.createElement(\"div\");(a=i.style).textAlign=\"center\",a.fontSize=\"16px\",a.lineHeight=\"24px\",a.margin=\"24px 25%\",a.width=\"50%\",i.innerHTML=\"Place your phone into your Cardboard viewer.\",e.appendChild(i);var r=document.createElement(\"div\");(a=r.style).backgroundColor=\"#CFD8DC\",a.position=\"fixed\",a.bottom=0,a.width=\"100%\",a.height=\"48px\",a.padding=\"14px 24px\",a.boxSizing=\"border-box\",a.color=\"#656A6B\",e.appendChild(r);var n=document.createElement(\"div\");n.style.float=\"left\",n.innerHTML=\"No Cardboard viewer?\";var a,o=document.createElement(\"a\");o.href=\"https://www.google.com/get/cardboard/get-cardboard/\",o.innerHTML=\"get one\",o.target=\"_blank\",(a=o.style).float=\"right\",a.fontWeight=600,a.textTransform=\"uppercase\",a.borderLeft=\"1px solid gray\",a.paddingLeft=\"24px\",a.textDecoration=\"none\",a.color=\"#656A6B\",r.appendChild(n),r.appendChild(o),this.overlay=e,this.text=i,this.hide()}function se(e){try{this.selectedKey=localStorage.getItem(\"WEBVR_CARDBOARD_VIEWER\")}catch(e){console.error(\"Failed to load viewer profile: %s\",e)}this.selectedKey||(this.selectedKey=e||\"CardboardV1\"),this.dialog=this.createDialog_(Y.Viewers),this.root=null,this.onChangeCallbacks_=[]}oe.prototype.show=function(e){e||this.overlay.parentElement?e&&(this.overlay.parentElement&&this.overlay.parentElement!=e&&this.overlay.parentElement.removeChild(this.overlay),e.appendChild(this.overlay)):document.body.appendChild(this.overlay),this.overlay.style.display=\"block\";var t=this.overlay.querySelector(\"img\").style;m()?(t.width=\"20%\",t.marginLeft=\"40%\",t.marginTop=\"3%\"):(t.width=\"50%\",t.marginLeft=\"25%\",t.marginTop=\"25%\")},oe.prototype.hide=function(){this.overlay.style.display=\"none\"},oe.prototype.showTemporarily=function(e,t){this.show(t),this.timer=setTimeout(this.hide.bind(this),e)},oe.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},oe.prototype.update=function(){this.disableShowTemporarily(),!m()&&w()?this.show():this.hide()},oe.prototype.loadIcon_=function(){this.icon=\"data:image/svg+xml,\"+encodeURIComponent(\"\")},se.prototype.show=function(e){this.root=e,e.appendChild(this.dialog),this.dialog.querySelector(\"#\"+this.selectedKey).checked=!0,this.dialog.style.display=\"block\"},se.prototype.hide=function(){this.root&&this.root.contains(this.dialog)&&this.root.removeChild(this.dialog),this.dialog.style.display=\"none\"},se.prototype.getCurrentViewer=function(){return Y.Viewers[this.selectedKey]},se.prototype.getSelectedKey_=function(){var e=this.dialog.querySelector(\"input[name=field]:checked\");return e?e.id:null},se.prototype.onChange=function(e){this.onChangeCallbacks_.push(e)},se.prototype.fireOnChange_=function(e){for(var t=0;t.5&&(this.noSleepVideo.currentTime=Math.random())}.bind(this)))}return r(e,[{key:\"enable\",value:function(){a?(this.disable(),this.noSleepTimer=window.setInterval((function(){window.location.href=\"/\",window.setTimeout(window.stop,0)}),15e3)):this.noSleepVideo.play()}},{key:\"disable\",value:function(){a?this.noSleepTimer&&(window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),e}();e.exports=o},function(e,t,i){e.exports=\"data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA=\"}])}))})))&&ce.__esModule&&Object.prototype.hasOwnProperty.call(ce,\"default\")?ce.default:ce,le=1e3,ue=[0,0,.5,1],de=[.5,0,.5,1],pe=window.requestAnimationFrame,fe=window.cancelAnimationFrame;function me(e){Object.defineProperties(this,{hasPosition:{writable:!1,enumerable:!0,value:e.hasPosition},hasExternalDisplay:{writable:!1,enumerable:!0,value:e.hasExternalDisplay},canPresent:{writable:!1,enumerable:!0,value:e.canPresent},maxLayers:{writable:!1,enumerable:!0,value:e.maxLayers},hasOrientation:{enumerable:!0,get:function(){return S(\"VRDisplayCapabilities.prototype.hasOrientation\",\"VRDisplay.prototype.getFrameData\"),e.hasOrientation}}})}function ve(e){var t=!(\"wakelock\"in(e=e||{}))||e.wakelock;this.isPolyfilled=!0,this.displayId=le++,this.displayName=\"\",this.depthNear=.01,this.depthFar=1e4,this.isPresenting=!1,Object.defineProperty(this,\"isConnected\",{get:function(){return S(\"VRDisplay.prototype.isConnected\",\"VRDisplayCapabilities.prototype.hasExternalDisplay\"),!1}}),this.capabilities=new me({hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1}),this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.originalParent_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenElementCachedStyle_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,t&&w()&&(this.wakelock_=new he)}ve.prototype.getFrameData=function(e){return E(e,this._getPose(),this)},ve.prototype.getPose=function(){return S(\"VRDisplay.prototype.getPose\",\"VRDisplay.prototype.getFrameData\"),this._getPose()},ve.prototype.resetPose=function(){return S(\"VRDisplay.prototype.resetPose\"),this._resetPose()},ve.prototype.getImmediatePose=function(){return S(\"VRDisplay.prototype.getImmediatePose\",\"VRDisplay.prototype.getFrameData\"),this._getPose()},ve.prototype.requestAnimationFrame=function(e){return pe(e)},ve.prototype.cancelAnimationFrame=function(e){return fe(e)},ve.prototype.wrapForFullscreen=function(e){if(s())return e;if(!this.fullscreenWrapper_){this.fullscreenWrapper_=document.createElement(\"div\");var t=[\"height: \"+Math.min(screen.height,screen.width)+\"px !important\",\"top: 0 !important\",\"left: 0 !important\",\"right: 0 !important\",\"border: 0\",\"margin: 0\",\"padding: 0\",\"z-index: 999999 !important\",\"position: fixed\"];this.fullscreenWrapper_.setAttribute(\"style\",t.join(\"; \")+\";\"),this.fullscreenWrapper_.classList.add(\"webvr-polyfill-fullscreen-wrapper\")}if(this.fullscreenElement_==e)return this.fullscreenWrapper_;if(this.fullscreenElement_&&(this.originalParent_?this.originalParent_.appendChild(this.fullscreenElement_):this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)),this.fullscreenElement_=e,this.originalParent_=e.parentElement,this.originalParent_||document.body.appendChild(e),!this.fullscreenWrapper_.parentElement){var i=this.fullscreenElement_.parentElement;i.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),i.removeChild(this.fullscreenElement_)}this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenElementCachedStyle_=this.fullscreenElement_.getAttribute(\"style\");var r=this;return function(){if(r.fullscreenElement_){var e=[\"position: absolute\",\"top: 0\",\"left: 0\",\"width: \"+Math.max(screen.width,screen.height)+\"px\",\"height: \"+Math.min(screen.height,screen.width)+\"px\",\"border: 0\",\"margin: 0\",\"padding: 0\"];r.fullscreenElement_.setAttribute(\"style\",e.join(\"; \")+\";\")}}(),this.fullscreenWrapper_},ve.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var e=this.fullscreenElement_;this.fullscreenElementCachedStyle_?e.setAttribute(\"style\",this.fullscreenElementCachedStyle_):e.removeAttribute(\"style\"),this.fullscreenElement_=null,this.fullscreenElementCachedStyle_=null;var t=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(e),this.originalParent_===t?t.insertBefore(e,this.fullscreenWrapper_):this.originalParent_&&this.originalParent_.appendChild(e),t.removeChild(this.fullscreenWrapper_),e}},ve.prototype.requestPresent=function(e){var t=this.isPresenting,i=this;return e instanceof Array||(S(\"VRDisplay.prototype.requestPresent with non-array argument\",\"an array of VRLayers as the first argument\"),e=[e]),new Promise((function(r,n){if(i.capabilities.canPresent)if(0==e.length||e.length>i.capabilities.maxLayers)n(new Error(\"Invalid number of layers.\"));else{var a=e[0];if(a.source){var o=a.leftBounds||ue,h=a.rightBounds||de;if(t){var l=i.layer_;l.source!==a.source&&(l.source=a.source);for(var u=0;u<4;u++)l.leftBounds[u]=o[u],l.rightBounds[u]=h[u];return i.wrapForFullscreen(i.layer_.source),i.updatePresent_(),void r()}if(i.layer_={predistorted:a.predistorted,source:a.source,leftBounds:o.slice(0),rightBounds:h.slice(0)},i.waitingForPresent_=!1,i.layer_&&i.layer_.source){var d=i.wrapForFullscreen(i.layer_.source);i.addFullscreenListeners_(d,(function(){var e=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;i.isPresenting=d===e,i.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock(\"landscape-primary\").catch((function(e){console.error(\"screen.orientation.lock() failed due to\",e.message)})),i.waitingForPresent_=!1,i.beginPresent_(),r()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),i.removeFullscreenWrapper(),i.disableWakeLock(),i.endPresent_(),i.removeFullscreenListeners_()),i.fireVRDisplayPresentChange_()}),(function(){i.waitingForPresent_&&(i.removeFullscreenWrapper(),i.removeFullscreenListeners_(),i.disableWakeLock(),i.waitingForPresent_=!1,i.isPresenting=!1,n(new Error(\"Unable to present.\")))})),function(e){if(c())return!1;if(e.requestFullscreen)e.requestFullscreen();else if(e.webkitRequestFullscreen)e.webkitRequestFullscreen();else if(e.mozRequestFullScreen)e.mozRequestFullScreen();else{if(!e.msRequestFullscreen)return!1;e.msRequestFullscreen()}return!0}(d)?(i.enableWakeLock(),i.waitingForPresent_=!0):(s()||c())&&(i.enableWakeLock(),i.isPresenting=!0,i.beginPresent_(),i.fireVRDisplayPresentChange_(),r())}i.waitingForPresent_||s()||(y(),n(new Error(\"Unable to present.\")))}else r()}else n(new Error(\"VRDisplay is not capable of presenting.\"))}))},ve.prototype.exitPresent=function(){var e=this.isPresenting,t=this;return this.isPresenting=!1,this.layer_=null,this.disableWakeLock(),new Promise((function(i,r){e?(!y()&&s()&&(t.endPresent_(),t.fireVRDisplayPresentChange_()),c()&&(t.removeFullscreenWrapper(),t.removeFullscreenListeners_(),t.endPresent_(),t.fireVRDisplayPresentChange_()),i()):r(new Error(\"Was not presenting to VRDisplay.\"))}))},ve.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},ve.prototype.fireVRDisplayPresentChange_=function(){var e=new CustomEvent(\"vrdisplaypresentchange\",{detail:{display:this}});window.dispatchEvent(e)},ve.prototype.fireVRDisplayConnect_=function(){var e=new CustomEvent(\"vrdisplayconnect\",{detail:{display:this}});window.dispatchEvent(e)},ve.prototype.addFullscreenListeners_=function(e,t,i){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=e,this.fullscreenChangeHandler_=t,this.fullscreenErrorHandler_=i,t&&(document.fullscreenEnabled?e.addEventListener(\"fullscreenchange\",t,!1):document.webkitFullscreenEnabled?e.addEventListener(\"webkitfullscreenchange\",t,!1):document.mozFullScreenEnabled?document.addEventListener(\"mozfullscreenchange\",t,!1):document.msFullscreenEnabled&&e.addEventListener(\"msfullscreenchange\",t,!1)),i&&(document.fullscreenEnabled?e.addEventListener(\"fullscreenerror\",i,!1):document.webkitFullscreenEnabled?e.addEventListener(\"webkitfullscreenerror\",i,!1):document.mozFullScreenEnabled?document.addEventListener(\"mozfullscreenerror\",i,!1):document.msFullscreenEnabled&&e.addEventListener(\"msfullscreenerror\",i,!1))},ve.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var e=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var t=this.fullscreenChangeHandler_;e.removeEventListener(\"fullscreenchange\",t,!1),e.removeEventListener(\"webkitfullscreenchange\",t,!1),document.removeEventListener(\"mozfullscreenchange\",t,!1),e.removeEventListener(\"msfullscreenchange\",t,!1)}if(this.fullscreenErrorHandler_){var i=this.fullscreenErrorHandler_;e.removeEventListener(\"fullscreenerror\",i,!1),e.removeEventListener(\"webkitfullscreenerror\",i,!1),document.removeEventListener(\"mozfullscreenerror\",i,!1),e.removeEventListener(\"msfullscreenerror\",i,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},ve.prototype.enableWakeLock=function(){this.wakelock_&&this.wakelock_.enable()},ve.prototype.disableWakeLock=function(){this.wakelock_&&this.wakelock_.disable()},ve.prototype.beginPresent_=function(){},ve.prototype.endPresent_=function(){},ve.prototype.submitFrame=function(e){},ve.prototype.getEyeParameters=function(e){return null};var ge={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:\"\",MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:\"https://dpdb.webvr.rocks/dpdb.json\",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},ye=\"left\",Ae=\"right\";function xe(e){var t=b({},ge);e=b(t,e||{}),ve.call(this,{wakelock:e.MOBILE_WAKE_LOCK}),this.config=e,this.displayName=\"Cardboard VRDisplay\",this.capabilities=new me({hasPosition:!1,hasOrientation:!0,hasExternalDisplay:!1,canPresent:!0,maxLayers:1}),this.stageParameters=null,this.bufferScale_=this.config.BUFFER_SCALE,this.poseSensor_=new ae(this.config),this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new Z(this.config.DPDB_URL,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new Y(this.dpdb_.getDeviceParams(),e.ADDITIONAL_VIEWERS),this.viewerSelector_=new se(e.DEFAULT_VIEWER),this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.config.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new oe),s()&&window.addEventListener(\"resize\",this.onResize_.bind(this))}return xe.prototype=Object.create(ve.prototype),xe.prototype._getPose=function(){return{position:null,orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},xe.prototype._resetPose=function(){this.poseSensor_.resetPose&&this.poseSensor_.resetPose()},xe.prototype._getFieldOfView=function(e){var t;if(e==ye)t=this.deviceInfo_.getFieldOfViewLeftEye();else{if(e!=Ae)return console.error(\"Invalid eye provided: %s\",e),null;t=this.deviceInfo_.getFieldOfViewRightEye()}return t},xe.prototype._getEyeOffset=function(e){var t;if(e==ye)t=[.5*-this.deviceInfo_.viewer.interLensDistance,0,0];else{if(e!=Ae)return console.error(\"Invalid eye provided: %s\",e),null;t=[.5*this.deviceInfo_.viewer.interLensDistance,0,0]}return t},xe.prototype.getEyeParameters=function(e){var t=this._getEyeOffset(e),i=this._getFieldOfView(e),r={offset:t,renderWidth:.5*this.deviceInfo_.device.width*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_};return Object.defineProperty(r,\"fieldOfView\",{enumerable:!0,get:function(){return S(\"VRFieldOfView\",\"VRFrameData's projection matrices\"),i}}),r},xe.prototype.onDeviceParamsUpdated_=function(e){this.config.DEBUG&&console.log(\"DPDB reported that device params were updated.\"),this.deviceInfo_.updateDeviceParams(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_)},xe.prototype.updateBounds_=function(){this.layer_&&this.distorter_&&(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)},xe.prototype.beginPresent_=function(){var e=this.layer_.source.getContext(\"webgl\");e||(e=this.layer_.source.getContext(\"experimental-webgl\")),e||(e=this.layer_.source.getContext(\"webgl2\")),e&&(this.layer_.predistorted?this.config.CARDBOARD_UI_DISABLED||(e.canvas.width=v()*this.bufferScale_,e.canvas.height=g()*this.bufferScale_,this.cardboardUI_=new N(e)):(this.config.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new N(e)),this.distorter_=new C(e,this.cardboardUI_,this.config.BUFFER_SCALE,this.config.DIRTY_SUBMIT_FRAME_BINDINGS),this.distorter_.updateDeviceInfo(this.deviceInfo_)),this.cardboardUI_&&this.cardboardUI_.listen(function(e){this.viewerSelector_.show(this.layer_.source.parentElement),e.stopPropagation(),e.preventDefault()}.bind(this),function(e){this.exitPresent(),e.stopPropagation(),e.preventDefault()}.bind(this)),this.rotateInstructions_&&(m()&&w()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener(\"orientationchange\",this.orientationHandler),this.vrdisplaypresentchangeHandler=this.updateBounds_.bind(this),window.addEventListener(\"vrdisplaypresentchange\",this.vrdisplaypresentchangeHandler),this.fireVRDisplayDeviceParamsChange_())},xe.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener(\"orientationchange\",this.orientationHandler),window.removeEventListener(\"vrdisplaypresentchange\",this.vrdisplaypresentchangeHandler)},xe.prototype.updatePresent_=function(){this.endPresent_(),this.beginPresent_()},xe.prototype.submitFrame=function(e){if(this.distorter_)this.updateBounds_(),this.distorter_.submitFrame();else if(this.cardboardUI_&&this.layer_){var t=this.layer_.source.getContext(\"webgl\");t||(t=this.layer_.source.getContext(\"experimental-webgl\")),t||(t=this.layer_.source.getContext(\"webgl2\"));var i=t.canvas;i.width==this.lastWidth&&i.height==this.lastHeight||this.cardboardUI_.onResize(),this.lastWidth=i.width,this.lastHeight=i.height,this.cardboardUI_.render()}},xe.prototype.onOrientationChange_=function(e){this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update(),this.onResize_()},xe.prototype.onResize_=function(e){if(this.layer_){var t=this.layer_.source.getContext(\"webgl\");t||(t=this.layer_.source.getContext(\"experimental-webgl\")),t||(t=this.layer_.source.getContext(\"webgl2\")),t.canvas.setAttribute(\"style\",[\"position: absolute\",\"top: 0\",\"left: 0\",\"width: 100vw\",\"height: 100vh\",\"border: 0\",\"margin: 0\",\"padding: 0px\",\"box-sizing: content-box\"].join(\"; \")+\";\"),_(t.canvas)}},xe.prototype.onViewerChanged_=function(e){this.deviceInfo_.setViewer(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},xe.prototype.fireVRDisplayDeviceParamsChange_=function(){var e=new CustomEvent(\"vrdisplaydeviceparamschange\",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(e)},xe.VRFrameData=function(){this.leftProjectionMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.rightViewMatrix=new Float32Array(16),this.pose=null},xe.VRDisplay=ve,xe}()})))&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,\"default\")?e.default:e,s={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:\"\",PROVIDE_MOBILE_VRDISPLAY:!0,MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:\"https://dpdb.webvr.rocks/dpdb.json\",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1};function c(e){this.config=a(a({},s),e),this.polyfillDisplays=[],this.enabled=!1,this.hasNative=\"getVRDisplays\"in navigator,this.native={},this.native.getVRDisplays=navigator.getVRDisplays,this.native.VRFrameData=window.VRFrameData,this.native.VRDisplay=window.VRDisplay,(!this.hasNative||this.config.PROVIDE_MOBILE_VRDISPLAY&&i())&&(this.enable(),this.getVRDisplays().then((function(e){e&&e[0]&&e[0].fireVRDisplayConnect_&&e[0].fireVRDisplayConnect_()})))}c.prototype.getPolyfillDisplays=function(){if(this._polyfillDisplaysPopulated)return this.polyfillDisplays;if(i()){var e=new o({ADDITIONAL_VIEWERS:this.config.ADDITIONAL_VIEWERS,DEFAULT_VIEWER:this.config.DEFAULT_VIEWER,MOBILE_WAKE_LOCK:this.config.MOBILE_WAKE_LOCK,DEBUG:this.config.DEBUG,DPDB_URL:this.config.DPDB_URL,CARDBOARD_UI_DISABLED:this.config.CARDBOARD_UI_DISABLED,K_FILTER:this.config.K_FILTER,PREDICTION_TIME_S:this.config.PREDICTION_TIME_S,ROTATE_INSTRUCTIONS_DISABLED:this.config.ROTATE_INSTRUCTIONS_DISABLED,YAW_ONLY:this.config.YAW_ONLY,BUFFER_SCALE:this.config.BUFFER_SCALE,DIRTY_SUBMIT_FRAME_BINDINGS:this.config.DIRTY_SUBMIT_FRAME_BINDINGS});this.polyfillDisplays.push(e)}return this._polyfillDisplaysPopulated=!0,this.polyfillDisplays},c.prototype.enable=function(){if(this.enabled=!0,this.hasNative&&this.native.VRFrameData){var e=this.native.VRFrameData,t=new this.native.VRFrameData,i=this.native.VRDisplay.prototype.getFrameData;window.VRDisplay.prototype.getFrameData=function(r){r instanceof e?i.call(this,r):(i.call(this,t),r.pose=t.pose,n(t.leftProjectionMatrix,r.leftProjectionMatrix),n(t.rightProjectionMatrix,r.rightProjectionMatrix),n(t.leftViewMatrix,r.leftViewMatrix),n(t.rightViewMatrix,r.rightViewMatrix))}}navigator.getVRDisplays=this.getVRDisplays.bind(this),window.VRDisplay=o.VRDisplay,window.VRFrameData=o.VRFrameData},c.prototype.getVRDisplays=function(){var e=this;return this.config,this.hasNative?this.native.getVRDisplays.call(navigator).then((function(t){return t.length>0?t:e.getPolyfillDisplays()})):Promise.resolve(this.getPolyfillDisplays())},c.version=\"0.10.12\",c.VRFrameData=o.VRFrameData,c.VRDisplay=o.VRDisplay;var h=Object.freeze({default:c}),l=h&&c||h;return void 0!==t&&t.window&&(t.document||(t.document=t.window.document),t.navigator||(t.navigator=t.window.navigator)),l}()})));function l(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return\"number\"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),\"name\"in Function.prototype==!1&&Object.defineProperty(Function.prototype,\"name\",{get:function(){return this.toString().match(/^\\s*function\\s*([^\\(\\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError(\"Cannot convert undefined or null to object\");for(var t=Object(e),i=1;i>8&255]+e[t>>16&255]+e[t>>24&255]+\"-\"+e[255&i]+e[i>>8&255]+\"-\"+e[i>>16&15|64]+e[i>>24&255]+\"-\"+e[63&r|128]+e[r>>8&255]+\"-\"+e[r>>16&255]+e[r>>24&255]+e[255&n]+e[n>>8&255]+e[n>>16&255]+e[n>>24&255]).toUpperCase()}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*M.DEG2RAD},radToDeg:function(e){return e*M.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};function T(e,t){this.x=e||0,this.y=t||0}function S(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error(\"THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.\")}function R(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1}function L(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}function P(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error(\"THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.\")}Object.defineProperties(T.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(T.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error(\"index is out of range: \"+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error(\"index is out of range: \"+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:(u=new T,d=new T,function(e,t){return u.set(e,e),d.set(t,t),this.clamp(u,d)}),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn(\"THREE.Vector2: offset has been removed from .fromBufferAttribute().\"),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*r+e.x,this.y=n*r+a*i+e.y,this}}),Object.assign(S.prototype,{isMatrix4:!0,set:function(e,t,i,r,n,a,o,s,c,h,l,u,d,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=n,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=h,v[10]=l,v[14]=u,v[3]=d,v[7]=p,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new S).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:(x=new L,function(e){var t=this.elements,i=e.elements,r=1/x.setFromMatrixColumn(e,0).length(),n=1/x.setFromMatrixColumn(e,1).length(),a=1/x.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}),makeRotationFromEuler:function(e){e&&e.isEuler||console.error(\"THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.\");var t=this.elements,i=e.x,r=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),s=Math.cos(r),c=Math.sin(r),h=Math.cos(n),l=Math.sin(n);if(\"XYZ\"===e.order){var u=a*h,d=a*l,p=o*h,f=o*l;t[0]=s*h,t[4]=-s*l,t[8]=c,t[1]=d+p*c,t[5]=u-f*c,t[9]=-o*s,t[2]=f-u*c,t[6]=p+d*c,t[10]=a*s}else if(\"YXZ\"===e.order){var m=s*h,v=s*l,g=c*h,y=c*l;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*c,t[1]=a*l,t[5]=a*h,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if(\"ZXY\"===e.order){m=s*h,v=s*l,g=c*h,y=c*l;t[0]=m-y*o,t[4]=-a*l,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*h,t[9]=y-m*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(\"ZYX\"===e.order){u=a*h,d=a*l,p=o*h,f=o*l;t[0]=s*h,t[4]=p*c-d,t[8]=u*c+f,t[1]=s*l,t[5]=f*c+u,t[9]=d*c-p,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(\"YZX\"===e.order){var A=a*s,x=a*c,w=o*s,b=o*c;t[0]=s*h,t[4]=b-A*l,t[8]=w*l+x,t[1]=l,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=x*l+w,t[10]=A-b*l}else if(\"XZY\"===e.order){A=a*s,x=a*c,w=o*s,b=o*c;t[0]=s*h,t[4]=-l,t[8]=c*h,t[1]=A*l+b,t[5]=a*h,t[9]=x*l-w,t[2]=w*l-x,t[6]=o*h,t[10]=b*l+A}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:(y=new L(0,0,0),A=new L(1,1,1),function(e){return this.compose(y,e,A)}),lookAt:(m=new L,v=new L,g=new L,function(e,t,i){var r=this.elements;return g.subVectors(e,t),0===g.lengthSq()&&(g.z=1),g.normalize(),m.crossVectors(i,g),0===m.lengthSq()&&(1===Math.abs(i.z)?g.x+=1e-4:g.z+=1e-4,g.normalize(),m.crossVectors(i,g)),m.normalize(),v.crossVectors(g,m),r[0]=m.x,r[4]=v.x,r[8]=g.x,r[1]=m.y,r[5]=v.y,r[9]=g.y,r[2]=m.z,r[6]=v.z,r[10]=g.z,this}),multiply:function(e,t){return void 0!==t?(console.warn(\"THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.\"),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,a=i[0],o=i[4],s=i[8],c=i[12],h=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],v=i[14],g=i[3],y=i[7],A=i[11],x=i[15],w=r[0],b=r[4],_=r[8],E=r[12],M=r[1],T=r[5],S=r[9],R=r[13],L=r[2],P=r[6],C=r[10],D=r[14],I=r[3],O=r[7],N=r[11],B=r[15];return n[0]=a*w+o*M+s*L+c*I,n[4]=a*b+o*T+s*P+c*O,n[8]=a*_+o*S+s*C+c*N,n[12]=a*E+o*R+s*D+c*B,n[1]=h*w+l*M+u*L+d*I,n[5]=h*b+l*T+u*P+d*O,n[9]=h*_+l*S+u*C+d*N,n[13]=h*E+l*R+u*D+d*B,n[2]=p*w+f*M+m*L+v*I,n[6]=p*b+f*T+m*P+v*O,n[10]=p*_+f*S+m*C+v*N,n[14]=p*E+f*R+m*D+v*B,n[3]=g*w+y*M+A*L+x*I,n[7]=g*b+y*T+A*P+x*O,n[11]=g*_+y*S+A*C+x*N,n[15]=g*E+y*R+A*D+x*B,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new L;return function(t){for(var i=0,r=t.count;i=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var A=Math.sqrt(y),x=Math.atan2(A,v*g);m=Math.sin(m*x)/A,o=Math.sin(o*x)/A}var w=o*g;if(s=s*m+u*w,c=c*m+d*w,h=h*m+p*w,l=l*m+f*w,m===1-o){var b=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=b,c*=b,h*=b,l*=b}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),Object.defineProperties(R.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(R.prototype,{set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error(\"THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.\");var i=e._x,r=e._y,n=e._z,a=e.order,o=Math.cos,s=Math.sin,c=o(i/2),h=o(r/2),l=o(n/2),u=s(i/2),d=s(r/2),p=s(n/2);return\"XYZ\"===a?(this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p):\"YXZ\"===a?(this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p):\"ZXY\"===a?(this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p):\"ZYX\"===a?(this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p):\"YZX\"===a?(this._x=u*h*l+c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l-u*d*p):\"XZY\"===a&&(this._x=u*h*l-c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l+u*d*p),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],a=i[8],o=i[1],s=i[5],c=i[9],h=i[2],l=i[6],u=i[10],d=r+s+u;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(l-c)*t,this._y=(a-h)*t,this._z=(o-n)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(a+h)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(a-h)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(o-n)/t,this._x=(a+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new L;return function(i,r){return void 0===t&&(t=new L),(e=i.dot(r)+1)<1e-6?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,r),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn(\"THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.\"),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,a=e._w,o=t._x,s=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+r*c-n*s,this._y=r*h+a*s+n*o-i*c,this._z=n*h+a*c+i*s-r*o,this._w=a*h-i*o-r*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,a=this._w,o=a*e._w+i*e._x+r*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,o),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=a*h+this._w*l,this._x=i*h+this._x*l,this._y=r*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(L.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error(\"index is out of range: \"+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error(\"index is out of range: \"+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.\"),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:(w=new R,function(e){return e&&e.isEuler||console.error(\"THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.\"),this.applyQuaternion(w.setFromEuler(e))}),applyAxisAngle:function(){var e=new R;return function(t,i){return this.applyQuaternion(e.setFromAxisAngle(t,i))}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,a=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*a,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*r-o*i,h=s*i+o*t-n*r,l=s*r+n*i-a*t,u=-n*t-a*i-o*r;return this.x=c*s+u*-n+h*-o-l*-a,this.y=h*s+u*-a+l*-n-c*-o,this.z=l*s+u*-o+c*-a-h*-n,this},project:function(){var e=new S;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new S;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new L,t=new L;return function(i,r){return e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.\"),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-n*o,this.y=n*a-i*s,this.z=i*o-r*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new L;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new L;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(M.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn(\"THREE.Vector3: offset has been removed from .fromBufferAttribute().\"),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(P.prototype,{isMatrix3:!0,set:function(e,t,i,r,n,a,o,s,c){var h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=n,h[5]=s,h[6]=i,h[7]=a,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new L;return function(t){for(var i=0,r=t.count;i2048||t.height>2048?t.toDataURL(\"image/jpeg\",.6):t.toDataURL(\"image/png\")}(r)}),i.image=r.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:\"dispose\"})},transformUv:function(e){if(300===this.mapping){if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.defineProperty(F.prototype,\"needsUpdate\",{set:function(e){!0===e&&this.version++}}),Object.assign(U.prototype,{isVector4:!0,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error(\"index is out of range: \"+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error(\"index is out of range: \"+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.\"),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn(\"THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.\"),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,r,n,a=e.elements,o=a[0],s=a[4],c=a[8],h=a[1],l=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-h)<.01&&Math.abs(c-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(s+h)<.1&&Math.abs(c+d)<.1&&Math.abs(u+p)<.1&&Math.abs(o+l+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(l+1)/2,g=(f+1)/2,y=(s+h)/4,A=(c+d)/4,x=(u+p)/4;return m>v&&m>g?m<.01?(i=0,r=.707106781,n=.707106781):(r=y/(i=Math.sqrt(m)),n=A/i):v>g?v<.01?(i=.707106781,r=0,n=.707106781):(i=y/(r=Math.sqrt(v)),n=x/r):g<.01?(i=.707106781,r=.707106781,n=0):(i=A/(n=Math.sqrt(g)),r=x/n),this.set(i,r,n,t),this}var w=Math.sqrt((p-u)*(p-u)+(c-d)*(c-d)+(h-s)*(h-s));return Math.abs(w)<.001&&(w=1),this.x=(p-u)/w,this.y=(c-d)/w,this.z=(h-s)/w,this.w=Math.acos((o+l+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new U,t=new U),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn(\"THREE.Vector4: offset has been removed from .fromBufferAttribute().\"),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),z.prototype=Object.assign(Object.create(l.prototype),{constructor:z,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:\"dispose\"})}}),G.prototype=Object.create(z.prototype),G.prototype.constructor=G,G.prototype.isWebGLRenderTargetCube=!0,V.prototype=Object.create(F.prototype),V.prototype.constructor=V,V.prototype.isDataTexture=!0,Object.assign(H.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;sn&&(n=h),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,i,r),this.max.set(n,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0,s=0,c=e.count;sn&&(n=h),l>a&&(a=l),u>o&&(o=u)}return this.min.set(t,i,r),this.max.set(n,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn(\"THREE.Box3: .getParameter() target is now required\"),t=new L),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:(C=new L,function(e){return this.clampPoint(e.center,C),C.distanceToSquared(e.center)<=e.radius*e.radius}),intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},intersectsTriangle:function(){var e=new L,t=new L,i=new L,r=new L,n=new L,a=new L,o=new L,s=new L,c=new L,h=new L;function l(r){var n,a;for(n=0,a=r.length-3;n<=a;n+=3){o.fromArray(r,n);var s=c.x*Math.abs(o.x)+c.y*Math.abs(o.y)+c.z*Math.abs(o.z),h=e.dot(o),l=t.dot(o),u=i.dot(o);if(Math.max(-Math.max(h,l,u),Math.min(h,l,u))>s)return!1}return!0}return function(o){if(this.isEmpty())return!1;this.getCenter(s),c.subVectors(this.max,s),e.subVectors(o.a,s),t.subVectors(o.b,s),i.subVectors(o.c,s),r.subVectors(t,e),n.subVectors(i,t),a.subVectors(e,i);var u=[0,-r.z,r.y,0,-n.z,n.y,0,-a.z,a.y,r.z,0,-r.x,n.z,0,-n.x,a.z,0,-a.x,-r.y,r.x,0,-n.y,n.x,0,-a.y,a.x,0];return!!l(u)&&(!!l(u=[1,0,0,0,1,0,0,0,1])&&(h.crossVectors(r,n),l(u=[h.x,h.y,h.z])))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn(\"THREE.Box3: .clampPoint() target is now required\"),t=new L),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new L;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new L;return function(t){return void 0===t&&(console.warn(\"THREE.Box3: .getBoundingSphere() target is now required\"),t=new k),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){if(this.isEmpty())return this;var t=e.elements,i=t[0]*this.min.x,r=t[1]*this.min.x,n=t[2]*this.min.x,a=t[0]*this.max.x,o=t[1]*this.max.x,s=t[2]*this.max.x,c=t[4]*this.min.y,h=t[5]*this.min.y,l=t[6]*this.min.y,u=t[4]*this.max.y,d=t[5]*this.max.y,p=t[6]*this.max.y,f=t[8]*this.min.z,m=t[9]*this.min.z,v=t[10]*this.min.z,g=t[8]*this.max.z,y=t[9]*this.max.z,A=t[10]*this.max.z;return this.min.x=Math.min(i,a)+Math.min(c,u)+Math.min(f,g)+t[12],this.min.y=Math.min(r,o)+Math.min(h,d)+Math.min(m,y)+t[13],this.min.z=Math.min(n,s)+Math.min(l,p)+Math.min(v,A)+t[14],this.max.x=Math.max(i,a)+Math.max(c,u)+Math.max(f,g)+t[12],this.max.y=Math.max(r,o)+Math.max(h,d)+Math.max(m,y)+t[13],this.max.z=Math.max(n,s)+Math.max(l,p)+Math.max(v,A)+t[14],this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(k.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:(D=new H,function(e,t){var i=this.center;void 0!==t?i.copy(t):D.setFromPoints(e).getCenter(i);for(var r=0,n=0,a=e.length;nthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn(\"THREE.Sphere: .getBoundingBox() target is now required\"),e=new H),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(j.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new L,t=new L;return function(i,r,n){var a=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(a,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn(\"THREE.Plane: .projectPoint() target is now required\"),t=new L),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new L;return function(t,i){void 0===i&&(console.warn(\"THREE.Plane: .intersectLine() target is now required\"),i=new L);var r=t.delta(e),n=this.normal.dot(r);if(0===n)return 0===this.distanceToPoint(t.start)?i.copy(t.start):void 0;var a=-(t.start.dot(this.normal)+this.constant)/n;return a<0||a>1?void 0:i.copy(r).multiplyScalar(a).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn(\"THREE.Plane: .coplanarPoint() target is now required\"),e=new L),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new L,t=new P;return function(i,r){var n=r||t.getNormalMatrix(i),a=this.coplanarPoint(e).applyMatrix4(i),o=this.normal.applyMatrix3(n).normalize();return this.constant=-a.dot(o),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(W.prototype,{set:function(e,t,i,r,n,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(n),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],a=i[2],o=i[3],s=i[4],c=i[5],h=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],v=i[13],g=i[14],y=i[15];return t[0].setComponents(o-r,l-s,f-u,y-m).normalize(),t[1].setComponents(o+r,l+s,f+u,y+m).normalize(),t[2].setComponents(o+n,l+c,f+d,y+v).normalize(),t[3].setComponents(o-n,l-c,f-d,y-v).normalize(),t[4].setComponents(o-a,l-h,f-p,y-g).normalize(),t[5].setComponents(o+a,l+h,f+p,y+g).normalize(),this},intersectsObject:(N=new k,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),N.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(N)}),intersectsSprite:function(){var e=new k;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(i)0?e.min.x:e.max.x,O.x=r.normal.x>0?e.max.x:e.min.x,I.y=r.normal.y>0?e.min.y:e.max.y,O.y=r.normal.y>0?e.max.y:e.min.y,I.z=r.normal.z>0?e.min.z:e.max.z,O.z=r.normal.z>0?e.max.z:e.min.z;var n=r.distanceToPoint(I),a=r.distanceToPoint(O);if(n<0&&a<0)return!1}return!0}),containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}});var X,Y={alphamap_fragment:\"#ifdef USE_ALPHAMAP\\n\\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\\n#endif\\n\",alphamap_pars_fragment:\"#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\\n\",alphatest_fragment:\"#ifdef ALPHATEST\\n\\tif ( diffuseColor.a < ALPHATEST ) discard;\\n#endif\\n\",aomap_fragment:\"#ifdef USE_AOMAP\\n\\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n\\treflectedLight.indirectDiffuse *= ambientOcclusion;\\n\\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\\n\\t#endif\\n#endif\\n\",aomap_pars_fragment:\"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif\",begin_vertex:\"\\nvec3 transformed = vec3( position );\\n\",beginnormal_vertex:\"\\nvec3 objectNormal = vec3( normal );\\n\",bsdfs:\"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\\n\\tif( decayExponent > 0.0 ) {\\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\\n\\t\\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\\n\\t\\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\\n\\t\\treturn distanceFalloff * maxDistanceCutoffFactor;\\n#else\\n\\t\\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\\n#endif\\n\\t}\\n\\treturn 1.0;\\n}\\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\\n\\treturn RECIPROCAL_PI * diffuseColor;\\n}\\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\\n\\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\\n\\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\\n}\\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\treturn 1.0 / ( gl * gv );\\n}\\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\treturn 0.5 / max( gv + gl, EPSILON );\\n}\\nfloat D_GGX( const in float alpha, const in float dotNH ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\\n\\treturn RECIPROCAL_PI * a2 / pow2( denom );\\n}\\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat alpha = pow2( roughness );\\n\\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\\n\\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\\n\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\\n\\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\\n\\tvec3 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\\n\\tfloat D = D_GGX( alpha, dotNH );\\n\\treturn F * ( G * D );\\n}\\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\\n\\tconst float LUT_SIZE = 64.0;\\n\\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\\n\\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\\n\\tfloat dotNV = saturate( dot( N, V ) );\\n\\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\\n\\tuv = uv * LUT_SCALE + LUT_BIAS;\\n\\treturn uv;\\n}\\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\\n\\tfloat l = length( f );\\n\\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\\n}\\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\\n\\tfloat x = dot( v1, v2 );\\n\\tfloat y = abs( x );\\n\\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\\n\\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\\n\\tfloat v = a / b;\\n\\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\\n\\treturn cross( v1, v2 ) * theta_sintheta;\\n}\\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\\n\\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\\n\\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\\n\\tvec3 lightNormal = cross( v1, v2 );\\n\\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\\n\\tvec3 T1, T2;\\n\\tT1 = normalize( V - N * dot( V, N ) );\\n\\tT2 = - cross( N, T1 );\\n\\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\\n\\tvec3 coords[ 4 ];\\n\\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\\n\\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\\n\\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\\n\\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\\n\\tcoords[ 0 ] = normalize( coords[ 0 ] );\\n\\tcoords[ 1 ] = normalize( coords[ 1 ] );\\n\\tcoords[ 2 ] = normalize( coords[ 2 ] );\\n\\tcoords[ 3 ] = normalize( coords[ 3 ] );\\n\\tvec3 vectorFormFactor = vec3( 0.0 );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\\n\\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\\n\\treturn vec3( result );\\n}\\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\\n\\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\\n\\tvec4 r = roughness * c0 + c1;\\n\\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\\n\\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\\n\\treturn specularColor * AB.x + AB.y;\\n}\\nfloat G_BlinnPhong_Implicit( ) {\\n\\treturn 0.25;\\n}\\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\\n\\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\\n}\\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\\n\\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\\n\\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\\n\\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\\n\\tvec3 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_BlinnPhong_Implicit( );\\n\\tfloat D = D_BlinnPhong( shininess, dotNH );\\n\\treturn F * ( G * D );\\n}\\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\\n\\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\\n}\\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\\n\\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\\n}\\n\",bumpmap_pars_fragment:\"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd() {\\n\\t\\tvec2 dSTdx = dFdx( vUv );\\n\\t\\tvec2 dSTdy = dFdy( vUv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\\n\\t\\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\\n\\t\\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 );\\n\\t\\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\\n\",clipping_planes_fragment:\"#if NUM_CLIPPING_PLANES > 0\\n\\tvec4 plane;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\\n\\t\\tplane = clippingPlanes[ i ];\\n\\t\\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\\n\\t}\\n\\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\\n\\t\\tbool clipped = true;\\n\\t\\t#pragma unroll_loop\\n\\t\\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\\n\\t\\t\\tplane = clippingPlanes[ i ];\\n\\t\\t\\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\\n\\t\\t}\\n\\t\\tif ( clipped ) discard;\\n\\t#endif\\n#endif\\n\",clipping_planes_pars_fragment:\"#if NUM_CLIPPING_PLANES > 0\\n\\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\\n\\t\\tvarying vec3 vViewPosition;\\n\\t#endif\\n\\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif\\n\",clipping_planes_pars_vertex:\"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n\",clipping_planes_vertex:\"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\\n\",color_fragment:\"#ifdef USE_COLOR\\n\\tdiffuseColor.rgb *= vColor;\\n#endif\",color_pars_fragment:\"#ifdef USE_COLOR\\n\\tvarying vec3 vColor;\\n#endif\\n\",color_pars_vertex:\"#ifdef USE_COLOR\\n\\tvarying vec3 vColor;\\n#endif\",color_vertex:\"#ifdef USE_COLOR\\n\\tvColor.xyz = color.xyz;\\n#endif\",common:\"#define PI 3.14159265359\\n#define PI2 6.28318530718\\n#define PI_HALF 1.5707963267949\\n#define RECIPROCAL_PI 0.31830988618\\n#define RECIPROCAL_PI2 0.15915494\\n#define LOG2 1.442695\\n#define EPSILON 1e-6\\n#define saturate(a) clamp( a, 0.0, 1.0 )\\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\\nfloat pow2( const in float x ) { return x*x; }\\nfloat pow3( const in float x ) { return x*x*x; }\\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\\nhighp float rand( const in vec2 uv ) {\\n\\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\\n\\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\\n\\treturn fract(sin(sn) * c);\\n}\\nstruct IncidentLight {\\n\\tvec3 color;\\n\\tvec3 direction;\\n\\tbool visible;\\n};\\nstruct ReflectedLight {\\n\\tvec3 directDiffuse;\\n\\tvec3 directSpecular;\\n\\tvec3 indirectDiffuse;\\n\\tvec3 indirectSpecular;\\n};\\nstruct GeometricContext {\\n\\tvec3 position;\\n\\tvec3 normal;\\n\\tvec3 viewDir;\\n};\\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\\n}\\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\\n}\\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\tfloat distance = dot( planeNormal, point - pointOnPlane );\\n\\treturn - distance * planeNormal + point;\\n}\\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\treturn sign( dot( point - pointOnPlane, planeNormal ) );\\n}\\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\\n}\\nmat3 transposeMat3( const in mat3 m ) {\\n\\tmat3 tmp;\\n\\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\\n\\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\\n\\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\\n\\treturn tmp;\\n}\\nfloat linearToRelativeLuminance( const in vec3 color ) {\\n\\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\\n\\treturn dot( weights, color.rgb );\\n}\\n\",cube_uv_reflection_fragment:\"#ifdef ENVMAP_TYPE_CUBE_UV\\n#define cubeUV_textureSize (1024.0)\\nint getFaceFromDirection(vec3 direction) {\\n\\tvec3 absDirection = abs(direction);\\n\\tint face = -1;\\n\\tif( absDirection.x > absDirection.z ) {\\n\\t\\tif(absDirection.x > absDirection.y )\\n\\t\\t\\tface = direction.x > 0.0 ? 0 : 3;\\n\\t\\telse\\n\\t\\t\\tface = direction.y > 0.0 ? 1 : 4;\\n\\t}\\n\\telse {\\n\\t\\tif(absDirection.z > absDirection.y )\\n\\t\\t\\tface = direction.z > 0.0 ? 2 : 5;\\n\\t\\telse\\n\\t\\t\\tface = direction.y > 0.0 ? 1 : 4;\\n\\t}\\n\\treturn face;\\n}\\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\\n\\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\\n\\tfloat dxRoughness = dFdx(roughness);\\n\\tfloat dyRoughness = dFdy(roughness);\\n\\tvec3 dx = dFdx( vec * scale * dxRoughness );\\n\\tvec3 dy = dFdy( vec * scale * dyRoughness );\\n\\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\\n\\td = clamp(d, 1.0, cubeUV_rangeClamp);\\n\\tfloat mipLevel = 0.5 * log2(d);\\n\\treturn vec2(floor(mipLevel), fract(mipLevel));\\n}\\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\\n\\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\\n\\tfloat a = 16.0 * cubeUV_rcpTextureSize;\\n\\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\\n\\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\\n\\tfloat powScale = exp2_packed.x * exp2_packed.y;\\n\\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\\n\\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\\n\\tbool bRes = mipLevel == 0.0;\\n\\tscale = bRes && (scale < a) ? a : scale;\\n\\tvec3 r;\\n\\tvec2 offset;\\n\\tint face = getFaceFromDirection(direction);\\n\\tfloat rcpPowScale = 1.0 / powScale;\\n\\tif( face == 0) {\\n\\t\\tr = vec3(direction.x, -direction.z, direction.y);\\n\\t\\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 1) {\\n\\t\\tr = vec3(direction.y, direction.x, direction.z);\\n\\t\\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 2) {\\n\\t\\tr = vec3(direction.z, direction.x, direction.y);\\n\\t\\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 3) {\\n\\t\\tr = vec3(direction.x, direction.z, direction.y);\\n\\t\\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\telse if( face == 4) {\\n\\t\\tr = vec3(direction.y, direction.x, -direction.z);\\n\\t\\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\telse {\\n\\t\\tr = vec3(direction.z, -direction.x, direction.y);\\n\\t\\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\tr = normalize(r);\\n\\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\\n\\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\\n\\tvec2 base = offset + vec2( texelOffset );\\n\\treturn base + s * ( scale - 2.0 * texelOffset );\\n}\\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\\n\\tfloat roughnessVal = roughness* cubeUV_maxLods3;\\n\\tfloat r1 = floor(roughnessVal);\\n\\tfloat r2 = r1 + 1.0;\\n\\tfloat t = fract(roughnessVal);\\n\\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\\n\\tfloat s = mipInfo.y;\\n\\tfloat level0 = mipInfo.x;\\n\\tfloat level1 = level0 + 1.0;\\n\\tlevel1 = level1 > 5.0 ? 5.0 : level1;\\n\\tlevel0 += min( floor( s + 0.5 ), 5.0 );\\n\\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\\n\\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\\n\\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\\n\\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\\n\\tvec4 result = mix(color10, color20, t);\\n\\treturn vec4(result.rgb, 1.0);\\n}\\n#endif\\n\",defaultnormal_vertex:\"vec3 transformedNormal = normalMatrix * objectNormal;\\n#ifdef FLIP_SIDED\\n\\ttransformedNormal = - transformedNormal;\\n#endif\\n\",displacementmap_pars_vertex:\"#ifdef USE_DISPLACEMENTMAP\\n\\tuniform sampler2D displacementMap;\\n\\tuniform float displacementScale;\\n\\tuniform float displacementBias;\\n#endif\\n\",displacementmap_vertex:\"#ifdef USE_DISPLACEMENTMAP\\n\\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\\n#endif\\n\",emissivemap_fragment:\"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\\n\\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif\\n\",emissivemap_pars_fragment:\"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif\\n\",encodings_fragment:\" gl_FragColor = linearToOutputTexel( gl_FragColor );\\n\",encodings_pars_fragment:\"\\nvec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\\n}\\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\\n}\\nvec4 sRGBToLinear( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\\n}\\nvec4 LinearTosRGB( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\\n}\\nvec4 RGBEToLinear( in vec4 value ) {\\n\\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\\n}\\nvec4 LinearToRGBE( in vec4 value ) {\\n\\tfloat maxComponent = max( max( value.r, value.g ), value.b );\\n\\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\\n\\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\\n}\\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\\n}\\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\\n\\tM = ceil( M * 255.0 ) / 255.0;\\n\\treturn vec4( value.rgb / ( M * maxRange ), M );\\n}\\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\\n}\\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\\n\\tfloat D = max( maxRange / maxRGB, 1.0 );\\n\\tD = min( floor( D ) / 255.0, 1.0 );\\n\\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\\n}\\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\\nvec4 LinearToLogLuv( in vec4 value ) {\\n\\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\\n\\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\\n\\tvec4 vResult;\\n\\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\\n\\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\\n\\tvResult.w = fract(Le);\\n\\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\\n\\treturn vResult;\\n}\\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\\nvec4 LogLuvToLinear( in vec4 value ) {\\n\\tfloat Le = value.z * 255.0 + value.w;\\n\\tvec3 Xp_Y_XYZp;\\n\\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\\n\\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\\n\\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\\n\\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\\n\\treturn vec4( max(vRGB, 0.0), 1.0 );\\n}\\n\",envmap_fragment:\"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\\n\\t\\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\\n\\t\\t#endif\\n\\t#else\\n\\t\\tvec3 reflectVec = vReflect;\\n\\t#endif\\n\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\\n\\t#elif defined( ENVMAP_TYPE_EQUIREC )\\n\\t\\tvec2 sampleUV;\\n\\t\\treflectVec = normalize( reflectVec );\\n\\t\\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\t\\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\\n\\t\\tvec4 envColor = texture2D( envMap, sampleUV );\\n\\t#elif defined( ENVMAP_TYPE_SPHERE )\\n\\t\\treflectVec = normalize( reflectVec );\\n\\t\\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\\n\\t\\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\\n\\t#else\\n\\t\\tvec4 envColor = vec4( 0.0 );\\n\\t#endif\\n\\tenvColor = envMapTexelToLinear( envColor );\\n\\t#ifdef ENVMAP_BLENDING_MULTIPLY\\n\\t\\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_MIX )\\n\\t\\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_ADD )\\n\\t\\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\\n\\t#endif\\n#endif\\n\",envmap_pars_fragment:\"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\\n\\tuniform float reflectivity;\\n\\tuniform float envMapIntensity;\\n#endif\\n#ifdef USE_ENVMAP\\n\\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t#endif\\n\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\tuniform samplerCube envMap;\\n\\t#else\\n\\t\\tuniform sampler2D envMap;\\n\\t#endif\\n\\tuniform float flipEnvMap;\\n\\tuniform int maxMipLevel;\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\\n\\t\\tuniform float refractionRatio;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t#endif\\n#endif\\n\",envmap_pars_vertex:\"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t\\tuniform float refractionRatio;\\n\\t#endif\\n#endif\\n\",envmap_vertex:\"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvWorldPosition = worldPosition.xyz;\\n\\t#else\\n\\t\\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\\n\\t\\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvReflect = reflect( cameraToVertex, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\\n\\t\\t#endif\\n\\t#endif\\n#endif\\n\",fog_vertex:\"\\n#ifdef USE_FOG\\nfogDepth = -mvPosition.z;\\n#endif\",fog_pars_vertex:\"#ifdef USE_FOG\\n varying float fogDepth;\\n#endif\\n\",fog_fragment:\"#ifdef USE_FOG\\n\\t#ifdef FOG_EXP2\\n\\t\\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\\n\\t#else\\n\\t\\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\\n\\t#endif\\n\\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\\n#endif\\n\",fog_pars_fragment:\"#ifdef USE_FOG\\n\\tuniform vec3 fogColor;\\n\\tvarying float fogDepth;\\n\\t#ifdef FOG_EXP2\\n\\t\\tuniform float fogDensity;\\n\\t#else\\n\\t\\tuniform float fogNear;\\n\\t\\tuniform float fogFar;\\n\\t#endif\\n#endif\\n\",gradientmap_pars_fragment:\"#ifdef TOON\\n\\tuniform sampler2D gradientMap;\\n\\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\\n\\t\\tfloat dotNL = dot( normal, lightDirection );\\n\\t\\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\\n\\t\\t#ifdef USE_GRADIENTMAP\\n\\t\\t\\treturn texture2D( gradientMap, coord ).rgb;\\n\\t\\t#else\\n\\t\\t\\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\\n\\t\\t#endif\\n\\t}\\n#endif\\n\",lightmap_fragment:\"#ifdef USE_LIGHTMAP\\n\\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n#endif\\n\",lightmap_pars_fragment:\"#ifdef USE_LIGHTMAP\\n\\tuniform sampler2D lightMap;\\n\\tuniform float lightMapIntensity;\\n#endif\",lights_lambert_vertex:\"vec3 diffuse = vec3( 1.0 );\\nGeometricContext geometry;\\ngeometry.position = mvPosition.xyz;\\ngeometry.normal = normalize( transformedNormal );\\ngeometry.viewDir = normalize( -mvPosition.xyz );\\nGeometricContext backGeometry;\\nbackGeometry.position = geometry.position;\\nbackGeometry.normal = -geometry.normal;\\nbackGeometry.viewDir = geometry.viewDir;\\nvLightFront = vec3( 0.0 );\\n#ifdef DOUBLE_SIDED\\n\\tvLightBack = vec3( 0.0 );\\n#endif\\nIncidentLight directLight;\\nfloat dotNL;\\nvec3 directLightColor_Diffuse;\\n#if NUM_POINT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_SPOT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_DIR_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\\n\\t\\t#endif\\n\\t}\\n#endif\\n\",lights_pars_begin:\"uniform vec3 ambientLightColor;\\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\\n\\tvec3 irradiance = ambientLightColor;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treturn irradiance;\\n}\\n#if NUM_DIR_LIGHTS > 0\\n\\tstruct DirectionalLight {\\n\\t\\tvec3 direction;\\n\\t\\tvec3 color;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t};\\n\\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\\n\\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tdirectLight.color = directionalLight.color;\\n\\t\\tdirectLight.direction = directionalLight.direction;\\n\\t\\tdirectLight.visible = true;\\n\\t}\\n#endif\\n#if NUM_POINT_LIGHTS > 0\\n\\tstruct PointLight {\\n\\t\\tvec3 position;\\n\\t\\tvec3 color;\\n\\t\\tfloat distance;\\n\\t\\tfloat decay;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t\\tfloat shadowCameraNear;\\n\\t\\tfloat shadowCameraFar;\\n\\t};\\n\\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\\n\\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tvec3 lVector = pointLight.position - geometry.position;\\n\\t\\tdirectLight.direction = normalize( lVector );\\n\\t\\tfloat lightDistance = length( lVector );\\n\\t\\tdirectLight.color = pointLight.color;\\n\\t\\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\\n\\t\\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\\n\\t}\\n#endif\\n#if NUM_SPOT_LIGHTS > 0\\n\\tstruct SpotLight {\\n\\t\\tvec3 position;\\n\\t\\tvec3 direction;\\n\\t\\tvec3 color;\\n\\t\\tfloat distance;\\n\\t\\tfloat decay;\\n\\t\\tfloat coneCos;\\n\\t\\tfloat penumbraCos;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t};\\n\\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\\n\\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tvec3 lVector = spotLight.position - geometry.position;\\n\\t\\tdirectLight.direction = normalize( lVector );\\n\\t\\tfloat lightDistance = length( lVector );\\n\\t\\tfloat angleCos = dot( directLight.direction, spotLight.direction );\\n\\t\\tif ( angleCos > spotLight.coneCos ) {\\n\\t\\t\\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\\n\\t\\t\\tdirectLight.color = spotLight.color;\\n\\t\\t\\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\\n\\t\\t\\tdirectLight.visible = true;\\n\\t\\t} else {\\n\\t\\t\\tdirectLight.color = vec3( 0.0 );\\n\\t\\t\\tdirectLight.visible = false;\\n\\t\\t}\\n\\t}\\n#endif\\n#if NUM_RECT_AREA_LIGHTS > 0\\n\\tstruct RectAreaLight {\\n\\t\\tvec3 color;\\n\\t\\tvec3 position;\\n\\t\\tvec3 halfWidth;\\n\\t\\tvec3 halfHeight;\\n\\t};\\n\\tuniform sampler2D ltc_1;\\tuniform sampler2D ltc_2;\\n\\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\tstruct HemisphereLight {\\n\\t\\tvec3 direction;\\n\\t\\tvec3 skyColor;\\n\\t\\tvec3 groundColor;\\n\\t};\\n\\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\\n\\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\\n\\t\\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\\n\\t\\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\\n\\t\\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tirradiance *= PI;\\n\\t\\t#endif\\n\\t\\treturn irradiance;\\n\\t}\\n#endif\\n\",lights_pars_maps:\"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\\n\\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\\n\\t\\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\t\\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\t\\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\\n\\t\\t\\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\\n\\t\\t#else\\n\\t\\t\\tvec4 envMapColor = vec4( 0.0 );\\n\\t\\t#endif\\n\\t\\treturn PI * envMapColor.rgb * envMapIntensity;\\n\\t}\\n\\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n\\t\\tfloat maxMIPLevelScalar = float( maxMIPLevel );\\n\\t\\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\\n\\t\\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\\n\\t}\\n\\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\\n\\t\\t#endif\\n\\t\\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\\n\\t\\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\\n\\t\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\t\\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\t\\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\\n\\t\\t\\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\\n\\t\\t#elif defined( ENVMAP_TYPE_EQUIREC )\\n\\t\\t\\tvec2 sampleUV;\\n\\t\\t\\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\t\\t\\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_SPHERE )\\n\\t\\t\\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#endif\\n\\t\\treturn envMapColor.rgb * envMapIntensity;\\n\\t}\\n#endif\\n\",lights_phong_fragment:\"BlinnPhongMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\\nmaterial.specularColor = specular;\\nmaterial.specularShininess = shininess;\\nmaterial.specularStrength = specularStrength;\\n\",lights_phong_pars_fragment:\"varying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\nstruct BlinnPhongMaterial {\\n\\tvec3\\tdiffuseColor;\\n\\tvec3\\tspecularColor;\\n\\tfloat\\tspecularShininess;\\n\\tfloat\\tspecularStrength;\\n};\\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t#ifdef TOON\\n\\t\\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\\n\\t#else\\n\\t\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\t\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#endif\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n\\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\\n}\\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_BlinnPhong\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_BlinnPhong\\n#define Material_LightProbeLOD( material )\\t(0)\\n\",lights_physical_fragment:\"PhysicalMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\\n#ifdef STANDARD\\n\\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\\n#else\\n\\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\\n\\tmaterial.clearCoat = saturate( clearCoat );\\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\\n#endif\\n\",lights_physical_pars_fragment:\"struct PhysicalMaterial {\\n\\tvec3\\tdiffuseColor;\\n\\tfloat\\tspecularRoughness;\\n\\tvec3\\tspecularColor;\\n\\t#ifndef STANDARD\\n\\t\\tfloat clearCoat;\\n\\t\\tfloat clearCoatRoughness;\\n\\t#endif\\n};\\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\\n\\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\\n}\\n#if NUM_RECT_AREA_LIGHTS > 0\\n\\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t\\tvec3 normal = geometry.normal;\\n\\t\\tvec3 viewDir = geometry.viewDir;\\n\\t\\tvec3 position = geometry.position;\\n\\t\\tvec3 lightPos = rectAreaLight.position;\\n\\t\\tvec3 halfWidth = rectAreaLight.halfWidth;\\n\\t\\tvec3 halfHeight = rectAreaLight.halfHeight;\\n\\t\\tvec3 lightColor = rectAreaLight.color;\\n\\t\\tfloat roughness = material.specularRoughness;\\n\\t\\tvec3 rectCoords[ 4 ];\\n\\t\\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\\t\\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\\n\\t\\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\\n\\t\\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\\n\\t\\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\\n\\t\\tvec4 t1 = texture2D( ltc_1, uv );\\n\\t\\tvec4 t2 = texture2D( ltc_2, uv );\\n\\t\\tmat3 mInv = mat3(\\n\\t\\t\\tvec3( t1.x, 0, t1.y ),\\n\\t\\t\\tvec3( 0, 1, 0 ),\\n\\t\\t\\tvec3( t1.z, 0, t1.w )\\n\\t\\t);\\n\\t\\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\\n\\t\\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\\n\\t\\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\\n\\t}\\n#endif\\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\t#ifndef STANDARD\\n\\t\\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\\n\\t#else\\n\\t\\tfloat clearCoatDHR = 0.0;\\n\\t#endif\\n\\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\\n\\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n\\t#ifndef STANDARD\\n\\t\\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\\n\\t#endif\\n}\\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t#ifndef STANDARD\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\tfloat dotNL = dotNV;\\n\\t\\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\\n\\t#else\\n\\t\\tfloat clearCoatDHR = 0.0;\\n\\t#endif\\n\\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\\n\\t#ifndef STANDARD\\n\\t\\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\\n\\t#endif\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_Physical\\n#define RE_Direct_RectArea\\t\\tRE_Direct_RectArea_Physical\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_Physical\\n#define RE_IndirectSpecular\\t\\tRE_IndirectSpecular_Physical\\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\\n\\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\\n}\\n\",lights_fragment_begin:\"\\nGeometricContext geometry;\\ngeometry.position = - vViewPosition;\\ngeometry.normal = normal;\\ngeometry.viewDir = normalize( vViewPosition );\\nIncidentLight directLight;\\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tPointLight pointLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tpointLight = pointLights[ i ];\\n\\t\\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tSpotLight spotLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tspotLight = spotLights[ i ];\\n\\t\\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tDirectionalLight directionalLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLights[ i ];\\n\\t\\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\\n\\tRectAreaLight rectAreaLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\\n\\t\\trectAreaLight = rectAreaLights[ i ];\\n\\t\\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if defined( RE_IndirectDiffuse )\\n\\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\\n\\t#if ( NUM_HEMI_LIGHTS > 0 )\\n\\t\\t#pragma unroll_loop\\n\\t\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\t\\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t}\\n\\t#endif\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tvec3 radiance = vec3( 0.0 );\\n\\tvec3 clearCoatRadiance = vec3( 0.0 );\\n#endif\\n\",lights_fragment_maps:\"#if defined( RE_IndirectDiffuse )\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tlightMapIrradiance *= PI;\\n\\t\\t#endif\\n\\t\\tirradiance += lightMapIrradiance;\\n\\t#endif\\n\\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\\n\\t#endif\\n#endif\\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\\n\\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\\n\\t#ifndef STANDARD\\n\\t\\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\\n\\t#endif\\n#endif\\n\",lights_fragment_end:\"#if defined( RE_IndirectDiffuse )\\n\\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\\n#endif\\n\",logdepthbuf_fragment:\"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\\n#endif\",logdepthbuf_pars_fragment:\"#ifdef USE_LOGDEPTHBUF\\n\\tuniform float logDepthBufFC;\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvarying float vFragDepth;\\n\\t#endif\\n#endif\\n\",logdepthbuf_pars_vertex:\"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvarying float vFragDepth;\\n\\t#endif\\n\\tuniform float logDepthBufFC;\\n#endif\",logdepthbuf_vertex:\"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvFragDepth = 1.0 + gl_Position.w;\\n\\t#else\\n\\t\\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\\n\\t\\tgl_Position.z *= gl_Position.w;\\n\\t#endif\\n#endif\\n\",map_fragment:\"#ifdef USE_MAP\\n\\tvec4 texelColor = texture2D( map, vUv );\\n\\ttexelColor = mapTexelToLinear( texelColor );\\n\\tdiffuseColor *= texelColor;\\n#endif\\n\",map_pars_fragment:\"#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\\n\",map_particle_fragment:\"#ifdef USE_MAP\\n\\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\\n\\tvec4 mapTexel = texture2D( map, uv );\\n\\tdiffuseColor *= mapTexelToLinear( mapTexel );\\n#endif\\n\",map_particle_pars_fragment:\"#ifdef USE_MAP\\n\\tuniform mat3 uvTransform;\\n\\tuniform sampler2D map;\\n#endif\\n\",metalnessmap_fragment:\"float metalnessFactor = metalness;\\n#ifdef USE_METALNESSMAP\\n\\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\\n\\tmetalnessFactor *= texelMetalness.b;\\n#endif\\n\",metalnessmap_pars_fragment:\"#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\",morphnormal_vertex:\"#ifdef USE_MORPHNORMALS\\n\\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\\n\\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\\n\\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\\n\\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\\n#endif\\n\",morphtarget_pars_vertex:\"#ifdef USE_MORPHTARGETS\\n\\t#ifndef USE_MORPHNORMALS\\n\\tuniform float morphTargetInfluences[ 8 ];\\n\\t#else\\n\\tuniform float morphTargetInfluences[ 4 ];\\n\\t#endif\\n#endif\",morphtarget_vertex:\"#ifdef USE_MORPHTARGETS\\n\\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\\n\\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\\n\\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\\n\\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\\n\\t#ifndef USE_MORPHNORMALS\\n\\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\\n\\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\\n\\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\\n\\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\\n\\t#endif\\n#endif\\n\",normal_fragment_begin:\"#ifdef FLAT_SHADED\\n\\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\\n\\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\\n\\tvec3 normal = normalize( cross( fdx, fdy ) );\\n#else\\n\\tvec3 normal = normalize( vNormal );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t#endif\\n#endif\\n\",normal_fragment_maps:\"#ifdef USE_NORMALMAP\\n\\tnormal = perturbNormal2Arb( -vViewPosition, normal );\\n#elif defined( USE_BUMPMAP )\\n\\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\\n#endif\\n\",normalmap_pars_fragment:\"#ifdef USE_NORMALMAP\\n\\tuniform sampler2D normalMap;\\n\\tuniform vec2 normalScale;\\n\\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\\n\\t\\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\\n\\t\\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\\n\\t\\tvec2 st0 = dFdx( vUv.st );\\n\\t\\tvec2 st1 = dFdy( vUv.st );\\n\\t\\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\\n\\t\\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\\n\\t\\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\\n\\t\\tvec3 N = normalize( surf_norm );\\n\\t\\tmat3 tsn = mat3( S, T, N );\\n\\t\\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\t\\tmapN.xy *= normalScale;\\n\\t\\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\treturn normalize( tsn * mapN );\\n\\t}\\n#endif\\n\",packing:\"vec3 packNormalToRGB( const in vec3 normal ) {\\n\\treturn normalize( normal ) * 0.5 + 0.5;\\n}\\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\\n\\treturn 2.0 * rgb.xyz - 1.0;\\n}\\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n\\tvec4 r = vec4( fract( v * PackFactors ), v );\\n\\tr.yzw -= r.xyz * ShiftRight8;\\treturn r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n\\treturn dot( v, UnpackFactors );\\n}\\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn ( viewZ + near ) / ( near - far );\\n}\\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\\n\\treturn linearClipZ * ( near - far ) - near;\\n}\\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\\n}\\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\\n\\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\\n}\\n\",premultiplied_alpha_fragment:\"#ifdef PREMULTIPLIED_ALPHA\\n\\tgl_FragColor.rgb *= gl_FragColor.a;\\n#endif\\n\",project_vertex:\"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\\ngl_Position = projectionMatrix * mvPosition;\\n\",dithering_fragment:\"#if defined( DITHERING )\\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\\n#endif\\n\",dithering_pars_fragment:\"#if defined( DITHERING )\\n\\tvec3 dithering( vec3 color ) {\\n\\t\\tfloat grid_position = rand( gl_FragCoord.xy );\\n\\t\\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\\n\\t\\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\\n\\t\\treturn color + dither_shift_RGB;\\n\\t}\\n#endif\\n\",roughnessmap_fragment:\"float roughnessFactor = roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\\n\\troughnessFactor *= texelRoughness.g;\\n#endif\\n\",roughnessmap_pars_fragment:\"#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\",shadowmap_pars_fragment:\"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t\\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t\\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t\\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\\n\\t#endif\\n\\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\\n\\t\\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\\n\\t}\\n\\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\\n\\t\\tconst vec2 offset = vec2( 0.0, 1.0 );\\n\\t\\tvec2 texelSize = vec2( 1.0 ) / size;\\n\\t\\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\\n\\t\\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\\n\\t\\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\\n\\t\\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\\n\\t\\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\\n\\t\\tvec2 f = fract( uv * size + 0.5 );\\n\\t\\tfloat a = mix( lb, lt, f.y );\\n\\t\\tfloat b = mix( rb, rt, f.y );\\n\\t\\tfloat c = mix( a, b, f.x );\\n\\t\\treturn c;\\n\\t}\\n\\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\\n\\t\\tfloat shadow = 1.0;\\n\\t\\tshadowCoord.xyz /= shadowCoord.w;\\n\\t\\tshadowCoord.z += shadowBias;\\n\\t\\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n\\t\\tbool inFrustum = all( inFrustumVec );\\n\\t\\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\\n\\t\\tbool frustumTest = all( frustumTestVec );\\n\\t\\tif ( frustumTest ) {\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx0 = - texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy0 = - texelSize.y * shadowRadius;\\n\\t\\t\\tfloat dx1 = + texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy1 = + texelSize.y * shadowRadius;\\n\\t\\t\\tshadow = (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx0 = - texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy0 = - texelSize.y * shadowRadius;\\n\\t\\t\\tfloat dx1 = + texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy1 = + texelSize.y * shadowRadius;\\n\\t\\t\\tshadow = (\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\\n\\t\\t#endif\\n\\t\\t}\\n\\t\\treturn shadow;\\n\\t}\\n\\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\\n\\t\\tvec3 absV = abs( v );\\n\\t\\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\\n\\t\\tabsV *= scaleToCube;\\n\\t\\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\\n\\t\\tvec2 planar = v.xy;\\n\\t\\tfloat almostATexel = 1.5 * texelSizeY;\\n\\t\\tfloat almostOne = 1.0 - almostATexel;\\n\\t\\tif ( absV.z >= almostOne ) {\\n\\t\\t\\tif ( v.z > 0.0 )\\n\\t\\t\\t\\tplanar.x = 4.0 - v.x;\\n\\t\\t} else if ( absV.x >= almostOne ) {\\n\\t\\t\\tfloat signX = sign( v.x );\\n\\t\\t\\tplanar.x = v.z * signX + 2.0 * signX;\\n\\t\\t} else if ( absV.y >= almostOne ) {\\n\\t\\t\\tfloat signY = sign( v.y );\\n\\t\\t\\tplanar.x = v.x + 2.0 * signY + 2.0;\\n\\t\\t\\tplanar.y = v.z * signY - 2.0;\\n\\t\\t}\\n\\t\\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\\n\\t}\\n\\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\\n\\t\\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\\n\\t\\tvec3 lightToPosition = shadowCoord.xyz;\\n\\t\\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\\t\\tdp += shadowBias;\\n\\t\\tvec3 bd3D = normalize( lightToPosition );\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\\n\\t\\t\\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\\n\\t\\t\\treturn (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\\n\\t\\t#endif\\n\\t}\\n#endif\\n\",shadowmap_pars_vertex:\"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t\\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t\\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t\\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\\n\\t#endif\\n#endif\\n\",shadowmap_vertex:\"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n#endif\\n\",shadowmask_pars_fragment:\"float getShadowMask() {\\n\\tfloat shadow = 1.0;\\n\\t#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\tDirectionalLight directionalLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLights[ i ];\\n\\t\\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\tSpotLight spotLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tspotLight = spotLights[ i ];\\n\\t\\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\tPointLight pointLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tpointLight = pointLights[ i ];\\n\\t\\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#endif\\n\\treturn shadow;\\n}\\n\",skinbase_vertex:\"#ifdef USE_SKINNING\\n\\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\\n\\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\\n\\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\\n\\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\\n#endif\",skinning_pars_vertex:\"#ifdef USE_SKINNING\\n\\tuniform mat4 bindMatrix;\\n\\tuniform mat4 bindMatrixInverse;\\n\\t#ifdef BONE_TEXTURE\\n\\t\\tuniform sampler2D boneTexture;\\n\\t\\tuniform int boneTextureSize;\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tfloat j = i * 4.0;\\n\\t\\t\\tfloat x = mod( j, float( boneTextureSize ) );\\n\\t\\t\\tfloat y = floor( j / float( boneTextureSize ) );\\n\\t\\t\\tfloat dx = 1.0 / float( boneTextureSize );\\n\\t\\t\\tfloat dy = 1.0 / float( boneTextureSize );\\n\\t\\t\\ty = dy * ( y + 0.5 );\\n\\t\\t\\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n\\t\\t\\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n\\t\\t\\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n\\t\\t\\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n\\t\\t\\tmat4 bone = mat4( v1, v2, v3, v4 );\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#else\\n\\t\\tuniform mat4 boneMatrices[ MAX_BONES ];\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tmat4 bone = boneMatrices[ int(i) ];\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#endif\\n#endif\\n\",skinning_vertex:\"#ifdef USE_SKINNING\\n\\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\\n\\tvec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n\\ttransformed = ( bindMatrixInverse * skinned ).xyz;\\n#endif\\n\",skinnormal_vertex:\"#ifdef USE_SKINNING\\n\\tmat4 skinMatrix = mat4( 0.0 );\\n\\tskinMatrix += skinWeight.x * boneMatX;\\n\\tskinMatrix += skinWeight.y * boneMatY;\\n\\tskinMatrix += skinWeight.z * boneMatZ;\\n\\tskinMatrix += skinWeight.w * boneMatW;\\n\\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\\n\\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\\n#endif\\n\",specularmap_fragment:\"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, vUv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif\",specularmap_pars_fragment:\"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif\",tonemapping_fragment:\"#if defined( TONE_MAPPING )\\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\\n#endif\\n\",tonemapping_pars_fragment:\"#ifndef saturate\\n\\t#define saturate(a) clamp( a, 0.0, 1.0 )\\n#endif\\nuniform float toneMappingExposure;\\nuniform float toneMappingWhitePoint;\\nvec3 LinearToneMapping( vec3 color ) {\\n\\treturn toneMappingExposure * color;\\n}\\nvec3 ReinhardToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( color / ( vec3( 1.0 ) + color ) );\\n}\\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\\nvec3 Uncharted2ToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\\n}\\nvec3 OptimizedCineonToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\tcolor = max( vec3( 0.0 ), color - 0.004 );\\n\\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\\n}\\n\",uv_pars_fragment:\"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvarying vec2 vUv;\\n#endif\",uv_pars_vertex:\"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvarying vec2 vUv;\\n\\tuniform mat3 uvTransform;\\n#endif\\n\",uv_vertex:\"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n#endif\",uv2_pars_fragment:\"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvarying vec2 vUv2;\\n#endif\",uv2_pars_vertex:\"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tattribute vec2 uv2;\\n\\tvarying vec2 vUv2;\\n#endif\",uv2_vertex:\"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvUv2 = uv2;\\n#endif\",worldpos_vertex:\"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\\n\\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\\n#endif\\n\",cube_frag:\"uniform samplerCube tCube;\\nuniform float tFlip;\\nuniform float opacity;\\nvarying vec3 vWorldPosition;\\nvoid main() {\\n\\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\\n\\tgl_FragColor.a *= opacity;\\n}\\n\",cube_vert:\"varying vec3 vWorldPosition;\\n#include \\nvoid main() {\\n\\tvWorldPosition = transformDirection( position, modelMatrix );\\n\\t#include \\n\\t#include \\n\\tgl_Position.z = gl_Position.w;\\n}\\n\",depth_frag:\"#if DEPTH_PACKING == 3200\\n\\tuniform float opacity;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tdiffuseColor.a = opacity;\\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\\n\\t#elif DEPTH_PACKING == 3201\\n\\t\\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\\n\\t#endif\\n}\\n\",depth_vert:\"#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include \\n\\t\\t#include \\n\\t\\t#include \\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",distanceRGBA_frag:\"#define DISTANCE\\nuniform vec3 referencePosition;\\nuniform float nearDistance;\\nuniform float farDistance;\\nvarying vec3 vWorldPosition;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main () {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\tfloat dist = length( vWorldPosition - referencePosition );\\n\\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\\n\\tdist = saturate( dist );\\n\\tgl_FragColor = packDepthToRGBA( dist );\\n}\\n\",distanceRGBA_vert:\"#define DISTANCE\\nvarying vec3 vWorldPosition;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include \\n\\t\\t#include \\n\\t\\t#include \\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvWorldPosition = worldPosition.xyz;\\n}\\n\",equirect_frag:\"uniform sampler2D tEquirect;\\nvarying vec3 vWorldPosition;\\n#include \\nvoid main() {\\n\\tvec3 direction = normalize( vWorldPosition );\\n\\tvec2 sampleUV;\\n\\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\\n\\tgl_FragColor = texture2D( tEquirect, sampleUV );\\n}\\n\",equirect_vert:\"varying vec3 vWorldPosition;\\n#include \\nvoid main() {\\n\\tvWorldPosition = transformDirection( position, modelMatrix );\\n\\t#include \\n\\t#include \\n}\\n\",linedashed_frag:\"uniform vec3 diffuse;\\nuniform float opacity;\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",linedashed_vert:\"uniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvLineDistance = scale * lineDistance;\\n\\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\\n\\tgl_Position = projectionMatrix * mvPosition;\\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshbasic_frag:\"uniform vec3 diffuse;\\nuniform float opacity;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n\\t#else\\n\\t\\treflectedLight.indirectDiffuse += vec3( 1.0 );\\n\\t#endif\\n\\t#include \\n\\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\\n\\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\\n\\t#include \\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshbasic_vert:\"#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#ifdef USE_ENVMAP\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshlambert_frag:\"uniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float opacity;\\nvarying vec3 vLightFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\\n\\t#include \\n\\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\\n\\t#else\\n\\t\\treflectedLight.directDiffuse = vLightFront;\\n\\t#endif\\n\\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\\n\\t#include \\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\\n\\t#include \\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshlambert_vert:\"#define LAMBERT\\nvarying vec3 vLightFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshphong_frag:\"#define PHONG\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform vec3 specular;\\nuniform float shininess;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\t#include \\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshphong_vert:\"#define PHONG\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshphysical_frag:\"#define PHYSICAL\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float roughness;\\nuniform float metalness;\\nuniform float opacity;\\n#ifndef STANDARD\\n\\tuniform float clearCoat;\\n\\tuniform float clearCoatRoughness;\\n#endif\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",meshphysical_vert:\"#define PHYSICAL\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",normal_frag:\"#define NORMAL\\nuniform float opacity;\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\\n}\\n\",normal_vert:\"#define NORMAL\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\\n}\\n\",points_frag:\"uniform vec3 diffuse;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",points_vert:\"uniform float size;\\nuniform float scale;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#ifdef USE_SIZEATTENUATION\\n\\t\\tgl_PointSize = size * ( scale / - mvPosition.z );\\n\\t#else\\n\\t\\tgl_PointSize = size;\\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\",shadow_frag:\"uniform vec3 color;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\\n\\t#include \\n}\\n\",shadow_vert:\"#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\\n\"},q={merge:function(e){for(var t={},i=0;i>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}return function(t,i,r){if(t=M.euclideanModulo(t,1),i=M.clamp(i,0,1),r=M.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+i):r+i-r*i,a=2*r-n;this.r=e(a,n,t+1/3),this.g=e(a,n,t),this.b=e(a,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn(\"THREE.Color: Alpha component of \"+e+\" will be ignored.\")}var i;if(i=/^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec(e)){var r,n=i[1],a=i[2];switch(n){case\"rgb\":case\"rgba\":if(r=/^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case\"hsl\":case\"hsla\":if(r=/^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(o,s,c)}}}else if(i=/^\\#([A-Fa-f0-9]+)$/.exec(e)){var h,l=(h=i[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}e&&e.length>0&&(void 0!==(h=Q[e])?this.setHex(h):console.warn(\"THREE.Color: Unknown color \"+e));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return(\"000000\"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn(\"THREE.Color: .getHSL() target is now required\"),e={h:0,s:0,l:0});var t,i,r=this.r,n=this.g,a=this.b,o=Math.max(r,n,a),s=Math.min(r,n,a),c=(s+o)/2;if(s===o)t=0,i=0;else{var h=o-s;switch(i=c<=.5?h/(o+s):h/(2-o-s),o){case r:t=(n-a)/h+(n1){for(var t=0;t1){for(var t=0;t0){r.children=[];for(s=0;s0&&(i.geometries=u),d.length>0&&(i.materials=d),p.length>0&&(i.textures=p),f.length>0&&(i.images=f),o.length>0&&(i.shapes=o)}return i.object=r,i;function m(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var i=0;it&&(t=e[i]);return t}ve.prototype=Object.assign(Object.create(l.prototype),{constructor:ve,isGeometry:!0,applyMatrix:function(e){for(var t=(new P).getNormalMatrix(e),i=0,r=this.vertices.length;i0)for(d=0;d0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,n;for(i=0,r=this.faces.length;i=0;i--){var f=d[i];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.vertexColors.length>0,A=0;if(A=_(A,0,0),A=_(A,1,!0),A=_(A,2,!1),A=_(A,3,f),A=_(A,4,m),A=_(A,5,v),A=_(A,6,g),A=_(A,7,y),o.push(A),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var x=this.faceVertexUvs[0][n];o.push(T(x[0]),T(x[1]),T(x[2]))}if(m&&o.push(E(p.normal)),v){var w=p.vertexNormals;o.push(E(w[0]),E(w[1]),E(w[2]))}if(g&&o.push(M(p.color)),y){var b=p.vertexColors;o.push(M(b[0]),M(b[1]),M(b[2]))}}function _(e,t,i){return i?e|1<0&&(e.data.colors=h),u.length>0&&(e.data.uvs=[u]),e.data.faces=o,e},clone:function(){return(new ve).copy(this)},copy:function(e){var t,i,r,n,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,i=s.length;t0,o=n[1]&&n[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(var h=0;h0){l=[];for(h=0;h0?1:-1,h.push(P.x,P.y,P.z),l.push(y/m),l.push(1-A/v),S+=1}}for(A=0;A65535?Ee:be)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?\"index\"===e?(console.warn(\"THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.\"),this.setIndex(t),this):(this.attributes[e]=t,this):(console.warn(\"THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).\"),this.addAttribute(e,new ge(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var i=this.attributes.normal;void 0!==i&&((new P).getNormalMatrix(e).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new S;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new S;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new S;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new S;return function(t,i,r){return e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e=new S;return function(t,i,r){return e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e=new he;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new L;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new Me(3*t.vertices.length,3),r=new Me(3*t.colors.length,3);if(this.addAttribute(\"position\",i.copyVector3sArray(t.vertices)),this.addAttribute(\"color\",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new Me(t.lineDistances.length,1);this.addAttribute(\"lineDistance\",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,r=e.length;i0){var i=new Float32Array(3*e.normals.length);this.addAttribute(\"normal\",new ge(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute(\"color\",new ge(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.addAttribute(\"uv\",new ge(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.addAttribute(\"uv2\",new ge(a,2).copyVector2sArray(e.uvs2))}for(var o in this.groups=e.groups,e.morphTargets){for(var s=[],c=e.morphTargets[o],h=0,l=c.length;h0){var p=new Me(4*e.skinIndices.length,4);this.addAttribute(\"skinIndex\",p.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new Me(4*e.skinWeights.length,4);this.addAttribute(\"skinWeight\",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new H);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new H,t=new L;return function(){null===this.boundingSphere&&(this.boundingSphere=new k);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;e.setFromBufferAttribute(i),e.getCenter(r);for(var n=0,a=0,o=i.count;a0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};var r=this.index;if(null!==r){var n=Array.prototype.slice.call(r.array);e.data.index={type:r.array.constructor.name,array:n}}var a=this.attributes;for(var i in a){var o=a[i];n=Array.prototype.slice.call(o.array);e.data.attributes[i]={itemSize:o.itemSize,type:o.array.constructor.name,array:n,normalized:o.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new Pe).copy(this)},copy:function(e){var t,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone());var a=e.attributes;for(t in a){var o=a[t];this.addAttribute(t,o.clone())}var s=e.morphAttributes;for(t in s){var c=[],h=s[t];for(i=0,r=h.length;i0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return\"highp\";t=\"mediump\"}return\"mediump\"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?\"mediump\":\"lowp\"}var a=void 0!==i.precision?i.precision:\"highp\",o=n(a);o!==a&&(console.warn(\"THREE.WebGLRenderer:\",a,\"not supported, using\",o,\"instead.\"),a=o);var s=!0===i.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=e.getParameter(e.MAX_TEXTURE_SIZE),u=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),p=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,g=!!t.get(\"OES_texture_float\");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var i=t.get(\"EXT_texture_filter_anisotropic\");return r=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:a,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:u,maxAttributes:d,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:v&&g}}function $e(){var e=this,t=null,i=0,r=!1,n=!1,a=new j,o=new P,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(t,i,r,n){var c=null!==t?t.length:0,h=null;if(0!==c){if(h=s.value,!0!==n||null===h){var l=r+4*c,u=i.matrixWorldInverse;o.getNormalMatrix(u),(null===h||h.length65535?Ee:be)(o,1),t.update(r,e.ELEMENT_ARRAY_BUFFER),n[i.id]=r,r}}}function it(e,t,i){var r,n,a;this.setMode=function(e){r=e},this.setIndex=function(e){n=e.type,a=e.bytesPerElement},this.render=function(t,o){e.drawElements(r,o,n,t*a),i.update(o,r)},this.renderInstances=function(e,o,s){var c=t.get(\"ANGLE_instanced_arrays\");null!==c?(c.drawElementsInstancedANGLE(r,s,n,o*a,e.maxInstancedCount),i.update(s,r,e.maxInstancedCount)):console.error(\"THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.\")}}function rt(e){var t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(i,r,n){switch(n=n||1,t.calls++,r){case e.TRIANGLES:t.triangles+=n*(i/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:t.triangles+=n*(i-2);break;case e.LINES:t.lines+=n*(i/2);break;case e.LINE_STRIP:t.lines+=n*(i-1);break;case e.LINE_LOOP:t.lines+=n*i;break;case e.POINTS:t.points+=n*i;break;default:console.error(\"THREE.WebGLInfo: Unknown draw mode:\",r)}}}}function nt(e,t){return Math.abs(t[1])-Math.abs(e[1])}function at(e){var t={},i=new Float32Array(8);return{update:function(r,n,a,o){var s=r.morphTargetInfluences,c=s.length,h=t[n.id];if(void 0===h){h=[];for(var l=0;l0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),\"round\"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),\"round\"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),\"{}\"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){var n=r(e.textures),a=r(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:\"dispose\"})}}),je.prototype=Object.create(ke.prototype),je.prototype.constructor=je,je.prototype.isMeshBasicMaterial=!0,je.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},We.prototype=Object.create(ke.prototype),We.prototype.constructor=We,We.prototype.isShaderMaterial=!0,We.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=q.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},We.prototype.toJSON=function(e){var t=ke.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Object.assign(Xe.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn(\"THREE.Ray: .at() target is now required\"),t=new L),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new L;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn(\"THREE.Ray: .closestPointToPoint() target is now required\"),t=new L),t.subVectors(e,this.origin);var i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new L;return function(t){var i=e.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(i).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:(Be=new L,Fe=new L,Ue=new L,function(e,t,i,r){Be.copy(e).add(t).multiplyScalar(.5),Fe.copy(t).sub(e).normalize(),Ue.copy(this.origin).sub(Be);var n,a,o,s,c=.5*e.distanceTo(t),h=-this.direction.dot(Fe),l=Ue.dot(this.direction),u=-Ue.dot(Fe),d=Ue.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(a=h*l-u,s=c*p,(n=h*u-l)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(n*=f)*(n+h*(a*=f)+2*l)+a*(h*n+a+2*u)+d}else a=c,o=-(n=Math.max(0,-(h*a+l)))*n+a*(a+2*u)+d;else a=-c,o=-(n=Math.max(0,-(h*a+l)))*n+a*(a+2*u)+d;else a<=-s?o=-(n=Math.max(0,-(-h*c+l)))*n+(a=n>0?-c:Math.min(Math.max(-c,-u),c))*(a+2*u)+d:a<=s?(n=0,o=(a=Math.min(Math.max(-c,-u),c))*(a+2*u)+d):o=-(n=Math.max(0,-(h*c+l)))*n+(a=n>0?c:Math.min(Math.max(-c,-u),c))*(a+2*u)+d;else a=h>0?-c:c,o=-(n=Math.max(0,-(h*a+l)))*n+a*(a+2*u)+d;return i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(Fe).multiplyScalar(a).add(Be),o}),intersectSphere:function(){var e=new L;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r,a=t.radius*t.radius;if(n>a)return null;var o=Math.sqrt(a-n),s=r-o,c=r+o;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var i,r,n,a,o,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(n=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||n>r?null:((n>i||i!=i)&&(i=n),(a=0?(o=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(o=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),i>s||o>r?null:((o>i||i!=i)&&(i=o),(s=0?i:r,t)))},intersectsBox:(Ne=new L,function(e){return null!==this.intersectBox(e,Ne)}),intersectTriangle:function(){var e=new L,t=new L,i=new L,r=new L;return function(n,a,o,s,c){t.subVectors(a,n),i.subVectors(o,n),r.crossVectors(t,i);var h,l=this.direction.dot(r);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}e.subVectors(this.origin,n);var u=h*this.direction.dot(i.crossVectors(e,i));if(u<0)return null;var d=h*this.direction.dot(t.cross(e));if(d<0)return null;if(u+d>l)return null;var p=-h*e.dot(r);return p<0?null:this.at(p/l,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(Ye.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn(\"THREE.Line3: .getCenter() target is now required\"),e=new L),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn(\"THREE.Line3: .delta() target is now required\"),e=new L),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn(\"THREE.Line3: .at() target is now required\"),t=new L),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:(ze=new L,Ge=new L,function(e,t){ze.subVectors(e,this.start),Ge.subVectors(this.end,this.start);var i=Ge.dot(Ge),r=Ge.dot(ze)/i;return t&&(r=M.clamp(r,0,1)),r}),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t);return void 0===i&&(console.warn(\"THREE.Line3: .closestPointToPoint() target is now required\"),i=new L),this.delta(i).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(qe,{getNormal:(Ve=new L,function(e,t,i,r){void 0===r&&(console.warn(\"THREE.Triangle: .getNormal() target is now required\"),r=new L),r.subVectors(i,t),Ve.subVectors(e,t),r.cross(Ve);var n=r.lengthSq();return n>0?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}),getBarycoord:function(){var e=new L,t=new L,i=new L;return function(r,n,a,o,s){e.subVectors(o,n),t.subVectors(a,n),i.subVectors(r,n);var c=e.dot(e),h=e.dot(t),l=e.dot(i),u=t.dot(t),d=t.dot(i),p=c*u-h*h;if(void 0===s&&(console.warn(\"THREE.Triangle: .getBarycoord() target is now required\"),s=new L),0===p)return s.set(-2,-1,-1);var f=1/p,m=(u*l-h*d)*f,v=(c*d-h*l)*f;return s.set(1-m-v,v,m)}}(),containsPoint:function(){var e=new L;return function(t,i,r,n){return qe.getBarycoord(t,i,r,n,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}()}),Object.assign(qe.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new L,t=new L;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn(\"THREE.Triangle: .getMidpoint() target is now required\"),e=new L),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return qe.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn(\"THREE.Triangle: .getPlane() target is now required\"),e=new L),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return qe.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return qe.containsPoint(e,this.a,this.b,this.c)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new j,t=[new Ye,new Ye,new Ye],i=new L,r=new L;return function(n,a){void 0===a&&(console.warn(\"THREE.Triangle: .closestPointToPoint() target is now required\"),a=new L);var o=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(n,i),!0===this.containsPoint(i))a.copy(i);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var s=0;s0){var o=n[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;ei.far?null:{distance:c,point:f.clone(),object:e}}function g(e,t,i,o,s,c,d,f){r.fromBufferAttribute(o,c),n.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f);var g=v(e,e.material,t,i,r,n,a,p);if(g){s&&(h.fromBufferAttribute(s,c),l.fromBufferAttribute(s,d),u.fromBufferAttribute(s,f),g.uv=m(p,r,n,a,h,l,u));var y=new de(c,d,f);qe.getNormal(r,n,a,y.normal),g.face=y}return g}return function(d,f){var y,A=this.geometry,x=this.material,w=this.matrixWorld;if(void 0!==x&&(null===A.boundingSphere&&A.computeBoundingSphere(),i.copy(A.boundingSphere),i.applyMatrix4(w),!1!==d.ray.intersectsSphere(i)&&(e.getInverse(w),t.copy(d.ray).applyMatrix4(e),null===A.boundingBox||!1!==t.intersectsBox(A.boundingBox))))if(A.isBufferGeometry){var b,_,E,M,T,S=A.index,R=A.attributes.position,L=A.attributes.uv;if(null!==S)for(M=0,T=S.count;M0&&(I=F);for(var U=0,z=B.length;U0)return e;var n=t*i,a=ut[n];if(void 0===a&&(a=new Float32Array(n),ut[n]=a),0!==t){r.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=i,e[o].toArray(a,s)}return a}function gt(e,t){if(e.length!==t.length)return!1;for(var i=0,r=e.length;i/gm,(function(e,t){var i=Y[t];if(void 0===i)throw new Error(\"Can not resolve #include <\"+t+\">\");return ni(i)}))}function ai(e){return e.replace(/#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g,(function(e,t,i,r){for(var n=\"\",a=parseInt(t);a0?e.gammaFactor:1,x=function(e,t,i){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?\"#extension GL_OES_standard_derivatives : enable\":\"\",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get(\"EXT_frag_depth\")?\"#extension GL_EXT_frag_depth : enable\":\"\",e.drawBuffers&&i.get(\"WEBGL_draw_buffers\")?\"#extension GL_EXT_draw_buffers : require\":\"\",(e.shaderTextureLOD||t.envMap)&&i.get(\"EXT_shader_texture_lod\")?\"#extension GL_EXT_shader_texture_lod : enable\":\"\"].filter(ti).join(\"\\n\")}(r.extensions,a,t),w=function(e){var t=[];for(var i in e){var r=e[i];!1!==r&&t.push(\"#define \"+i+\" \"+r)}return t.join(\"\\n\")}(s),b=o.createProgram();r.isRawShaderMaterial?((f=[w].filter(ti).join(\"\\n\")).length>0&&(f+=\"\\n\"),(m=[x,w].filter(ti).join(\"\\n\")).length>0&&(m+=\"\\n\")):(f=[\"precision \"+a.precision+\" float;\",\"precision \"+a.precision+\" int;\",\"#define SHADER_NAME \"+n.name,w,a.supportsVertexTextures?\"#define VERTEX_TEXTURES\":\"\",\"#define GAMMA_FACTOR \"+A,\"#define MAX_BONES \"+a.maxBones,a.useFog&&a.fog?\"#define USE_FOG\":\"\",a.useFog&&a.fogExp?\"#define FOG_EXP2\":\"\",a.map?\"#define USE_MAP\":\"\",a.envMap?\"#define USE_ENVMAP\":\"\",a.envMap?\"#define \"+d:\"\",a.lightMap?\"#define USE_LIGHTMAP\":\"\",a.aoMap?\"#define USE_AOMAP\":\"\",a.emissiveMap?\"#define USE_EMISSIVEMAP\":\"\",a.bumpMap?\"#define USE_BUMPMAP\":\"\",a.normalMap?\"#define USE_NORMALMAP\":\"\",a.displacementMap&&a.supportsVertexTextures?\"#define USE_DISPLACEMENTMAP\":\"\",a.specularMap?\"#define USE_SPECULARMAP\":\"\",a.roughnessMap?\"#define USE_ROUGHNESSMAP\":\"\",a.metalnessMap?\"#define USE_METALNESSMAP\":\"\",a.alphaMap?\"#define USE_ALPHAMAP\":\"\",a.vertexColors?\"#define USE_COLOR\":\"\",a.flatShading?\"#define FLAT_SHADED\":\"\",a.skinning?\"#define USE_SKINNING\":\"\",a.useVertexTexture?\"#define BONE_TEXTURE\":\"\",a.morphTargets?\"#define USE_MORPHTARGETS\":\"\",a.morphNormals&&!1===a.flatShading?\"#define USE_MORPHNORMALS\":\"\",a.doubleSided?\"#define DOUBLE_SIDED\":\"\",a.flipSided?\"#define FLIP_SIDED\":\"\",a.shadowMapEnabled?\"#define USE_SHADOWMAP\":\"\",a.shadowMapEnabled?\"#define \"+l:\"\",a.sizeAttenuation?\"#define USE_SIZEATTENUATION\":\"\",a.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",a.logarithmicDepthBuffer&&t.get(\"EXT_frag_depth\")?\"#define USE_LOGDEPTHBUF_EXT\":\"\",\"uniform mat4 modelMatrix;\",\"uniform mat4 modelViewMatrix;\",\"uniform mat4 projectionMatrix;\",\"uniform mat4 viewMatrix;\",\"uniform mat3 normalMatrix;\",\"uniform vec3 cameraPosition;\",\"attribute vec3 position;\",\"attribute vec3 normal;\",\"attribute vec2 uv;\",\"#ifdef USE_COLOR\",\"\\tattribute vec3 color;\",\"#endif\",\"#ifdef USE_MORPHTARGETS\",\"\\tattribute vec3 morphTarget0;\",\"\\tattribute vec3 morphTarget1;\",\"\\tattribute vec3 morphTarget2;\",\"\\tattribute vec3 morphTarget3;\",\"\\t#ifdef USE_MORPHNORMALS\",\"\\t\\tattribute vec3 morphNormal0;\",\"\\t\\tattribute vec3 morphNormal1;\",\"\\t\\tattribute vec3 morphNormal2;\",\"\\t\\tattribute vec3 morphNormal3;\",\"\\t#else\",\"\\t\\tattribute vec3 morphTarget4;\",\"\\t\\tattribute vec3 morphTarget5;\",\"\\t\\tattribute vec3 morphTarget6;\",\"\\t\\tattribute vec3 morphTarget7;\",\"\\t#endif\",\"#endif\",\"#ifdef USE_SKINNING\",\"\\tattribute vec4 skinIndex;\",\"\\tattribute vec4 skinWeight;\",\"#endif\",\"\\n\"].filter(ti).join(\"\\n\"),m=[x,\"precision \"+a.precision+\" float;\",\"precision \"+a.precision+\" int;\",\"#define SHADER_NAME \"+n.name,w,a.alphaTest?\"#define ALPHATEST \"+a.alphaTest+(a.alphaTest%1?\"\":\".0\"):\"\",\"#define GAMMA_FACTOR \"+A,a.useFog&&a.fog?\"#define USE_FOG\":\"\",a.useFog&&a.fogExp?\"#define FOG_EXP2\":\"\",a.map?\"#define USE_MAP\":\"\",a.envMap?\"#define USE_ENVMAP\":\"\",a.envMap?\"#define \"+u:\"\",a.envMap?\"#define \"+d:\"\",a.envMap?\"#define \"+p:\"\",a.lightMap?\"#define USE_LIGHTMAP\":\"\",a.aoMap?\"#define USE_AOMAP\":\"\",a.emissiveMap?\"#define USE_EMISSIVEMAP\":\"\",a.bumpMap?\"#define USE_BUMPMAP\":\"\",a.normalMap?\"#define USE_NORMALMAP\":\"\",a.specularMap?\"#define USE_SPECULARMAP\":\"\",a.roughnessMap?\"#define USE_ROUGHNESSMAP\":\"\",a.metalnessMap?\"#define USE_METALNESSMAP\":\"\",a.alphaMap?\"#define USE_ALPHAMAP\":\"\",a.vertexColors?\"#define USE_COLOR\":\"\",a.gradientMap?\"#define USE_GRADIENTMAP\":\"\",a.flatShading?\"#define FLAT_SHADED\":\"\",a.doubleSided?\"#define DOUBLE_SIDED\":\"\",a.flipSided?\"#define FLIP_SIDED\":\"\",a.shadowMapEnabled?\"#define USE_SHADOWMAP\":\"\",a.shadowMapEnabled?\"#define \"+l:\"\",a.premultipliedAlpha?\"#define PREMULTIPLIED_ALPHA\":\"\",a.physicallyCorrectLights?\"#define PHYSICALLY_CORRECT_LIGHTS\":\"\",a.logarithmicDepthBuffer?\"#define USE_LOGDEPTHBUF\":\"\",a.logarithmicDepthBuffer&&t.get(\"EXT_frag_depth\")?\"#define USE_LOGDEPTHBUF_EXT\":\"\",a.envMap&&t.get(\"EXT_shader_texture_lod\")?\"#define TEXTURE_LOD_EXT\":\"\",\"uniform mat4 viewMatrix;\",\"uniform vec3 cameraPosition;\",0!==a.toneMapping?\"#define TONE_MAPPING\":\"\",0!==a.toneMapping?Y.tonemapping_pars_fragment:\"\",0!==a.toneMapping?ei(\"toneMapping\",a.toneMapping):\"\",a.dithering?\"#define DITHERING\":\"\",a.outputEncoding||a.mapEncoding||a.envMapEncoding||a.emissiveMapEncoding?Y.encodings_pars_fragment:\"\",a.mapEncoding?$t(\"mapTexelToLinear\",a.mapEncoding):\"\",a.envMapEncoding?$t(\"envMapTexelToLinear\",a.envMapEncoding):\"\",a.emissiveMapEncoding?$t(\"emissiveMapTexelToLinear\",a.emissiveMapEncoding):\"\",a.outputEncoding?(v=\"linearToOutputTexel\",g=a.outputEncoding,y=Kt(g),\"vec4 \"+v+\"( vec4 value ) { return LinearTo\"+y[0]+y[1]+\"; }\"):\"\",a.depthPacking?\"#define DEPTH_PACKING \"+r.depthPacking:\"\",\"\\n\"].filter(ti).join(\"\\n\")),c=ri(c=ii(c=ni(c),a),a),h=ri(h=ii(h=ni(h),a),a);var _=f+(c=ai(c)),E=m+(h=ai(h)),M=Zt(o,o.VERTEX_SHADER,_),T=Zt(o,o.FRAGMENT_SHADER,E);o.attachShader(b,M),o.attachShader(b,T),void 0!==r.index0AttributeName?o.bindAttribLocation(b,0,r.index0AttributeName):!0===a.morphTargets&&o.bindAttribLocation(b,0,\"position\"),o.linkProgram(b);var S,R,L=o.getProgramInfoLog(b).trim(),P=o.getShaderInfoLog(M).trim(),C=o.getShaderInfoLog(T).trim(),D=!0,I=!0;return!1===o.getProgramParameter(b,o.LINK_STATUS)?(D=!1,console.error(\"THREE.WebGLProgram: shader error: \",o.getError(),\"gl.VALIDATE_STATUS\",o.getProgramParameter(b,o.VALIDATE_STATUS),\"gl.getProgramInfoLog\",L,P,C)):\"\"!==L?console.warn(\"THREE.WebGLProgram: gl.getProgramInfoLog()\",L):\"\"!==P&&\"\"!==C||(I=!1),I&&(this.diagnostics={runnable:D,material:r,programLog:L,vertexShader:{log:P,prefix:f},fragmentShader:{log:C,prefix:m}}),o.deleteShader(M),o.deleteShader(T),this.getUniforms=function(){return void 0===S&&(S=new Qt(o,b,e)),S},this.getAttributes=function(){return void 0===R&&(R=function(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;n0,maxBones:d,useVertexTexture:i.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numClippingPlanes:c,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.receiveShadow&&a.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:2===t.side,flipSided:1===t.side,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var o=0;o1&&i.sort(hi),r.length>1&&r.sort(li)}}}function di(){var e={};return{get:function(t,i){var r=t.id+\",\"+i.id,n=e[r];return void 0===n&&(n=new ui,e[r]=n),n},dispose:function(){e={}}}}function pi(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case\"DirectionalLight\":i={direction:new L,color:new Z,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new T};break;case\"SpotLight\":i={position:new L,direction:new L,color:new Z,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new T};break;case\"PointLight\":i={position:new L,color:new Z,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new T,shadowCameraNear:1,shadowCameraFar:1e3};break;case\"HemisphereLight\":i={direction:new L,skyColor:new Z,groundColor:new Z};break;case\"RectAreaLight\":i={color:new Z,position:new L,halfWidth:new L,halfHeight:new L}}return e[t.id]=i,i}}}var fi,mi,vi,gi,yi,Ai,xi,wi,bi=0;function _i(){var e=new pi,t={id:bi++,hash:\"\",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},i=new L,r=new S,n=new S;return{setup:function(a,o,s){for(var c=0,h=0,l=0,u=0,d=0,p=0,f=0,m=0,v=s.matrixWorldInverse,g=0,y=a.length;g0:s&&s.isGeometry&&(m=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===i.skinning&&console.warn(\"THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:\",t);var v=0;m&&(v|=1),t.isSkinnedMesh&&i.skinning&&(v|=2),c=p[v]}if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var g=c.uuid,y=i.uuid,A=u[g];void 0===A&&(A={},u[g]=A);var x=A[y];void 0===x&&(x=c.clone(),A[y]=x),c=x}return c.visible=i.visible,c.wireframe=i.wireframe,c.side=null!=i.shadowSide?i.shadowSide:d[i.side],c.clipShadows=i.clipShadows,c.clippingPlanes=i.clippingPlanes,c.clipIntersection=i.clipIntersection,c.wireframeLinewidth=i.wireframeLinewidth,c.linewidth=i.linewidth,r&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(n),c.nearDistance=a,c.farDistance=o),c}function _(i,n,a,o){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&i.castShadow&&(!i.frustumCulled||r.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,i.matrixWorld);var s=t.update(i),h=i.material;if(Array.isArray(h))for(var l=s.groups,u=0,d=l.length;u 0 ) {\",\"\\t\\tfloat fogFactor = 0.0;\",\"\\t\\tif ( fogType == 1 ) {\",\"\\t\\t\\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );\",\"\\t\\t} else {\",\"\\t\\t\\tconst float LOG2 = 1.442695;\",\"\\t\\t\\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );\",\"\\t\\t\\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\",\"\\t\\t}\",\"\\t\\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\",\"\\t}\",\"}\"].join(\"\\n\")),t.compileShader(i),t.compileShader(r),t.attachShader(e,i),t.attachShader(e,r),t.linkProgram(e),e}(),c={position:t.getAttribLocation(s,\"position\"),uv:t.getAttribLocation(s,\"uv\")},h={uvOffset:t.getUniformLocation(s,\"uvOffset\"),uvScale:t.getUniformLocation(s,\"uvScale\"),rotation:t.getUniformLocation(s,\"rotation\"),center:t.getUniformLocation(s,\"center\"),scale:t.getUniformLocation(s,\"scale\"),color:t.getUniformLocation(s,\"color\"),map:t.getUniformLocation(s,\"map\"),opacity:t.getUniformLocation(s,\"opacity\"),modelViewMatrix:t.getUniformLocation(s,\"modelViewMatrix\"),projectionMatrix:t.getUniformLocation(s,\"projectionMatrix\"),fogType:t.getUniformLocation(s,\"fogType\"),fogDensity:t.getUniformLocation(s,\"fogDensity\"),fogNear:t.getUniformLocation(s,\"fogNear\"),fogFar:t.getUniformLocation(s,\"fogFar\"),fogColor:t.getUniformLocation(s,\"fogColor\"),fogDepth:t.getUniformLocation(s,\"fogDepth\"),alphaTest:t.getUniformLocation(s,\"alphaTest\")};var r=document.createElementNS(\"http://www.w3.org/1999/xhtml\",\"canvas\");r.width=8,r.height=8;var u=r.getContext(\"2d\");u.fillStyle=\"white\",u.fillRect(0,0,8,8),l=new Li(r)}function m(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}this.render=function(n,v,g){if(0!==n.length){void 0===s&&f(),i.useProgram(s),i.initAttributes(),i.enableAttribute(c.position),i.enableAttribute(c.uv),i.disableUnusedAttributes(),i.disable(t.CULL_FACE),i.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,a),t.vertexAttribPointer(c.position,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(c.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),t.uniformMatrix4fv(h.projectionMatrix,!1,g.projectionMatrix.elements),i.activeTexture(t.TEXTURE0),t.uniform1i(h.map,0);var y=0,A=0,x=v.fog;x?(t.uniform3f(h.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(t.uniform1f(h.fogNear,x.near),t.uniform1f(h.fogFar,x.far),t.uniform1i(h.fogType,1),y=1,A=1):x.isFogExp2&&(t.uniform1f(h.fogDensity,x.density),t.uniform1i(h.fogType,2),y=2,A=2)):(t.uniform1i(h.fogType,0),y=0,A=0);for(var w=0,b=n.length;w=1):-1!==L.indexOf(\"OpenGL ES\")&&(R=parseFloat(/^OpenGL\\ ES\\ ([0-9])/.exec(L)[1]),S=R>=2);var P=null,C={},D=new U,I=new U;function O(t,i,r){var n=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;ot||e.height>t){if(\"data\"in e)return void console.warn(\"THREE.WebGLRenderer: image in DataTexture is too big (\"+e.width+\"x\"+e.height+\").\");var i=t/Math.max(e.width,e.height),r=document.createElementNS(\"http://www.w3.org/1999/xhtml\",\"canvas\");return r.width=Math.floor(e.width*i),r.height=Math.floor(e.height*i),r.getContext(\"2d\").drawImage(e,0,0,e.width,e.height,0,0,r.width,r.height),console.warn(\"THREE.WebGLRenderer: image is too big (\"+e.width+\"x\"+e.height+\"). Resized to \"+r.width+\"x\"+r.height,e),r}return e}function u(e){return M.isPowerOfTwo(e.width)&&M.isPowerOfTwo(e.height)}function d(e,t){return e.generateMipmaps&&t&&1003!==e.minFilter&&1006!==e.minFilter}function p(t,i,n,a){e.generateMipmap(t),r.get(i).__maxMipLevel=Math.log(Math.max(n,a))*Math.LOG2E}function f(t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function m(t){var i=t.target;i.removeEventListener(\"dispose\",m),function(t){var i=r.get(t);if(t.image&&i.__image__webglTextureCube)e.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture)}r.remove(t)}(i),i.isVideoTexture&&delete h[i.id],o.memory.textures--}function v(t){var i=t.target;i.removeEventListener(\"dispose\",v),function(t){var i=r.get(t),n=r.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(i.__webglFramebuffer[a]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[a]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(t.texture),r.remove(t)}(i),o.memory.textures--}function g(t,f){var v=r.get(t);if(t.isVideoTexture&&function(e){var t=e.id,i=o.render.frame;h[t]!==i&&(h[t]=i,e.update())}(t),t.version>0&&v.__version!==t.version){var g=t.image;if(void 0===g)console.warn(\"THREE.WebGLRenderer: Texture marked for update but image is undefined\",t);else{if(!1!==g.complete)return void function(t,r,h){void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener(\"dispose\",m),t.__webglTexture=e.createTexture(),o.memory.textures++);i.activeTexture(e.TEXTURE0+h),i.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment);var f=l(r.image,n.maxTextureSize);(function(e){return 1001!==e.wrapS||1001!==e.wrapT||1003!==e.minFilter&&1006!==e.minFilter})(r)&&!1===u(f)&&(f=function(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap?(void 0===s&&(s=document.createElementNS(\"http://www.w3.org/1999/xhtml\",\"canvas\")),s.width=M.floorPowerOfTwo(e.width),s.height=M.floorPowerOfTwo(e.height),s.getContext(\"2d\").drawImage(e,0,0,s.width,s.height),console.warn(\"THREE.WebGLRenderer: image is not power of two (\"+e.width+\"x\"+e.height+\"). Resized to \"+s.width+\"x\"+s.height,e),s):e}(f));var v=u(f),g=a.convert(r.format),A=a.convert(r.type);y(e.TEXTURE_2D,r,v);var x,w=r.mipmaps;if(r.isDepthTexture){var b=e.DEPTH_COMPONENT;if(1015===r.type){if(!c)throw new Error(\"Float Depth Texture only supported in WebGL2.0\");b=e.DEPTH_COMPONENT32F}else c&&(b=e.DEPTH_COMPONENT16);1026===r.format&&b===e.DEPTH_COMPONENT&&1012!==r.type&&1014!==r.type&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.\"),r.type=1012,A=a.convert(r.type)),1027===r.format&&(b=e.DEPTH_STENCIL,1020!==r.type&&(console.warn(\"THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.\"),r.type=1020,A=a.convert(r.type))),i.texImage2D(e.TEXTURE_2D,0,b,f.width,f.height,0,g,A,null)}else if(r.isDataTexture)if(w.length>0&&v){for(var _=0,E=w.length;_-1?i.compressedTexImage2D(e.TEXTURE_2D,_,g,x.width,x.height,0,x.data):console.warn(\"THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()\"):i.texImage2D(e.TEXTURE_2D,_,g,x.width,x.height,0,g,A,x.data);t.__maxMipLevel=w.length-1}else if(w.length>0&&v){for(_=0,E=w.length;_1||r.get(o).__currentAnisotropy)&&(e.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,n.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function A(t,n,o,s){var c=a.convert(n.texture.format),h=a.convert(n.texture.type);i.texImage2D(s,0,c,n.width,n.height,0,c,h,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,o,s,r.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function x(t,i){e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):i.depthBuffer&&i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,i.width,i.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function w(t){var i=r.get(t),n=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(n)throw new Error(\"target.depthTexture not supported in Cube render targets\");!function(t,i){if(i&&i.isWebGLRenderTargetCube)throw new Error(\"Depth Texture with cube render targets is not supported\");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error(\"renderTarget.depthTexture must be an instance of THREE.DepthTexture\");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),g(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(1026===i.depthTexture.format)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,n,0);else{if(1027!==i.depthTexture.format)throw new Error(\"Unknown depthTexture format\");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,n,0)}}(i.__webglFramebuffer,t)}else if(n){i.__webglDepthbuffer=[];for(var a=0;a<6;a++)e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[a]),i.__webglDepthbuffer[a]=e.createRenderbuffer(),x(i.__webglDepthbuffer[a],t)}else e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),x(i.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}this.setTexture2D=g,this.setTextureCube=function(t,s){var c=r.get(t);if(6===t.image.length)if(t.version>0&&c.__version!==t.version){c.__image__webglTextureCube||(t.addEventListener(\"dispose\",m),c.__image__webglTextureCube=e.createTexture(),o.memory.textures++),i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,c.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var h=t&&t.isCompressedTexture,f=t.image[0]&&t.image[0].isDataTexture,v=[],g=0;g<6;g++)v[g]=h||f?f?t.image[g].image:t.image[g]:l(t.image[g],n.maxCubemapSize);var A=v[0],x=u(A),w=a.convert(t.format),b=a.convert(t.type);y(e.TEXTURE_CUBE_MAP,t,x);for(g=0;g<6;g++)if(h)for(var _,E=v[g].mipmaps,M=0,T=E.length;M-1?i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,M,w,_.width,_.height,0,_.data):console.warn(\"THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()\"):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,M,w,_.width,_.height,0,w,b,_.data);else f?i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,w,v[g].width,v[g].height,0,w,b,v[g].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,w,w,b,v[g]);c.__maxMipLevel=h?E.length-1:0,d(t,x)&&p(e.TEXTURE_CUBE_MAP,t,A.width,A.height),c.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,n){i.activeTexture(e.TEXTURE0+n),i.bindTexture(e.TEXTURE_CUBE_MAP,r.get(t).__webglTexture)},this.setupRenderTarget=function(t){var n=r.get(t),a=r.get(t.texture);t.addEventListener(\"dispose\",v),a.__webglTexture=e.createTexture(),o.memory.textures++;var s=!0===t.isWebGLRenderTargetCube,c=u(t);if(s){n.__webglFramebuffer=[];for(var h=0;h<6;h++)n.__webglFramebuffer[h]=e.createFramebuffer()}else n.__webglFramebuffer=e.createFramebuffer();if(s){i.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture),y(e.TEXTURE_CUBE_MAP,t.texture,c);for(h=0;h<6;h++)A(n.__webglFramebuffer[h],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+h);d(t.texture,c)&&p(e.TEXTURE_CUBE_MAP,t.texture,t.width,t.height),i.bindTexture(e.TEXTURE_CUBE_MAP,null)}else i.bindTexture(e.TEXTURE_2D,a.__webglTexture),y(e.TEXTURE_2D,t.texture,c),A(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),d(t.texture,c)&&p(e.TEXTURE_2D,t.texture,t.width,t.height),i.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&w(t)},this.updateRenderTargetMipmap=function(t){var n=t.texture;if(d(n,u(t))){var a=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,o=r.get(n).__webglTexture;i.bindTexture(a,o),p(a,n,t.width,t.height),i.bindTexture(a,null)}}}function Ii(e,t){return{convert:function(i){var r;if(1e3===i)return e.REPEAT;if(1001===i)return e.CLAMP_TO_EDGE;if(1002===i)return e.MIRRORED_REPEAT;if(1003===i)return e.NEAREST;if(1004===i)return e.NEAREST_MIPMAP_NEAREST;if(1005===i)return e.NEAREST_MIPMAP_LINEAR;if(1006===i)return e.LINEAR;if(1007===i)return e.LINEAR_MIPMAP_NEAREST;if(1008===i)return e.LINEAR_MIPMAP_LINEAR;if(1009===i)return e.UNSIGNED_BYTE;if(1017===i)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===i)return e.UNSIGNED_SHORT_5_5_5_1;if(1019===i)return e.UNSIGNED_SHORT_5_6_5;if(1010===i)return e.BYTE;if(1011===i)return e.SHORT;if(1012===i)return e.UNSIGNED_SHORT;if(1013===i)return e.INT;if(1014===i)return e.UNSIGNED_INT;if(1015===i)return e.FLOAT;if(1016===i&&null!==(r=t.get(\"OES_texture_half_float\")))return r.HALF_FLOAT_OES;if(1021===i)return e.ALPHA;if(1022===i)return e.RGB;if(1023===i)return e.RGBA;if(1024===i)return e.LUMINANCE;if(1025===i)return e.LUMINANCE_ALPHA;if(1026===i)return e.DEPTH_COMPONENT;if(1027===i)return e.DEPTH_STENCIL;if(100===i)return e.FUNC_ADD;if(101===i)return e.FUNC_SUBTRACT;if(102===i)return e.FUNC_REVERSE_SUBTRACT;if(200===i)return e.ZERO;if(201===i)return e.ONE;if(202===i)return e.SRC_COLOR;if(203===i)return e.ONE_MINUS_SRC_COLOR;if(204===i)return e.SRC_ALPHA;if(205===i)return e.ONE_MINUS_SRC_ALPHA;if(206===i)return e.DST_ALPHA;if(207===i)return e.ONE_MINUS_DST_ALPHA;if(208===i)return e.DST_COLOR;if(209===i)return e.ONE_MINUS_DST_COLOR;if(210===i)return e.SRC_ALPHA_SATURATE;if((33776===i||33777===i||33778===i||33779===i)&&null!==(r=t.get(\"WEBGL_compressed_texture_s3tc\"))){if(33776===i)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===i)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===i)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===i)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((35840===i||35841===i||35842===i||35843===i)&&null!==(r=t.get(\"WEBGL_compressed_texture_pvrtc\"))){if(35840===i)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===i)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===i)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===i)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===i&&null!==(r=t.get(\"WEBGL_compressed_texture_etc1\")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((37808===i||37809===i||37810===i||37811===i||37812===i||37813===i||37814===i||37815===i||37816===i||37817===i||37818===i||37819===i||37820===i||37821===i)&&null!==(r=t.get(\"WEBGL_compressed_texture_astc\")))return i;if((103===i||104===i)&&null!==(r=t.get(\"EXT_blend_minmax\"))){if(103===i)return r.MIN_EXT;if(104===i)return r.MAX_EXT}return 1020===i&&null!==(r=t.get(\"WEBGL_depth_texture\"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function Oi(e,t,i,r){le.call(this),this.type=\"PerspectiveCamera\",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Ni(e){Oi.call(this),this.cameras=e||[]}function Bi(e){var t=this,i=null,r=null,n=null,a=new S,o=new S;\"undefined\"!=typeof window&&\"VRFrameData\"in window&&(r=new window.VRFrameData,window.addEventListener(\"vrdisplaypresentchange\",v,!1));var s=new S,c=new R,h=new L,l=new Oi;l.bounds=new U(0,0,.5,1),l.layers.enable(1);var u=new Oi;u.bounds=new U(.5,0,.5,1),u.layers.enable(2);var d,p,f=new Ni([l,u]);function m(){return null!==i&&!0===i.isPresenting}function v(){if(m()){var r=i.getEyeParameters(\"left\"),n=r.renderWidth,a=r.renderHeight;p=e.getPixelRatio(),d=e.getSize(),e.setDrawingBufferSize(2*n,a,1),g.start()}else t.enabled&&(e.setDrawingBufferSize(d.width,d.height,p),g.stop())}f.layers.enable(1),f.layers.enable(2),this.enabled=!1,this.userHeight=1.6,this.getDevice=function(){return i},this.setDevice=function(e){void 0!==e&&(i=e),g.setContext(e)},this.setPoseTarget=function(e){void 0!==e&&(n=e)},this.getCamera=function(e){if(null===i)return e;i.depthNear=e.near,i.depthFar=e.far,i.getFrameData(r);var d=i.stageParameters;d?a.fromArray(d.sittingToStandingTransform):a.makeTranslation(0,t.userHeight,0);var p=r.pose,m=null!==n?n:e;if(m.matrix.copy(a),m.matrix.decompose(m.position,m.quaternion,m.scale),null!==p.orientation&&(c.fromArray(p.orientation),m.quaternion.multiply(c)),null!==p.position&&(c.setFromRotationMatrix(a),h.fromArray(p.position),h.applyQuaternion(c),m.position.add(h)),m.updateMatrixWorld(),!1===i.isPresenting)return e;l.near=e.near,u.near=e.near,l.far=e.far,u.far=e.far,f.matrixWorld.copy(e.matrixWorld),f.matrixWorldInverse.copy(e.matrixWorldInverse),l.matrixWorldInverse.fromArray(r.leftViewMatrix),u.matrixWorldInverse.fromArray(r.rightViewMatrix),o.getInverse(a),l.matrixWorldInverse.multiply(o),u.matrixWorldInverse.multiply(o);var v=m.parent;null!==v&&(s.getInverse(v.matrixWorld),l.matrixWorldInverse.multiply(s),u.matrixWorldInverse.multiply(s)),l.matrixWorld.getInverse(l.matrixWorldInverse),u.matrixWorld.getInverse(u.matrixWorldInverse),l.projectionMatrix.fromArray(r.leftProjectionMatrix),u.projectionMatrix.fromArray(r.rightProjectionMatrix),f.projectionMatrix.copy(l.projectionMatrix);var g=i.getLayers();if(g.length){var y=g[0];null!==y.leftBounds&&4===y.leftBounds.length&&l.bounds.fromArray(y.leftBounds),null!==y.rightBounds&&4===y.rightBounds.length&&u.bounds.fromArray(y.rightBounds)}return f},this.getStandingMatrix=function(){return a},this.isPresenting=m;var g=new ee;this.setAnimationLoop=function(e){g.setAnimationLoop(e)},this.submitFrame=function(){m()&&i.submitFrame()},this.dispose=function(){\"undefined\"!=typeof window&&window.removeEventListener(\"vrdisplaypresentchange\",v)}}function Fi(e){var t=e.context,i=null,r=null,n=null,a=null;function o(){return null!==r&&null!==n}var s=new Oi;s.layers.enable(1),s.viewport=new U;var c=new Oi;c.layers.enable(2),c.viewport=new U;var h=new Ni([s,c]);function l(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.getInverse(e.matrixWorld)}h.layers.enable(1),h.layers.enable(2),this.enabled=!1,this.getDevice=function(){return i},this.setDevice=function(e){void 0!==e&&(i=e),t.setCompatibleXRDevice(e)},this.setSession=function(i,a){null!==(r=i)&&(r.addEventListener(\"end\",(function(){e.setFramebuffer(null),d.stop()})),r.baseLayer=new XRWebGLLayer(r,t),r.requestFrameOfReference(a.frameOfReferenceType).then((function(t){n=t,e.setFramebuffer(r.baseLayer.framebuffer),d.setContext(r),d.start()})))},this.getCamera=function(e){if(o()){var t=e.parent,i=h.cameras;l(h,t);for(var r=0;r=0){var c=r[o];if(void 0!==c){var h=c.normalized,l=c.itemSize,u=A.get(c);if(void 0===u)continue;var f=u.buffer,v=u.type,g=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var y=c.data,x=y.stride,w=c.offset;y&&y.isInstancedInterleavedBuffer?(m.enableAttributeAndDivisor(s,y.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=y.meshPerAttribute*y.count)):m.enableAttribute(s),d.bindBuffer(d.ARRAY_BUFFER,f),d.vertexAttribPointer(s,l,v,h,x*g,w*g)}else c.isInstancedBufferAttribute?(m.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=c.meshPerAttribute*c.count)):m.enableAttribute(s),d.bindBuffer(d.ARRAY_BUFFER,f),d.vertexAttribPointer(s,l,v,h,0,0)}else if(void 0!==a){var b=a[o];if(void 0!==b)switch(b.length){case 2:d.vertexAttrib2fv(s,b);break;case 3:d.vertexAttrib3fv(s,b);break;case 4:d.vertexAttrib4fv(s,b);break;default:d.vertexAttrib1fv(s,b)}}}}m.disableUnusedAttributes()}(r,s,i),null!==u&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==f&&(y=f.count);var w=i.drawRange.start*v,b=i.drawRange.count*v,_=null!==a?a.start*v:0,E=null!==a?a.count*v:1/0,M=Math.max(w,_),T=Math.min(y,w+b,_+E)-1,S=Math.max(0,T-M+1);if(0!==S){if(n.isMesh)if(!0===r.wireframe)m.setLineWidth(r.wireframeLinewidth*pe()),g.setMode(d.LINES);else switch(n.drawMode){case 0:g.setMode(d.TRIANGLES);break;case 1:g.setMode(d.TRIANGLE_STRIP);break;case 2:g.setMode(d.TRIANGLE_FAN)}else if(n.isLine){var L=r.linewidth;void 0===L&&(L=1),m.setLineWidth(L*pe()),n.isLineSegments?g.setMode(d.LINES):n.isLineLoop?g.setMode(d.LINE_LOOP):g.setMode(d.LINE_STRIP)}else n.isPoints&&g.setMode(d.POINTS);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&g.renderInstances(i,M,S):g.render(M,S)}},this.compile=function(e,t){(u=E.get(e,t)).init(),e.traverse((function(e){e.isLight&&(u.pushLight(e),e.castShadow&&u.pushShadow(e))})),u.setupLights(t),e.traverse((function(t){if(t.material)if(Array.isArray(t.material))for(var i=0;i=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(p=0;p=0&&e.numSupportedMorphNormals++}var f=r.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=ce.numPlanes,r.numIntersection=ce.numIntersection,f.clippingPlanes=ce.uniform),r.fog=t,r.lightsHash=n.state.hash,e.lights&&(f.ambientLightColor.value=n.state.ambient,f.directionalLights.value=n.state.directional,f.spotLights.value=n.state.spot,f.rectAreaLights.value=n.state.rectArea,f.pointLights.value=n.state.point,f.hemisphereLights.value=n.state.hemi,f.directionalShadowMap.value=n.state.directionalShadowMap,f.directionalShadowMatrix.value=n.state.directionalShadowMatrix,f.spotShadowMap.value=n.state.spotShadowMap,f.spotShadowMatrix.value=n.state.spotShadowMatrix,f.pointShadowMap.value=n.state.pointShadowMap,f.pointShadowMatrix.value=n.state.pointShadowMatrix);var m=r.program.getUniforms(),v=Qt.seqWithValue(m.seq,f);r.uniformsList=v}function Re(e,t,i,r){Z=0;var n=g.get(i),a=u.state.lights;if(he&&(le||e!==k)){var o=e===k&&i.id===G;ce.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,n,o)}!1===i.needsUpdate&&(void 0===n.program||i.fog&&n.fog!==t||i.lights&&n.lightsHash!==a.state.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===ce.numPlanes&&n.numIntersection===ce.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(Se(i,t,r),i.needsUpdate=!1);var s,c,h=!1,l=!1,p=!1,v=n.program,y=v.getUniforms(),A=n.shader.uniforms;if(m.useProgram(v.program)&&(h=!0,l=!0,p=!0),i.id!==G&&(G=i.id,l=!0),h||e!==k){if(y.setValue(d,\"projectionMatrix\",e.projectionMatrix),f.logarithmicDepthBuffer&&y.setValue(d,\"logDepthBufFC\",2/(Math.log(e.far+1)/Math.LN2)),k!==(j||e)&&(k=j||e,l=!0,p=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var x=y.map.cameraPosition;void 0!==x&&x.setValue(d,de.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&y.setValue(d,\"viewMatrix\",e.matrixWorldInverse)}if(i.skinning){y.setOptional(d,r,\"bindMatrix\"),y.setOptional(d,r,\"bindMatrixInverse\");var w=r.skeleton;if(w){var b=w.bones;if(f.floatVertexTextures){if(void 0===w.boneTexture){var _=Math.sqrt(4*b.length);_=M.ceilPowerOfTwo(_),_=Math.max(_,4);var E=new Float32Array(_*_*4);E.set(w.boneMatrices);var T=new V(E,_,_,1023,1015);T.needsUpdate=!0,w.boneMatrices=E,w.boneTexture=T,w.boneTextureSize=_}y.setValue(d,\"boneTexture\",w.boneTexture),y.setValue(d,\"boneTextureSize\",w.boneTextureSize)}else y.setOptional(d,w,\"boneMatrices\")}}return l&&(y.setValue(d,\"toneMappingExposure\",O.toneMappingExposure),y.setValue(d,\"toneMappingWhitePoint\",O.toneMappingWhitePoint),i.lights&&(c=p,(s=A).ambientLightColor.needsUpdate=c,s.directionalLights.needsUpdate=c,s.pointLights.needsUpdate=c,s.spotLights.needsUpdate=c,s.rectAreaLights.needsUpdate=c,s.hemisphereLights.needsUpdate=c),t&&i.fog&&function(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}(A,t),i.isMeshBasicMaterial?Le(A,i):i.isMeshLambertMaterial?(Le(A,i),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(A,i)):i.isMeshPhongMaterial?(Le(A,i),i.isMeshToonMaterial?function(e,t){Pe(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(A,i):Pe(A,i)):i.isMeshStandardMaterial?(Le(A,i),i.isMeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,Ce(e,t)}(A,i):Ce(A,i)):i.isMeshDepthMaterial?(Le(A,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(A,i)):i.isMeshDistanceMaterial?(Le(A,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(A,i)):i.isMeshNormalMaterial?(Le(A,i),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(A,i)):i.isLineBasicMaterial?(function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}(A,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(A,i)):i.isPointsMaterial?function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*re,e.scale.value=.5*ie,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}(A,i):i.isShadowMaterial&&(A.color.value=i.color,A.opacity.value=i.opacity),void 0!==A.ltc_1&&(A.ltc_1.value=K.LTC_1),void 0!==A.ltc_2&&(A.ltc_2.value=K.LTC_2),Qt.upload(d,n.uniformsList,A,O)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Qt.upload(d,n.uniformsList,A,O),i.uniformsNeedUpdate=!1),y.setValue(d,\"modelViewMatrix\",r.modelViewMatrix),y.setValue(d,\"normalMatrix\",r.normalMatrix),y.setValue(d,\"modelMatrix\",r.matrixWorld),v}function Le(e,t){var i;e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=g.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}function Pe(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Ce(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}Ee.setAnimationLoop((function(){ve.isPresenting()||be&&be()})),Ee.setContext(window),this.setAnimationLoop=function(e){be=e,ve.setAnimationLoop(e),Ee.start()},this.render=function(e,t,i,r){if(t&&t.isCamera){if(!N){H=\"\",G=-1,k=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),ve.enabled&&(t=ve.getCamera(t)),(u=E.get(e,t)).init(),e.onBeforeRender(O,e,t,i),ue.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromMatrix(ue),le=this.localClippingEnabled,he=ce.init(this.clippingPlanes,le,t),(l=_.get(e,t)).init(),function e(t,i,r){if(!1===t.visible)return;if(t.layers.test(i.layers))if(t.isLight)u.pushLight(t),t.castShadow&&u.pushShadow(t);else if(t.isSprite)t.frustumCulled&&!se.intersectsSprite(t)||u.pushSprite(t);else if(t.isImmediateRenderObject)r&&de.setFromMatrixPosition(t.matrixWorld).applyMatrix4(ue),l.push(t,null,t.material,de.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||se.intersectsObject(t))){r&&de.setFromMatrixPosition(t.matrixWorld).applyMatrix4(ue);var n=w.update(t),a=t.material;if(Array.isArray(a))for(var o=n.groups,s=0,c=o.length;s=f.maxTextures&&console.warn(\"THREE.WebGLRenderer: Trying to use \"+e+\" texture units while this GPU supports only \"+f.maxTextures),Z+=1,e},this.setTexture2D=(_e=!1,function(e,t){e&&e.isWebGLRenderTarget&&(_e||(console.warn(\"THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead.\"),_e=!0),e=e.texture),y.setTexture2D(e,t)}),this.setTexture=function(){var e=!1;return function(t,i){e||(console.warn(\"THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead.\"),e=!0),y.setTexture2D(t,i)}}(),this.setTextureCube=function(){var e=!1;return function(t,i){t&&t.isWebGLRenderTargetCube&&(e||(console.warn(\"THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead.\"),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?y.setTextureCube(t,i):y.setTextureCubeDynamic(t,i)}}(),this.setFramebuffer=function(e){B=e},this.getRenderTarget=function(){return F},this.setRenderTarget=function(e){F=e,e&&void 0===g.get(e).__webglFramebuffer&&y.setupRenderTarget(e);var t=B,i=!1;if(e){var r=g.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(t=r[e.activeCubeFace],i=!0):t=r,X.copy(e.viewport),Y.copy(e.scissor),Q=e.scissorTest}else X.copy(ne).multiplyScalar(re),Y.copy(ae).multiplyScalar(re),Q=oe;if(z!==t&&(d.bindFramebuffer(d.FRAMEBUFFER,t),z=t),m.viewport(X),m.scissor(Y),m.setScissorTest(Q),i){var n=g.get(e.texture);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,n.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,i,r,n,a){if(e&&e.isWebGLRenderTarget){var o=g.get(e).__webglFramebuffer;if(o){var s=!1;o!==z&&(d.bindFramebuffer(d.FRAMEBUFFER,o),s=!0);try{var c=e.texture,h=c.format,l=c.type;if(1023!==h&&I.convert(h)!==d.getParameter(d.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.\");if(!(1009===l||I.convert(l)===d.getParameter(d.IMPLEMENTATION_COLOR_READ_TYPE)||1015===l&&(p.get(\"OES_texture_float\")||p.get(\"WEBGL_color_buffer_float\"))||1016===l&&p.get(\"EXT_color_buffer_half_float\")))return void console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.\");d.checkFramebufferStatus(d.FRAMEBUFFER)===d.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-r&&i>=0&&i<=e.height-n&&d.readPixels(t,i,r,n,I.convert(h),I.convert(l),a):console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.\")}finally{s&&d.bindFramebuffer(d.FRAMEBUFFER,z)}}}else console.error(\"THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.\")},this.copyFramebufferToTexture=function(e,t,i){var r=t.image.width,n=t.image.height,a=I.convert(t.format);this.setTexture2D(t,0),d.copyTexImage2D(d.TEXTURE_2D,i||0,a,e.x,e.y,r,n,0)},this.copyTextureToTexture=function(e,t,i,r){var n=t.image.width,a=t.image.height,o=I.convert(i.format),s=I.convert(i.type);this.setTexture2D(i,0),t.isDataTexture?d.texSubImage2D(d.TEXTURE_2D,r||0,e.x,e.y,n,a,o,s,t.image.data):d.texSubImage2D(d.TEXTURE_2D,r||0,e.x,e.y,o,s,t.image)}}function zi(e,t){this.name=\"\",this.color=new Z(e),this.density=void 0!==t?t:25e-5}function Gi(e,t,i){this.name=\"\",this.color=new Z(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function Vi(){he.call(this),this.type=\"Scene\",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Hi(e){ke.call(this),this.type=\"SpriteMaterial\",this.color=new Z(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function ki(e){he.call(this),this.type=\"Sprite\",this.material=void 0!==e?e:new Hi,this.center=new T(.5,.5)}function ji(){he.call(this),this.type=\"LOD\",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Wi(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn(\"THREE.Skeleton boneInverses is the wrong length.\"),this.boneInverses=[];for(var i=0,r=this.bones.length;i=0?(e(g-h,v,d),p.subVectors(u,d)):(e(g+h,v,d),p.subVectors(d,u)),v-h>=0?(e(g,v-h,d),f.subVectors(u,d)):(e(g,v+h,d),f.subVectors(d,u)),l.crossVectors(p,f).normalize(),s.push(l.x,l.y,l.z),c.push(g,v)}}for(r=0;r.9&&o<.1&&(t<.2&&(a[e+0]+=1),i<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}()}(),this.addAttribute(\"position\",new Me(n,3)),this.addAttribute(\"normal\",new Me(n.slice(),3)),this.addAttribute(\"uv\",new Me(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function hr(e,t){ve.call(this),this.type=\"TetrahedronGeometry\",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new lr(e,t)),this.mergeVertices()}function lr(e,t){cr.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=\"TetrahedronBufferGeometry\",this.parameters={radius:e,detail:t}}function ur(e,t){ve.call(this),this.type=\"OctahedronGeometry\",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new dr(e,t)),this.mergeVertices()}function dr(e,t){cr.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=\"OctahedronBufferGeometry\",this.parameters={radius:e,detail:t}}function pr(e,t){ve.call(this),this.type=\"IcosahedronGeometry\",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new fr(e,t)),this.mergeVertices()}function fr(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];cr.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type=\"IcosahedronBufferGeometry\",this.parameters={radius:e,detail:t}}function mr(e,t){ve.call(this),this.type=\"DodecahedronGeometry\",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new vr(e,t)),this.mergeVertices()}function vr(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];cr.call(this,n,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type=\"DodecahedronBufferGeometry\",this.parameters={radius:e,detail:t}}function gr(e,t,i,r,n,a){ve.call(this),this.type=\"TubeGeometry\",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},void 0!==a&&console.warn(\"THREE.TubeGeometry: taper has been removed.\");var o=new yr(e,t,i,r,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function yr(e,t,i,r,n){Pe.call(this),this.type=\"TubeBufferGeometry\",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},t=t||64,i=i||1,r=r||8,n=n||!1;var a=e.computeFrenetFrames(t,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new L,h=new L,l=new T,u=new L,d=[],p=[],f=[],m=[];function v(n){u=e.getPointAt(n/t,u);var o=a.normals[n],l=a.binormals[n];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);h.x=v*o.x+m*l.x,h.y=v*o.y+m*l.y,h.z=v*o.z+m*l.z,h.normalize(),p.push(h.x,h.y,h.z),c.x=u.x+i*h.x,c.y=u.y+i*h.y,c.z=u.z+i*h.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;oi)){var r=e.ray.origin.distanceTo(fi);re.far||t.push({distance:r,point:fi.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return he.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),ji.prototype=Object.assign(Object.create(he.prototype),{constructor:ji,copy:function(e){he.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;i1){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);r[0].object.visible=!0;for(var a=1,o=r.length;a=r[a].distance;a++)r[a-1].object.visible=!1,r[a].object.visible=!0;for(;ao))d.applyMatrix4(this.matrixWorld),(_=r.ray.origin.distanceTo(d))r.far||n.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}else for(g=0,y=m.length/3-1;go))d.applyMatrix4(this.matrixWorld),(_=r.ray.origin.distanceTo(d))r.far||n.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var w=s.vertices,b=w.length;for(g=0;go))d.applyMatrix4(this.matrixWorld),(_=r.ray.origin.distanceTo(d))r.far||n.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Zi.prototype=Object.assign(Object.create(Qi.prototype),{constructor:Zi,isLineSegments:!0,computeLineDistances:function(){var e=new L,t=new L;return function(){var i=this.geometry;if(i.isBufferGeometry)if(null===i.index){for(var r=i.attributes.position,n=[],a=0,o=r.count;ar.far)return;n.push({distance:c,distanceToRay:Math.sqrt(o),point:d.clone(),index:i,face:null,object:a})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),er.prototype=Object.assign(Object.create(he.prototype),{constructor:er,isGroup:!0}),tr.prototype=Object.assign(Object.create(F.prototype),{constructor:tr,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),ir.prototype=Object.create(F.prototype),ir.prototype.constructor=ir,ir.prototype.isCompressedTexture=!0,rr.prototype=Object.create(F.prototype),rr.prototype.constructor=rr,rr.prototype.isDepthTexture=!0,nr.prototype=Object.create(Pe.prototype),nr.prototype.constructor=nr,ar.prototype=Object.create(ve.prototype),ar.prototype.constructor=ar,or.prototype=Object.create(Pe.prototype),or.prototype.constructor=or,sr.prototype=Object.create(ve.prototype),sr.prototype.constructor=sr,cr.prototype=Object.create(Pe.prototype),cr.prototype.constructor=cr,hr.prototype=Object.create(ve.prototype),hr.prototype.constructor=hr,lr.prototype=Object.create(cr.prototype),lr.prototype.constructor=lr,ur.prototype=Object.create(ve.prototype),ur.prototype.constructor=ur,dr.prototype=Object.create(cr.prototype),dr.prototype.constructor=dr,pr.prototype=Object.create(ve.prototype),pr.prototype.constructor=pr,fr.prototype=Object.create(cr.prototype),fr.prototype.constructor=fr,mr.prototype=Object.create(ve.prototype),mr.prototype.constructor=mr,vr.prototype=Object.create(cr.prototype),vr.prototype.constructor=vr,gr.prototype=Object.create(ve.prototype),gr.prototype.constructor=gr,yr.prototype=Object.create(Pe.prototype),yr.prototype.constructor=yr,Ar.prototype=Object.create(ve.prototype),Ar.prototype.constructor=Ar,xr.prototype=Object.create(Pe.prototype),xr.prototype.constructor=xr,wr.prototype=Object.create(ve.prototype),wr.prototype.constructor=wr,br.prototype=Object.create(Pe.prototype),br.prototype.constructor=br;var _r=function(e,t,i){i=i||2;var r,n,a,o,s,c,h,l=t&&t.length,u=l?t[0]*i:e.length,d=Er(e,0,u,i,!0),p=[];if(!d)return p;if(l&&(d=function(e,t,i,r){var n,a,o,s,c,h=[];for(n=0,a=t.length;n80*i){r=a=e[0],n=o=e[1];for(var f=i;fa&&(a=s),c>o&&(o=c);h=0!==(h=Math.max(a-r,o-n))?1/h:0}return Tr(d,p,i,r,n,h),p};function Er(e,t,i,r,n){var a,o;if(n===function(e,t,i,r){for(var n=0,a=t,o=i-r;a0)for(a=t;a=t;a-=r)o=Hr(a,e[a],e[a+1],o);return o&&Ur(o,o.next)&&(kr(o),o=o.next),o}function Mr(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Ur(r,r.next)&&0!==Fr(r.prev,r,r.next))r=r.next;else{if(kr(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function Tr(e,t,i,r,n,a,o){if(e){!o&&a&&function(e,t,i,r){var n=e;do{null===n.z&&(n.z=Ir(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,a,o,s,c,h=1;do{for(i=e,e=null,a=null,o=0;i;){for(o++,r=i,s=0,t=0;t0||c>0&&r;)0!==s&&(0===c||!r||i.z<=r.z)?(n=i,i=i.nextZ,s--):(n=r,r=r.nextZ,c--),a?a.nextZ=n:e=n,n.prevZ=a,a=n;i=r}a.nextZ=null,h*=2}while(o>1)}(n)}(e,r,n,a);for(var s,c,h=e;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Rr(e,r,n,a):Sr(e))t.push(s.i/i),t.push(e.i/i),t.push(c.i/i),kr(e),e=c.next,h=c.next;else if((e=c)===h){o?1===o?Tr(e=Lr(e,t,i),t,i,r,n,a,2):2===o&&Pr(e,t,i,r,n,a):Tr(Mr(e),t,i,r,n,a,1);break}}}function Sr(e){var t=e.prev,i=e,r=e.next;if(Fr(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Nr(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Fr(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Rr(e,t,i,r){var n=e.prev,a=e,o=e.next;if(Fr(n,a,o)>=0)return!1;for(var s=n.xa.x?n.x>o.x?n.x:o.x:a.x>o.x?a.x:o.x,l=n.y>a.y?n.y>o.y?n.y:o.y:a.y>o.y?a.y:o.y,u=Ir(s,c,t,i,r),d=Ir(h,l,t,i,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Nr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Fr(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=u;){if(p!==e.prev&&p!==e.next&&Nr(n.x,n.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Fr(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Lr(e,t,i){var r=e;do{var n=r.prev,a=r.next.next;!Ur(n,a)&&zr(n,r,r.next,a)&&Gr(n,a)&&Gr(a,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(a.i/i),kr(r),kr(r.next),r=e=a),r=r.next}while(r!==e);return r}function Pr(e,t,i,r,n,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Br(o,s)){var c=Vr(o,s);return o=Mr(o,o.next),c=Mr(c,c.next),Tr(o,t,i,r,n,a),void Tr(c,t,i,r,n,a)}s=s.next}o=o.next}while(o!==e)}function Cr(e,t){return e.x-t.x}function Dr(e,t){if(t=function(e,t){var i,r=t,n=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=n&&s>o){if(o=s,s===n){if(a===r.y)return r;if(a===r.next.y)return r.next}i=r.x=r.x&&r.x>=l&&n!==r.x&&Nr(ai.x)&&Gr(r,e)&&(i=r,d=c),r=r.next;return i}(e,t)){var i=Vr(t,e);Mr(i,i.next)}}function Ir(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Or(e){var t=e,i=e;do{t.x=0&&(e-o)*(r-s)-(i-o)*(t-s)>=0&&(i-o)*(a-s)-(n-o)*(r-s)>=0}function Br(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&zr(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&Gr(e,t)&&Gr(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,a=(e.y+t.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&n<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)}function Fr(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Ur(e,t){return e.x===t.x&&e.y===t.y}function zr(e,t,i,r){return!!(Ur(e,t)&&Ur(i,r)||Ur(e,r)&&Ur(i,t))||Fr(e,t,i)>0!=Fr(e,t,r)>0&&Fr(i,r,e)>0!=Fr(i,r,t)>0}function Gr(e,t){return Fr(e.prev,e,e.next)<0?Fr(e,t,e.next)>=0&&Fr(e,e.prev,t)>=0:Fr(e,t,e.prev)<0||Fr(e,e.next,t)<0}function Vr(e,t){var i=new jr(e.i,e.x,e.y),r=new jr(t.i,t.x,t.y),n=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function Hr(e,t,i,r){var n=new jr(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function kr(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function jr(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Wr={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;n2&&e[t-1].equals(e[0])&&e.pop()}function Yr(e,t){for(var i=0;iNumber.EPSILON){var d=Math.sqrt(l),p=Math.sqrt(c*c+h*h),f=t.x-s/d,m=t.y+o/d,v=((i.x-h/p-f)*h-(i.y+c/p-m)*c)/(o*h-s*c),g=(r=f+o*v-e.x)*r+(n=m+s*v-e.y)*n;if(g<=2)return new T(r,n);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(h)&&(y=!0),y?(r=-s,n=o,a=Math.sqrt(l)):(r=o,n=s,a=Math.sqrt(l/2))}return new T(r/a,n/a)}for(var V=[],H=0,k=P.length,j=k-1,W=H+1;H=0;D--){for(O=D/d,N=l*Math.cos(O*Math.PI/2),I=u*Math.sin(O*Math.PI/2),H=0,k=P.length;H=0;){i=H,(r=H-1)<0&&(r=e.length-1);var n=0,a=s+2*d;for(n=0;n0)&&f.push(w,b,E),(c!==i-1||h0&&g(!0),t>0&&g(!1)),this.setIndex(h),this.addAttribute(\"position\",new Me(l,3)),this.addAttribute(\"normal\",new Me(u,3)),this.addAttribute(\"uv\",new Me(d,2))}function pn(e,t,i,r,n,a,o){un.call(this,0,e,t,i,r,n,a,o),this.type=\"ConeGeometry\",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:o}}function fn(e,t,i,r,n,a,o){dn.call(this,0,e,t,i,r,n,a,o),this.type=\"ConeBufferGeometry\",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:o}}function mn(e,t,i,r){ve.call(this),this.type=\"CircleGeometry\",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new vn(e,t,i,r)),this.mergeVertices()}function vn(e,t,i,r){Pe.call(this),this.type=\"CircleBufferGeometry\",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,a,o=[],s=[],c=[],h=[],l=new L,u=new T;for(s.push(0,0,0),c.push(0,0,1),h.push(.5,.5),a=0,n=3;a<=t;a++,n+=3){var d=i+a/t*r;l.x=e*Math.cos(d),l.y=e*Math.sin(d),s.push(l.x,l.y,l.z),c.push(0,0,1),u.x=(s[n]/e+1)/2,u.y=(s[n+1]/e+1)/2,h.push(u.x,u.y)}for(n=1;n<=t;n++)o.push(n,n+1,0);this.setIndex(o),this.addAttribute(\"position\",new Me(s,3)),this.addAttribute(\"normal\",new Me(c,3)),this.addAttribute(\"uv\",new Me(h,2))}Kr.prototype=Object.create(ve.prototype),Kr.prototype.constructor=Kr,$r.prototype=Object.create(Qr.prototype),$r.prototype.constructor=$r,en.prototype=Object.create(ve.prototype),en.prototype.constructor=en,tn.prototype=Object.create(Pe.prototype),tn.prototype.constructor=tn,rn.prototype=Object.create(ve.prototype),rn.prototype.constructor=rn,nn.prototype=Object.create(Pe.prototype),nn.prototype.constructor=nn,an.prototype=Object.create(ve.prototype),an.prototype.constructor=an,on.prototype=Object.create(Pe.prototype),on.prototype.constructor=on,sn.prototype=Object.create(ve.prototype),sn.prototype.constructor=sn,sn.prototype.toJSON=function(){var e=ve.prototype.toJSON.call(this);return hn(this.parameters.shapes,e)},cn.prototype=Object.create(Pe.prototype),cn.prototype.constructor=cn,cn.prototype.toJSON=function(){var e=Pe.prototype.toJSON.call(this);return hn(this.parameters.shapes,e)},ln.prototype=Object.create(Pe.prototype),ln.prototype.constructor=ln,un.prototype=Object.create(ve.prototype),un.prototype.constructor=un,dn.prototype=Object.create(Pe.prototype),dn.prototype.constructor=dn,pn.prototype=Object.create(un.prototype),pn.prototype.constructor=pn,fn.prototype=Object.create(dn.prototype),fn.prototype.constructor=fn,mn.prototype=Object.create(ve.prototype),mn.prototype.constructor=mn,vn.prototype=Object.create(Pe.prototype),vn.prototype.constructor=vn;var gn=Object.freeze({WireframeGeometry:nr,ParametricGeometry:ar,ParametricBufferGeometry:or,TetrahedronGeometry:hr,TetrahedronBufferGeometry:lr,OctahedronGeometry:ur,OctahedronBufferGeometry:dr,IcosahedronGeometry:pr,IcosahedronBufferGeometry:fr,DodecahedronGeometry:mr,DodecahedronBufferGeometry:vr,PolyhedronGeometry:sr,PolyhedronBufferGeometry:cr,TubeGeometry:gr,TubeBufferGeometry:yr,TorusKnotGeometry:Ar,TorusKnotBufferGeometry:xr,TorusGeometry:wr,TorusBufferGeometry:br,TextGeometry:Kr,TextBufferGeometry:$r,SphereGeometry:en,SphereBufferGeometry:tn,RingGeometry:rn,RingBufferGeometry:nn,PlaneGeometry:Ie,PlaneBufferGeometry:Oe,LatheGeometry:an,LatheBufferGeometry:on,ShapeGeometry:sn,ShapeBufferGeometry:cn,ExtrudeGeometry:qr,ExtrudeBufferGeometry:Qr,EdgesGeometry:ln,ConeGeometry:pn,ConeBufferGeometry:fn,CylinderGeometry:un,CylinderBufferGeometry:dn,CircleGeometry:mn,CircleBufferGeometry:vn,BoxGeometry:Ce,BoxBufferGeometry:De});function yn(e){ke.call(this),this.type=\"ShadowMaterial\",this.color=new Z(0),this.transparent=!0,this.setValues(e)}function An(e){We.call(this,e),this.type=\"RawShaderMaterial\"}function xn(e){ke.call(this),this.defines={STANDARD:\"\"},this.type=\"MeshStandardMaterial\",this.color=new Z(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new T(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=\"round\",this.wireframeLinejoin=\"round\",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function wn(e){xn.call(this),this.defines={PHYSICAL:\"\"},this.type=\"MeshPhysicalMaterial\",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function bn(e){ke.call(this),this.type=\"MeshPhongMaterial\",this.color=new Z(16777215),this.specular=new Z(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new T(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=\"round\",this.wireframeLinejoin=\"round\",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function _n(e){bn.call(this),this.defines={TOON:\"\"},this.type=\"MeshToonMaterial\",this.gradientMap=null,this.setValues(e)}function En(e){ke.call(this),this.type=\"MeshNormalMaterial\",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new T(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Mn(e){ke.call(this),this.type=\"MeshLambertMaterial\",this.color=new Z(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Z(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=\"round\",this.wireframeLinejoin=\"round\",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Tn(e){qi.call(this),this.type=\"LineDashedMaterial\",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}yn.prototype=Object.create(ke.prototype),yn.prototype.constructor=yn,yn.prototype.isShadowMaterial=!0,yn.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.color.copy(e.color),this},An.prototype=Object.create(We.prototype),An.prototype.constructor=An,An.prototype.isRawShaderMaterial=!0,xn.prototype=Object.create(ke.prototype),xn.prototype.constructor=xn,xn.prototype.isMeshStandardMaterial=!0,xn.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.defines={STANDARD:\"\"},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},wn.prototype=Object.create(xn.prototype),wn.prototype.constructor=wn,wn.prototype.isMeshPhysicalMaterial=!0,wn.prototype.copy=function(e){return xn.prototype.copy.call(this,e),this.defines={PHYSICAL:\"\"},this.reflectivity=e.reflectivity,this.clearCoat=e.clearCoat,this.clearCoatRoughness=e.clearCoatRoughness,this},bn.prototype=Object.create(ke.prototype),bn.prototype.constructor=bn,bn.prototype.isMeshPhongMaterial=!0,bn.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},_n.prototype=Object.create(bn.prototype),_n.prototype.constructor=_n,_n.prototype.isMeshToonMaterial=!0,_n.prototype.copy=function(e){return bn.prototype.copy.call(this,e),this.gradientMap=e.gradientMap,this},En.prototype=Object.create(ke.prototype),En.prototype.constructor=En,En.prototype.isMeshNormalMaterial=!0,En.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Mn.prototype=Object.create(ke.prototype),Mn.prototype.constructor=Mn,Mn.prototype.isMeshLambertMaterial=!0,Mn.prototype.copy=function(e){return ke.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Tn.prototype=Object.create(qi.prototype),Tn.prototype.constructor=Tn,Tn.prototype.isLineDashedMaterial=!0,Tn.prototype.copy=function(e){return qi.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var Sn=Object.freeze({ShadowMaterial:yn,SpriteMaterial:Hi,RawShaderMaterial:An,ShaderMaterial:We,PointsMaterial:Ki,MeshPhysicalMaterial:wn,MeshStandardMaterial:xn,MeshPhongMaterial:bn,MeshToonMaterial:_n,MeshNormalMaterial:En,MeshLambertMaterial:Mn,MeshDepthMaterial:Ti,MeshDistanceMaterial:Si,MeshBasicMaterial:je,LineDashedMaterial:Tn,LineBasicMaterial:qi,Material:ke}),Rn={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Ln(e,t,i){var r=this,n=!1,a=0,o=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){o++,!1===n&&void 0!==r.onStart&&r.onStart(e,a,o),n=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,o),a===o&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}var Pn=new Ln,Cn={};function Dn(e){this.manager=void 0!==e?e:Pn}function In(e){this.manager=void 0!==e?e:Pn}function On(e){this.manager=void 0!==e?e:Pn}function Nn(){this.type=\"Curve\",this.arcLengthDivisions=200}function Bn(e,t,i,r,n,a,o,s){Nn.call(this),this.type=\"EllipseCurve\",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=r||1,this.aStartAngle=n||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function Fn(e,t,i,r,n,a){Bn.call(this,e,t,i,i,r,n,a),this.type=\"ArcCurve\"}function Un(){var e=0,t=0,i=0,r=0;function n(n,a,o,s){e=n,t=o,i=-3*n+3*a-2*o-s,r=2*n-2*a+o+s}return{initCatmullRom:function(e,t,i,r,a){n(t,i,a*(i-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,i,r,a,o,s){var c=(t-e)/a-(i-e)/(a+o)+(i-t)/o,h=(i-t)/o-(r-t)/(o+s)+(r-i)/s;n(t,i,c*=o,h*=o)},calc:function(n){var a=n*n;return e+t*n+i*a+r*(a*n)}}}Object.assign(Dn.prototype,{load:function(e,t,i,r){void 0===e&&(e=\"\"),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,a=Rn.get(e);if(void 0!==a)return n.manager.itemStart(e),setTimeout((function(){t&&t(a),n.manager.itemEnd(e)}),0),a;if(void 0===Cn[e]){var o=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(o){var s=o[1],c=!!o[2],h=o[3];h=window.decodeURIComponent(h),c&&(h=window.atob(h));try{var l,u=(this.responseType||\"\").toLowerCase();switch(u){case\"arraybuffer\":case\"blob\":for(var d=new Uint8Array(h.length),p=0;p0||0===e.search(/^data\\:image\\/jpeg/);n.format=r?1022:1023,n.needsUpdate=!0,void 0!==t&&t(n)}),i,r),n},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Nn.prototype,{getPoint:function(){return console.warn(\"THREE.Curve: .getPoint() not implemented.\"),null},getPointAt:function(e,t){var i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,r=[],n=this.getPoint(0),a=0;for(r.push(0),i=1;i<=e;i++)a+=(t=this.getPoint(i/e)).distanceTo(n),r.push(a),n=t;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i,r=this.getLengths(),n=0,a=r.length;i=t||e*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[n=Math.floor(s+(c-s)/2)]-i)<0)s=n+1;else{if(!(o>0)){c=n;break}c=n-1}if(r[n=c]===i)return n/(a-1);var h=r[n];return(n+(i-h)/(r[n+1]-h))/(a-1)},getTangent:function(e){var t=e-1e-4,i=e+1e-4;t<0&&(t=0),i>1&&(i=1);var r=this.getPoint(t);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var i,r,n,a=new L,o=[],s=[],c=[],h=new L,l=new S;for(i=0;i<=e;i++)r=i/e,o[i]=this.getTangentAt(r),o[i].normalize();s[0]=new L,c[0]=new L;var u=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=u&&(u=d,a.set(1,0,0)),p<=u&&(u=p,a.set(0,1,0)),f<=u&&a.set(0,0,1),h.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],h),c[0].crossVectors(o[0],s[0]),i=1;i<=e;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),h.crossVectors(o[i-1],o[i]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(M.clamp(o[i-1].dot(o[i]),-1,1)),s[i].applyMatrix4(l.makeRotationAxis(h,n))),c[i].crossVectors(o[i],s[i]);if(!0===t)for(n=Math.acos(M.clamp(s[0].dot(s[e]),-1,1)),n/=e,o[0].dot(h.crossVectors(s[0],s[e]))>0&&(n=-n),i=1;i<=e;i++)s[i].applyMatrix4(l.makeRotationAxis(o[i],n*i)),c[i].crossVectors(o[i],s[i]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:\"Curve\",generator:\"Curve.toJSON\"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),Bn.prototype=Object.create(Nn.prototype),Bn.prototype.constructor=Bn,Bn.prototype.isEllipseCurve=!0,Bn.prototype.getPoint=function(e,t){for(var i=t||new T,r=2*Math.PI,n=this.aEndAngle-this.aStartAngle,a=Math.abs(n)r;)n-=r;n0?0:(Math.floor(Math.abs(l)/c)+1)*c:0===u&&l===c-1&&(l=c-2,u=1),this.closed||l>0?i=s[(l-1)%c]:(zn.subVectors(s[0],s[1]).add(s[0]),i=zn),r=s[l%c],n=s[(l+1)%c],this.closed||l+2r.length-2?r.length-1:a+1],l=r[a>r.length-3?r.length-1:a+2];return i.set(jn(o,s.x,c.x,h.x,l.x),jn(o,s.y,c.y,h.y,l.y)),i},$n.prototype.copy=function(e){Nn.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t=t){var n=i[r]-t,a=this.curves[r],o=a.getLength(),s=0===o?0:1-n/o;return a.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,r=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(e){Nn.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;t0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(e){return ta.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=ta.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return ta.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),ra.prototype=Object.assign(Object.create(ia.prototype),{constructor:ra,getPointsHoles:function(e){for(var t=[],i=0,r=this.holes.length;i=n)break e;var s=t[1];e=(n=t[--i-1]))break t}a=i,i=0}for(;i>>1;et;)--a;if(++a,0!==n||a!==r){n>=a&&(n=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Ea.arraySlice(i,n,a),this.values=Ea.arraySlice(this.values,n*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error(\"THREE.KeyframeTrack: Invalid value size in track.\",this),e=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error(\"THREE.KeyframeTrack: Track is empty.\",this),e=!1);for(var a=null,o=0;o!==n;o++){var s=i[o];if(\"number\"==typeof s&&isNaN(s)){console.error(\"THREE.KeyframeTrack: Time is not a valid number.\",this,o,s),e=!1;break}if(null!==a&&a>s){console.error(\"THREE.KeyframeTrack: Out of order keys.\",this,o,s,a),e=!1;break}a=s}if(void 0!==r&&Ea.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var h=r[o];if(isNaN(h)){console.error(\"THREE.KeyframeTrack: Value is not a valid number.\",this,o,h),e=!1;break}}}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,a=e.length-1,o=1;o0){e[n]=e[a];for(f=a*i,m=n*i,d=0;d!==i;++d)t[m+d]=t[f+d];++n}return n!==e.length&&(this.times=Ea.arraySlice(e,0,n),this.values=Ea.arraySlice(t,0,n*i)),this}}),Ta.prototype=Object.assign(Object.create(Ma.prototype),{constructor:Ta,ValueTypeName:\"vector\"}),Object.assign(Sa,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),n=0,a=i.length;n!==a;++n)t.push(Ma.parse(i[n]).scale(r));return new Sa(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},n=0,a=i.length;n!==a;++n)t.push(Ma.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(e,t,i,r){for(var n=t.length,a=[],o=0;o1){var h=r[u=c[1]];h||(r[u]=h=[]),h.push(s)}}var l=[];for(var u in r)l.push(Sa.CreateFromMorphTargetSequence(u,r[u],t,i));return l},parseAnimation:function(e,t){if(!e)return console.error(\"THREE.AnimationClip: No animation in JSONLoader data.\"),null;for(var i=function(e,t,i,r,n){if(0!==i.length){var a=[],o=[];Ea.flattenJSON(i,a,o,r),0!==a.length&&n.push(new e(t,a,o))}},r=[],n=e.name||\"default\",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],c=0;c1?e.skinWeights[r+1]:0,s=i>2?e.skinWeights[r+2]:0,c=i>3?e.skinWeights[r+3]:0;t.skinWeights.push(new U(a,o,s,c))}if(e.skinIndices)for(r=0,n=e.skinIndices.length;r1?e.skinIndices[r+1]:0,u=i>2?e.skinIndices[r+2]:0,d=i>3?e.skinIndices[r+3]:0;t.skinIndices.push(new U(h,l,u,d))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn(\"When skinning, number of vertices (\"+t.vertices.length+\"), skinIndices (\"+t.skinIndices.length+\"), and skinWeights (\"+t.skinWeights.length+\") should match.\")}(e,i),function(e,t){var i=e.scale;if(void 0!==e.morphTargets)for(var r=0,n=e.morphTargets.length;r0){console.warn('THREE.JSONLoader: \"morphColors\" no longer supported. Using them as face colors.');var l=t.faces,u=e.morphColors[0].colors;for(r=0,n=l.length;r0&&(t.animations=i)}(e,i),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===e.materials||0===e.materials.length?{geometry:i}:{geometry:i,materials:Na.prototype.initMaterials(e.materials,t,this.crossOrigin)}}}),Object.assign(function(e){this.manager=void 0!==e?e:Pn,this.texturePath=\"\"}.prototype,{load:function(e,t,i,r){\"\"===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf(\"/\")+1));var n=this;new Dn(n.manager).load(e,(function(i){var a=null;try{a=JSON.parse(i)}catch(t){return void 0!==r&&r(t),void console.error(\"THREE:ObjectLoader: Can't parse \"+e+\".\",t.message)}var o=a.metadata;void 0!==o&&void 0!==o.type&&\"geometry\"!==o.type.toLowerCase()?n.parse(a,t):console.error(\"THREE.ObjectLoader: Can't load \"+e+\". Use THREE.JSONLoader instead.\")}),i,r)},setTexturePath:function(e){return this.texturePath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){var i=this.parseShape(e.shapes),r=this.parseGeometries(e.geometries,i),n=this.parseImages(e.images,(function(){void 0!==t&&t(s)})),a=this.parseTextures(e.textures,n),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,r,o);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var i=0,r=e.length;i0){var a=new In(new Ln(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0?new Yi(o,s):new Qe(o,s);break;case\"LOD\":r=new ji;break;case\"Line\":r=new Qi(n(e.geometry),a(e.material),e.mode);break;case\"LineLoop\":r=new Ji(n(e.geometry),a(e.material));break;case\"LineSegments\":r=new Zi(n(e.geometry),a(e.material));break;case\"PointCloud\":case\"Points\":r=new $i(n(e.geometry),a(e.material));break;case\"Sprite\":r=new ki(a(e.material));break;case\"Group\":r=new er;break;default:r=new he}if(r.uuid=e.uuid,void 0!==e.name&&(r.name=e.name),void 0!==e.matrix?(r.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(r.matrixAutoUpdate=e.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==e.position&&r.position.fromArray(e.position),void 0!==e.rotation&&r.rotation.fromArray(e.rotation),void 0!==e.quaternion&&r.quaternion.fromArray(e.quaternion),void 0!==e.scale&&r.scale.fromArray(e.scale)),void 0!==e.castShadow&&(r.castShadow=e.castShadow),void 0!==e.receiveShadow&&(r.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(r.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(r.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&r.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(r.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.frustumCulled&&(r.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(r.renderOrder=e.renderOrder),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.children)for(var c=e.children,h=0;hNumber.EPSILON){if(h<0&&(o=t[a],c=-c,s=t[n],h=-h),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var l=h*(e.x-o.x)-c*(e.y-o.y);if(0===l)return!0;if(l<0)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return r}var n=Wr.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return i(a);var o,s,c,h=[];if(1===a.length)return s=a[0],(c=new ra).curves=s.curves,h.push(c),h;var l=!n(a[0].getPoints());l=e?!l:l;var u,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var A=!1,x=[],w=0,b=f.length;w0&&(A||(m=p))}g=0;for(var R=f.length;g0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var a=0;a!==n;++a)e[t+a]=e[i+a]},_slerp:function(e,t,i,r){R.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var a=1-r,o=0;o!==n;++o){var s=t+o;e[s]=e[s]*a+e[i+o]*r}}});var ho,lo,uo,po,fo,mo,vo,go,yo,Ao,xo,wo;function bo(e,t,i){var r=i||_o.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}function _o(e,t,i){this.path=t,this.parsedPath=i||_o.parseTrackName(t),this.node=_o.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Eo(e,t,i){this._mixer=e,this._clip=t,this._localRoot=i||null;for(var r=t.tracks,n=r.length,a=new Array(n),o={endingStart:2400,endingEnd:2400},s=0;s!==n;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Mo(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function To(e){\"string\"==typeof e&&(console.warn(\"THREE.Uniform: Type parameter is no longer needed.\"),e=arguments[1]),this.value=e}function So(){Pe.call(this),this.type=\"InstancedBufferGeometry\",this.maxInstancedCount=void 0}function Ro(e,t,i,r){this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===r}function Lo(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Po(e,t,i){Lo.call(this,e,t),this.meshPerAttribute=i||1}function Co(e,t,i){ge.call(this,e,t),this.meshPerAttribute=i||1}function Do(e,t){return e.distance-t.distance}function Io(e,t,i,r){if(!1!==e.visible&&(e.raycast(t,i),!0===r))for(var n=e.children,a=0,o=n.length;a=t){var l=t++,u=e[l];i[u.uuid]=h,e[h]=u,i[c]=l,e[l]=s;for(var d=0,p=n;d!==p;++d){var f=r[d],m=f[l],v=f[h];f[h]=m,f[l]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,a=n.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],h=c.uuid,l=r[h];if(void 0!==l)if(delete r[h],l0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(o),h[l].accumulate(r,s)}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:\"finished\",action:this,direction:e<0?-1:1})}}else{var a=2202===r;if(-1===n&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=i||t<0){var o=Math.floor(t/i);t-=i*o,n+=Math.abs(o);var s=this.repetitions-n;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this._mixer.dispatchEvent({type:\"finished\",action:this,direction:e>0?1:-1});else{if(1===s){var c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this._mixer.dispatchEvent({type:\"loop\",action:this,loopDelta:o})}}if(a&&1==(1&n))return this.time=t,i-t}return this.time=t,t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=e?this.zeroSlopeAtStart?2401:2400:2402,r.endingEnd=t?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=n,s[0]=t,o[1]=n+e,s[1]=i,this}}),Mo.prototype=Object.assign(Object.create(l.prototype),{constructor:Mo,_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,a=e._propertyBindings,o=e._interpolants,s=i.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==n;++l){var u=r[l],d=u.name,p=h[d];if(void 0!==p)a[l]=p;else{if(void 0!==(p=a[l])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=t&&t._propertyBindings[l].binding.parsedPath;++(p=new co(_o.create(i,d,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[l]=p}o[l].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,a=0,o=n.length;a!==o;++a){var s=n[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn(\"THREE.Box2: .getParameter() target is now required\"),t=new T),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn(\"THREE.Box2: .clampPoint() target is now required\"),t=new T),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new T;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Bo.prototype=Object.create(he.prototype),Bo.prototype.constructor=Bo,Bo.prototype.isImmediateRenderObject=!0,Fo.prototype=Object.create(Zi.prototype),Fo.prototype.constructor=Fo,Fo.prototype.update=function(){var e=new L,t=new L,i=new P;return function(){var r=[\"a\",\"b\",\"c\"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var n=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,c=o.faces,h=0,l=0,u=c.length;l.99999?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(wo.set(e.z,0,-e.x).normalize(),xo=Math.acos(e.y),this.quaternion.setFromAxisAngle(wo,xo))}),Jo.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},Jo.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},Ko.prototype=Object.create(Zi.prototype),Ko.prototype.constructor=Ko,Nn.create=function(e,t){return console.log(\"THREE.Curve.create() has been deprecated\"),e.prototype=Object.create(Nn.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(ta.prototype,{createPointsGeometry:function(e){console.warn(\"THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.\");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn(\"THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.\");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn(\"THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.\");for(var t=new ve,i=0,r=e.length;i0?i=e[0]:t&&t(\"VR input not available.\")})).catch((function(){console.warn(\"VRControls: Unable to get VR Displays\")})),this.scale=1,this.standing=!1,this.userHeight=1.6,this.getVRDisplay=function(){return i},this.setVRDisplay=function(e){i=e},this.getVRDisplays=function(){return console.warn(\"VRControls: getVRDisplays() is being deprecated.\"),r},this.getStandingMatrix=function(){return a},this.update=function(){var t;i&&(i.getFrameData?(i.getFrameData(o),t=o.pose):i.getPose&&(t=i.getPose()),null!==t.orientation&&e.quaternion.fromArray(t.orientation),null!==t.position?e.position.fromArray(t.position):e.position.set(0,0,0),this.standing&&(i.stageParameters?(e.updateMatrix(),a.fromArray(i.stageParameters.sittingToStandingTransform),e.applyMatrix(a)):e.position.setY(e.position.y+this.userHeight)),e.position.multiplyScalar(n.scale))},this.dispose=function(){i=null}},ts=function(e,t){var i,r,n,a,o=new L,s=new L,c=new S,h=new S,l=new S,u=null;\"VRFrameData\"in window&&(u=new window.VRFrameData),navigator.getVRDisplays&&navigator.getVRDisplays().then((function(e){r=e,e.length>0?i=e[0]:t&&t(\"HMD not available\")})).catch((function(){console.warn(\"VREffect: Unable to get VR Displays\")})),this.isPresenting=!1;var d=this,p=e.getSize(),f=!1,m=e.getPixelRatio();this.getVRDisplay=function(){return i},this.setVRDisplay=function(e){i=e},this.getVRDisplays=function(){return console.warn(\"VREffect: getVRDisplays() is being deprecated.\"),r},this.setSize=function(t,r,n){if(p={width:t,height:r},f=n,d.isPresenting){var a=i.getEyeParameters(\"left\");e.setPixelRatio(1),e.setSize(2*a.renderWidth,a.renderHeight,!1)}else e.setPixelRatio(m),e.setSize(t,r,n)};var v=e.domElement,g=[0,0,.5,1],y=[.5,0,.5,1];function A(){var t=d.isPresenting;if(d.isPresenting=void 0!==i&&i.isPresenting,d.isPresenting){var r=i.getEyeParameters(\"left\"),n=r.renderWidth,a=r.renderHeight;t||(m=e.getPixelRatio(),p=e.getSize(),e.setPixelRatio(1),e.setSize(2*n,a,!1))}else t&&(e.setPixelRatio(m),e.setSize(p.width,p.height,f))}window.addEventListener(\"vrdisplaypresentchange\",A,!1),this.setFullScreen=function(e){return new Promise((function(t,r){void 0!==i?d.isPresenting!==e?t(e?i.requestPresent([{source:v}]):i.exitPresent()):t():r(new Error(\"No VR hardware found.\"))}))},this.requestPresent=function(){return this.setFullScreen(!0)},this.exitPresent=function(){return this.setFullScreen(!1)},this.requestAnimationFrame=function(e){return void 0!==i?i.requestAnimationFrame(e):window.requestAnimationFrame(e)},this.cancelAnimationFrame=function(e){void 0!==i?i.cancelAnimationFrame(e):window.cancelAnimationFrame(e)},this.submitFrame=function(){void 0!==i&&d.isPresenting&&i.submitFrame()},this.autoSubmitFrame=!0;var x=new Oi;x.layers.enable(1);var w=new Oi;w.layers.enable(2),this.render=function(t,r,p,f){if(i&&d.isPresenting){var m=t.autoUpdate;m&&(t.updateMatrixWorld(),t.autoUpdate=!1),Array.isArray(t)&&(console.warn(\"VREffect.render() no longer supports arrays. Use object.layers instead.\"),t=t[0]);var v,A,M=e.getSize(),T=i.getLayers();if(T.length){var S=T[0];v=null!==S.leftBounds&&4===S.leftBounds.length?S.leftBounds:g,A=null!==S.rightBounds&&4===S.rightBounds.length?S.rightBounds:y}else v=g,A=y;if(n={x:Math.round(M.width*v[0]),y:Math.round(M.height*v[1]),width:Math.round(M.width*v[2]),height:Math.round(M.height*v[3])},a={x:Math.round(M.width*A[0]),y:Math.round(M.height*A[1]),width:Math.round(M.width*A[2]),height:Math.round(M.height*A[3])},p?(e.setRenderTarget(p),p.scissorTest=!0):(e.setRenderTarget(null),e.setScissorTest(!0)),(e.autoClear||f)&&e.clear(),null===r.parent&&r.updateMatrixWorld(),r.matrixWorld.decompose(x.position,x.quaternion,x.scale),w.position.copy(x.position),w.quaternion.copy(x.quaternion),w.scale.copy(x.scale),i.getFrameData)i.depthNear=r.near,i.depthFar=r.far,i.getFrameData(u),x.projectionMatrix.elements=u.leftProjectionMatrix,w.projectionMatrix.elements=u.rightProjectionMatrix,function(e){e.pose.orientation?(b.fromArray(e.pose.orientation),c.makeRotationFromQuaternion(b)):c.identity();e.pose.position&&(_.fromArray(e.pose.position),c.setPosition(_));h.fromArray(e.leftViewMatrix),h.multiply(c),l.fromArray(e.rightViewMatrix),l.multiply(c),h.getInverse(h),l.getInverse(l)}(u),x.updateMatrix(),x.matrix.multiply(h),x.matrix.decompose(x.position,x.quaternion,x.scale),w.updateMatrix(),w.matrix.multiply(l),w.matrix.decompose(w.position,w.quaternion,w.scale);else{var R=i.getEyeParameters(\"left\"),L=i.getEyeParameters(\"right\");x.projectionMatrix=E(R.fieldOfView,!0,r.near,r.far),w.projectionMatrix=E(L.fieldOfView,!0,r.near,r.far),o.fromArray(R.offset),s.fromArray(L.offset),x.translateOnAxis(o,x.scale.x),w.translateOnAxis(s,w.scale.x)}return p?(p.viewport.set(n.x,n.y,n.width,n.height),p.scissor.set(n.x,n.y,n.width,n.height)):(e.setViewport(n.x,n.y,n.width,n.height),e.setScissor(n.x,n.y,n.width,n.height)),e.render(t,x,p,f),p?(p.viewport.set(a.x,a.y,a.width,a.height),p.scissor.set(a.x,a.y,a.width,a.height)):(e.setViewport(a.x,a.y,a.width,a.height),e.setScissor(a.x,a.y,a.width,a.height)),e.render(t,w,p,f),p?(p.viewport.set(0,0,M.width,M.height),p.scissor.set(0,0,M.width,M.height),p.scissorTest=!1,e.setRenderTarget(null)):(e.setViewport(0,0,M.width,M.height),e.setScissorTest(!1)),m&&(t.autoUpdate=!0),void(d.autoSubmitFrame&&d.submitFrame())}e.render(t,r,p,f)},this.dispose=function(){window.removeEventListener(\"vrdisplaypresentchange\",A,!1)};var b=new R,_=new L;function E(e,t,i,r){var n=Math.PI/180;return function(e,t,i,r){i=void 0===i?.01:i,r=void 0===r?1e4:r;var n=(t=void 0===t||t)?-1:1,a=new S,o=a.elements,s=function(e){var t=2/(e.leftTan+e.rightTan),i=(e.leftTan-e.rightTan)*t*.5,r=2/(e.upTan+e.downTan);return{scale:[t,r],offset:[i,(e.upTan-e.downTan)*r*.5]}}(e);return o[0]=s.scale[0],o[1]=0,o[2]=s.offset[0]*n,o[3]=0,o[4]=0,o[5]=s.scale[1],o[6]=-s.offset[1]*n,o[7]=0,o[8]=0,o[9]=0,o[10]=r/(i-r)*-n,o[11]=r*i/(i-r),o[12]=0,o[13]=0,o[14]=n,o[15]=0,a.transpose(),a}({upTan:Math.tan(e.upDegrees*n),downTan:Math.tan(e.downDegrees*n),leftTan:Math.tan(e.leftDegrees*n),rightTan:Math.tan(e.rightDegrees*n)},t,i,r)}},is=function(e,t){this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new L,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:b,ZOOM:_,PAN:E},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return h.phi},this.getAzimuthalAngle=function(){return h.theta},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(r),i.update(),s=o.NONE},this.update=function(){var t=new L,n=(new R).setFromUnitVectors(e.up,new L(0,1,0)),a=n.clone().inverse(),f=new L,m=new R;return function(){var e=i.object.position;return t.copy(e).sub(i.target),t.applyQuaternion(n),h.setFromVector3(t),i.autoRotate&&s===o.NONE&&i.rotateLeft(2*Math.PI/60/60*i.autoRotateSpeed),h.theta+=l.theta,h.phi+=l.phi,h.theta=Math.max(i.minAzimuthAngle,Math.min(i.maxAzimuthAngle,h.theta)),h.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,h.phi)),h.makeSafe(),h.radius*=u,h.radius=Math.max(i.minDistance,Math.min(i.maxDistance,h.radius)),i.target.add(d),t.setFromSpherical(h),t.applyQuaternion(a),e.copy(i.target).add(t),i.object.lookAt(i.target),!0===i.enableDamping?(l.theta*=1-i.dampingFactor,l.phi*=1-i.dampingFactor,d.multiplyScalar(1-i.dampingFactor)):(l.set(0,0,0),d.set(0,0,0)),u=1,!!(p||f.distanceToSquared(i.object.position)>c||8*(1-m.dot(i.object.quaternion))>c)&&(i.dispatchEvent(r),f.copy(i.object.position),m.copy(i.object.quaternion),p=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener(\"contextmenu\",k,!1),i.domElement.removeEventListener(\"mousedown\",N,!1),i.domElement.removeEventListener(\"wheel\",U,!1),i.domElement.removeEventListener(\"touchstart\",G,!1),i.domElement.removeEventListener(\"touchend\",H,!1),i.domElement.removeEventListener(\"touchmove\",V,!1),document.removeEventListener(\"mousemove\",B,!1),document.removeEventListener(\"mouseup\",F,!1),window.removeEventListener(\"keydown\",z,!1)};var i=this,r={type:\"change\"},n={type:\"start\"},a={type:\"end\"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},s=o.NONE,c=1e-6,h=new Oo,l=new Oo,u=1,d=new L,p=!1,f=new T,m=new T,v=new T,g=new T,y=new T,A=new T,x=new T,w=new T,M=new T;function S(){return Math.pow(.95,i.zoomSpeed)}i.rotateLeft=function(e){l.theta-=e},i.rotateUp=function(e){l.phi-=e};var P=function(){var e=new L;return function(t,i){e.setFromMatrixColumn(i,0),e.multiplyScalar(-t),d.add(e)}}(),C=function(){var e=new L;return function(t,r){!0===i.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(i.object.up,e)),e.multiplyScalar(t),d.add(e)}}(),D=function(){var e=new L;return function(t,r){var n=i.domElement===document?i.domElement.body:i.domElement;if(i.object.isPerspectiveCamera){var a=i.object.position;e.copy(a).sub(i.target);var o=e.length();o*=Math.tan(i.object.fov/2*Math.PI/180),P(2*t*o/n.clientHeight,i.object.matrix),C(2*r*o/n.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(P(t*(i.object.right-i.object.left)/i.object.zoom/n.clientWidth,i.object.matrix),C(r*(i.object.top-i.object.bottom)/i.object.zoom/n.clientHeight,i.object.matrix)):(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.\"),i.enablePan=!1)}}();function I(e){i.object.isPerspectiveCamera?u/=e:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*e)),i.object.updateProjectionMatrix(),p=!0):(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.\"),i.enableZoom=!1)}function O(e){i.object.isPerspectiveCamera?u*=e:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/e)),i.object.updateProjectionMatrix(),p=!0):(console.warn(\"WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.\"),i.enableZoom=!1)}function N(e){if(!1!==i.enabled){switch(e.preventDefault(),e.button){case i.mouseButtons.ORBIT:if(!1===i.enableRotate)return;!function(e){f.set(e.clientX,e.clientY)}(e),s=o.ROTATE;break;case i.mouseButtons.ZOOM:if(!1===i.enableZoom)return;!function(e){x.set(e.clientX,e.clientY)}(e),s=o.DOLLY;break;case i.mouseButtons.PAN:if(!1===i.enablePan)return;!function(e){g.set(e.clientX,e.clientY)}(e),s=o.PAN}s!==o.NONE&&(document.addEventListener(\"mousemove\",B,!1),document.addEventListener(\"mouseup\",F,!1),i.dispatchEvent(n))}}function B(e){if(!1!==i.enabled)switch(e.preventDefault(),s){case o.ROTATE:if(!1===i.enableRotate)return;!function(e){m.set(e.clientX,e.clientY),v.subVectors(m,f).multiplyScalar(i.rotateSpeed);var t=i.domElement===document?i.domElement.body:i.domElement;i.rotateLeft(2*Math.PI*v.x/t.clientHeight),i.rotateUp(2*Math.PI*v.y/t.clientHeight),f.copy(m),i.update()}(e);break;case o.DOLLY:if(!1===i.enableZoom)return;!function(e){w.set(e.clientX,e.clientY),M.subVectors(w,x),M.y>0?I(S()):M.y<0&&O(S()),x.copy(w),i.update()}(e);break;case o.PAN:if(!1===i.enablePan)return;!function(e){y.set(e.clientX,e.clientY),A.subVectors(y,g).multiplyScalar(i.panSpeed),D(A.x,A.y),g.copy(y),i.update()}(e)}}function F(e){!1!==i.enabled&&(document.removeEventListener(\"mousemove\",B,!1),document.removeEventListener(\"mouseup\",F,!1),i.dispatchEvent(a),s=o.NONE)}function U(e){!1===i.enabled||!1===i.enableZoom||s!==o.NONE&&s!==o.ROTATE||(e.preventDefault(),e.stopPropagation(),i.dispatchEvent(n),function(e){e.deltaY<0?O(S()):e.deltaY>0&&I(S()),i.update()}(e),i.dispatchEvent(a))}function z(e){!1!==i.enabled&&!1!==i.enableKeys&&!1!==i.enablePan&&function(e){switch(e.keyCode){case i.keys.UP:D(0,i.keyPanSpeed),i.update();break;case i.keys.BOTTOM:D(0,-i.keyPanSpeed),i.update();break;case i.keys.LEFT:D(i.keyPanSpeed,0),i.update();break;case i.keys.RIGHT:D(-i.keyPanSpeed,0),i.update()}}(e)}function G(e){if(!1!==i.enabled){switch(e.preventDefault(),e.touches.length){case 1:if(!1===i.enableRotate)return;!function(e){f.set(e.touches[0].pageX,e.touches[0].pageY)}(e),s=o.TOUCH_ROTATE;break;case 2:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(e){if(i.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(t*t+r*r);x.set(0,n)}if(i.enablePan){var a=.5*(e.touches[0].pageX+e.touches[1].pageX),o=.5*(e.touches[0].pageY+e.touches[1].pageY);g.set(a,o)}}(e),s=o.TOUCH_DOLLY_PAN;break;default:s=o.NONE}s!==o.NONE&&i.dispatchEvent(n)}}function V(e){if(!1!==i.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===i.enableRotate)return;if(s!==o.TOUCH_ROTATE)return;!function(e){m.set(e.touches[0].pageX,e.touches[0].pageY),v.subVectors(m,f).multiplyScalar(i.rotateSpeed);var t=i.domElement===document?i.domElement.body:i.domElement;i.rotateLeft(2*Math.PI*v.x/t.clientHeight),i.rotateUp(2*Math.PI*v.y/t.clientHeight),f.copy(m),i.update()}(e);break;case 2:if(!1===i.enableZoom&&!1===i.enablePan)return;if(s!==o.TOUCH_DOLLY_PAN)return;!function(e){if(i.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(t*t+r*r);w.set(0,n),M.set(0,Math.pow(w.y/x.y,i.zoomSpeed)),I(M.y),x.copy(w)}if(i.enablePan){var a=.5*(e.touches[0].pageX+e.touches[1].pageX),o=.5*(e.touches[0].pageY+e.touches[1].pageY);y.set(a,o),A.subVectors(y,g).multiplyScalar(i.panSpeed),D(A.x,A.y),g.copy(y)}i.update()}(e);break;default:s=o.NONE}}function H(e){!1!==i.enabled&&(i.dispatchEvent(a),s=o.NONE)}function k(e){!1!==i.enabled&&e.preventDefault()}i.domElement.addEventListener(\"mousedown\",N,!1),i.domElement.addEventListener(\"wheel\",U,!1),i.domElement.addEventListener(\"touchstart\",G,!1),i.domElement.addEventListener(\"touchend\",H,!1),i.domElement.addEventListener(\"touchmove\",V,!1),window.addEventListener(\"keydown\",z,!1),this.update()};(is.prototype=Object.create(l.prototype)).constructor=is,Object.defineProperties(is.prototype,{center:{get:function(){return console.warn(\"OrbitControls: .center has been renamed to .target\"),this.target}},noZoom:{get:function(){return console.warn(\"OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.\"),!this.enableZoom},set:function(e){console.warn(\"OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.\"),this.enableZoom=!e}},noRotate:{get:function(){return console.warn(\"OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.\"),!this.enableRotate},set:function(e){console.warn(\"OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.\"),this.enableRotate=!e}},noPan:{get:function(){return console.warn(\"OrbitControls: .noPan has been deprecated. Use .enablePan instead.\"),!this.enablePan},set:function(e){console.warn(\"OrbitControls: .noPan has been deprecated. Use .enablePan instead.\"),this.enablePan=!e}},noKeys:{get:function(){return console.warn(\"OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.\"),!this.enableKeys},set:function(e){console.warn(\"OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.\"),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn(\"OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.\"),!this.enableDamping},set:function(e){console.warn(\"OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.\"),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn(\"OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.\"),this.dampingFactor},set:function(e){console.warn(\"OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.\"),this.dampingFactor=e}}});var rs=function(e){var t=this;this.object=e,this.object.rotation.reorder(\"YXZ\"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;var i=function(e){t.deviceOrientation=e},r=function(){t.screenOrientation=window.orientation||0},n=function(){var e=new L(0,0,1),t=new ie,i=new R,r=new R(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(n,a,o,s,c){t.set(o,a,-s,\"YXZ\"),n.setFromEuler(t),n.multiply(r),n.multiply(i.setFromAxisAngle(e,-c))}}();this.connect=function(){r(),window.addEventListener(\"orientationchange\",r,!1),window.addEventListener(\"deviceorientation\",i,!1),t.enabled=!0},this.disconnect=function(){window.removeEventListener(\"orientationchange\",r,!1),window.removeEventListener(\"deviceorientation\",i,!1),t.enabled=!1},this.update=function(){if(!1!==t.enabled){var e=t.deviceOrientation;if(e){var i=e.alpha?M.degToRad(e.alpha)+t.alphaOffset:0,r=e.beta?M.degToRad(e.beta):0,a=e.gamma?M.degToRad(e.gamma):0,o=t.screenOrientation?M.degToRad(t.screenOrientation):0;n(t.object.quaternion,i,r,a,o)}}},this.dispose=function(){t.disconnect()},this.connect()};var ns,as=function(){function e(e){this.object=e.camera,this.domElement=e.canvas,this.orbit=new is(this.object,this.domElement),this.speed=.5,this.orbit.target.set(0,0,-1),this.orbit.enableZoom=!1,this.orbit.enablePan=!1,this.orbit.rotateSpeed=-this.speed,e.orientation&&(this.orientation=new rs(this.object)),e.halfView&&(this.orbit.minAzimuthAngle=-Math.PI/4,this.orbit.maxAzimuthAngle=Math.PI/4)}var t=e.prototype;return t.update=function(){if(this.orientation){this.orientation.update();var e=this.orientation.object.quaternion,t=function(e,t,i,r){var n=e*t+i*r;if(n>.499){var a=2*Math.atan2(e,r);return new L(Math.PI/2,0,a)}if(n<-.499){var o=-2*Math.atan2(e,r);return new L(-Math.PI/2,0,o)}var s=e*e,c=t*t,h=i*i,l=Math.atan2(2*t*r-2*e*i,1-2*c-2*h);return new L(Math.asin(2*n),Math.atan2(2*e*r-2*t*i,1-2*s-2*h),l)}(e.x,e.y,e.z,e.w);void 0===this.lastAngle_&&(this.lastAngle_=t),this.orbit.rotateLeft((this.lastAngle_.z-t.z)*(1+this.speed)),this.orbit.rotateUp((this.lastAngle_.y-t.y)*(1+this.speed)),this.lastAngle_=t}this.orbit.update()},t.dispose=function(){this.orbit.dispose(),this.orientation&&this.orientation.dispose()},e}(),os=((ns=t.createElement(\"video\")).crossOrigin=\"anonymous\",ns.hasAttribute(\"crossorigin\")),ss=[\"360\",\"360_LR\",\"360_TB\",\"360_CUBE\",\"EAC\",\"EAC_LR\",\"NONE\",\"AUTO\",\"Sphere\",\"Cube\",\"equirectangular\",\"180\",\"180_LR\",\"180_MONO\"],cs=function(e){if(e){if(e=e.toString().trim(),/sphere/i.test(e))return\"360\";if(/cube/i.test(e))return\"360_CUBE\";if(/equirectangular/i.test(e))return\"360\";for(var t=0;t=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}function fs(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);ihttp://webvr.info for more info.\"},\"web-vr-not-supported\":{headline:\"360 not supported on this device\",type:\"360_NOT_SUPPORTED\",message:\"Your browser does not support 360. See http://webvr.info for assistance.\"},\"web-vr-hls-cors-not-supported\":{headline:\"360 HLS video not supported on this device\",type:\"360_NOT_SUPPORTED\",message:\"Your browser/device does not support HLS 360 video. See http://webvr.info for assistance.\"}},gs=i.getPlugin(\"plugin\"),ys=i.getComponent(\"Component\"),As=function(r){function n(e,t){var n,a=i.mergeOptions(ms,t);return(n=r.call(this,e,a)||this).options_=a,n.player_=e,n.bigPlayButtonIndex_=e.children().indexOf(e.getChild(\"BigPlayButton\"))||0,n.videojsErrorsSupport_=!!i.errors,n.videojsErrorsSupport_&&e.errors({errors:vs}),i.browser.IE_VERSION||!os?(n.player_.on(\"loadstart\",(function(){n.triggerError_({code:\"web-vr-not-supported\",dismiss:!1})})),o(n)):(n.polyfill_=new h({ROTATE_INSTRUCTIONS_DISABLED:!0}),n.polyfill_=new h,n.handleVrDisplayActivate_=i.bind(o(n),n.handleVrDisplayActivate_),n.handleVrDisplayDeactivate_=i.bind(o(n),n.handleVrDisplayDeactivate_),n.handleResize_=i.bind(o(n),n.handleResize_),n.animate_=i.bind(o(n),n.animate_),n.setProjection(n.options_.projection),n.on(e,\"adstart\",(function(){return e.setTimeout((function(){e.ads&&e.ads.videoElementRecycled()?(n.log(\"video element recycled for this ad, reseting\"),n.reset(),n.one(e,\"playing\",n.init)):n.log(\"video element not recycled for this ad, no need to reset\")}))}),1),n.on(e,\"loadedmetadata\",n.init),n)}c(n,r);var a=n.prototype;return a.changeProjection_=function(e){var t=this;(e=cs(e))||(e=\"NONE\");var i=0,r=0,n=0;if(this.scene&&this.scene.remove(this.movieScreen),\"AUTO\"===e){if(this.player_.mediainfo&&this.player_.mediainfo.projection&&\"AUTO\"!==this.player_.mediainfo.projection){var a=cs(this.player_.mediainfo.projection);return this.changeProjection_(a)}return this.changeProjection_(\"NONE\")}if(\"360\"===e)this.movieGeometry=new tn(256,this.options_.sphereDetail,this.options_.sphereDetail),this.movieMaterial=new je({map:this.videoTexture,overdraw:!0,side:1}),this.movieScreen=new Qe(this.movieGeometry,this.movieMaterial),this.movieScreen.position.set(i,r,n),this.movieScreen.scale.x=-1,this.movieScreen.quaternion.setFromAxisAngle({x:0,y:1,z:0},-Math.PI/2),this.scene.add(this.movieScreen);else if(\"360_LR\"===e||\"360_TB\"===e){for(var o=new en(256,this.options_.sphereDetail,this.options_.sphereDetail),s=o.faceVertexUvs[0],c=0;cy&&(y=x.y)}for(var w,b=ps(m);!(w=b()).done;){var _=w.value;Math.abs(_.y-g)0&&(t.log(\"Displays found\",e),t.vrDisplay=e[0],t.vrDisplay.isPolyfilled||(t.log(\"Real HMD found using VRControls\",t.vrDisplay),t.addCardboardButton_(),t.controls3d=new es(t.camera))),!t.controls3d){t.log(\"no HMD found Using Orbit & Orientation Controls\");var r={camera:t.camera,canvas:t.renderedCanvas,halfView:0===t.currentProjection_.indexOf(\"180\"),orientation:i.browser.IS_IOS||i.browser.IS_ANDROID||!1};!1===t.options_.motionControls&&(r.orientation=!1),t.controls3d=new as(r),t.canvasPlayerControls=new hs(t.player_,t.renderedCanvas,t.options_)}t.animationFrameId_=t.requestAnimationFrame(t.animate_)}))):e.navigator.getVRDevices?this.triggerError_({code:\"web-vr-out-of-date\",dismiss:!1}):this.triggerError_({code:\"web-vr-not-supported\",dismiss:!1}),this.options_.omnitone){var o=to();this.omniController=new ls(o,this.options_.omnitone,this.getVideoEl_(),this.options_.omnitoneOptions),this.omniController.one(\"audiocontext-suspended\",(function(){t.player.pause(),t.player.one(\"playing\",(function(){o.resume()}))}))}this.on(this.player_,\"fullscreenchange\",this.handleResize_),e.addEventListener(\"vrdisplaypresentchange\",this.handleResize_,!0),e.addEventListener(\"resize\",this.handleResize_,!0),e.addEventListener(\"vrdisplayactivate\",this.handleVrDisplayActivate_,!0),e.addEventListener(\"vrdisplaydeactivate\",this.handleVrDisplayDeactivate_,!0),this.initialized_=!0,this.trigger(\"initialized\")},a.addCardboardButton_=function(){this.player_.controlBar.getChild(\"CardboardButton\")||this.player_.controlBar.addChild(\"CardboardButton\",{})},a.getVideoEl_=function(){return this.player_.el().getElementsByTagName(\"video\")[0]},a.reset=function(){if(this.initialized_){this.omniController&&(this.omniController.off(\"audiocontext-suspended\"),this.omniController.dispose(),this.omniController=void 0),this.controls3d&&(this.controls3d.dispose(),this.controls3d=null),this.canvasPlayerControls&&(this.canvasPlayerControls.dispose(),this.canvasPlayerControls=null),this.effect&&(this.effect.dispose(),this.effect=null),e.removeEventListener(\"resize\",this.handleResize_,!0),e.removeEventListener(\"vrdisplaypresentchange\",this.handleResize_,!0),e.removeEventListener(\"vrdisplayactivate\",this.handleVrDisplayActivate_,!0),e.removeEventListener(\"vrdisplaydeactivate\",this.handleVrDisplayDeactivate_,!0),this.player_.getChild(\"BigPlayButton\")||this.player_.addChild(\"BigPlayButton\",{},this.bigPlayButtonIndex_),this.player_.getChild(\"BigVrPlayButton\")&&this.player_.removeChild(\"BigVrPlayButton\"),this.player_.getChild(\"CardboardButton\")&&this.player_.controlBar.removeChild(\"CardboardButton\"),i.browser.IS_IOS&&this.player_.controlBar&&this.player_.controlBar.fullscreenToggle&&this.player_.controlBar.fullscreenToggle.show();var t=this.getVideoEl_().style;t.zIndex=\"\",t.opacity=\"\",this.currentProjection_=this.defaultProjection_,this.iosRevertTouchToClick_&&this.iosRevertTouchToClick_(),this.renderedCanvas&&this.renderedCanvas.parentNode.removeChild(this.renderedCanvas),this.animationFrameId_&&this.cancelAnimationFrame(this.animationFrameId_),this.initialized_=!1}},a.dispose=function(){r.prototype.dispose.call(this),this.reset()},a.polyfillVersion=function(){return h.version},n}(gs);return As.prototype.setTimeout=ys.prototype.setTimeout,As.prototype.clearTimeout=ys.prototype.clearTimeout,As.VERSION=\"1.8.0\",i.registerPlugin(\"vr\",As),As}));\n\n/*!\n * fancyBox - jQuery Plugin\n * version: 2.1.5 (Fri, 14 Jun 2013)\n * @requires jQuery v1.6 or later\n *\n * Examples at http://fancyapps.com/fancybox/\n * License: www.fancyapps.com/fancybox/#license\n *\n * Copyright 2012 Janis Skarnelis - janis@fancyapps.com\n *\n */\n\n(function (window, document, $, undefined) {\n\t\"use strict\";\n\n\tvar H = $(\"html\"),\n\t\tW = $(window),\n\t\tD = $(document),\n\t\tF = $.fancybox = function () {\n\t\t\tF.open.apply( this, arguments );\n\t\t},\n\t\tIE = navigator.userAgent.match(/msie/i),\n\t\tdidUpdate\t= null,\n\t\tisTouch\t\t= document.createTouch !== undefined,\n\n\t\tisQuery\t= function(obj) {\n\t\t\treturn obj && obj.hasOwnProperty && obj instanceof $;\n\t\t},\n\t\tisString = function(str) {\n\t\t\treturn str && $.type(str) === \"string\";\n\t\t},\n\t\tisPercentage = function(str) {\n\t\t\treturn isString(str) && str.indexOf('%') > 0;\n\t\t},\n\t\tisScrollable = function(el) {\n\t\t\treturn (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));\n\t\t},\n\t\tgetScalar = function(orig, dim) {\n\t\t\tvar value = parseInt(orig, 10) || 0;\n\n\t\t\tif (dim && isPercentage(orig)) {\n\t\t\t\tvalue = F.getViewport()[ dim ] / 100 * value;\n\t\t\t}\n\n\t\t\treturn Math.ceil(value);\n\t\t},\n\t\tgetValue = function(value, dim) {\n\t\t\treturn getScalar(value, dim) + 'px';\n\t\t};\n\n\t$.extend(F, {\n\t\t// The current version of fancyBox\n\t\tversion: '2.1.5',\n\n\t\tdefaults: {\n\t\t\tpadding : 15,\n\t\t\tmargin : 20,\n\n\t\t\twidth : 800,\n\t\t\theight : 600,\n\t\t\tminWidth : 100,\n\t\t\tminHeight : 100,\n\t\t\tmaxWidth : 9999,\n\t\t\tmaxHeight : 9999,\n\t\t\tpixelRatio: 1, // Set to 2 for retina display support\n\n\t\t\tautoSize : true,\n\t\t\tautoHeight : false,\n\t\t\tautoWidth : false,\n\n\t\t\tautoResize : true,\n\t\t\tautoCenter : !isTouch,\n\t\t\tfitToView : true,\n\t\t\taspectRatio : false,\n\t\t\ttopRatio : 0.5,\n\t\t\tleftRatio : 0.5,\n\n\t\t\tscrolling : 'auto', // 'auto', 'yes' or 'no'\n\t\t\twrapCSS : '',\n\n\t\t\tarrows : true,\n\t\t\tcloseBtn : true,\n\t\t\tcloseClick : false,\n\t\t\tnextClick : false,\n\t\t\tmouseWheel : true,\n\t\t\tautoPlay : false,\n\t\t\tplaySpeed : 3000,\n\t\t\tpreload : 3,\n\t\t\tmodal : false,\n\t\t\tloop : true,\n\n\t\t\tajax : {\n\t\t\t\tdataType : 'html',\n\t\t\t\theaders : { 'X-fancyBox': true }\n\t\t\t},\n\t\t\tiframe : {\n\t\t\t\tscrolling : 'auto',\n\t\t\t\tpreload : true\n\t\t\t},\n\t\t\tswf : {\n\t\t\t\twmode: 'transparent',\n\t\t\t\tallowfullscreen : 'true',\n\t\t\t\tallowscriptaccess : 'always'\n\t\t\t},\n\n\t\t\tkeys : {\n\t\t\t\tnext : {\n\t\t\t\t\t13 : 'left', // enter\n\t\t\t\t\t34 : 'up', // page down\n\t\t\t\t\t39 : 'left', // right arrow\n\t\t\t\t\t40 : 'up' // down arrow\n\t\t\t\t},\n\t\t\t\tprev : {\n\t\t\t\t\t8 : 'right', // backspace\n\t\t\t\t\t33 : 'down', // page up\n\t\t\t\t\t37 : 'right', // left arrow\n\t\t\t\t\t38 : 'down' // up arrow\n\t\t\t\t},\n\t\t\t\tclose : [27], // escape key\n\t\t\t\tplay : [32], // space - start/stop slideshow\n\t\t\t\ttoggle : [70] // letter \"f\" - toggle fullscreen\n\t\t\t},\n\n\t\t\tdirection : {\n\t\t\t\tnext : 'left',\n\t\t\t\tprev : 'right'\n\t\t\t},\n\n\t\t\tscrollOutside : true,\n\n\t\t\t// Override some properties\n\t\t\tindex : 0,\n\t\t\ttype : null,\n\t\t\thref : null,\n\t\t\tcontent : null,\n\t\t\ttitle : null,\n\n\t\t\t// HTML templates\n\t\t\ttpl: {\n\t\t\t\twrap : '
',\n\t\t\t\timage : '\"\"',\n\t\t\t\tiframe : '',\n\t\t\t\terror : '

The requested content cannot be loaded.
Please try again later.

',\n\t\t\t\tcloseBtn : '',\n\t\t\t\tnext : '',\n\t\t\t\tprev : ''\n\t\t\t},\n\n\t\t\t// Properties for each animation type\n\t\t\t// Opening fancyBox\n\t\t\topenEffect : 'fade', // 'elastic', 'fade' or 'none'\n\t\t\topenSpeed : 250,\n\t\t\topenEasing : 'swing',\n\t\t\topenOpacity : true,\n\t\t\topenMethod : 'zoomIn',\n\n\t\t\t// Closing fancyBox\n\t\t\tcloseEffect : 'fade', // 'elastic', 'fade' or 'none'\n\t\t\tcloseSpeed : 250,\n\t\t\tcloseEasing : 'swing',\n\t\t\tcloseOpacity : true,\n\t\t\tcloseMethod : 'zoomOut',\n\n\t\t\t// Changing next gallery item\n\t\t\tnextEffect : 'elastic', // 'elastic', 'fade' or 'none'\n\t\t\tnextSpeed : 250,\n\t\t\tnextEasing : 'swing',\n\t\t\tnextMethod : 'changeIn',\n\n\t\t\t// Changing previous gallery item\n\t\t\tprevEffect : 'elastic', // 'elastic', 'fade' or 'none'\n\t\t\tprevSpeed : 250,\n\t\t\tprevEasing : 'swing',\n\t\t\tprevMethod : 'changeOut',\n\n\t\t\t// Enable default helpers\n\t\t\thelpers : {\n\t\t\t\toverlay : true,\n\t\t\t\ttitle : true\n\t\t\t},\n\n\t\t\t// Callbacks\n\t\t\tonCancel : $.noop, // If canceling\n\t\t\tbeforeLoad : $.noop, // Before loading\n\t\t\tafterLoad : $.noop, // After loading\n\t\t\tbeforeShow : $.noop, // Before changing in current item\n\t\t\tafterShow : $.noop, // After opening\n\t\t\tbeforeChange : $.noop, // Before changing gallery item\n\t\t\tbeforeClose : $.noop, // Before closing\n\t\t\tafterClose : $.noop // After closing\n\t\t},\n\n\t\t//Current state\n\t\tgroup : {}, // Selected group\n\t\topts : {}, // Group options\n\t\tprevious : null, // Previous element\n\t\tcoming : null, // Element being loaded\n\t\tcurrent : null, // Currently loaded element\n\t\tisActive : false, // Is activated\n\t\tisOpen : false, // Is currently open\n\t\tisOpened : false, // Have been fully opened at least once\n\n\t\twrap : null,\n\t\tskin : null,\n\t\touter : null,\n\t\tinner : null,\n\n\t\tplayer : {\n\t\t\ttimer : null,\n\t\t\tisActive : false\n\t\t},\n\n\t\t// Loaders\n\t\tajaxLoad : null,\n\t\timgPreload : null,\n\n\t\t// Some collections\n\t\ttransitions : {},\n\t\thelpers : {},\n\n\t\t/*\n\t\t *\tStatic methods\n\t\t */\n\n\t\topen: function (group, opts) {\n\t\t\tif (!group) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!$.isPlainObject(opts)) {\n\t\t\t\topts = {};\n\t\t\t}\n\n\t\t\t// Close if already active\n\t\t\tif (false === F.close(true)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Normalize group\n\t\t\tif (!$.isArray(group)) {\n\t\t\t\tgroup = isQuery(group) ? $(group).get() : [group];\n\t\t\t}\n\n\t\t\t// Recheck if the type of each element is `object` and set content type (image, ajax, etc)\n\t\t\t$.each(group, function(i, element) {\n\t\t\t\tvar obj = {},\n\t\t\t\t\thref,\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent,\n\t\t\t\t\ttype,\n\t\t\t\t\trez,\n\t\t\t\t\threfParts,\n\t\t\t\t\tselector;\n\n\t\t\t\tif ($.type(element) === \"object\") {\n\t\t\t\t\t// Check if is DOM element\n\t\t\t\t\tif (element.nodeType) {\n\t\t\t\t\t\telement = $(element);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isQuery(element)) {\n\t\t\t\t\t\tobj = {\n\t\t\t\t\t\t\thref : element.data('fancybox-href') || element.attr('href'),\n\t\t\t\t\t\t\ttitle : element.data('fancybox-title') || element.attr('title'),\n\t\t\t\t\t\t\tisDom : true,\n\t\t\t\t\t\t\telement : element\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif ($.metadata) {\n\t\t\t\t\t\t\t$.extend(true, obj, element.metadata());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tobj = element;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\thref = opts.href || obj.href || (isString(element) ? element : null);\n\t\t\t\ttitle = opts.title !== undefined ? opts.title : obj.title || '';\n\n\t\t\t\tcontent = opts.content || obj.content;\n\t\t\t\ttype = content ? 'html' : (opts.type || obj.type);\n\n\t\t\t\tif (!type && obj.isDom) {\n\t\t\t\t\ttype = element.data('fancybox-type');\n\n\t\t\t\t\tif (!type) {\n\t\t\t\t\t\trez = element.prop('class').match(/fancybox\\.(\\w+)/);\n\t\t\t\t\t\ttype = rez ? rez[1] : null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (isString(href)) {\n\t\t\t\t\t// Try to guess the content type\n\t\t\t\t\tif (!type) {\n\t\t\t\t\t\tif (F.isImage(href)) {\n\t\t\t\t\t\t\ttype = 'image';\n\n\t\t\t\t\t\t} else if (F.isSWF(href)) {\n\t\t\t\t\t\t\ttype = 'swf';\n\n\t\t\t\t\t\t} else if (href.charAt(0) === '#') {\n\t\t\t\t\t\t\ttype = 'inline';\n\n\t\t\t\t\t\t} else if (isString(element)) {\n\t\t\t\t\t\t\ttype = 'html';\n\t\t\t\t\t\t\tcontent = element;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Split url into two pieces with source url and content selector, e.g,\n\t\t\t\t\t// \"/mypage.html #my_id\" will load \"/mypage.html\" and display element having id \"my_id\"\n\t\t\t\t\tif (type === 'ajax') {\n\t\t\t\t\t\threfParts = href.split(/\\s+/, 2);\n\t\t\t\t\t\thref = hrefParts.shift();\n\t\t\t\t\t\tselector = hrefParts.shift();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!content) {\n\t\t\t\t\tif (type === 'inline') {\n\t\t\t\t\t\tif (href) {\n\t\t\t\t\t\t\tcontent = $( isString(href) ? href.replace(/.*(?=#[^\\s]+$)/, '') : href ); //strip for ie7\n\n\t\t\t\t\t\t} else if (obj.isDom) {\n\t\t\t\t\t\t\tcontent = element;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if (type === 'html') {\n\t\t\t\t\t\tcontent = href;\n\n\t\t\t\t\t} else if (!type && !href && obj.isDom) {\n\t\t\t\t\t\ttype = 'inline';\n\t\t\t\t\t\tcontent = element;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t$.extend(obj, {\n\t\t\t\t\thref : href,\n\t\t\t\t\ttype : type,\n\t\t\t\t\tcontent : content,\n\t\t\t\t\ttitle : title,\n\t\t\t\t\tselector : selector\n\t\t\t\t});\n\n\t\t\t\tgroup[ i ] = obj;\n\t\t\t});\n\n\t\t\t// Extend the defaults\n\t\t\tF.opts = $.extend(true, {}, F.defaults, opts);\n\n\t\t\t// All options are merged recursive except keys\n\t\t\tif (opts.keys !== undefined) {\n\t\t\t\tF.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;\n\t\t\t}\n\n\t\t\tF.group = group;\n\n\t\t\treturn F._start(F.opts.index);\n\t\t},\n\n\t\t// Cancel image loading or abort ajax request\n\t\tcancel: function () {\n\t\t\tvar coming = F.coming;\n\n\t\t\tif (!coming || false === F.trigger('onCancel')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tF.hideLoading();\n\n\t\t\tif (F.ajaxLoad) {\n\t\t\t\tF.ajaxLoad.abort();\n\t\t\t}\n\n\t\t\tF.ajaxLoad = null;\n\n\t\t\tif (F.imgPreload) {\n\t\t\t\tF.imgPreload.onload = F.imgPreload.onerror = null;\n\t\t\t}\n\n\t\t\tif (coming.wrap) {\n\t\t\t\tcoming.wrap.stop(true, true).trigger('onReset').remove();\n\t\t\t}\n\n\t\t\tF.coming = null;\n\n\t\t\t// If the first item has been canceled, then clear everything\n\t\t\tif (!F.current) {\n\t\t\t\tF._afterZoomOut( coming );\n\t\t\t}\n\t\t},\n\n\t\t// Start closing animation if is open; remove immediately if opening/closing\n\t\tclose: function (event) {\n\t\t\tF.cancel();\n\n\t\t\tif (false === F.trigger('beforeClose')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tF.unbindEvents();\n\n\t\t\tif (!F.isActive) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!F.isOpen || event === true) {\n\t\t\t\t$('.fancybox-wrap').stop(true).trigger('onReset').remove();\n\n\t\t\t\tF._afterZoomOut();\n\n\t\t\t} else {\n\t\t\t\tF.isOpen = F.isOpened = false;\n\t\t\t\tF.isClosing = true;\n\n\t\t\t\t$('.fancybox-item, .fancybox-nav').remove();\n\n\t\t\t\tF.wrap.stop(true, true).removeClass('fancybox-opened');\n\n\t\t\t\tF.transitions[ F.current.closeMethod ]();\n\t\t\t}\n\t\t},\n\n\t\t// Manage slideshow:\n\t\t// $.fancybox.play(); - toggle slideshow\n\t\t// $.fancybox.play( true ); - start\n\t\t// $.fancybox.play( false ); - stop\n\t\tplay: function ( action ) {\n\t\t\tvar clear = function () {\n\t\t\t\t\tclearTimeout(F.player.timer);\n\t\t\t\t},\n\t\t\t\tset = function () {\n\t\t\t\t\tclear();\n\n\t\t\t\t\tif (F.current && F.player.isActive) {\n\t\t\t\t\t\tF.player.timer = setTimeout(F.next, F.current.playSpeed);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tstop = function () {\n\t\t\t\t\tclear();\n\n\t\t\t\t\tD.unbind('.player');\n\n\t\t\t\t\tF.player.isActive = false;\n\n\t\t\t\t\tF.trigger('onPlayEnd');\n\t\t\t\t},\n\t\t\t\tstart = function () {\n\t\t\t\t\tif (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {\n\t\t\t\t\t\tF.player.isActive = true;\n\n\t\t\t\t\t\tD.bind({\n\t\t\t\t\t\t\t'onCancel.player beforeClose.player' : stop,\n\t\t\t\t\t\t\t'onUpdate.player' : set,\n\t\t\t\t\t\t\t'beforeLoad.player' : clear\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tset();\n\n\t\t\t\t\t\tF.trigger('onPlayStart');\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\tif (action === true || (!F.player.isActive && action !== false)) {\n\t\t\t\tstart();\n\t\t\t} else {\n\t\t\t\tstop();\n\t\t\t}\n\t\t},\n\n\t\t// Navigate to next gallery item\n\t\tnext: function ( direction ) {\n\t\t\tvar current = F.current;\n\n\t\t\tif (current) {\n\t\t\t\tif (!isString(direction)) {\n\t\t\t\t\tdirection = current.direction.next;\n\t\t\t\t}\n\n\t\t\t\tF.jumpto(current.index + 1, direction, 'next');\n\t\t\t}\n\t\t},\n\n\t\t// Navigate to previous gallery item\n\t\tprev: function ( direction ) {\n\t\t\tvar current = F.current;\n\n\t\t\tif (current) {\n\t\t\t\tif (!isString(direction)) {\n\t\t\t\t\tdirection = current.direction.prev;\n\t\t\t\t}\n\n\t\t\t\tF.jumpto(current.index - 1, direction, 'prev');\n\t\t\t}\n\t\t},\n\n\t\t// Navigate to gallery item by index\n\t\tjumpto: function ( index, direction, router ) {\n\t\t\tvar current = F.current;\n\n\t\t\tif (!current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tindex = getScalar(index);\n\n\t\t\tF.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];\n\t\t\tF.router = router || 'jumpto';\n\n\t\t\tif (current.loop) {\n\t\t\t\tif (index < 0) {\n\t\t\t\t\tindex = current.group.length + (index % current.group.length);\n\t\t\t\t}\n\n\t\t\t\tindex = index % current.group.length;\n\t\t\t}\n\n\t\t\tif (current.group[ index ] !== undefined) {\n\t\t\t\tF.cancel();\n\n\t\t\t\tF._start(index);\n\t\t\t}\n\t\t},\n\n\t\t// Center inside viewport and toggle position type to fixed or absolute if needed\n\t\treposition: function (e, onlyAbsolute) {\n\t\t\tvar current = F.current,\n\t\t\t\twrap = current ? current.wrap : null,\n\t\t\t\tpos;\n\n\t\t\tif (wrap) {\n\t\t\t\tpos = F._getPosition(onlyAbsolute);\n\n\t\t\t\tif (e && e.type === 'scroll') {\n\t\t\t\t\tdelete pos.position;\n\n\t\t\t\t\twrap.stop(true, true).animate(pos, 200);\n\n\t\t\t\t} else {\n\t\t\t\t\twrap.css(pos);\n\n\t\t\t\t\tcurrent.pos = $.extend({}, current.dim, pos);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tupdate: function (e) {\n\t\t\tvar type = (e && e.type),\n\t\t\t\tanyway = !type || type === 'orientationchange';\n\n\t\t\tif (anyway) {\n\t\t\t\tclearTimeout(didUpdate);\n\n\t\t\t\tdidUpdate = null;\n\t\t\t}\n\n\t\t\tif (!F.isOpen || didUpdate) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidUpdate = setTimeout(function() {\n\t\t\t\tvar current = F.current;\n\n\t\t\t\tif (!current || F.isClosing) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tF.wrap.removeClass('fancybox-tmp');\n\n\t\t\t\tif (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {\n\t\t\t\t\tF._setDimension();\n\t\t\t\t}\n\n\t\t\t\tif (!(type === 'scroll' && current.canShrink)) {\n\t\t\t\t\tF.reposition(e);\n\t\t\t\t}\n\n\t\t\t\tF.trigger('onUpdate');\n\n\t\t\t\tdidUpdate = null;\n\n\t\t\t}, (anyway && !isTouch ? 0 : 300));\n\t\t},\n\n\t\t// Shrink content to fit inside viewport or restore if resized\n\t\ttoggle: function ( action ) {\n\t\t\tif (F.isOpen) {\n\t\t\t\tF.current.fitToView = $.type(action) === \"boolean\" ? action : !F.current.fitToView;\n\n\t\t\t\t// Help browser to restore document dimensions\n\t\t\t\tif (isTouch) {\n\t\t\t\t\tF.wrap.removeAttr('style').addClass('fancybox-tmp');\n\n\t\t\t\t\tF.trigger('onUpdate');\n\t\t\t\t}\n\n\t\t\t\tF.update();\n\t\t\t}\n\t\t},\n\n\t\thideLoading: function () {\n\t\t\tD.unbind('.loading');\n\n\t\t\t$('#fancybox-loading').remove();\n\t\t},\n\n\t\tshowLoading: function () {\n\t\t\tvar el, viewport;\n\n\t\t\tF.hideLoading();\n\n\t\t\tel = $('
').click(F.cancel).appendTo('body');\n\n\t\t\t// If user will press the escape-button, the request will be canceled\n\t\t\tD.bind('keydown.loading', function(e) {\n\t\t\t\tif ((e.which || e.keyCode) === 27) {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tF.cancel();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!F.defaults.fixed) {\n\t\t\t\tviewport = F.getViewport();\n\n\t\t\t\tel.css({\n\t\t\t\t\tposition : 'absolute',\n\t\t\t\t\ttop : (viewport.h * 0.5) + viewport.y,\n\t\t\t\t\tleft : (viewport.w * 0.5) + viewport.x\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\tgetViewport: function () {\n\t\t\tvar locked = (F.current && F.current.locked) || false,\n\t\t\t\trez = {\n\t\t\t\t\tx: W.scrollLeft(),\n\t\t\t\t\ty: W.scrollTop()\n\t\t\t\t};\n\n\t\t\tif (locked) {\n\t\t\t\trez.w = locked[0].clientWidth;\n\t\t\t\trez.h = locked[0].clientHeight;\n\n\t\t\t} else {\n\t\t\t\t// See http://bugs.jquery.com/ticket/6724\n\t\t\t\trez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();\n\t\t\t\trez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();\n\t\t\t}\n\n\t\t\treturn rez;\n\t\t},\n\n\t\t// Unbind the keyboard / clicking actions\n\t\tunbindEvents: function () {\n\t\t\tif (F.wrap && isQuery(F.wrap)) {\n\t\t\t\tF.wrap.unbind('.fb');\n\t\t\t}\n\n\t\t\tD.unbind('.fb');\n\t\t\tW.unbind('.fb');\n\t\t},\n\n\t\tbindEvents: function () {\n\t\t\tvar current = F.current,\n\t\t\t\tkeys;\n\n\t\t\tif (!current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Changing document height on iOS devices triggers a 'resize' event,\n\t\t\t// that can change document height... repeating infinitely\n\t\t\tW.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);\n\n\t\t\tkeys = current.keys;\n\n\t\t\tif (keys) {\n\t\t\t\tD.bind('keydown.fb', function (e) {\n\t\t\t\t\tvar code = e.which || e.keyCode,\n\t\t\t\t\t\ttarget = e.target || e.srcElement;\n\n\t\t\t\t\t// Skip esc key if loading, because showLoading will cancel preloading\n\t\t\t\t\tif (code === 27 && F.coming) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ignore key combinations and key events within form elements\n\t\t\t\t\tif (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {\n\t\t\t\t\t\t$.each(keys, function(i, val) {\n\t\t\t\t\t\t\tif (current.group.length > 1 && val[ code ] !== undefined) {\n\t\t\t\t\t\t\t\tF[ i ]( val[ code ] );\n\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ($.inArray(code, val) > -1) {\n\t\t\t\t\t\t\t\tF[ i ] ();\n\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ($.fn.mousewheel && current.mouseWheel) {\n\t\t\t\tF.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {\n\t\t\t\t\tvar target = e.target || null,\n\t\t\t\t\t\tparent = $(target),\n\t\t\t\t\t\tcanScroll = false;\n\n\t\t\t\t\twhile (parent.length) {\n\t\t\t\t\t\tif (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcanScroll = isScrollable( parent[0] );\n\t\t\t\t\t\tparent = $(parent).parent();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (delta !== 0 && !canScroll) {\n\t\t\t\t\t\tif (F.group.length > 1 && !current.canShrink) {\n\t\t\t\t\t\t\tif (deltaY > 0 || deltaX > 0) {\n\t\t\t\t\t\t\t\tF.prev( deltaY > 0 ? 'down' : 'left' );\n\n\t\t\t\t\t\t\t} else if (deltaY < 0 || deltaX < 0) {\n\t\t\t\t\t\t\t\tF.next( deltaY < 0 ? 'up' : 'right' );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\ttrigger: function (event, o) {\n\t\t\tvar ret, obj = o || F.coming || F.current;\n\n\t\t\tif (!obj) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ($.isFunction( obj[event] )) {\n\t\t\t\tret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));\n\t\t\t}\n\n\t\t\tif (ret === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (obj.helpers) {\n\t\t\t\t$.each(obj.helpers, function (helper, opts) {\n\t\t\t\t\tif (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {\n\t\t\t\t\t\tF.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tD.trigger(event);\n\t\t},\n\n\t\tisImage: function (str) {\n\t\t\treturn isString(str) && str.match(/(^data:image\\/.*,)|(\\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\\?|#).*)?$)/i);\n\t\t},\n\n\t\tisSWF: function (str) {\n\t\t\treturn isString(str) && str.match(/\\.(swf)((\\?|#).*)?$/i);\n\t\t},\n\n\t\t_start: function (index) {\n\t\t\tvar coming = {},\n\t\t\t\tobj,\n\t\t\t\thref,\n\t\t\t\ttype,\n\t\t\t\tmargin,\n\t\t\t\tpadding;\n\n\t\t\tindex = getScalar( index );\n\t\t\tobj = F.group[ index ] || null;\n\n\t\t\tif (!obj) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tcoming = $.extend(true, {}, F.opts, obj);\n\n\t\t\t// Convert margin and padding properties to array - top, right, bottom, left\n\t\t\tmargin = coming.margin;\n\t\t\tpadding = coming.padding;\n\n\t\t\tif ($.type(margin) === 'number') {\n\t\t\t\tcoming.margin = [margin, margin, margin, margin];\n\t\t\t}\n\n\t\t\tif ($.type(padding) === 'number') {\n\t\t\t\tcoming.padding = [padding, padding, padding, padding];\n\t\t\t}\n\n\t\t\t// 'modal' propery is just a shortcut\n\t\t\tif (coming.modal) {\n\t\t\t\t$.extend(true, coming, {\n\t\t\t\t\tcloseBtn : false,\n\t\t\t\t\tcloseClick : false,\n\t\t\t\t\tnextClick : false,\n\t\t\t\t\tarrows : false,\n\t\t\t\t\tmouseWheel : false,\n\t\t\t\t\tkeys : null,\n\t\t\t\t\thelpers: {\n\t\t\t\t\t\toverlay : {\n\t\t\t\t\t\t\tcloseClick : false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// 'autoSize' property is a shortcut, too\n\t\t\tif (coming.autoSize) {\n\t\t\t\tcoming.autoWidth = coming.autoHeight = true;\n\t\t\t}\n\n\t\t\tif (coming.width === 'auto') {\n\t\t\t\tcoming.autoWidth = true;\n\t\t\t}\n\n\t\t\tif (coming.height === 'auto') {\n\t\t\t\tcoming.autoHeight = true;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Add reference to the group, so it`s possible to access from callbacks, example:\n\t\t\t * afterLoad : function() {\n\t\t\t * this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');\n\t\t\t * }\n\t\t\t */\n\n\t\t\tcoming.group = F.group;\n\t\t\tcoming.index = index;\n\n\t\t\t// Give a chance for callback or helpers to update coming item (type, title, etc)\n\t\t\tF.coming = coming;\n\n\t\t\tif (false === F.trigger('beforeLoad')) {\n\t\t\t\tF.coming = null;\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttype = coming.type;\n\t\t\thref = coming.href;\n\n\t\t\tif (!type) {\n\t\t\t\tF.coming = null;\n\n\t\t\t\t//If we can not determine content type then drop silently or display next/prev item if looping through gallery\n\t\t\t\tif (F.current && F.router && F.router !== 'jumpto') {\n\t\t\t\t\tF.current.index = index;\n\n\t\t\t\t\treturn F[ F.router ]( F.direction );\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tF.isActive = true;\n\n\t\t\tif (type === 'image' || type === 'swf') {\n\t\t\t\tcoming.autoHeight = coming.autoWidth = false;\n\t\t\t\tcoming.scrolling = 'visible';\n\t\t\t}\n\n\t\t\tif (type === 'image') {\n\t\t\t\tcoming.aspectRatio = true;\n\t\t\t}\n\n\t\t\tif (type === 'iframe' && isTouch) {\n\t\t\t\tcoming.scrolling = 'scroll';\n\t\t\t}\n\n\t\t\t// Build the neccessary markup\n\t\t\tcoming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );\n\n\t\t\t$.extend(coming, {\n\t\t\t\tskin : $('.fancybox-skin', coming.wrap),\n\t\t\t\touter : $('.fancybox-outer', coming.wrap),\n\t\t\t\tinner : $('.fancybox-inner', coming.wrap)\n\t\t\t});\n\n\t\t\t$.each([\"Top\", \"Right\", \"Bottom\", \"Left\"], function(i, v) {\n\t\t\t\tcoming.skin.css('padding' + v, getValue(coming.padding[ i ]));\n\t\t\t});\n\n\t\t\tF.trigger('onReady');\n\n\t\t\t// Check before try to load; 'inline' and 'html' types need content, others - href\n\t\t\tif (type === 'inline' || type === 'html') {\n\t\t\t\tif (!coming.content || !coming.content.length) {\n\t\t\t\t\treturn F._error( 'content' );\n\t\t\t\t}\n\n\t\t\t} else if (!href) {\n\t\t\t\treturn F._error( 'href' );\n\t\t\t}\n\n\t\t\tif (type === 'image') {\n\t\t\t\tF._loadImage();\n\n\t\t\t} else if (type === 'ajax') {\n\t\t\t\tF._loadAjax();\n\n\t\t\t} else if (type === 'iframe') {\n\t\t\t\tF._loadIframe();\n\n\t\t\t} else {\n\t\t\t\tF._afterLoad();\n\t\t\t}\n\t\t},\n\n\t\t_error: function ( type ) {\n\t\t\t$.extend(F.coming, {\n\t\t\t\ttype : 'html',\n\t\t\t\tautoWidth : true,\n\t\t\t\tautoHeight : true,\n\t\t\t\tminWidth : 0,\n\t\t\t\tminHeight : 0,\n\t\t\t\tscrolling : 'no',\n\t\t\t\thasError : type,\n\t\t\t\tcontent : F.coming.tpl.error\n\t\t\t});\n\n\t\t\tF._afterLoad();\n\t\t},\n\n\t\t_loadImage: function () {\n\t\t\t// Reset preload image so it is later possible to check \"complete\" property\n\t\t\tvar img = F.imgPreload = new Image();\n\n\t\t\timg.onload = function () {\n\t\t\t\tthis.onload = this.onerror = null;\n\n\t\t\t\tF.coming.width = this.width / F.opts.pixelRatio;\n\t\t\t\tF.coming.height = this.height / F.opts.pixelRatio;\n\n\t\t\t\tF._afterLoad();\n\t\t\t};\n\n\t\t\timg.onerror = function () {\n\t\t\t\tthis.onload = this.onerror = null;\n\n\t\t\t\tF._error( 'image' );\n\t\t\t};\n\n\t\t\timg.src = F.coming.href;\n\n\t\t\tif (img.complete !== true) {\n\t\t\t\tF.showLoading();\n\t\t\t}\n\t\t},\n\n\t\t_loadAjax: function () {\n\t\t\tvar coming = F.coming;\n\n\t\t\tF.showLoading();\n\n\t\t\tF.ajaxLoad = $.ajax($.extend({}, coming.ajax, {\n\t\t\t\turl: coming.href,\n\t\t\t\terror: function (jqXHR, textStatus) {\n\t\t\t\t\tif (F.coming && textStatus !== 'abort') {\n\t\t\t\t\t\tF._error( 'ajax', jqXHR );\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tF.hideLoading();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsuccess: function (data, textStatus) {\n\t\t\t\t\tif (textStatus === 'success') {\n\t\t\t\t\t\tcoming.content = data;\n\n\t\t\t\t\t\tF._afterLoad();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}));\n\t\t},\n\n\t\t_loadIframe: function() {\n\t\t\tvar coming = F.coming,\n\t\t\t\tiframe = $(coming.tpl.iframe.replace(/\\{rnd\\}/g, new Date().getTime()))\n\t\t\t\t\t.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)\n\t\t\t\t\t.attr('src', coming.href);\n\n\t\t\t// This helps IE\n\t\t\t$(coming.wrap).bind('onReset', function () {\n\t\t\t\ttry {\n\t\t\t\t\t$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();\n\t\t\t\t} catch (e) {}\n\t\t\t});\n\n\t\t\tif (coming.iframe.preload) {\n\t\t\t\tF.showLoading();\n\n\t\t\t\tiframe.one('load', function() {\n\t\t\t\t\t$(this).data('ready', 1);\n\n\t\t\t\t\t// iOS will lose scrolling if we resize\n\t\t\t\t\tif (!isTouch) {\n\t\t\t\t\t\t$(this).bind('load.fb', F.update);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Without this trick:\n\t\t\t\t\t// - iframe won't scroll on iOS devices\n\t\t\t\t\t// - IE7 sometimes displays empty iframe\n\t\t\t\t\t$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();\n\n\t\t\t\t\tF._afterLoad();\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcoming.content = iframe.appendTo( coming.inner );\n\n\t\t\tif (!coming.iframe.preload) {\n\t\t\t\tF._afterLoad();\n\t\t\t}\n\t\t},\n\n\t\t_preloadImages: function() {\n\t\t\tvar group = F.group,\n\t\t\t\tcurrent = F.current,\n\t\t\t\tlen = group.length,\n\t\t\t\tcnt = current.preload ? Math.min(current.preload, len - 1) : 0,\n\t\t\t\titem,\n\t\t\t\ti;\n\n\t\t\tfor (i = 1; i <= cnt; i += 1) {\n\t\t\t\titem = group[ (current.index + i ) % len ];\n\n\t\t\t\tif (item.type === 'image' && item.href) {\n\t\t\t\t\tnew Image().src = item.href;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t_afterLoad: function () {\n\t\t\tvar coming = F.coming,\n\t\t\t\tprevious = F.current,\n\t\t\t\tplaceholder = 'fancybox-placeholder',\n\t\t\t\tcurrent,\n\t\t\t\tcontent,\n\t\t\t\ttype,\n\t\t\t\tscrolling,\n\t\t\t\thref,\n\t\t\t\tembed;\n\n\t\t\tF.hideLoading();\n\n\t\t\tif (!coming || F.isActive === false) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (false === F.trigger('afterLoad', coming, previous)) {\n\t\t\t\tcoming.wrap.stop(true).trigger('onReset').remove();\n\n\t\t\t\tF.coming = null;\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (previous) {\n\t\t\t\tF.trigger('beforeChange', previous);\n\n\t\t\t\tprevious.wrap.stop(true).removeClass('fancybox-opened')\n\t\t\t\t\t.find('.fancybox-item, .fancybox-nav')\n\t\t\t\t\t.remove();\n\t\t\t}\n\n\t\t\tF.unbindEvents();\n\n\t\t\tcurrent = coming;\n\t\t\tcontent = coming.content;\n\t\t\ttype = coming.type;\n\t\t\tscrolling = coming.scrolling;\n\n\t\t\t$.extend(F, {\n\t\t\t\twrap : current.wrap,\n\t\t\t\tskin : current.skin,\n\t\t\t\touter : current.outer,\n\t\t\t\tinner : current.inner,\n\t\t\t\tcurrent : current,\n\t\t\t\tprevious : previous\n\t\t\t});\n\n\t\t\thref = current.href;\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'inline':\n\t\t\t\tcase 'ajax':\n\t\t\t\tcase 'html':\n\t\t\t\t\tif (current.selector) {\n\t\t\t\t\t\tcontent = $('
').html(content).find(current.selector);\n\n\t\t\t\t\t} else if (isQuery(content)) {\n\t\t\t\t\t\tif (!content.data(placeholder)) {\n\t\t\t\t\t\t\tcontent.data(placeholder, $('
').insertAfter( content ).hide() );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontent = content.show().detach();\n\n\t\t\t\t\t\tcurrent.wrap.bind('onReset', function () {\n\t\t\t\t\t\t\tif ($(this).find(content).length) {\n\t\t\t\t\t\t\t\tcontent.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\t\tcase 'image':\n\t\t\t\t\tcontent = current.tpl.image.replace('{href}', href);\n\t\t\t\tbreak;\n\n\t\t\t\tcase 'swf':\n\t\t\t\t\tcontent = '';\n\t\t\t\t\tembed = '';\n\n\t\t\t\t\t$.each(current.swf, function(name, val) {\n\t\t\t\t\t\tcontent += '';\n\t\t\t\t\t\tembed += ' ' + name + '=\"' + val + '\"';\n\t\t\t\t\t});\n\n\t\t\t\t\tcontent += '';\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!(isQuery(content) && content.parent().is(current.inner))) {\n\t\t\t\tcurrent.inner.append( content );\n\t\t\t}\n\n\t\t\t// Give a chance for helpers or callbacks to update elements\n\t\t\tF.trigger('beforeShow');\n\n\t\t\t// Set scrolling before calculating dimensions\n\t\t\tcurrent.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));\n\n\t\t\t// Set initial dimensions and start position\n\t\t\tF._setDimension();\n\n\t\t\tF.reposition();\n\n\t\t\tF.isOpen = false;\n\t\t\tF.coming = null;\n\n\t\t\tF.bindEvents();\n\n\t\t\tif (!F.isOpened) {\n\t\t\t\t$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();\n\n\t\t\t} else if (previous.prevMethod) {\n\t\t\t\tF.transitions[ previous.prevMethod ]();\n\t\t\t}\n\n\t\t\tF.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();\n\n\t\t\tF._preloadImages();\n\t\t},\n\n\t\t_setDimension: function () {\n\t\t\tvar viewport = F.getViewport(),\n\t\t\t\tsteps = 0,\n\t\t\t\tcanShrink = false,\n\t\t\t\tcanExpand = false,\n\t\t\t\twrap = F.wrap,\n\t\t\t\tskin = F.skin,\n\t\t\t\tinner = F.inner,\n\t\t\t\tcurrent = F.current,\n\t\t\t\twidth = current.width,\n\t\t\t\theight = current.height,\n\t\t\t\tminWidth = current.minWidth,\n\t\t\t\tminHeight = current.minHeight,\n\t\t\t\tmaxWidth = current.maxWidth,\n\t\t\t\tmaxHeight = current.maxHeight,\n\t\t\t\tscrolling = current.scrolling,\n\t\t\t\tscrollOut = current.scrollOutside ? current.scrollbarWidth : 0,\n\t\t\t\tmargin = current.margin,\n\t\t\t\twMargin = getScalar(margin[1] + margin[3]),\n\t\t\t\thMargin = getScalar(margin[0] + margin[2]),\n\t\t\t\twPadding,\n\t\t\t\thPadding,\n\t\t\t\twSpace,\n\t\t\t\thSpace,\n\t\t\t\torigWidth,\n\t\t\t\torigHeight,\n\t\t\t\torigMaxWidth,\n\t\t\t\torigMaxHeight,\n\t\t\t\tratio,\n\t\t\t\twidth_,\n\t\t\t\theight_,\n\t\t\t\tmaxWidth_,\n\t\t\t\tmaxHeight_,\n\t\t\t\tiframe,\n\t\t\t\tbody;\n\n\t\t\t// Reset dimensions so we could re-check actual size\n\t\t\twrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');\n\n\t\t\twPadding = getScalar(skin.outerWidth(true) - skin.width());\n\t\t\thPadding = getScalar(skin.outerHeight(true) - skin.height());\n\n\t\t\t// Any space between content and viewport (margin, padding, border, title)\n\t\t\twSpace = wMargin + wPadding;\n\t\t\thSpace = hMargin + hPadding;\n\n\t\t\torigWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;\n\t\t\torigHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;\n\n\t\t\tif (current.type === 'iframe') {\n\t\t\t\tiframe = current.content;\n\n\t\t\t\tif (current.autoHeight && iframe.data('ready') === 1) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (iframe[0].contentWindow.document.location) {\n\t\t\t\t\t\t\tinner.width( origWidth ).height(9999);\n\n\t\t\t\t\t\t\tbody = iframe.contents().find('body');\n\n\t\t\t\t\t\t\tif (scrollOut) {\n\t\t\t\t\t\t\t\tbody.css('overflow-x', 'hidden');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\torigHeight = body.outerHeight(true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} catch (e) {}\n\t\t\t\t}\n\n\t\t\t} else if (current.autoWidth || current.autoHeight) {\n\t\t\t\tinner.addClass( 'fancybox-tmp' );\n\n\t\t\t\t// Set width or height in case we need to calculate only one dimension\n\t\t\t\tif (!current.autoWidth) {\n\t\t\t\t\tinner.width( origWidth );\n\t\t\t\t}\n\n\t\t\t\tif (!current.autoHeight) {\n\t\t\t\t\tinner.height( origHeight );\n\t\t\t\t}\n\n\t\t\t\tif (current.autoWidth) {\n\t\t\t\t\torigWidth = inner.width();\n\t\t\t\t}\n\n\t\t\t\tif (current.autoHeight) {\n\t\t\t\t\torigHeight = inner.height();\n\t\t\t\t}\n\n\t\t\t\tinner.removeClass( 'fancybox-tmp' );\n\t\t\t}\n\n\t\t\twidth = getScalar( origWidth );\n\t\t\theight = getScalar( origHeight );\n\n\t\t\tratio = origWidth / origHeight;\n\n\t\t\t// Calculations for the content\n\t\t\tminWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);\n\t\t\tmaxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);\n\n\t\t\tminHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);\n\t\t\tmaxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);\n\n\t\t\t// These will be used to determine if wrap can fit in the viewport\n\t\t\torigMaxWidth = maxWidth;\n\t\t\torigMaxHeight = maxHeight;\n\n\t\t\tif (current.fitToView) {\n\t\t\t\tmaxWidth = Math.min(viewport.w - wSpace, maxWidth);\n\t\t\t\tmaxHeight = Math.min(viewport.h - hSpace, maxHeight);\n\t\t\t}\n\n\t\t\tmaxWidth_ = viewport.w - wMargin;\n\t\t\tmaxHeight_ = viewport.h - hMargin;\n\n\t\t\tif (current.aspectRatio) {\n\t\t\t\tif (width > maxWidth) {\n\t\t\t\t\twidth = maxWidth;\n\t\t\t\t\theight = getScalar(width / ratio);\n\t\t\t\t}\n\n\t\t\t\tif (height > maxHeight) {\n\t\t\t\t\theight = maxHeight;\n\t\t\t\t\twidth = getScalar(height * ratio);\n\t\t\t\t}\n\n\t\t\t\tif (width < minWidth) {\n\t\t\t\t\twidth = minWidth;\n\t\t\t\t\theight = getScalar(width / ratio);\n\t\t\t\t}\n\n\t\t\t\tif (height < minHeight) {\n\t\t\t\t\theight = minHeight;\n\t\t\t\t\twidth = getScalar(height * ratio);\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\twidth = Math.max(minWidth, Math.min(width, maxWidth));\n\n\t\t\t\tif (current.autoHeight && current.type !== 'iframe') {\n\t\t\t\t\tinner.width( width );\n\n\t\t\t\t\theight = inner.height();\n\t\t\t\t}\n\n\t\t\t\theight = Math.max(minHeight, Math.min(height, maxHeight));\n\t\t\t}\n\n\t\t\t// Try to fit inside viewport (including the title)\n\t\t\tif (current.fitToView) {\n\t\t\t\tinner.width( width ).height( height );\n\n\t\t\t\twrap.width( width + wPadding );\n\n\t\t\t\t// Real wrap dimensions\n\t\t\t\twidth_ = wrap.width();\n\t\t\t\theight_ = wrap.height();\n\n\t\t\t\tif (current.aspectRatio) {\n\t\t\t\t\twhile ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {\n\t\t\t\t\t\tif (steps++ > 19) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\theight = Math.max(minHeight, Math.min(maxHeight, height - 10));\n\t\t\t\t\t\twidth = getScalar(height * ratio);\n\n\t\t\t\t\t\tif (width < minWidth) {\n\t\t\t\t\t\t\twidth = minWidth;\n\t\t\t\t\t\t\theight = getScalar(width / ratio);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (width > maxWidth) {\n\t\t\t\t\t\t\twidth = maxWidth;\n\t\t\t\t\t\t\theight = getScalar(width / ratio);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tinner.width( width ).height( height );\n\n\t\t\t\t\t\twrap.width( width + wPadding );\n\n\t\t\t\t\t\twidth_ = wrap.width();\n\t\t\t\t\t\theight_ = wrap.height();\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\twidth = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));\n\t\t\t\t\theight = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {\n\t\t\t\twidth += scrollOut;\n\t\t\t}\n\n\t\t\tinner.width( width ).height( height );\n\n\t\t\twrap.width( width + wPadding );\n\n\t\t\twidth_ = wrap.width();\n\t\t\theight_ = wrap.height();\n\n\t\t\tcanShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;\n\t\t\tcanExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));\n\n\t\t\t$.extend(current, {\n\t\t\t\tdim : {\n\t\t\t\t\twidth\t: getValue( width_ ),\n\t\t\t\t\theight\t: getValue( height_ )\n\t\t\t\t},\n\t\t\t\torigWidth : origWidth,\n\t\t\t\torigHeight : origHeight,\n\t\t\t\tcanShrink : canShrink,\n\t\t\t\tcanExpand : canExpand,\n\t\t\t\twPadding : wPadding,\n\t\t\t\thPadding : hPadding,\n\t\t\t\twrapSpace : height_ - skin.outerHeight(true),\n\t\t\t\tskinSpace : skin.height() - height\n\t\t\t});\n\n\t\t\tif (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {\n\t\t\t\tinner.height('auto');\n\t\t\t}\n\t\t},\n\n\t\t_getPosition: function (onlyAbsolute) {\n\t\t\tvar current = F.current,\n\t\t\t\tviewport = F.getViewport(),\n\t\t\t\tmargin = current.margin,\n\t\t\t\twidth = F.wrap.width() + margin[1] + margin[3],\n\t\t\t\theight = F.wrap.height() + margin[0] + margin[2],\n\t\t\t\trez = {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\ttop : margin[0],\n\t\t\t\t\tleft : margin[3]\n\t\t\t\t};\n\n\t\t\tif (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {\n\t\t\t\trez.position = 'fixed';\n\n\t\t\t} else if (!current.locked) {\n\t\t\t\trez.top += viewport.y;\n\t\t\t\trez.left += viewport.x;\n\t\t\t}\n\n\t\t\trez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));\n\t\t\trez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));\n\n\t\t\treturn rez;\n\t\t},\n\n\t\t_afterZoomIn: function () {\n\t\t\tvar current = F.current;\n\n\t\t\tif (!current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tF.isOpen = F.isOpened = true;\n\n\t\t\tF.wrap.css('overflow', 'visible').addClass('fancybox-opened');\n\n\t\t\tF.update();\n\n\t\t\t// Assign a click event\n\t\t\tif ( current.closeClick || (current.nextClick && F.group.length > 1) ) {\n\t\t\t\tF.inner.css('cursor', 'pointer').bind('click.fb', function(e) {\n\t\t\t\t\tif (!$(e.target).is('a') && !$(e.target).parent().is('a')) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\tF[ current.closeClick ? 'close' : 'next' ]();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Create a close button\n\t\t\tif (current.closeBtn) {\n\t\t\t\t$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tF.close();\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Create navigation arrows\n\t\t\tif (current.arrows && F.group.length > 1) {\n\t\t\t\tif (current.loop || current.index > 0) {\n\t\t\t\t\t$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);\n\t\t\t\t}\n\n\t\t\t\tif (current.loop || current.index < F.group.length - 1) {\n\t\t\t\t\t$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tF.trigger('afterShow');\n\n\t\t\t// Stop the slideshow if this is the last item\n\t\t\tif (!current.loop && current.index === current.group.length - 1) {\n\t\t\t\tF.play( false );\n\n\t\t\t} else if (F.opts.autoPlay && !F.player.isActive) {\n\t\t\t\tF.opts.autoPlay = false;\n\n\t\t\t\tF.play();\n\t\t\t}\n\t\t},\n\n\t\t_afterZoomOut: function ( obj ) {\n\t\t\tobj = obj || F.current;\n\n\t\t\t$('.fancybox-wrap').trigger('onReset').remove();\n\n\t\t\t$.extend(F, {\n\t\t\t\tgroup : {},\n\t\t\t\topts : {},\n\t\t\t\trouter : false,\n\t\t\t\tcurrent : null,\n\t\t\t\tisActive : false,\n\t\t\t\tisOpened : false,\n\t\t\t\tisOpen : false,\n\t\t\t\tisClosing : false,\n\t\t\t\twrap : null,\n\t\t\t\tskin : null,\n\t\t\t\touter : null,\n\t\t\t\tinner : null\n\t\t\t});\n\n\t\t\tF.trigger('afterClose', obj);\n\t\t}\n\t});\n\n\t/*\n\t *\tDefault transitions\n\t */\n\n\tF.transitions = {\n\t\tgetOrigPosition: function () {\n\t\t\tvar current = F.current,\n\t\t\t\telement = current.element,\n\t\t\t\torig = current.orig,\n\t\t\t\tpos = {},\n\t\t\t\twidth = 50,\n\t\t\t\theight = 50,\n\t\t\t\thPadding = current.hPadding,\n\t\t\t\twPadding = current.wPadding,\n\t\t\t\tviewport = F.getViewport();\n\n\t\t\tif (!orig && current.isDom && element.is(':visible')) {\n\t\t\t\torig = element.find('img:first');\n\n\t\t\t\tif (!orig.length) {\n\t\t\t\t\torig = element;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isQuery(orig)) {\n\t\t\t\tpos = orig.offset();\n\n\t\t\t\tif (orig.is('img')) {\n\t\t\t\t\twidth = orig.outerWidth();\n\t\t\t\t\theight = orig.outerHeight();\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tpos.top = viewport.y + (viewport.h - height) * current.topRatio;\n\t\t\t\tpos.left = viewport.x + (viewport.w - width) * current.leftRatio;\n\t\t\t}\n\n\t\t\tif (F.wrap.css('position') === 'fixed' || current.locked) {\n\t\t\t\tpos.top -= viewport.y;\n\t\t\t\tpos.left -= viewport.x;\n\t\t\t}\n\n\t\t\tpos = {\n\t\t\t\ttop : getValue(pos.top - hPadding * current.topRatio),\n\t\t\t\tleft : getValue(pos.left - wPadding * current.leftRatio),\n\t\t\t\twidth : getValue(width + wPadding),\n\t\t\t\theight : getValue(height + hPadding)\n\t\t\t};\n\n\t\t\treturn pos;\n\t\t},\n\n\t\tstep: function (now, fx) {\n\t\t\tvar ratio,\n\t\t\t\tpadding,\n\t\t\t\tvalue,\n\t\t\t\tprop = fx.prop,\n\t\t\t\tcurrent = F.current,\n\t\t\t\twrapSpace = current.wrapSpace,\n\t\t\t\tskinSpace = current.skinSpace;\n\n\t\t\tif (prop === 'width' || prop === 'height') {\n\t\t\t\tratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);\n\n\t\t\t\tif (F.isClosing) {\n\t\t\t\t\tratio = 1 - ratio;\n\t\t\t\t}\n\n\t\t\t\tpadding = prop === 'width' ? current.wPadding : current.hPadding;\n\t\t\t\tvalue = now - padding;\n\n\t\t\t\tF.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );\n\t\t\t\tF.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );\n\t\t\t}\n\t\t},\n\n\t\tzoomIn: function () {\n\t\t\tvar current = F.current,\n\t\t\t\tstartPos = current.pos,\n\t\t\t\teffect = current.openEffect,\n\t\t\t\telastic = effect === 'elastic',\n\t\t\t\tendPos = $.extend({opacity : 1}, startPos);\n\n\t\t\t// Remove \"position\" property that breaks older IE\n\t\t\tdelete endPos.position;\n\n\t\t\tif (elastic) {\n\t\t\t\tstartPos = this.getOrigPosition();\n\n\t\t\t\tif (current.openOpacity) {\n\t\t\t\t\tstartPos.opacity = 0.1;\n\t\t\t\t}\n\n\t\t\t} else if (effect === 'fade') {\n\t\t\t\tstartPos.opacity = 0.1;\n\t\t\t}\n\n\t\t\tF.wrap.css(startPos).animate(endPos, {\n\t\t\t\tduration : effect === 'none' ? 0 : current.openSpeed,\n\t\t\t\teasing : current.openEasing,\n\t\t\t\tstep : elastic ? this.step : null,\n\t\t\t\tcomplete : F._afterZoomIn\n\t\t\t});\n\t\t},\n\n\t\tzoomOut: function () {\n\t\t\tvar current = F.current,\n\t\t\t\teffect = current.closeEffect,\n\t\t\t\telastic = effect === 'elastic',\n\t\t\t\tendPos = {opacity : 0.1};\n\n\t\t\tif (elastic) {\n\t\t\t\tendPos = this.getOrigPosition();\n\n\t\t\t\tif (current.closeOpacity) {\n\t\t\t\t\tendPos.opacity = 0.1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tF.wrap.animate(endPos, {\n\t\t\t\tduration : effect === 'none' ? 0 : current.closeSpeed,\n\t\t\t\teasing : current.closeEasing,\n\t\t\t\tstep : elastic ? this.step : null,\n\t\t\t\tcomplete : F._afterZoomOut\n\t\t\t});\n\t\t},\n\n\t\tchangeIn: function () {\n\t\t\tvar current = F.current,\n\t\t\t\teffect = current.nextEffect,\n\t\t\t\tstartPos = current.pos,\n\t\t\t\tendPos = { opacity : 1 },\n\t\t\t\tdirection = F.direction,\n\t\t\t\tdistance = 200,\n\t\t\t\tfield;\n\n\t\t\tstartPos.opacity = 0.1;\n\n\t\t\tif (effect === 'elastic') {\n\t\t\t\tfield = direction === 'down' || direction === 'up' ? 'top' : 'left';\n\n\t\t\t\tif (direction === 'down' || direction === 'right') {\n\t\t\t\t\tstartPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);\n\t\t\t\t\tendPos[ field ] = '+=' + distance + 'px';\n\n\t\t\t\t} else {\n\t\t\t\t\tstartPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);\n\t\t\t\t\tendPos[ field ] = '-=' + distance + 'px';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Workaround for http://bugs.jquery.com/ticket/12273\n\t\t\tif (effect === 'none') {\n\t\t\t\tF._afterZoomIn();\n\n\t\t\t} else {\n\t\t\t\tF.wrap.css(startPos).animate(endPos, {\n\t\t\t\t\tduration : current.nextSpeed,\n\t\t\t\t\teasing : current.nextEasing,\n\t\t\t\t\tcomplete : F._afterZoomIn\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\tchangeOut: function () {\n\t\t\tvar previous = F.previous,\n\t\t\t\teffect = previous.prevEffect,\n\t\t\t\tendPos = { opacity : 0.1 },\n\t\t\t\tdirection = F.direction,\n\t\t\t\tdistance = 200;\n\n\t\t\tif (effect === 'elastic') {\n\t\t\t\tendPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';\n\t\t\t}\n\n\t\t\tprevious.wrap.animate(endPos, {\n\t\t\t\tduration : effect === 'none' ? 0 : previous.prevSpeed,\n\t\t\t\teasing : previous.prevEasing,\n\t\t\t\tcomplete : function () {\n\t\t\t\t\t$(this).trigger('onReset').remove();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t/*\n\t *\tOverlay helper\n\t */\n\n\tF.helpers.overlay = {\n\t\tdefaults : {\n\t\t\tcloseClick : true, // if true, fancyBox will be closed when user clicks on the overlay\n\t\t\tspeedOut : 200, // duration of fadeOut animation\n\t\t\tshowEarly : true, // indicates if should be opened immediately or wait until the content is ready\n\t\t\tcss : {}, // custom CSS properties\n\t\t\tlocked : !isTouch, // if true, the content will be locked into overlay\n\t\t\tfixed : true // if false, the overlay CSS position property will not be set to \"fixed\"\n\t\t},\n\n\t\toverlay : null, // current handle\n\t\tfixed : false, // indicates if the overlay has position \"fixed\"\n\t\tel : $('html'), // element that contains \"the lock\"\n\n\t\t// Public methods\n\t\tcreate : function(opts) {\n\t\t\topts = $.extend({}, this.defaults, opts);\n\n\t\t\tif (this.overlay) {\n\t\t\t\tthis.close();\n\t\t\t}\n\n\t\t\tthis.overlay = $('
').appendTo( F.coming ? F.coming.parent : opts.parent );\n\t\t\tthis.fixed = false;\n\n\t\t\tif (opts.fixed && F.defaults.fixed) {\n\t\t\t\tthis.overlay.addClass('fancybox-overlay-fixed');\n\n\t\t\t\tthis.fixed = true;\n\t\t\t}\n\t\t},\n\n\t\topen : function(opts) {\n\t\t\tvar that = this;\n\n\t\t\topts = $.extend({}, this.defaults, opts);\n\n\t\t\tif (this.overlay) {\n\t\t\t\tthis.overlay.unbind('.overlay').width('auto').height('auto');\n\n\t\t\t} else {\n\t\t\t\tthis.create(opts);\n\t\t\t}\n\n\t\t\tif (!this.fixed) {\n\t\t\t\tW.bind('resize.overlay', $.proxy( this.update, this) );\n\n\t\t\t\tthis.update();\n\t\t\t}\n\n\t\t\tif (opts.closeClick) {\n\t\t\t\tthis.overlay.bind('click.overlay', function(e) {\n\t\t\t\t\tif ($(e.target).hasClass('fancybox-overlay')) {\n\t\t\t\t\t\tif (F.isActive) {\n\t\t\t\t\t\t\tF.close();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthat.close();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.overlay.css( opts.css ).show();\n\t\t},\n\n\t\tclose : function() {\n\t\t\tvar scrollV, scrollH;\n\n\t\t\tW.unbind('resize.overlay');\n\n\t\t\tif (this.el.hasClass('fancybox-lock')) {\n\t\t\t\t$('.fancybox-margin').removeClass('fancybox-margin');\n\n\t\t\t\tscrollV = W.scrollTop();\n\t\t\t\tscrollH = W.scrollLeft();\n\n\t\t\t\tthis.el.removeClass('fancybox-lock');\n\n\t\t\t\tW.scrollTop( scrollV ).scrollLeft( scrollH );\n\t\t\t}\n\n\t\t\t$('.fancybox-overlay').remove().hide();\n\n\t\t\t$.extend(this, {\n\t\t\t\toverlay : null,\n\t\t\t\tfixed : false\n\t\t\t});\n\t\t},\n\n\t\t// Private, callbacks\n\n\t\tupdate : function () {\n\t\t\tvar width = '100%', offsetWidth;\n\n\t\t\t// Reset width/height so it will not mess\n\t\t\tthis.overlay.width(width).height('100%');\n\n\t\t\t// jQuery does not return reliable result for IE\n\t\t\tif (IE) {\n\t\t\t\toffsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);\n\n\t\t\t\tif (D.width() > offsetWidth) {\n\t\t\t\t\twidth = D.width();\n\t\t\t\t}\n\n\t\t\t} else if (D.width() > W.width()) {\n\t\t\t\twidth = D.width();\n\t\t\t}\n\n\t\t\tthis.overlay.width(width).height(D.height());\n\t\t},\n\n\t\t// This is where we can manipulate DOM, because later it would cause iframes to reload\n\t\tonReady : function (opts, obj) {\n\t\t\tvar overlay = this.overlay;\n\n\t\t\t$('.fancybox-overlay').stop(true, true);\n\n\t\t\tif (!overlay) {\n\t\t\t\tthis.create(opts);\n\t\t\t}\n\n\t\t\tif (opts.locked && this.fixed && obj.fixed) {\n\t\t\t\tif (!overlay) {\n\t\t\t\t\tthis.margin = D.height() > W.height() ? $('html').css('margin-right').replace(\"px\", \"\") : false;\n\t\t\t\t}\n\n\t\t\t\tobj.locked = this.overlay.append( obj.wrap );\n\t\t\t\tobj.fixed = false;\n\t\t\t}\n\n\t\t\tif (opts.showEarly === true) {\n\t\t\t\tthis.beforeShow.apply(this, arguments);\n\t\t\t}\n\t\t},\n\n\t\tbeforeShow : function(opts, obj) {\n\t\t\tvar scrollV, scrollH;\n\n\t\t\tif (obj.locked) {\n\t\t\t\tif (this.margin !== false) {\n\t\t\t\t\t$('*').filter(function(){\n\t\t\t\t\t\treturn ($(this).css('position') === 'fixed' && !$(this).hasClass(\"fancybox-overlay\") && !$(this).hasClass(\"fancybox-wrap\") );\n\t\t\t\t\t}).addClass('fancybox-margin');\n\n\t\t\t\t\tthis.el.addClass('fancybox-margin');\n\t\t\t\t}\n\n\t\t\t\tscrollV = W.scrollTop();\n\t\t\t\tscrollH = W.scrollLeft();\n\n\t\t\t\tthis.el.addClass('fancybox-lock');\n\n\t\t\t\tW.scrollTop( scrollV ).scrollLeft( scrollH );\n\t\t\t}\n\n\t\t\tthis.open(opts);\n\t\t},\n\n\t\tonUpdate : function() {\n\t\t\tif (!this.fixed) {\n\t\t\t\tthis.update();\n\t\t\t}\n\t\t},\n\n\t\tafterClose: function (opts) {\n\t\t\t// Remove overlay if exists and fancyBox is not opening\n\t\t\t// (e.g., it is not being open using afterClose callback)\n\t\t\t//if (this.overlay && !F.isActive) {\n\t\t\tif (this.overlay && !F.coming) {\n\t\t\t\tthis.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));\n\t\t\t}\n\t\t}\n\t};\n\n\t/*\n\t *\tTitle helper\n\t */\n\n\tF.helpers.title = {\n\t\tdefaults : {\n\t\t\ttype : 'float', // 'float', 'inside', 'outside' or 'over',\n\t\t\tposition : 'bottom' // 'top' or 'bottom'\n\t\t},\n\n\t\tbeforeShow: function (opts) {\n\t\t\tvar current = F.current,\n\t\t\t\ttext = current.title,\n\t\t\t\ttype = opts.type,\n\t\t\t\ttitle,\n\t\t\t\ttarget;\n\n\t\t\tif ($.isFunction(text)) {\n\t\t\t\ttext = text.call(current.element, current);\n\t\t\t}\n\n\t\t\tif (!isString(text) || $.trim(text) === '') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttitle = $('
' + text + '
');\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'inside':\n\t\t\t\t\ttarget = F.skin;\n\t\t\t\tbreak;\n\n\t\t\t\tcase 'outside':\n\t\t\t\t\ttarget = F.wrap;\n\t\t\t\tbreak;\n\n\t\t\t\tcase 'over':\n\t\t\t\t\ttarget = F.inner;\n\t\t\t\tbreak;\n\n\t\t\t\tdefault: // 'float'\n\t\t\t\t\ttarget = F.skin;\n\n\t\t\t\t\ttitle.appendTo('body');\n\n\t\t\t\t\tif (IE) {\n\t\t\t\t\t\ttitle.width( title.width() );\n\t\t\t\t\t}\n\n\t\t\t\t\ttitle.wrapInner('');\n\n\t\t\t\t\t//Increase bottom margin so this title will also fit into viewport\n\t\t\t\t\tF.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\ttitle[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);\n\t\t}\n\t};\n\n\t// jQuery plugin initialization\n\t$.fn.fancybox = function (options) {\n\t\tvar index,\n\t\t\tthat = $(this),\n\t\t\tselector = this.selector || '',\n\t\t\trun = function(e) {\n\t\t\t\tvar what = $(this).blur(), idx = index, relType, relVal;\n\n\t\t\t\tif (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {\n\t\t\t\t\trelType = options.groupAttr || 'data-fancybox-group';\n\t\t\t\t\trelVal = what.attr(relType);\n\n\t\t\t\t\tif (!relVal) {\n\t\t\t\t\t\trelType = 'rel';\n\t\t\t\t\t\trelVal = what.get(0)[ relType ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (relVal && relVal !== '' && relVal !== 'nofollow') {\n\t\t\t\t\t\twhat = selector.length ? $(selector) : that;\n\t\t\t\t\t\twhat = what.filter('[' + relType + '=\"' + relVal + '\"]');\n\t\t\t\t\t\tidx = what.index(this);\n\t\t\t\t\t}\n\n\t\t\t\t\toptions.index = idx;\n\n\t\t\t\t\t// Stop an event from bubbling if everything is fine\n\t\t\t\t\tif (F.open(what, options) !== false) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\toptions = options || {};\n\t\tindex = options.index || 0;\n\n\t\tif (!selector || options.live === false) {\n\t\t\tthat.unbind('click.fb-start').bind('click.fb-start', run);\n\n\t\t} else {\n\t\t\tD.undelegate(selector, 'click.fb-start').delegate(selector + \":not('.fancybox-item, .fancybox-nav')\", 'click.fb-start', run);\n\t\t}\n\n\t\tthis.filter('[data-fancybox-start=1]').trigger('click');\n\n\t\treturn this;\n\t};\n\n\t// Tests that need a body at doc ready\n\tD.ready(function() {\n\t\tvar w1, w2;\n\n\t\tif ( $.scrollbarWidth === undefined ) {\n\t\t\t// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth\n\t\t\t$.scrollbarWidth = function() {\n\t\t\t\tvar parent = $('
').appendTo('body'),\n\t\t\t\t\tchild = parent.children(),\n\t\t\t\t\twidth = child.innerWidth() - child.height( 99 ).innerWidth();\n\n\t\t\t\tparent.remove();\n\n\t\t\t\treturn width;\n\t\t\t};\n\t\t}\n\n\t\tif ( $.support.fixedPosition === undefined ) {\n\t\t\t$.support.fixedPosition = (function() {\n\t\t\t\tvar elem = $('
').appendTo('body'),\n\t\t\t\t\tfixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );\n\n\t\t\t\telem.remove();\n\n\t\t\t\treturn fixed;\n\t\t\t}());\n\t\t}\n\n\t\t$.extend(F.defaults, {\n\t\t\tscrollbarWidth : $.scrollbarWidth(),\n\t\t\tfixed : $.support.fixedPosition,\n\t\t\tparent : $('body')\n\t\t});\n\n\t\t//Get real width of page scroll-bar\n\t\tw1 = $(window).width();\n\n\t\tH.addClass('fancybox-lock-test');\n\n\t\tw2 = $(window).width();\n\n\t\tH.removeClass('fancybox-lock-test');\n\n\t\t$(\"\").appendTo(\"head\");\n\t});\n\n}(window, document, jQuery));"],"file":"scriptsCommonExtended-cf4dbda83b.js"}