@gamelearn/arcade-components 3.32.6 → 3.32.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,7 @@ object-assign
63
63
  */var objectAssign,hasRequiredObjectAssign;function requireObjectAssign(){if(hasRequiredObjectAssign)return objectAssign;hasRequiredObjectAssign=1;var l=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function t(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function a(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var d={},h=0;h<10;h++)d["_"+String.fromCharCode(h)]=h;var f=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(f.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(p){u[p]=p}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return objectAssign=a()?Object.assign:function(o,d){for(var h,f=t(o),u,p=1;p<arguments.length;p++){h=Object(arguments[p]);for(var _ in h)e.call(h,_)&&(f[_]=h[_]);if(l){u=l(h);for(var R=0;R<u.length;R++)n.call(h,u[R])&&(f[u[R]]=h[u[R]])}}return f},objectAssign}var ReactPropTypesSecret_1,hasRequiredReactPropTypesSecret;function requireReactPropTypesSecret(){if(hasRequiredReactPropTypesSecret)return ReactPropTypesSecret_1;hasRequiredReactPropTypesSecret=1;var l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1=l,ReactPropTypesSecret_1}var checkPropTypes_1,hasRequiredCheckPropTypes;function requireCheckPropTypes(){if(hasRequiredCheckPropTypes)return checkPropTypes_1;hasRequiredCheckPropTypes=1;var l=function(){};if(process.env.NODE_ENV!=="production"){var e=requireReactPropTypesSecret(),n={},t=Function.call.bind(Object.prototype.hasOwnProperty);l=function(o){var d="Warning: "+o;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function a(o,d,h,f,u){if(process.env.NODE_ENV!=="production"){for(var p in o)if(t(o,p)){var _;try{if(typeof o[p]!="function"){var R=Error((f||"React class")+": "+h+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[p]+"`.");throw R.name="Invariant Violation",R}_=o[p](d,p,f,h,null,e)}catch(S){_=S}if(_&&!(_ instanceof Error)&&l((f||"React class")+": type specification of "+h+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof _+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),_ instanceof Error&&!(_.message in n)){n[_.message]=!0;var x=u?u():"";l("Failed "+h+" type: "+_.message+(x??""))}}}}return a.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},checkPropTypes_1=a,checkPropTypes_1}var factoryWithTypeCheckers,hasRequiredFactoryWithTypeCheckers;function requireFactoryWithTypeCheckers(){if(hasRequiredFactoryWithTypeCheckers)return factoryWithTypeCheckers;hasRequiredFactoryWithTypeCheckers=1;var l=requireReactIs(),e=requireObjectAssign(),n=requireReactPropTypesSecret(),t=requireCheckPropTypes(),a=Function.call.bind(Object.prototype.hasOwnProperty),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(h){var f="Warning: "+h;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function d(){return null}return factoryWithTypeCheckers=function(h,f){var u=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function _(K){var ne=K&&(u&&K[u]||K[p]);if(typeof ne=="function")return ne}var R="<<anonymous>>",x={array:b("array"),bool:b("boolean"),func:b("function"),number:b("number"),object:b("object"),string:b("string"),symbol:b("symbol"),any:T(),arrayOf:y,element:w(),elementType:C(),instanceOf:D,node:F(),objectOf:P,oneOf:N,oneOfType:k,shape:M,exact:j};function S(K,ne){return K===ne?K!==0||1/K===1/ne:K!==K&&ne!==ne}function g(K){this.message=K,this.stack=""}g.prototype=Error.prototype;function v(K){if(process.env.NODE_ENV!=="production")var ne={},ue=0;function me(H,W,V,z,Y,ie,le){if(z=z||R,ie=ie||V,le!==n){if(f){var fe=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw fe.name="Invariant Violation",fe}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ce=z+":"+V;!ne[ce]&&ue<3&&(o("You are manually calling a React.PropTypes validation function for the `"+ie+"` prop on `"+z+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),ne[ce]=!0,ue++)}}return W[V]==null?H?W[V]===null?new g("The "+Y+" `"+ie+"` is marked as required "+("in `"+z+"`, but its value is `null`.")):new g("The "+Y+" `"+ie+"` is marked as required in "+("`"+z+"`, but its value is `undefined`.")):null:K(W,V,z,Y,ie)}var J=me.bind(null,!1);return J.isRequired=me.bind(null,!0),J}function b(K){function ne(ue,me,J,H,W,V){var z=ue[me],Y=X(z);if(Y!==K){var ie=re(z);return new g("Invalid "+H+" `"+W+"` of type "+("`"+ie+"` supplied to `"+J+"`, expected ")+("`"+K+"`."))}return null}return v(ne)}function T(){return v(d)}function y(K){function ne(ue,me,J,H,W){if(typeof K!="function")return new g("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var V=ue[me];if(!Array.isArray(V)){var z=X(V);return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected an array."))}for(var Y=0;Y<V.length;Y++){var ie=K(V,Y,J,H,W+"["+Y+"]",n);if(ie instanceof Error)return ie}return null}return v(ne)}function w(){function K(ne,ue,me,J,H){var W=ne[ue];if(!h(W)){var V=X(W);return new g("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+me+"`, expected a single ReactElement."))}return null}return v(K)}function C(){function K(ne,ue,me,J,H){var W=ne[ue];if(!l.isValidElementType(W)){var V=X(W);return new g("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+me+"`, expected a single ReactElement type."))}return null}return v(K)}function D(K){function ne(ue,me,J,H,W){if(!(ue[me]instanceof K)){var V=K.name||R,z=ee(ue[me]);return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected ")+("instance of `"+V+"`."))}return null}return v(ne)}function N(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),d;function ne(ue,me,J,H,W){for(var V=ue[me],z=0;z<K.length;z++)if(S(V,K[z]))return null;var Y=JSON.stringify(K,function(le,fe){var ce=re(fe);return ce==="symbol"?String(fe):fe});return new g("Invalid "+H+" `"+W+"` of value `"+String(V)+"` "+("supplied to `"+J+"`, expected one of "+Y+"."))}return v(ne)}function P(K){function ne(ue,me,J,H,W){if(typeof K!="function")return new g("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var V=ue[me],z=X(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected an object."));for(var Y in V)if(a(V,Y)){var ie=K(V,Y,J,H,W+"."+Y,n);if(ie instanceof Error)return ie}return null}return v(ne)}function k(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var ne=0;ne<K.length;ne++){var ue=K[ne];if(typeof ue!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ae(ue)+" at index "+ne+"."),d}function me(J,H,W,V,z){for(var Y=0;Y<K.length;Y++){var ie=K[Y];if(ie(J,H,W,V,z,n)==null)return null}return new g("Invalid "+V+" `"+z+"` supplied to "+("`"+W+"`."))}return v(me)}function F(){function K(ne,ue,me,J,H){return $(ne[ue])?null:new g("Invalid "+J+" `"+H+"` supplied to "+("`"+me+"`, expected a ReactNode."))}return v(K)}function M(K){function ne(ue,me,J,H,W){var V=ue[me],z=X(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+J+"`, expected `object`."));for(var Y in K){var ie=K[Y];if(ie){var le=ie(V,Y,J,H,W+"."+Y,n);if(le)return le}}return null}return v(ne)}function j(K){function ne(ue,me,J,H,W){var V=ue[me],z=X(V);if(z!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+J+"`, expected `object`."));var Y=e({},ue[me],K);for(var ie in Y){var le=K[ie];if(!le)return new g("Invalid "+H+" `"+W+"` key `"+ie+"` supplied to `"+J+"`.\nBad object: "+JSON.stringify(ue[me],null," ")+`
64
64
  Valid keys: `+JSON.stringify(Object.keys(K),null," "));var fe=le(V,ie,J,H,W+"."+ie,n);if(fe)return fe}return null}return v(ne)}function $(K){switch(typeof K){case"number":case"string":case"undefined":return!0;case"boolean":return!K;case"object":if(Array.isArray(K))return K.every($);if(K===null||h(K))return!0;var ne=_(K);if(ne){var ue=ne.call(K),me;if(ne!==K.entries){for(;!(me=ue.next()).done;)if(!$(me.value))return!1}else for(;!(me=ue.next()).done;){var J=me.value;if(J&&!$(J[1]))return!1}}else return!1;return!0;default:return!1}}function B(K,ne){return K==="symbol"?!0:ne?ne["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&ne instanceof Symbol:!1}function X(K){var ne=typeof K;return Array.isArray(K)?"array":K instanceof RegExp?"object":B(ne,K)?"symbol":ne}function re(K){if(typeof K>"u"||K===null)return""+K;var ne=X(K);if(ne==="object"){if(K instanceof Date)return"date";if(K instanceof RegExp)return"regexp"}return ne}function ae(K){var ne=re(K);switch(ne){case"array":case"object":return"an "+ne;case"boolean":case"date":case"regexp":return"a "+ne;default:return ne}}function ee(K){return!K.constructor||!K.constructor.name?R:K.constructor.name}return x.checkPropTypes=t,x.resetWarningCache=t.resetWarningCache,x.PropTypes=x,x},factoryWithTypeCheckers}var factoryWithThrowingShims,hasRequiredFactoryWithThrowingShims;function requireFactoryWithThrowingShims(){if(hasRequiredFactoryWithThrowingShims)return factoryWithThrowingShims;hasRequiredFactoryWithThrowingShims=1;var l=requireReactPropTypesSecret();function e(){}function n(){}return n.resetWarningCache=e,factoryWithThrowingShims=function(){function t(d,h,f,u,p,_){if(_!==l){var R=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw R.name="Invariant Violation",R}}t.isRequired=t;function a(){return t}var o={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:a,element:t,elementType:t,instanceOf:a,node:t,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:e};return o.PropTypes=o,o},factoryWithThrowingShims}if(process.env.NODE_ENV!=="production"){var ReactIs=requireReactIs(),throwOnDirectAccess=!0;propTypes.exports=requireFactoryWithTypeCheckers()(ReactIs.isElement,throwOnDirectAccess)}else propTypes.exports=requireFactoryWithThrowingShims()();var propTypesExports=propTypes.exports;const PropTypes=getDefaultExportFromCjs(propTypesExports);function BufferBar({time:l,setTimePoint:e,mandatory:n,mandatoryHasBeenViewed:t,viewed:a}){const o=Math.trunc(l.current*1e3/l.duration)/10,d=React$2.useRef(),[h,f]=React$2.useState(!1),u=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),p=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),_=(g,v)=>{f(!0);let b=g.offsetX;g.changedTouches&&(b=g.changedTouches[0].clientX);const T=v.offsetWidth+v.offsetLeft;b<=T&&b>=v.offsetLeft&&e(b,v.offsetWidth,v.offsetLeft)},R=()=>{window.onmousemove=null,window.onmouseup=null,f(!1)},x=g=>{window.onmousemove=v=>_(v,g),window.onmouseup=v=>R()},S=(g,v)=>{(!n||n&&t||a)&&(g.preventDefault(),e(g.clientX,v.offsetWidth,v.offsetLeft),x(v),f(!0))};return jsxRuntimeExports.jsx("div",{id:"buffer",ref:d,className:"video--controls__bar",onMouseDown:g=>{const v=d.current;S(g,v)},onTouchMove:g=>{const v=d.current;_(g,v)},onTouchStart:g=>{const v=d.current;f(!0),e(g.changedTouches[0].clientX,v.offsetWidth,v.offsetLeft)},children:jsxRuntimeExports.jsx("div",{className:"video--controls__progress",style:{width:`${o}%`},children:jsxRuntimeExports.jsx("span",{className:h?"video--controls__handle active":"video--controls__handle",children:h?jsxRuntimeExports.jsxs("div",{className:"video--current__time active",children:[u,":",p]}):null})})})}BufferBar.defaultProps={time:{current:0,duration:0},setTimePoint:()=>{}};BufferBar.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number}),setTimePoint:PropTypes.func};function Timer({time:l}){const e=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),n=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),t=Math.trunc(l.duration/60)<10?["0",Math.trunc(l.duration/60)].join("").trim():Math.trunc(l.duration/60),a=Math.trunc(l.duration%60)<10?["0",Math.trunc(l.duration%60)].join("").trim():Math.trunc(l.duration%60);return jsxRuntimeExports.jsxs("div",{className:"video--time",children:[jsxRuntimeExports.jsxs("span",{className:"time",children:[e,":",n]}),jsxRuntimeExports.jsxs("span",{className:"duration",children:[t,":",a]})]})}Timer.defaultProps={time:{current:0,duration:0}};Timer.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};function ControlButtons({pauseVideo:l,paused:e,translate:n}){return jsxRuntimeExports.jsx("div",{className:"video--controls__buttons",children:jsxRuntimeExports.jsx("button",{id:"playPause","aria-label":n(e?"storylines.misc.play":"storylines.misc.pause"),className:e?"unset-button icon-play":"unset-button icon-pause",type:"button",onClick:()=>{l(),document.querySelector("#playPause").blur()}})})}ControlButtons.defaultProps={paused:!1,pauseVideo:()=>{}};function FinishedVideoButtons({restart:l,translate:e}){return jsxRuntimeExports.jsx("div",{className:"video--extra__actions video--extra__actions--widthTransparencyLayer position--absolute z-index1",children:jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>{l()},className:"gat--btn gat--btn__secondary","aria-label":e("video.replay"),children:[jsxRuntimeExports.jsx("span",{className:"icon-rewind"}),jsxRuntimeExports.jsx("span",{id:"video.replay"})]})})}FinishedVideoButtons.defaultProps={restart:()=>{},finished:!1};function PlayInitButton({play:l,finished:e,paused:n}){return e||!n?jsxRuntimeExports.jsx("div",{}):jsxRuntimeExports.jsx("div",{className:"video--extra__actions position--absolute z-index1",children:jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":"play video",onKeyUp:()=>{},onClick:()=>{l()},className:"play--video__button",children:jsxRuntimeExports.jsx("span",{className:"icon-play-outline"})})})}PlayInitButton.defaultProps={play:()=>{},finished:!1,paused:!1};function skipButton({viewed:l,mandatory:e,finished:n,skip:t,mandatoryHasBeenViewed:a,translate:o}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e&&l||!e||n||a?jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{className:"gat--btn__round gat--btn__close",type:"button","aria-label":o("storylines.misc.closePiece"),onKeyUp:()=>{},onClick:()=>{t()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}):null})}skipButton.defaultProps={mandatory:!1,viewed:!1,finished:!1,skip:()=>{}};function VolumeBar({volume:l,muted:e,setVolume:n,mute:t}){const a=React$2.useRef(),o=e?0:Math.floor(l*100),d=(p,_)=>{const R=_.offsetWidth+_.offsetLeft;let x=p.clientX;p.changedTouches&&(x=p.changedTouches[0].clientX),x<=R&&x>=_.offsetLeft&&n(x,_.offsetWidth,_.offsetLeft)},h=()=>{window.onmousemove=null,window.onmouseup=null},f=p=>{window.onmousemove=_=>d(_,p),window.onmouseup=_=>h()},u=(p,_)=>{p.preventDefault(),n(p.clientX,_.offsetWidth,_.offsetLeft),f(_)};return jsxRuntimeExports.jsxs("div",{className:"video--sound",children:[jsxRuntimeExports.jsx("span",{onClick:()=>t(),className:o===0?"icon-sound-off":"icon-sound"}),jsxRuntimeExports.jsx("div",{ref:a,onMouseDown:p=>{const _=a.current;u(p,_)},onTouchMove:p=>{const _=a.current;d(p,_)},onTouchStart:p=>{const _=a.current;n(p.changedTouches[0].clientX,_.offsetWidth,_.offsetLeft)},id:"volume",className:"video--sound__level",children:jsxRuntimeExports.jsx("span",{style:{width:`${o<10?10:o}%`},className:"video--sound__progress",children:jsxRuntimeExports.jsx("span",{className:"video--handle"})})})]})}VolumeBar.defaultProps={volume:0,muted:!1,setVolume:()=>{},mute:()=>{}};VolumeBar.propTypes={volume:PropTypes.number,setVolume:PropTypes.func,mute:PropTypes.func,muted:PropTypes.bool};function VideoControllers({pause:l,mandatory:e,viewed:n,skip:t,rewind:a,paused:o,time:d,finished:h,restart:f,volume:u,muted:p,mute:_,setVolume:R,setTimePoint:x,audioAnimation:S,mandatoryHasBeenViewed:g,translate:v,visibility:b,withoutControls:T,documentType:y}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(skipButton,{mandatory:e,finished:h,viewed:n,skip:t,rewind:a,mandatoryHasBeenViewed:g,translate:v}),T?null:jsxRuntimeExports.jsxs("div",{className:`video--controls-wrap ${b?"video--controls-wrap--hidden":""}`,children:[S?null:jsxRuntimeExports.jsx(PlayInitButton,{play:l,paused:o,finished:h}),h&&(y==="document"||y==="lesson")?jsxRuntimeExports.jsx(FinishedVideoButtons,{restart:f,translate:v}):null,jsxRuntimeExports.jsxs("div",{className:"video--controls",children:[jsxRuntimeExports.jsx(BufferBar,{mandatory:e,mandatoryHasBeenViewed:g,time:d,setTimePoint:x,finished:h,viewed:n}),jsxRuntimeExports.jsxs("div",{className:"video--controls__actions",children:[jsxRuntimeExports.jsx(Timer,{time:d}),S?jsxRuntimeExports.jsx("div",{className:"audio-animation-wrap",children:jsxRuntimeExports.jsx("div",{className:`audio-animation ${o?"audio-animation--notAnimate ":null}`})}):null,jsxRuntimeExports.jsx(ControlButtons,{paused:o,pauseVideo:l,translate:v}),jsxRuntimeExports.jsx(VolumeBar,{muted:p,mute:_,volume:u,setVolume:R})]})]})]})]})}VideoControllers.defaultProps={audioAnimation:!1,paused:!1,mandatory:!1,viewed:!1,volume:0,muted:!1,finished:!1,restart:()=>{},pause:()=>{},skip:()=>{},rewind:()=>{},setTimePoint:()=>{},setVolume:()=>{},mute:()=>{},time:{current:0,duration:0}};VideoControllers.propTypes={audioAnimation:PropTypes.bool,paused:PropTypes.bool,mandatory:PropTypes.bool,muted:PropTypes.bool,volume:PropTypes.number,viewed:PropTypes.bool,pause:PropTypes.func,finished:PropTypes.bool,restart:PropTypes.func,skip:PropTypes.func,rewind:PropTypes.func,mute:PropTypes.func,setTimePoint:PropTypes.func,setVolume:PropTypes.func,time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};const defaultBgImageForAudio="https://min.gamelearn.io/css-resources/gamelearn/resources/bgAudioPiece.jpg";function VideoVisor({documentType:l,url:e,required:n,viewed:t,backgroundImage:a,soundActions:o,endVideo:d,translate:h,autoPlay:f,withoutControls:u}){const[p,_]=React$2.useState(!1),[R]=o,[x,S]=React$2.useState(0),[g,v]=React$2.useState(0),[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!0),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(),[k,F]=React$2.useState(0),[M,j]=React$2.useState(!1),$=e&&e.match(/\.m3u8(\?.+=.+)*$/i)&&Hls.isSupported(),B=e&&(e.match(/youtube/i)||e.match(/vimeo/i)),X=e&&(e.match(/.mp3/i)||e.match(/.ogg/i)||e.match(/.wav/i)||e.match(/.m4a/i)),re={ref:ce=>{P(ce)},src:e,style:{height:"100%",width:"100%"}},ae=()=>{n&&_(!0),T(!1),N.pause(),w(!0),D(!0),j(!1),l!=="document"&&l!=="lesson"&&d()},ee=()=>{d()},K=()=>{w(!1),T(!1)},ne=()=>{T(!0)},ue=()=>{T(!1),S(N.duration)};React$2.useEffect(()=>{let ce;if(N){if($){ce=new Hls;const ge=`${e}?v=${Math.floor(Math.random()*99999999)}`;ce.loadSource(ge),ce.attachMedia(N),ce.on(Hls.Events.FRAG_LOAD_PROGRESS,(Se,Te)=>{const{stats:Fe}=Te;v(Fe.loaded*100/Fe.total)})}return()=>{ce&&ce.destroy(),ce=null}}},[$,e,N]);const me=()=>{N.currentTime-=15},J=()=>{R("click-ui"),y?(N.play(),D(!1)):N.pause(),w(!y)},H=(ce,ge,Se)=>{D(!1),N.currentTime=ge?parseFloat((ce-Se)/ge*N.duration):0},W=()=>{D(!1),N.currentTime=0,J()},V=()=>{R("click-ui"),N.muted=!N.muted},z=(ce,ge,Se)=>{N.muted=!1;const Te=ce-Se>=0?(ce-Se)/ge:0;N.volume=Te*100>10?Te:0,F(N.volume)};React$2.useEffect(()=>{let ce;return!M&&!y&&(ce=setTimeout(()=>{j(!0),clearTimeout(ce)},3e3)),()=>clearTimeout(ce)},[M,y]);const Y=()=>{M&&j(!1)},ie=a||defaultBgImageForAudio,le=ie===defaultBgImageForAudio?"cover":"contain",fe={backgroundImage:`url("${ie}")`,backgroundSize:le,backgroundRepeat:"no-repeat",backgroundPosition:"center center"};return jsxRuntimeExports.jsx("div",{className:`video ${n&&!p&&!t?"forward-disabled":""}`,style:X?fe:null,children:B?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{type:"button","aria-label":h("storylines.misc.closePiece"),className:"gat--btn__round gat--btn__close",onClick:()=>{R("click-ui"),d()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),jsxRuntimeExports.jsx("iframe",{className:"embeddedVideo",title:"title",...re})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(VideoControllers,{documentType:l,visibility:M,mandatoryHasBeenViewed:p,audioAnimation:!!X,skip:d,mandatory:n,viewed:t,volume:N?N.volume:0,mute:V,muted:N?N.muted:!1,paused:y,finished:C,restart:W,setTimePoint:H,time:{duration:x,current:N?N.currentTime:0},rewind:me,pause:J,volumeState:k,setVolume:z,translate:h,withoutControls:u}),jsxRuntimeExports.jsx("video",{"data-testid":"video-visor-video",autoPlay:f,onMouseMove:()=>Y(),onClick:()=>{Y()},onFocus:()=>{Y()},onCanPlayThrough:ue,onWaiting:ne,onEnded:ae,onError:ee,onPlaying:K,...re,children:jsxRuntimeExports.jsx("track",{kind:"captions"})}),b?jsxRuntimeExports.jsxs("div",{className:"video-loading-container",style:{top:0,left:0},children:[jsxRuntimeExports.jsx("div",{className:"video-loading-container-bg opacity-wrapper"}),jsxRuntimeExports.jsx("div",{className:"popup-alert warning",children:jsxRuntimeExports.jsx("div",{className:"popup-message",children:jsxRuntimeExports.jsx("p",{children:Math.floor(g)})})})]}):null]})})}VideoVisor.defaultProps={url:"",name:"",backgroundImage:null,documentType:"",required:!1,viewed:!1,endVideo:()=>{}};function VideoComponent({emitEvent:l,getEvent:e,name:n,documentType:t,document:a,documentId_labelId:o,soundActions:d,required:h,viewed:f,visible:u,img:p,imgId_labelId:_,withoutControls:R,autoPlay:x,keyboardControl:S}){const g=w=>e({type:"translate",payload:w}),{url:v}=a,b=React$2.useMemo(()=>({documentId:o,imgId:_,required:h,name:n,type:"video",viewed:f,documentType:t}),[o,_,h,n,f,t]),T=React$2.useCallback(()=>{l({type:"finishMedia",payload:b})},[l,b]);React$2.useEffect(()=>{u||T()},[T,u]);const y=S({disabled:f,forward:T,escape:T});return React$2.useEffect(()=>y(),[y]),u?jsxRuntimeExports.jsx(VideoVisor,{autoPlay:x,withoutControls:R,backgroundImage:p==null?void 0:p.url,url:v,soundActions:d,documentType:t,required:h,viewed:f,endVideo:()=>T(),translate:g}):null}function ChangeCamera({targetUid:l,emitEvent:e,success:n=!0,onFinish:t=()=>{},transition:a={type:"pan",speed:10}}){const{change:o}=arcadeThreeCore.CameraControls.useStore(),d=fiber.useThree(f=>f.camera),h=React$2.useRef();return React$2.useEffect(()=>{const f=()=>{e({type:"changeCamera",payload:{targetUid:l,transition:a}}),setTimeout(()=>{n&&e({type:"success"}),t()},200)};return d.addEventListener("transitionEnd",f),()=>{d.removeEventListener("transitionEnd",f)}},[d,e,t,n,l,a]),React$2.useEffect(()=>{o&&h.current!==l&&(o(l,a),h.current=l)},[o,l,a]),null}var htmlReactParser={exports:{}},lib$4={},possibleStandardNamesOptimized$1={},SAME$1=0;possibleStandardNamesOptimized$1.SAME=SAME$1;var CAMELCASE$1=1;possibleStandardNamesOptimized$1.CAMELCASE=CAMELCASE$1;possibleStandardNamesOptimized$1.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1};Object.defineProperty(lib$4,"__esModule",{value:!0});function _slicedToArray(l,e){return _arrayWithHoles(l)||_iterableToArrayLimit(l,e)||_unsupportedIterableToArray(l,e)||_nonIterableRest()}function _arrayWithHoles(l){if(Array.isArray(l))return l}function _iterableToArrayLimit(l,e){var n=l==null?null:typeof Symbol<"u"&&l[Symbol.iterator]||l["@@iterator"];if(n!=null){var t=[],a=!0,o=!1,d,h;try{for(n=n.call(l);!(a=(d=n.next()).done)&&(t.push(d.value),!(e&&t.length===e));a=!0);}catch(f){o=!0,h=f}finally{try{!a&&n.return!=null&&n.return()}finally{if(o)throw h}}return t}}function _unsupportedIterableToArray(l,e){if(l){if(typeof l=="string")return _arrayLikeToArray(l,e);var n=Object.prototype.toString.call(l).slice(8,-1);if(n==="Object"&&l.constructor&&(n=l.constructor.name),n==="Map"||n==="Set")return Array.from(l);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(l,e)}}function _arrayLikeToArray(l,e){(e==null||e>l.length)&&(e=l.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=l[n];return t}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
65
65
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var RESERVED=0,STRING=1,BOOLEANISH_STRING=2,BOOLEAN=3,OVERLOADED_BOOLEAN=4,NUMERIC=5,POSITIVE_NUMERIC=6;function getPropertyInfo(l){return properties.hasOwnProperty(l)?properties[l]:null}function PropertyInfoRecord(l,e,n,t,a,o,d){this.acceptsBooleans=e===BOOLEANISH_STRING||e===BOOLEAN||e===OVERLOADED_BOOLEAN,this.attributeName=t,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=l,this.type=e,this.sanitizeURL=o,this.removeEmptyString=d}var properties={},reservedProps=["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"];reservedProps.forEach(function(l){properties[l]=new PropertyInfoRecord(l,RESERVED,!1,l,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var e=_slicedToArray(l,2),n=e[0],t=e[1];properties[n]=new PropertyInfoRecord(n,STRING,!1,t,null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l,null,!1,!1)});["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!1,l.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!0,l,null,!1,!1)});["capture","download"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,OVERLOADED_BOOLEAN,!1,l,null,!1,!1)});["cols","rows","size","span"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,POSITIVE_NUMERIC,!1,l,null,!1,!1)});["rowSpan","start"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,NUMERIC,!1,l.toLowerCase(),null,!1,!1)});var CAMELIZE=/[\-\:]([a-z])/g,capitalize$1=function l(e){return e[1].toUpperCase()};["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,null,!1,!1)});["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!1,!1)});var xlinkHref="xlinkHref";properties[xlinkHref]=new PropertyInfoRecord("xlinkHref",STRING,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!0,!0)});var _require=possibleStandardNamesOptimized$1,CAMELCASE=_require.CAMELCASE,SAME=_require.SAME,possibleStandardNamesOptimized=_require.possibleStandardNames,ATTRIBUTE_NAME_START_CHAR=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR=ATTRIBUTE_NAME_START_CHAR+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",isCustomAttribute=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+ATTRIBUTE_NAME_CHAR+"]*$")),possibleStandardNames=Object.keys(possibleStandardNamesOptimized).reduce(function(l,e){var n=possibleStandardNamesOptimized[e];return n===SAME?l[e]=e:n===CAMELCASE?l[e.toLowerCase()]=e:l[e]=n,l},{});lib$4.BOOLEAN=BOOLEAN;lib$4.BOOLEANISH_STRING=BOOLEANISH_STRING;lib$4.NUMERIC=NUMERIC;lib$4.OVERLOADED_BOOLEAN=OVERLOADED_BOOLEAN;lib$4.POSITIVE_NUMERIC=POSITIVE_NUMERIC;lib$4.RESERVED=RESERVED;lib$4.STRING=STRING;lib$4.getPropertyInfo=getPropertyInfo;lib$4.isCustomAttribute=isCustomAttribute;lib$4.possibleStandardNames=possibleStandardNames;var cjs={},COMMENT_REGEX=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,NEWLINE_REGEX=/\n/g,WHITESPACE_REGEX=/^\s*/,PROPERTY_REGEX=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,COLON_REGEX=/^:\s*/,VALUE_REGEX=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,SEMICOLON_REGEX=/^[;\s]*/,TRIM_REGEX=/^\s+|\s+$/g,NEWLINE=`
66
- `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var v=S.lastIndexOf(NEWLINE);t=~v?S.length-v:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var v=g[0];return a(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=_();)g!==!1&&S.push(g);return S}function _(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var v=l.slice(2,g-2);return t+=2,a(v),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:v})}}function R(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(_(),!f(COLON_REGEX))return h("property missing ':'");var v=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:v?trim(v[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function x(){var S=[];p(S);for(var g;g=R();)g!==!1&&(S.push(g),p(S));return S}return u(),x()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,_,R,x=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||x&&f)continue;d.push(h.data);continue}switch(_=h.attribs,skipAttributesToProps(h)?setStyleProp(_.style,_):_&&(_=attributesToProps$1(_)),R=null,h.type){case"script":case"style":h.children[0]&&(_.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?_.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(_.key=S),d.push(a(h.name,_,R))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,_){_===void 0&&(_=p);var R=Object.getOwnPropertyDescriptor(u,p);(!R||("get"in R?!u.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,_,R)}:function(f,u,p,_){_===void 0&&(_=p),f[_]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,_){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(_=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=_??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var _=this.options.xmlMode?t.ElementType.Tag:void 0,R=new a.Element(u,p,void 0,_);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,_=this.lastNode;if(_&&_.type===t.ElementType.Text)p?_.data=(_.data+u).replace(o," "):_.data+=u,this.options.withEndIndices&&(_.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new a.Text(u);this.addNode(R),this.lastNode=R}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var _=new a.ProcessingInstruction(u,p);this.addNode(_)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],_=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),_&&(u.prev=_,_.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onMute:p=noop$1,onError:_=noop$1,onStart:R=noop$1,pauseTTS:x})=>{const[S,g,v,b]=d,T=!o&&!l,y=React$2.useRef(),[w,C]=React$2.useState(!1),D=React$2.useRef({url:"",cc:"tts"}),N=React$2.useCallback(j=>h({type:"translate",payload:j}),[h]),P=React$2.useCallback(({id:j,type:$="base"})=>{var re;const B=N("usedVoices"),X=N("gameCharacters");return $==="base"?B==null?void 0:B[j]:$==="character"?(re=X==null?void 0:X[j])==null?void 0:re.voiceId:null},[N]),k=React$2.useCallback((j,$="tts")=>{if(D.current.url!==j)return D.current={url:j,cc:$},S(j,$,t,f,u,R,p,_)},[S,t,f,u,R,p,_]),F=React$2.useCallback(async j=>{if(w&&j.voiceId&&j.text){let $=ttsCache[`${j.voiceId}_${j.text}`];try{$||($=await h({type:"getSpeech",payload:j}),$?ttsCache[`${j.voiceId}_${j.text}`]=$:_()),$&&(y.current=k($))}catch{_()}}else _()},[h,w,_,k]),M=React$2.useCallback(()=>{D.current.url&&g(D.current.cc)},[g]);return React$2.useEffect(()=>(C(!0),()=>{C(!1),M()}),[M]),React$2.useEffect(()=>{x?v():b()},[v,x,b]),React$2.useEffect(()=>{T&&M()},[T,M]),React$2.useEffect(()=>{if(w&&a)if(n==="voice"&&(l!=null&&l.id)){const j=P(l);F({voiceId:j,text:e})}else(n==="file"||!n)&&o?y.current=k(o==null?void 0:o.url):_()},[o,n,P,w,_,F,k,a,e,l]),[y,M]},cleanTextOfHtmlTags=l=>{const e=document.createElement("div");return e.innerHTML=l,e.textContent||e.innerText||""},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:_,hideBackgroundImageTheme:R=!1,keyboardControl:x,audio:S,audioType:g,audioVolume:v,voice:b,pause:T,styles:y}){const[w,C]=React$2.useState(),[D,N]=React$2.useState(!1),[P,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),j=!a||a&&P>=M||a&&!h,[$]=p,B=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:B,audio:S,soundActions:p,getEvent:e,volume:v,pauseTTS:T});const X=J=>e({type:"translate",payload:J}),re=React$2.useCallback(()=>{j&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,j,t,d,$]),ae=x({disabled:u,forward:re,escape:re});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!D&&(re(),N(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[re,a,D,h]),React$2.useEffect(()=>{P===M&&clearInterval(w)},[w,P,M]);const ee=M-P,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",y&&(J+=` lectures--container--${y}`),_!=null&&_.url&&(J+=" lectures--container--with-custom-bg"),y&&R&&(J+=" disable-background-image")),J},[_==null?void 0:_.url,R,y,u]),me={backgroundImage:_!=null&&_.url?`url('${_.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:me,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${y}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:j,close:re,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var R;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(R=l==null?void 0:l.resource)==null?void 0:R.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",_=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:_,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(_){a&&a(_);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const _=this.pluginCallbacks[p](u);_.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[_.name]=_,d[_.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const _=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(_){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[_]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[_]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[_]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[_]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(_)>=0&&h[_]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const _=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=_;break;case"spot":u=new three.SpotLight(p),u.distance=_,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,_=a.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,_,R,a.mode,a.filter).then(function(x){return x.buffer}):d.ready.then(function(){const x=new ArrayBuffer(p*_);return d.decodeGltfBuffer(new Uint8Array(x),p,_,R,a.mode,a.filter),x})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),_=p.isGroup?p.children:[p],R=u[0].count,x=[];for(const S of _){const g=new three.Matrix4,v=new three.Vector3,b=new three.Quaternion,T=new three.Vector3(1,1,1),y=new three.InstancedMesh(S.geometry,S.material,R);for(let w=0;w<R;w++)f.TRANSLATION&&v.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&T.fromBufferAttribute(f.SCALE,w),y.setMatrixAt(w,g.compose(v,b,T));for(const w in f)if(w==="_COLOR_0"){const C=f[w];y.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(y,S),this.parser.assignFinalMaterial(y),x.push(y)}return p.isGroup?(p.clear(),p.add(...x),p):x[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const _=ATTRIBUTES[p]||p.toLowerCase();h[_]=d[p]}for(const p in e.attributes){const _=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],x=WEBGL_COMPONENT_TYPES[R.componentType];u[_]=x.name,f[_]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(_,R){a.decodeDracoFile(p,function(x){for(const S in x.attributes){const g=x.attributes[S],v=f[S];v!==void 0&&(g.normalized=v)}_(x)},h,u,three.LinearSRGBColorSpace,R)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,_=(t-n)/p,R=_*_,x=R*_,S=e*u,g=S-u,v=-2*x+3*R,b=x-R,T=1-v,y=b-R+_;for(let w=0;w!==h;w++){const C=d[g+w+h],D=d[g+w+f]*p,N=d[S+w+h],P=d[S+w]*p;o[w]=T*C+y*D+v*N+b*P}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const _=e[u];if(_.POSITION!==void 0&&(t=!0),_.NORMAL!==void 0&&(a=!0),_.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const _=e[u];if(t){const R=_.POSITION!==void 0?n.getDependency("accessor",_.POSITION):l.attributes.position;d.push(R)}if(a){const R=_.NORMAL!==void 0?n.getDependency("accessor",_.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=_.COLOR_0!==void 0?n.getDependency("accessor",_.COLOR_0):l.attributes.color;f.push(R)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],_=u[1],R=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=_),o&&(l.morphAttributes.color=R),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,_=p*f,R=a.byteOffset||0,x=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,v;if(x&&x!==_){const b=Math.floor(R/x),T="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let y=n.cache.get(T);y||(g=new u(h,b*x,a.count*x/p),y=new three.InterleavedBuffer(g,x/p),n.cache.add(T,y)),v=new three.InterleavedBufferAttribute(y,f,R%x/p,S)}else h===null?g=new u(a.count*f):g=new u(h,R,a.count*f),v=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,T=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],y=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new T(d[1],y,a.sparse.count*b),D=new u(d[2],w,a.sparse.count*f);h!==null&&(v=new three.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let N=0,P=C.length;N<P;N++){const k=C[N];if(v.setX(k,D[N*f]),f>=2&&v.setY(k,D[N*f+1]),f>=3&&v.setZ(k,D[N*f+2]),f>=4&&v.setW(k,D[N*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const R=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[R.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[R.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[R.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[R.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(_=>_.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(_){u=!0;const R=new Blob([_],{type:d.mimeType});return f=h.createObjectURL(R),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(_){return new Promise(function(R,x){let S=R;n.isImageBitmapLoader===!0&&(S=function(g){const v=new three.Texture(g);v.needsUpdate=!0,R(v)}),n.load(three.LoaderUtils.resolveURL(_,o.path),S,void 0,x)})}).then(function(_){return u===!0&&h.revokeObjectURL(f),_.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),_}).catch(function(_){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),_});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const _=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=_.getMaterialType(),u.push(_.extendParams(h,o,n))}else{const _=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(_.baseColorFactor)){const R=_.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}_.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",_.baseColorTexture,three.SRGBColorSpace)),h.metalness=_.metallicFactor!==void 0?_.metallicFactor:1,h.roughness=_.roughnessFactor!==void 0?_.roughnessFactor:1,_.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",_.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",_.metallicRoughnessTexture))),d=this._invokeOne(function(R){return R.getMaterialType&&R.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(R){return R.extendMaterialParams&&R.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const _=o.normalTexture.scale;h.normalScale.set(_,_)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const _=o.emissiveFactor;h.emissive=new three.Color().setRGB(_[0],_[1],_[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const _=new d(h);return o.name&&(_.name=o.name),assignExtrasToUserData(_,o),n.associations.set(_,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,_,o),_})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),_=a[p];if(_)d.push(_.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:R},d.push(R)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],_=[];for(let x=0,S=p.length;x<S;x++){const g=p[x],v=d[x];let b;const T=u[x];if(v.mode===WEBGL_CONSTANTS.TRIANGLES||v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||v.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,T):new three.Mesh(g,T),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(v.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,T);else if(v.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),v.extensions&&addUnknownExtensionsToUserData(a,b,v),n.assignFinalMaterial(b),_.push(b)}for(let x=0,S=_.length;x<S;x++)n.associations.set(_[x],{meshes:e,primitives:x});if(_.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,_[0],o),_[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,R,o),n.associations.set(R,{meshes:e});for(let x=0,S=_.length;x<S;x++)R.add(_[x]);return R})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const _=d[u];if(_){h.push(_);const R=new three.Matrix4;o!==null&&R.fromArray(o.array,u*16),f.push(R)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let _=0,R=a.channels.length;_<R;_++){const x=a.channels[_],S=a.samplers[x.sampler],g=x.target,v=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,T=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",v)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",T)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(_){const R=_[0],x=_[1],S=_[2],g=_[3],v=_[4],b=[];for(let T=0,y=R.length;T<y;T++){const w=R[T],C=x[T],D=S[T],N=g[T],P=v[T];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,D,N,P);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],_=u[1],R=u[2];R!==null&&p.traverse(function(x){x.isSkinnedMesh&&x.bind(R,_identityMatrix)});for(let x=0,S=_.length;x<S;x++)p.add(_[x]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let _=0,R=u.length;_<R;_++)p.add(u[_]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const _=new three.Matrix4;_.fromArray(o.matrix),p.applyMatrix4(_)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,_=f.length;p<_;p++)o.add(f[p]);const u=p=>{const _=new Map;for(const[R,x]of a.associations)(R instanceof three.Material||R instanceof three.Texture)&&_.set(R,x);return p.traverse(R=>{const x=a.associations.get(R);x!=null&&_.set(R,x)}),_};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(R){R.morphTargetInfluences&&f.push(R.name?R.name:R.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,_=this._getArrayFromAccessor(t);for(let R=0,x=f.length;R<x;R++){const S=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,_,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const _=o[u];if(_.POSITION!==void 0){const R=n.json.accessors[_.POSITION],x=R.min,S=R.max;if(x!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(x[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(x[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(x[2]),Math.abs(S[2]))),R.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[R.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t=!0,onLoad:a}){var v,b,T;const o=React$2.useRef(null),d=React$2.useRef(null),h=l.type==="character",[f,u]=React$2.useState(!1),[p,_]=React$2.useState(!1),R=React$2.useRef(),x=React$2.useMemo(()=>{var y,w,C,D,N,P,k,F;return h?l.animationId&&((y=l.animation)!=null&&y.url)?l.animation:(D=(C=(w=l==null?void 0:l.resource)==null?void 0:w.animations)==null?void 0:C[l.emotion])!=null&&D.url?(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P[l.emotion]:(F=(k=l==null?void 0:l.resource)==null?void 0:k.animations)==null?void 0:F.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(v=l==null?void 0:l.resource)==null?void 0:v.animations,h]),S=React$2.useCallback(()=>{if(R.current){const y=R.current.userData.animator;y.getAction("idle")&&y.mix("idle",.1)}},[]);React$2.useEffect(()=>{var y,w,C,D,N,P;if(n)if(e){const k=(C=(w=(y=l==null?void 0:l.resource)==null?void 0:y.animations)==null?void 0:w.talking)==null?void 0:C.url,M=((P=(N=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:N["talking-short"])==null?void 0:P.url)||k;if(M&&R.current){const j=R.current.userData.animator,$=`${M}_talking`;j.getAction($)?(j.mix($,.1),u(!0)):loader$1.load(M,({animations:B})=>{if(!R.current)return;const X=j.getAction("idle").getClip();j.register($,mixWithTalkingClip(B[0],X)),j.mix($,.1),u(!0)})}}else S();else f&&S()},[e,n,S,f,(b=l==null?void 0:l.resource)==null?void 0:b.animations]);const g=React$2.useCallback(y=>{if(l.type==="character"){const C=y.getObjectByName("Head_M",!0);C?(C.updateMatrixWorld(!0),box.setFromObject(y),box.getSize(size),C.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5}else cameraFitAnyObject(y,o.current),o.current.zoom=1;const w=()=>{_(!0),a==null||a(),y.removeEventListener("update_bounds",w)};y.addEventListener("update_bounds",w),o.current.updateProjectionMatrix()},[l,a]);return fiber.useFrame(({gl:y,scene:w})=>{if(o.current&&d.current){const C=document.querySelectorAll(".conversation--character__item")[l.slot];if(C){const D=C.getBoundingClientRect(),N=C.parentNode.getBoundingClientRect(),[P,k]=[D.right-D.left,D.bottom-D.top];if(o.current.aspect=P/k,o.current.updateProjectionMatrix(),h&&R.current){box.setFromObject(R.current),box.getSize(size);const j=R.current.getObjectByName("Head_M",!0);j?(j.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5}const F={top:D.top-N.top,right:D.right-N.right,left:D.left-N.left,bottom:D.bottom-N.bottom},M=isMobile?24:40;F.bottom+=n?-M:M,y.setViewport(F.left,F.bottom,P,k),y.setScissor(F.left,F.bottom,P,k),d.current.environment=w.environment,y.render(d.current,o.current)}}},1),!((T=l.resource)!=null&&T.url)||l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:d,children:[jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:R,name:`char_${l.uid}`,url:l.resource.url,animationStates:{idle:x.url},type:l.type,onRender:g,texturable:!0,interactive:!1,generate:!1,merge:l.type!=="character",visible:p&&t}),jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:o,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:y=>{y.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:d?o:"divideby64",active:d,children:e.map((f,u)=>{let p=null;const _=l.findIndex(R=>R&&R.uid===f.uid);if(_>=0){const R=t?_:u;return p={...l[_]},p.slot=R,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===R,ttsStarted:n},`${`${p.uid}_${u}`}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(drei.Environment,{files:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:T,slot:y})=>({character:b,active:T,emotion:T?a.emotion:"neutral",slot:y}),_=React$2.useMemo(()=>u({type:"currentLod"}),[u]),R=_==="divideby64",x=d.reduce((b,T)=>{var C,D;const y=e==null?void 0:e.find(N=>N.uid===T.uid),w={...T};if(T.character)w.name=T.alias||T.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(y){const{resource:N}=y;w.name=T.alias||T.name,w.position=w.position>=0?w.position:-1,w.resource=N,w.type=y.type,b.push(w)}else T.type?(w.name=T.alias||((C=T.character)==null?void 0:C.name)||T.name,w.resource=((D=w.character)==null?void 0:D.resource)||T.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=T.type,b.push(w)):o||b.push(null);return b},[]),S=x.length&&x.some(b=>b),g=l.filter(b=>d.find(T=>b.uid===T.uid));function v(){return S?x.map((b,T)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:R,...p({character:b,active:a.position===b.position,slot:T})},`${b.uid+T}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`void_${0+T}`)):o?g.map((b,T)=>{const y=a.position===T;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:y,slot:T})},`${b.uid+T}`)}):d.length>0?d.map((b,T)=>{const y=l.find(w=>w.uid===b.uid);if(y){const w=a.position===T;return y.name=b.alias||y.name,jsxRuntimeExports.jsx(Slot,{...p({character:y,active:w,slot:T})},`${y.uid+T}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`${0+T}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?x:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:_,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=_=>{o?(f(_),setTimeout(()=>{t(_),f(null)},1e3)):t(_)},p=_=>!!(a&&(n==null?void 0:n.id)===_.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(_=>_.text).map(_=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
66
+ `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var v=S.lastIndexOf(NEWLINE);t=~v?S.length-v:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var v=g[0];return a(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=_();)g!==!1&&S.push(g);return S}function _(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var v=l.slice(2,g-2);return t+=2,a(v),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:v})}}function R(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(_(),!f(COLON_REGEX))return h("property missing ':'");var v=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:v?trim(v[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function x(){var S=[];p(S);for(var g;g=R();)g!==!1&&(S.push(g),p(S));return S}return u(),x()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,_,R,x=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||x&&f)continue;d.push(h.data);continue}switch(_=h.attribs,skipAttributesToProps(h)?setStyleProp(_.style,_):_&&(_=attributesToProps$1(_)),R=null,h.type){case"script":case"style":h.children[0]&&(_.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?_.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(_.key=S),d.push(a(h.name,_,R))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,_){_===void 0&&(_=p);var R=Object.getOwnPropertyDescriptor(u,p);(!R||("get"in R?!u.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,_,R)}:function(f,u,p,_){_===void 0&&(_=p),f[_]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,_){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(_=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=_??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var _=this.options.xmlMode?t.ElementType.Tag:void 0,R=new a.Element(u,p,void 0,_);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,_=this.lastNode;if(_&&_.type===t.ElementType.Text)p?_.data=(_.data+u).replace(o," "):_.data+=u,this.options.withEndIndices&&(_.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new a.Text(u);this.addNode(R),this.lastNode=R}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var _=new a.ProcessingInstruction(u,p);this.addNode(_)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],_=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),_&&(u.prev=_,_.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onMute:p=noop$1,onError:_=noop$1,onStart:R=noop$1,pauseTTS:x})=>{const[S,g,v,b]=d,T=!o&&!l,y=React$2.useRef(),[w,C]=React$2.useState(!1),D=React$2.useRef({url:"",cc:"tts"}),N=React$2.useCallback(j=>h({type:"translate",payload:j}),[h]),P=React$2.useCallback(({id:j,type:$="base"})=>{var re;const B=N("usedVoices"),X=N("gameCharacters");return $==="base"?B==null?void 0:B[j]:$==="character"?(re=X==null?void 0:X[j])==null?void 0:re.voiceId:null},[N]),k=React$2.useCallback((j,$="tts")=>{if(D.current.url!==j)return D.current={url:j,cc:$},S(j,$,t,f,u,R,p,_)},[S,t,f,u,R,p,_]),F=React$2.useCallback(async j=>{if(w&&j.voiceId&&j.text){let $=ttsCache[`${j.voiceId}_${j.text}`];try{$||($=await h({type:"getSpeech",payload:j}),$?ttsCache[`${j.voiceId}_${j.text}`]=$:_()),$&&(y.current=k($))}catch{_()}}else _()},[h,w,_,k]),M=React$2.useCallback(()=>{D.current.url&&g(D.current.cc)},[g]);return React$2.useEffect(()=>(C(!0),()=>{C(!1),M()}),[M]),React$2.useEffect(()=>{x?v():b()},[v,x,b]),React$2.useEffect(()=>{T&&M()},[T,M]),React$2.useEffect(()=>{if(w&&a)if(n==="voice"&&(l!=null&&l.id)){const j=P(l);F({voiceId:j,text:e})}else(n==="file"||!n)&&o?y.current=k(o==null?void 0:o.url):_()},[o,n,P,w,_,F,k,a,e,l]),[y,M]},cleanTextOfHtmlTags=l=>{const e=document.createElement("div");return e.innerHTML=l,e.textContent||e.innerText||""},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:_,hideBackgroundImageTheme:R=!1,keyboardControl:x,audio:S,audioType:g,audioVolume:v,voice:b,pause:T,styles:y}){const[w,C]=React$2.useState(),[D,N]=React$2.useState(!1),[P,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),j=!a||a&&P>=M||a&&!h,[$]=p,B=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:B,audio:S,soundActions:p,getEvent:e,volume:v,pauseTTS:T});const X=J=>e({type:"translate",payload:J}),re=React$2.useCallback(()=>{j&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,j,t,d,$]),ae=x({disabled:u,forward:re,escape:re});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!D&&(re(),N(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[re,a,D,h]),React$2.useEffect(()=>{P===M&&clearInterval(w)},[w,P,M]);const ee=M-P,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",y&&(J+=` lectures--container--${y}`),_!=null&&_.url&&(J+=" lectures--container--with-custom-bg"),y&&R&&(J+=" disable-background-image")),J},[_==null?void 0:_.url,R,y,u]),me={backgroundImage:_!=null&&_.url?`url('${_.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:me,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${y}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:j,close:re,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var R;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(R=l==null?void 0:l.resource)==null?void 0:R.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",_=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:_,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(_){a&&a(_);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const _=this.pluginCallbacks[p](u);_.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[_.name]=_,d[_.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const _=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(_){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[_]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[_]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[_]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[_]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(_)>=0&&h[_]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const _=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=_;break;case"spot":u=new three.SpotLight(p),u.distance=_,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,_=a.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,_,R,a.mode,a.filter).then(function(x){return x.buffer}):d.ready.then(function(){const x=new ArrayBuffer(p*_);return d.decodeGltfBuffer(new Uint8Array(x),p,_,R,a.mode,a.filter),x})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),_=p.isGroup?p.children:[p],R=u[0].count,x=[];for(const S of _){const g=new three.Matrix4,v=new three.Vector3,b=new three.Quaternion,T=new three.Vector3(1,1,1),y=new three.InstancedMesh(S.geometry,S.material,R);for(let w=0;w<R;w++)f.TRANSLATION&&v.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&T.fromBufferAttribute(f.SCALE,w),y.setMatrixAt(w,g.compose(v,b,T));for(const w in f)if(w==="_COLOR_0"){const C=f[w];y.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(y,S),this.parser.assignFinalMaterial(y),x.push(y)}return p.isGroup?(p.clear(),p.add(...x),p):x[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const _=ATTRIBUTES[p]||p.toLowerCase();h[_]=d[p]}for(const p in e.attributes){const _=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],x=WEBGL_COMPONENT_TYPES[R.componentType];u[_]=x.name,f[_]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(_,R){a.decodeDracoFile(p,function(x){for(const S in x.attributes){const g=x.attributes[S],v=f[S];v!==void 0&&(g.normalized=v)}_(x)},h,u,three.LinearSRGBColorSpace,R)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,_=(t-n)/p,R=_*_,x=R*_,S=e*u,g=S-u,v=-2*x+3*R,b=x-R,T=1-v,y=b-R+_;for(let w=0;w!==h;w++){const C=d[g+w+h],D=d[g+w+f]*p,N=d[S+w+h],P=d[S+w]*p;o[w]=T*C+y*D+v*N+b*P}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const _=e[u];if(_.POSITION!==void 0&&(t=!0),_.NORMAL!==void 0&&(a=!0),_.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const _=e[u];if(t){const R=_.POSITION!==void 0?n.getDependency("accessor",_.POSITION):l.attributes.position;d.push(R)}if(a){const R=_.NORMAL!==void 0?n.getDependency("accessor",_.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=_.COLOR_0!==void 0?n.getDependency("accessor",_.COLOR_0):l.attributes.color;f.push(R)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],_=u[1],R=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=_),o&&(l.morphAttributes.color=R),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,_=p*f,R=a.byteOffset||0,x=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,v;if(x&&x!==_){const b=Math.floor(R/x),T="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let y=n.cache.get(T);y||(g=new u(h,b*x,a.count*x/p),y=new three.InterleavedBuffer(g,x/p),n.cache.add(T,y)),v=new three.InterleavedBufferAttribute(y,f,R%x/p,S)}else h===null?g=new u(a.count*f):g=new u(h,R,a.count*f),v=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,T=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],y=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new T(d[1],y,a.sparse.count*b),D=new u(d[2],w,a.sparse.count*f);h!==null&&(v=new three.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let N=0,P=C.length;N<P;N++){const k=C[N];if(v.setX(k,D[N*f]),f>=2&&v.setY(k,D[N*f+1]),f>=3&&v.setZ(k,D[N*f+2]),f>=4&&v.setW(k,D[N*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const R=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[R.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[R.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[R.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[R.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(_=>_.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(_){u=!0;const R=new Blob([_],{type:d.mimeType});return f=h.createObjectURL(R),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(_){return new Promise(function(R,x){let S=R;n.isImageBitmapLoader===!0&&(S=function(g){const v=new three.Texture(g);v.needsUpdate=!0,R(v)}),n.load(three.LoaderUtils.resolveURL(_,o.path),S,void 0,x)})}).then(function(_){return u===!0&&h.revokeObjectURL(f),_.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),_}).catch(function(_){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),_});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const _=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=_.getMaterialType(),u.push(_.extendParams(h,o,n))}else{const _=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(_.baseColorFactor)){const R=_.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}_.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",_.baseColorTexture,three.SRGBColorSpace)),h.metalness=_.metallicFactor!==void 0?_.metallicFactor:1,h.roughness=_.roughnessFactor!==void 0?_.roughnessFactor:1,_.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",_.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",_.metallicRoughnessTexture))),d=this._invokeOne(function(R){return R.getMaterialType&&R.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(R){return R.extendMaterialParams&&R.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const _=o.normalTexture.scale;h.normalScale.set(_,_)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const _=o.emissiveFactor;h.emissive=new three.Color().setRGB(_[0],_[1],_[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const _=new d(h);return o.name&&(_.name=o.name),assignExtrasToUserData(_,o),n.associations.set(_,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,_,o),_})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),_=a[p];if(_)d.push(_.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:R},d.push(R)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],_=[];for(let x=0,S=p.length;x<S;x++){const g=p[x],v=d[x];let b;const T=u[x];if(v.mode===WEBGL_CONSTANTS.TRIANGLES||v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||v.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,T):new three.Mesh(g,T),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(v.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,T);else if(v.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),v.extensions&&addUnknownExtensionsToUserData(a,b,v),n.assignFinalMaterial(b),_.push(b)}for(let x=0,S=_.length;x<S;x++)n.associations.set(_[x],{meshes:e,primitives:x});if(_.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,_[0],o),_[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,R,o),n.associations.set(R,{meshes:e});for(let x=0,S=_.length;x<S;x++)R.add(_[x]);return R})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const _=d[u];if(_){h.push(_);const R=new three.Matrix4;o!==null&&R.fromArray(o.array,u*16),f.push(R)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let _=0,R=a.channels.length;_<R;_++){const x=a.channels[_],S=a.samplers[x.sampler],g=x.target,v=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,T=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",v)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",T)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(_){const R=_[0],x=_[1],S=_[2],g=_[3],v=_[4],b=[];for(let T=0,y=R.length;T<y;T++){const w=R[T],C=x[T],D=S[T],N=g[T],P=v[T];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,D,N,P);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],_=u[1],R=u[2];R!==null&&p.traverse(function(x){x.isSkinnedMesh&&x.bind(R,_identityMatrix)});for(let x=0,S=_.length;x<S;x++)p.add(_[x]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let _=0,R=u.length;_<R;_++)p.add(u[_]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const _=new three.Matrix4;_.fromArray(o.matrix),p.applyMatrix4(_)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,_=f.length;p<_;p++)o.add(f[p]);const u=p=>{const _=new Map;for(const[R,x]of a.associations)(R instanceof three.Material||R instanceof three.Texture)&&_.set(R,x);return p.traverse(R=>{const x=a.associations.get(R);x!=null&&_.set(R,x)}),_};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(R){R.morphTargetInfluences&&f.push(R.name?R.name:R.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,_=this._getArrayFromAccessor(t);for(let R=0,x=f.length;R<x;R++){const S=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,_,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const _=o[u];if(_.POSITION!==void 0){const R=n.json.accessors[_.POSITION],x=R.min,S=R.max;if(x!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(x[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(x[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(x[2]),Math.abs(S[2]))),R.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[R.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t=!0,onLoad:a}){var v,b,T;const o=React$2.useRef(null),d=React$2.useRef(null),h=l.type==="character",[f,u]=React$2.useState(!1),[p,_]=React$2.useState(!1),R=React$2.useRef(),x=React$2.useMemo(()=>{var y,w,C,D,N,P,k,F;return h?l.animationId&&((y=l.animation)!=null&&y.url)?l.animation:(D=(C=(w=l==null?void 0:l.resource)==null?void 0:w.animations)==null?void 0:C[l.emotion])!=null&&D.url?(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P[l.emotion]:(F=(k=l==null?void 0:l.resource)==null?void 0:k.animations)==null?void 0:F.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(v=l==null?void 0:l.resource)==null?void 0:v.animations,h]),S=React$2.useCallback(()=>{if(R.current){const y=R.current.userData.animator;y.getAction("idle")&&y.mix("idle",.1)}},[]);React$2.useEffect(()=>{var y,w,C,D,N,P;if(n)if(e){const k=(C=(w=(y=l==null?void 0:l.resource)==null?void 0:y.animations)==null?void 0:w.talking)==null?void 0:C.url,M=((P=(N=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:N["talking-short"])==null?void 0:P.url)||k;if(M&&R.current){const j=R.current.userData.animator,$=`${M}_talking`;j.getAction($)?(j.mix($,.1),u(!0)):loader$1.load(M,({animations:B})=>{if(!R.current)return;const X=j.getAction("idle").getClip();j.register($,mixWithTalkingClip(B[0],X)),j.mix($,.1),u(!0)})}}else S();else f&&S()},[e,n,S,f,(b=l==null?void 0:l.resource)==null?void 0:b.animations]);const g=React$2.useCallback(y=>{if(l.type==="character"){const w=y.getObjectByName("Head_M",!0);w?(w.updateMatrixWorld(!0),box.setFromObject(y),box.getSize(size),w.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5;const C=()=>{_(!0),a==null||a(),y.removeEventListener("update_bounds",C)};y.addEventListener("update_bounds",C)}else cameraFitAnyObject(y,o.current),o.current.zoom=1,_(!0);o.current.updateProjectionMatrix()},[l,a]);return fiber.useFrame(({gl:y,scene:w})=>{if(o.current&&d.current){const C=document.querySelectorAll(".conversation--character__item")[l.slot];if(C){const D=C.getBoundingClientRect(),N=C.parentNode.getBoundingClientRect(),[P,k]=[D.right-D.left,D.bottom-D.top];if(o.current.aspect=P/k,o.current.updateProjectionMatrix(),h&&R.current){box.setFromObject(R.current),box.getSize(size);const j=R.current.getObjectByName("Head_M",!0);j?(j.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5}const F={top:D.top-N.top,right:D.right-N.right,left:D.left-N.left,bottom:D.bottom-N.bottom},M=isMobile?24:40;F.bottom+=n?-M:M,y.setViewport(F.left,F.bottom,P,k),y.setScissor(F.left,F.bottom,P,k),d.current.environment=w.environment,y.render(d.current,o.current)}}},1),!((T=l.resource)!=null&&T.url)||l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:d,children:[jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:R,name:`char_${l.uid}`,url:l.resource.url,animationStates:{idle:x.url},type:l.type,onRender:g,texturable:!0,interactive:!1,generate:!1,merge:l.type!=="character",visible:p&&t}),jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:o,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:y=>{y.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:d?o:"divideby64",active:d,children:e.map((f,u)=>{let p=null;const _=l.findIndex(R=>R&&R.uid===f.uid);if(_>=0){const R=t?_:u;return p={...l[_]},p.slot=R,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===R,ttsStarted:n},`${`${p.uid}_${u}`}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(drei.Environment,{files:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:T,slot:y})=>({character:b,active:T,emotion:T?a.emotion:"neutral",slot:y}),_=React$2.useMemo(()=>u({type:"currentLod"}),[u]),R=_==="divideby64",x=d.reduce((b,T)=>{var C,D;const y=e==null?void 0:e.find(N=>N.uid===T.uid),w={...T};if(T.character)w.name=T.alias||T.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(y){const{resource:N}=y;w.name=T.alias||T.name,w.position=w.position>=0?w.position:-1,w.resource=N,w.type=y.type,b.push(w)}else T.type?(w.name=T.alias||((C=T.character)==null?void 0:C.name)||T.name,w.resource=((D=w.character)==null?void 0:D.resource)||T.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=T.type,b.push(w)):o||b.push(null);return b},[]),S=x.length&&x.some(b=>b),g=l.filter(b=>d.find(T=>b.uid===T.uid));function v(){return S?x.map((b,T)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:R,...p({character:b,active:a.position===b.position,slot:T})},`${b.uid+T}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`void_${0+T}`)):o?g.map((b,T)=>{const y=a.position===T;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:y,slot:T})},`${b.uid+T}`)}):d.length>0?d.map((b,T)=>{const y=l.find(w=>w.uid===b.uid);if(y){const w=a.position===T;return y.name=b.alias||y.name,jsxRuntimeExports.jsx(Slot,{...p({character:y,active:w,slot:T})},`${y.uid+T}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`${0+T}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?x:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:_,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=_=>{o?(f(_),setTimeout(()=>{t(_),f(null)},1e3)):t(_)},p=_=>!!(a&&(n==null?void 0:n.id)===_.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(_=>_.text).map(_=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
67
67
  ${(h==null?void 0:h.id)===_.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(_)},className:"radio",type:"radio",id:_.text_labelId,name:_.id,checked:(n==null?void 0:n.id)===_.id,disabled:p(_)}),jsxRuntimeExports.jsx("label",{className:`${_.right?"radio-text-success":"radio-text-fail"}`,htmlFor:_.text_labelId,children:HTMLReactParser$1(_.text)})]},`${_.id}_${_.text_labelId}`))}const noop=()=>{};function BasicDecision({children:l,question:e,showingResults:n,selected:t,required:a,failed:o,onNext:d,translate:h,hasRewards:f,options:u}){const[p,_]=React$2.useState(!1);function R(){(t==null?void 0:t.id)!==void 0&&!p&&(_(!0),d())}return jsxRuntimeExports.jsxs("div",{className:`popup popup__large popup__basicDecision ${n&&(t!=null&&t.feedback)?"popup__feedback":""}`,children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:n?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l,!(t!=null&&t.feedback)&&f.length===0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e!==""&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e})}),!(t!=null&&t.feedback)&&f.length>0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})]}):jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})}),jsxRuntimeExports.jsx("div",{className:"popup__questions",dir:"auto",children:u}),jsxRuntimeExports.jsx("div",{className:"popup--buttons",children:(a?!o:(t==null?void 0:t.id)!==void 0)?jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonDecision",type:"button",className:`gat--btn__navigation ${p||(t==null?void 0:t.id)===void 0?"disabled":""}`,onClick:()=>R(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null})]})}function ComplexDecision({question:l,inScene:e,disabled:n,onNext:t,children:a,simplifiedOptions:o}){return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`conversation--body ${e?"conversation--body--inScene":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"conversation--message",children:[l!==""&&jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(l)}),a]}),jsxRuntimeExports.jsxs("div",{style:{visibility:o?"hidden":"visible"},className:"conversation--controls conversation--controls--fixedbottom",children:[jsxRuntimeExports.jsx("div",{className:"gat--btn__round disabled",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonComplexDecision",className:`gat--btn__round ${n?"disabled":""}`,type:"button",onClick:()=>!n&&t(),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})}function DecisionBody({options:l,question:e,inherited:n,branched:t,changeOption:a,onNext:o,failed:d,showingResults:h,currentSelectedChoice:f,children:u,translate:p,hasRewards:_,inScene:R,required:x,simplifiedOptions:S}){const g=T=>{h&&d&&a(T),o(T)},v=!h&&(f==null?void 0:f.id)!==void 0||!d,b={inherited:n,selectedChoice:f,selectChoice:(!x||t)&&(f==null?void 0:f.id)!==void 0||x&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:S,required:x};return n?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!v,question:e,inScene:R,onNext:()=>o(f),simplifiedOptions:S,children:jsxRuntimeExports.jsx(Options,{...b})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:h,selected:f,required:x,failed:d,onNext:()=>o(f),translate:p,hasRewards:_,options:jsxRuntimeExports.jsx(Options,{...b}),children:u})}function Wrapper({children:l,inherit:e}){return e?jsxRuntimeExports.jsx("div",{className:"conversation--feedback",children:l}):l}function FeedBack({choice:l,inherited:e,question:n}){return l.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,children:l.feedback&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"conversation--feedback__title",children:n}),jsxRuntimeExports.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[l.right?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"conversation--feedback__wysiwyg",children:HTMLReactParser$1(l.feedback)})]})]})}):null}function DecisionComponent({emitEvent:l,getEvent:e,soundActions:n,keyboardControl:t,inScene:a,...o}){var j,$;const{inheritProps:d={},decisionNumber:h,required:f,question:u,onAddPoints:p,onFinish:_,branched:R,simplifiedOptions:x}=o,S=Object.keys(d).length>0,[g,v]=React$2.useState("options"),[b,T]=React$2.useState({}),[y]=n,w=f&&!(b!=null&&b.right),C=React$2.useRef(),D=B=>{var X;(X=B.audio)!=null&&X.url&&y(B.audio.url,"audio_file",!1,B.audioVolume)},N={...d,slots:d.slots?d.slots:d.characters,currentMessage:{position:null,emotion:""},emitEvent:l,getEvent:e};d&&d.flex&&N.slots&&(N.characters=N.characters.filter(B=>N.slots.find(X=>X.uid===B.uid)));const P=B=>{l({type:"decisionJournal",payload:{choice:B,decisionNumber:h}})},k=B=>{if(!w&&g==="results")y("click-ui"),S?x?_&&(P(B),_(B,()=>{T({}),v("options")})):(p&&p(B),P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!1,complex:!0,onFinish:()=>{_?_(B,()=>{T({}),v("options")}):l({type:"success"}),T({}),v("options")}})):(P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!0,complex:!0}));else if(Object.keys(B).length>0)if(y("click-ui"),x)if(B!=null&&B.rewards.filter(X=>X.type==="var").length){P({...B,simplified:!0});const X=B==null?void 0:B.rewards.filter(re=>re.type==="var");l({type:"addPoints",payload:X,finish:!1,complex:!0,onFinish:()=>{_?_(B,()=>{T({}),v("options")}):l({type:"success"}),T({}),v("options")}})}else P({...B,simplified:!0}),_(B,()=>{T({}),v("options")});else B.right?y("score"):(y("fail"),R||(S||f?(P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!1,complex:!0})):f||(T({}),v("options")))),T(B),D(B),v("results")},F={...o,selectView:v,selectedView:g,emitEvent:l,inherited:S,branched:R,soundActions:n,showingResults:g==="results",currentSelectedChoice:b,hasRewards:(b==null?void 0:b.rewards)||[],failed:w,inScene:a,required:f,simplifiedOptions:x,changeOption:B=>{y("click-ui"),T(B),v("options")},onNext:k,translate:B=>e({type:"translate",payload:B})},M=t({disabled:g!=="results",repeat:!1,forward:()=>{if(C.current!==b)C.current=b;else return;k(b)}});return React$2.useEffect(()=>M(),[M]),S?jsxRuntimeExports.jsx("div",{className:`conversation--layer
68
68
  ${b!=null&&b.feedback?"":"conversation--layer__defaultFeedback"}
69
69
  ${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(j=d.background)!=null&&j.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...N,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[_,R]=React$2.useState(!1),x=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),v=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>v(),[v]),React$2.useEffect(()=>{!a&&!_&&(R(!0),g())},[g,a,_]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[x&&jsxRuntimeExports.jsx("img",{src:x,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:x?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100%",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:_,autoEnd:R,progress:x}){var $e,rt,ft;const S=a.length-1<=(x==null?void 0:x.line)?a.length-1:(x==null?void 0:x.line)||0,[g,v]=React$2.useState(!1),[b,T]=React$2.useState(!0),[y,w]=React$2.useState(!!_),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:j,stop:$}=useTimeout(),B=(($e=f==null?void 0:f.img)==null?void 0:$e.url)||null,X=a[N],{voiceOver:re,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=re||X.type==="conversationalNarration",me=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),z=React$2.useCallback(()=>{if(ne){const Ge=a.filter(De=>!o.find(Re=>Re.toId===De.id));if(Ge.length){const De=Ge[0],Re=a.indexOf(De);if(Re>=0)return Re}}return-1},[ne,a,o]),Y=React$2.useCallback(()=>{const Ge=o.find(Re=>Re.fromId===V)||o.find(Re=>Re.toId===V),De=a.find(Re=>Re.id===(Ge==null?void 0:Ge.fromId));return!V&&(x==null?void 0:x.line)>=0?{decision:!0}:De},[o,a,V,x==null?void 0:x.line]),ie=React$2.useCallback(()=>{if(ne){const De=Y();return De==null?void 0:De.decision}const Ge=a[N-1]?a[N-1]:{};return N>0&&(Ge==null?void 0:Ge.decision)},[ne,Y,a,N]),le=React$2.useCallback(()=>{if(ne){const De=Y();return(De==null?void 0:De.type)==="conversationalCamera"}const Ge=a[N-1]?a[N-1]:{};return N>0&&(Ge==null?void 0:Ge.type)==="conversationalCamera"},[ne,a,N,Y]),fe=React$2.useCallback(Ge=>n({type:"translate",payload:Ge}),[n]),ce=React$2.useMemo(()=>{var De,Re;if(me)return{};if(ue)return X;const Ge=(De=X==null?void 0:X.slots)==null?void 0:De.find(ye=>ye.uid&&ye.talking);return Ge||((Re=X==null?void 0:X.slots)==null?void 0:Re.find(ye=>ye.uid&&ye.text))},[X,ue,me]),ge=a.slice(0,N+1).reverse().find(Ge=>Ge.slots),Se=!me&&((rt=X.slots)==null?void 0:rt.filter(Ge=>Ge.uid).length),Te=characterMs$3*(((ft=ce==null?void 0:ce.text)==null?void 0:ft.length)||0);let Fe=[];X.slots?Fe=X.slots:ge&&(Fe=ge.slots);const Ne=Fe.filter(Ge=>Ge.uid).map(Ge=>{const De=(d||h||[]).find(Re=>Re.uid===Ge.uid);return De&&(Ge.resource=De.resource,Ge.type=De.type),Ge.resource||(Ge.resource={}),Ge}),Qe={characters:Ne,lodSettings:p,actors:h,currentMessage:ce||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const Ge=a.slice(N).find(Re=>Re.slots),De=ge||Ge;De&&(K=De.slots,ee=De.flex)}else if(!me&&Se&&(X.slots.forEach(Ge=>{const De=Ne.findIndex(Re=>Re.uid===Ge.uid);De>=0&&(Ne[De].emotion=Ge.emotion)}),ce&&ce.uid)){const Ge=X.slots.findIndex(Re=>Re.uid===ce.uid),De=Ne.findIndex(Re=>Re.uid===ce.uid);Ne.forEach(Re=>{Re.uid===ce.uid&&(Re.name=ce.alias)}),ce.position=ee?De:Ge}const st=React$2.useCallback(()=>{e({type:"success"})},[e]),Ze=React$2.useCallback((Ge,De)=>{const Re=[3,2,1][Ge.id],Pe=o.filter(Xe=>Xe.fromId===X.id).find(Xe=>parseInt(Xe.fromPointIndex)===Re);if(Pe){const Xe=a.findIndex(Ft=>Ft.id===Pe.toId);Pe.fromId===Pe.toId?De():Xe>=0?(P(Xe),e({type:"notifyProgress",payload:{line:Xe}})):st()}else st()},[X.id,o,e,st,a]),yt=React$2.useCallback((Ge=!0)=>{const De=Ge?["fromId","toId"]:["toId","fromId"],Re=o.filter(Xe=>Xe[De[0]]===X.id),ye=Re.length===1?Re[0]:Re.find(Xe=>Xe[De[1]]===V);if(!(ye!=null&&ye[De[0]])){st();return}Ge||W(H.slice(0,-1));const Pe=a.findIndex(Xe=>Xe.id===ye[De[1]]);Pe>=0?(P(Pe),e({type:"notifyProgress",payload:{line:Pe}})):st()},[X.id,o,H,e,st,V,a]),Ve=React$2.useCallback(Ge=>{if(ne){if(Ge){const De=[3,2,1][Ge.id],ye=o.filter(Pe=>Pe.fromId===X.id).find(Pe=>parseInt(Pe.fromPointIndex)===De);if(ye){const Pe=a.findIndex(Xe=>Xe.id===ye.toId);Pe>=0&&e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})}}else if(N<a.length-1){const Re=N+1;e({type:"notifyProgress",payload:{line:Re}})}else e({type:"saveNode"})},[o,a,e,N,X.id,ne]),Me=React$2.useCallback((Ge,De)=>{let Re=!1;if(F(!1),T(!1),D(!1),ne)W([...H,X.id]),Ge?Ze(Ge,De):yt();else if(N<a.length-1){const Pe=N+1;P(Pe),e({type:"notifyProgress",payload:{line:Pe}}),De&&De()}else R||me||J?st():Re=!0;Re||T(!0)},[H,X.id,ne,N,a.length,R,me,J,Ze,yt,e,st]),Le=()=>{if(T(!1),F(!1),D(!1),ne)yt(!1);else if(!ie()){const Ge=N-1;P(Ge),e({type:"notifyProgress",payload:{line:Ge}})}T(!0)},Ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(Ge=>Ge.fromId===X.id):N===a.length-1,[N,X,o,ne,a.length]),ke=()=>{M("click-ui"),Ke()?st():(w(!1),Me())},qe=()=>{M("click-ui"),w(!1),Le()},St=y&&!me&&!t&&!J,Ye=React$2.useMemo(()=>z()>=0&&H.length===0&&ne||N===0&&!ne||ie()||le(),[z,H.length,ne,N,ie,le]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:N,text:cleanTextOfHtmlTags(ce==null?void 0:ce.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var Ge;(Ge=ce==null?void 0:ce.emotion)!=null&&Ge.includes("think")||F(!0)},onError:()=>{D(!0)},onFinish:()=>{F(!1),St&&Me()}}),React$2.useEffect(()=>{var De;let Ge;return me?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((De=ce==null?void 0:ce.emotion)!=null&&De.includes("think"))&&(F(!0),Ge=setTimeout(()=>{F(!1)},Te<minMs$1?minMs$1:Te)),()=>{Ge&&clearTimeout(Ge)})},[C,X,ce==null?void 0:ce.emotion,Te,me]),React$2.useEffect(()=>(St&&((X==null?void 0:X.audioType)==="none"||C)&&(!Ke()||Ke()&&R)&&j(Me,Te<minMs$1?minMs$1:Te),()=>{$()}),[ce,j,$,Me,X==null?void 0:X.audioType,St,C,R,a,Ke,Te]),React$2.useEffect(()=>{if(ne&&!g){const Ge=x==null?void 0:x.line;if(Ge>=0){v(!0),P(Ge);return}const De=z();De>=0&&(v(!0),P(De))}},[o,z,ne,a,g,x==null?void 0:x.line]);const ot=l({disabled:me,repeat:!1,forward:ke,rewind:Ye?null:qe});if(React$2.useEffect(()=>ot(),[ot]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:Me},`change-camera-${N}`);if(me){const Ge=a[N].id?a.filter(Re=>Re.decision).findIndex(Re=>Re.id===a[N].id)+1:a.filter(Re=>Re.decision).findIndex(Re=>Re===a[N])+1,De={...X.payload,decisionNumber:Ge,required:!ne,branched:ne,onAddPoints:Ve,onFinish:Me,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Ne,background:f,flex:ge?ge.flex:!0,slots:ge?ge.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...De})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:B?{backgroundImage:`url("${B}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Qe,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[ce?jsxRuntimeExports.jsx(Message,{current:ce,translate:fe}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Ye?"disabled":""}`,disabled:Ye?!0:"",type:"button",onClick:qe,"aria-label":LangIsRtl()?fe("storylines.misc.forward"):fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${y&&Ke()?"glowing-animation":""}`,type:"button",onClick:ke,"aria-label":LangIsRtl()?fe("storylines.misc.rewind"):fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var v;const[f,u]=React$2.useState(0),[p]=n,_=((v=d==null?void 0:d.img)==null?void 0:v.url)||null,R=t[f],x=a.map((b,T)=>({...b,name:o[T]?o[T]:b.name,uid:T})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:_?{backgroundImage:`url("${_}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:x,lodSettings:h,currentMessage:R,slots:x,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[R?jsxRuntimeExports.jsx(Message,{current:R,voiceOver:R.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var _;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=R=>{document.querySelector(`#${R}`).focus(),h(!d)},u=/\.(mp4|mov|webm)$/i.test(o),p={src:o,style:t?{minHeight:"100%",minWidth:"100%",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}:{height:"100%",width:"100%"}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:[u&&jsxRuntimeExports.jsx("video",{"data-testid":"videoTestId",autoPlay:!0,...p}),o&&!u&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})]}),(_=l==null?void 0:l.textData)!=null&&_.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup