@gamelearn/arcade-components 3.34.2 → 3.34.4
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 s(){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=s()?Object.assign:function(o,d){for(var h,f=t(o),u,p=1;p<arguments.length;p++){h=Object(arguments[p]);for(var x in h)e.call(h,x)&&(f[x]=h[x]);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 s(o,d,h,f,u){if(process.env.NODE_ENV!=="production"){for(var p in o)if(t(o,p)){var x;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}x=o[p](d,p,f,h,null,e)}catch(S){x=S}if(x&&!(x 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 x+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),x instanceof Error&&!(x.message in n)){n[x.message]=!0;var _=u?u():"";l("Failed "+h+" type: "+x.message+(_??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},checkPropTypes_1=s,checkPropTypes_1}var factoryWithTypeCheckers,hasRequiredFactoryWithTypeCheckers;function requireFactoryWithTypeCheckers(){if(hasRequiredFactoryWithTypeCheckers)return factoryWithTypeCheckers;hasRequiredFactoryWithTypeCheckers=1;var l=requireReactIs(),e=requireObjectAssign(),n=requireReactPropTypesSecret(),t=requireCheckPropTypes(),s=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 x(K){var te=K&&(u&&K[u]||K[p]);if(typeof te=="function")return te}var R="<<anonymous>>",_={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,te){return K===te?K!==0||1/K===1/te:K!==K&&te!==te}function g(K){this.message=K,this.stack=""}g.prototype=Error.prototype;function v(K){if(process.env.NODE_ENV!=="production")var te={},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;!te[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."),te[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 te(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(te)}function T(){return v(d)}function y(K){function te(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(te)}function w(){function K(te,ue,me,J,H){var W=te[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(te,ue,me,J,H){var W=te[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 te(ue,me,J,H,W){if(!(ue[me]instanceof K)){var V=K.name||R,z=Z(ue[me]);return new g("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected ")+("instance of `"+V+"`."))}return null}return v(te)}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 te(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(te)}function P(K){function te(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(s(V,Y)){var ie=K(V,Y,J,H,W+"."+Y,n);if(ie instanceof Error)return ie}return null}return v(te)}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 te=0;te<K.length;te++){var ue=K[te];if(typeof ue!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+se(ue)+" at index "+te+"."),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(te,ue,me,J,H){return U(te[ue])?null:new g("Invalid "+J+" `"+H+"` supplied to "+("`"+me+"`, expected a ReactNode."))}return v(K)}function M(K){function te(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(te)}function j(K){function te(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(te)}function U(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(U);if(K===null||h(K))return!0;var te=x(K);if(te){var ue=te.call(K),me;if(te!==K.entries){for(;!(me=ue.next()).done;)if(!U(me.value))return!1}else for(;!(me=ue.next()).done;){var J=me.value;if(J&&!U(J[1]))return!1}}else return!1;return!0;default:return!1}}function B(K,te){return K==="symbol"?!0:te?te["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&te instanceof Symbol:!1}function X(K){var te=typeof K;return Array.isArray(K)?"array":K instanceof RegExp?"object":B(te,K)?"symbol":te}function re(K){if(typeof K>"u"||K===null)return""+K;var te=X(K);if(te==="object"){if(K instanceof Date)return"date";if(K instanceof RegExp)return"regexp"}return te}function se(K){var te=re(K);switch(te){case"array":case"object":return"an "+te;case"boolean":case"date":case"regexp":return"a "+te;default:return te}}function Z(K){return!K.constructor||!K.constructor.name?R:K.constructor.name}return _.checkPropTypes=t,_.resetWarningCache=t.resetWarningCache,_.PropTypes=_,_},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,x){if(x!==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 s(){return t}var o={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:s,element:t,elementType:t,instanceOf:s,node:t,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,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:s}){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),x=(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)},_=g=>{window.onmousemove=v=>x(v,g),window.onmouseup=v=>R()},S=(g,v)=>{(!n||n&&t||s)&&(g.preventDefault(),e(g.clientX,v.offsetWidth,v.offsetLeft),_(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;x(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),s=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,":",s]})]})}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:s,translate:o}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e&&l||!e||n||s?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 s=React$2.useRef(),o=e?0:Math.floor(l*100),d=(p,x)=>{const R=x.offsetWidth+x.offsetLeft;let _=p.clientX;p.changedTouches&&(_=p.changedTouches[0].clientX),_<=R&&_>=x.offsetLeft&&n(_,x.offsetWidth,x.offsetLeft)},h=()=>{window.onmousemove=null,window.onmouseup=null},f=p=>{window.onmousemove=x=>d(x,p),window.onmouseup=x=>h()},u=(p,x)=>{p.preventDefault(),n(p.clientX,x.offsetWidth,x.offsetLeft),f(x)};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:s,onMouseDown:p=>{const x=s.current;u(p,x)},onTouchMove:p=>{const x=s.current;d(p,x)},onTouchStart:p=>{const x=s.current;n(p.changedTouches[0].clientX,x.offsetWidth,x.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:s,paused:o,time:d,finished:h,restart:f,volume:u,muted:p,mute:x,setVolume:R,setTimePoint:_,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:s,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:_,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:x,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:s,soundActions:o,endVideo:d,translate:h,autoPlay:f,withoutControls:u}){const[p,x]=React$2.useState(!1),[R]=o,[_,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),U=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%"}},se=()=>{n&&x(!0),T(!1),N.pause(),w(!0),D(!0),j(!1),l!=="document"&&l!=="lesson"&&d()},Z=()=>{d()},K=()=>{w(!1),T(!1)},te=()=>{T(!0)},ue=()=>{T(!1),S(N.duration)};React$2.useEffect(()=>{let ce;if(N){if(U){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,Ae)=>{const{stats:Fe}=Ae;v(Fe.loaded*100/Fe.total)})}return()=>{ce&&ce.destroy(),ce=null}}},[U,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 Ae=ce-Se>=0?(ce-Se)/ge:0;N.volume=Ae*100>10?Ae: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=s||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:_,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:te,onEnded:se,onError:Z,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:s,documentId_labelId:o,soundActions:d,required:h,viewed:f,visible:u,img:p,imgId_labelId:x,withoutControls:R,autoPlay:_,keyboardControl:S}){const g=w=>e({type:"translate",payload:w}),{url:v}=s,b=React$2.useMemo(()=>({documentId:o,imgId:x,required:h,name:n,type:"video",viewed:f,documentType:t}),[o,x,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:_,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:s={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:s}}),setTimeout(()=>{n&&e({type:"success"}),t()},200)};return d.addEventListener("transitionEnd",f),()=>{d.removeEventListener("transitionEnd",f)}},[d,e,t,n,l,s]),React$2.useEffect(()=>{o&&h.current!==l&&(o(l,s),h.current=l)},[o,l,s]),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=[],s=!0,o=!1,d,h;try{for(n=n.call(l);!(s=(d=n.next()).done)&&(t.push(d.value),!(e&&t.length===e));s=!0);}catch(f){o=!0,h=f}finally{try{!s&&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,s,o,d){this.acceptsBooleans=e===BOOLEANISH_STRING||e===BOOLEAN||e===OVERLOADED_BOOLEAN,this.attributeName=t,this.attributeNamespace=s,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 s(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 s(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=x();)g!==!1&&S.push(g);return S}function x(){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,s(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(x(),!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 _(){var S=[];p(S);for(var g;g=R();)g!==!1&&(S.push(g),p(S));return S}return u(),_()};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,s=parse(l),o=typeof e=="function",d,h,f=0,u=s.length;f<u;f++)t=s[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 s(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=s})(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,s=typeof e=="function",o={},d={};for(n in l){if(t=l[n],s&&(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,s,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(s=t.toLowerCase(),d=getPropName(s),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+s)),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,s=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,x,R,_=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)||_&&f)continue;d.push(h.data);continue}switch(x=h.attribs,skipAttributesToProps(h)?setStyleProp(x.style,x):x&&(x=attributesToProps$1(x)),R=null,h.type){case"script":case"style":h.children[0]&&(x.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?x.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(x.key=S),d.push(s(h.name,x,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,s){t.__proto__=s}||function(t,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(t[o]=s[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 s in e)Object.prototype.hasOwnProperty.call(e,s)&&(l[s]=e[s])}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 s=l.call(this,n)||this;return s.data=t,s}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 s=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return s.name=n,s}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var s=l.call(this,n)||this;return s.children=t,s}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,s,o){s===void 0&&(s=[]),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,s)||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 s,o;return{name:t,value:n.attribs[t],namespace:(s=n["x-attribsNamespace"])===null||s===void 0?void 0:s[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):[],s=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=s}),l.namespace!=null&&(s.namespace=l.namespace),l["x-attribsNamespace"]&&(s["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(s["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=s}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,s=l.length;t<s;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=[],s=0,o=l.length;s<o;s++){var d=l[s],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[s-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,s,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(s=t.getElementsByTagName(HEAD)[0],s&&s.parentNode.removeChild(s)),BODY_TAG_REGEX.test(l)||(s=t.getElementsByTagName(BODY)[0],s&&s.parentNode.removeChild(s)),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,x){x===void 0&&(x=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,x,R)}:function(f,u,p,x){x===void 0&&(x=p),f[x]=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(),s=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,x){this.dom=[],this.root=new s.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(x=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=x??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new s.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 x=this.options.xmlMode?t.ElementType.Tag:void 0,R=new s.Element(u,p,void 0,x);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,x=this.lastNode;if(x&&x.type===t.ElementType.Text)p?x.data=(x.data+u).replace(o," "):x.data+=u,this.options.withEndIndices&&(x.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new s.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 s.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new s.Text(""),p=new s.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 x=new s.ProcessingInstruction(u,p);this.addNode(x)},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],x=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),x&&(u.prev=x,x.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:s}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":s,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:s=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onMute:p=noop$1,onError:x=noop$1,onStart:R=noop$1,pauseTTS:_})=>{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:U="base"})=>{var re;const B=N("usedVoices"),X=N("gameCharacters");return U==="base"?B==null?void 0:B[j]:U==="character"?(re=X==null?void 0:X[j])==null?void 0:re.voiceId:null},[N]),k=React$2.useCallback((j,U="tts")=>{if(D.current.url!==j)return D.current={url:j,cc:U},S(j,U,t,f,u,R,p,x)},[S,t,f,u,R,p,x]),F=React$2.useCallback(async j=>{if(w&&j.voiceId&&j.text){let U=ttsCache[`${j.voiceId}_${j.text}`];try{U||(U=await h({type:"getSpeech",payload:j}),U?ttsCache[`${j.voiceId}_${j.text}`]=U:x()),U&&(y.current=k(U))}catch{x()}}else x()},[h,w,x,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(()=>{_?v():b()},[v,_,b]),React$2.useEffect(()=>{T&&M()},[T,M]),React$2.useEffect(()=>{if(w&&s)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):x()},[o,n,P,w,x,F,k,s,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:s,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:x,hideBackgroundImageTheme:R=!1,keyboardControl:_,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=!s||s&&P>=M||s&&!h,[U]=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&&(U("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,j,t,d,U]),se=_({disabled:u,forward:re,escape:re});React$2.useEffect(()=>se(),[se]),React$2.useEffect(()=>{if(!h&&!D&&(re(),N(!0)),s&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[re,s,D,h]),React$2.useEffect(()=>{P===M&&clearInterval(w)},[w,P,M]);const Z=M-P,K=Math.floor(Z/60),te=Z%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",y&&(J+=` lectures--container--${y}`),x!=null&&x.url&&(J+=" lectures--container--with-custom-bg"),y&&R&&(J+=" disable-background-image")),J},[x==null?void 0:x.url,R,y,u]),me={backgroundImage:x!=null&&x.url?`url('${x.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:te,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 s=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=()=>s?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>s?"contain":o||d?"auto 95%":"",p=()=>s?"center":o||d?"center bottom":"",x=s||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:x,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,s=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)s.push(n.getX(0)),s.push(n.getX(d)),s.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(s.push(n.getX(d)),s.push(n.getX(d+1)),s.push(n.getX(d+2))):(s.push(n.getX(d+2)),s.push(n.getX(d+1)),s.push(n.getX(d)));s.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(s),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,s){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){s?s(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,s){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(x){s&&s(x);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){s&&s(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 x=this.pluginCallbacks[p](u);x.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[x.name]=x,d[x.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const x=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(x){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[x]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[x]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[x]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[x]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(x)>=0&&h[x]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+x+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,s)}parseAsync(e,n){const t=this;return new Promise(function(s,o){t.parse(e,n,s,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,s=n.length;t<s;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 s=n.cache.get(t);if(s)return s;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 x=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=x;break;case"spot":u=new three.SpotLight(p),u.distance=x,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),s=Promise.resolve(u),n.cache.add(t,s),s}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 s=[];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&&s.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(s)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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 s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.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,s=t.json,o=s.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=s.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(s.extensionsRequired&&s.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,s=t.json,o=s.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=s.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(s.extensionsRequired&&s.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 s=t.extensions[this.name],o=this.parser.getDependency("buffer",s.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=s.byteOffset||0,u=s.byteLength||0,p=s.count,x=s.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,x,R,s.mode,s.filter).then(function(_){return _.buffer}):d.ready.then(function(){const _=new ArrayBuffer(p*x);return d.decodeGltfBuffer(new Uint8Array(_),p,x,R,s.mode,s.filter),_})})}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 s=n.meshes[t.mesh];for(const u of s.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(),x=p.isGroup?p.children:[p],R=u[0].count,_=[];for(const S of x){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),_.push(y)}return p.isGroup?(p.clear(),p.add(..._),p):_[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 s=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<s;){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,s=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const x=ATTRIBUTES[p]||p.toLowerCase();h[x]=d[p]}for(const p in e.attributes){const x=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],_=WEBGL_COMPONENT_TYPES[R.componentType];u[x]=_.name,f[x]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(x,R){s.decodeDracoFile(p,function(_){for(const S in _.attributes){const g=_.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,s){super(e,n,t,s)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let d=0;d!==s;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,s){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=s-n,x=(t-n)/p,R=x*x,_=R*x,S=e*u,g=S-u,v=-2*_+3*R,b=_-R,T=1-v,y=b-R+x;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,s){const o=super.interpolate_(e,n,t,s);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,s=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const x=e[u];if(x.POSITION!==void 0&&(t=!0),x.NORMAL!==void 0&&(s=!0),x.COLOR_0!==void 0&&(o=!0),t&&s&&o)break}if(!t&&!s&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const x=e[u];if(t){const R=x.POSITION!==void 0?n.getDependency("accessor",x.POSITION):l.attributes.position;d.push(R)}if(s){const R=x.NORMAL!==void 0?n.getDependency("accessor",x.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=x.COLOR_0!==void 0?n.getDependency("accessor",x.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],x=u[1],R=u[2];return t&&(l.morphAttributes.position=p),s&&(l.morphAttributes.normal=x),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,s=n.length;t<s;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,s=l.targets.length;t<s;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,s=n.length;t<s;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,s=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||s&&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,s=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][s.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:s.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,s),assignExtrasToUserData(h,s),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 s=0,o=n.length;s<o;s++){const d=n[s].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const d=e[s];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 s=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,s),s.name+="_instance_"+e.uses[n]++,s}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const s=e(n[t]);if(s)return s}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let s=0;s<n.length;s++){const o=e(n[s]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let s=this.cache.get(t);if(!s){switch(e){case"scene":s=this.loadScene(n);break;case"node":s=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":s=this.loadAccessor(n);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":s=this.loadBuffer(n);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":s=this.loadSkin(n);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":s=this.loadCamera(n);break;default:if(s=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(t,s)}return s}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(s.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 s=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,s.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 s=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+s)})}loadAccessor(e){const n=this,t=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const d=WEBGL_TYPE_SIZES[s.type],h=WEBGL_COMPONENT_TYPES[s.componentType],f=s.normalized===!0,u=new h(s.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[s.type],u=WEBGL_COMPONENT_TYPES[s.componentType],p=u.BYTES_PER_ELEMENT,x=p*f,R=s.byteOffset||0,_=s.bufferView!==void 0?t.bufferViews[s.bufferView].byteStride:void 0,S=s.normalized===!0;let g,v;if(_&&_!==x){const b=Math.floor(R/_),T="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+b+":"+s.count;let y=n.cache.get(T);y||(g=new u(h,b*_,s.count*_/p),y=new three.InterleavedBuffer(g,_/p),n.cache.add(T,y)),v=new three.InterleavedBufferAttribute(y,f,R%_/p,S)}else h===null?g=new u(s.count*f):g=new u(h,R,s.count*f),v=new three.BufferAttribute(g,f,S);if(s.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,T=WEBGL_COMPONENT_TYPES[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,w=s.sparse.values.byteOffset||0,C=new T(d[1],y,s.sparse.count*b),D=new u(d[2],w,s.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 s=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,s.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(x=>x.clone());const d=s.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(x){u=!0;const R=new Blob([x],{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(x){return new Promise(function(R,_){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(x,o.path),S,void 0,_)})}).then(function(x){return u===!0&&h.revokeObjectURL(f),x.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),x}).catch(function(x){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),x});return this.sourceCache[e]=p,p}assignTexture(e,n,t,s){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 s!==void 0&&(d.colorSpace=s),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const s=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(s||o||d){let h="ClonedMaterial:"+t.uuid+":";s&&(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),s&&(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,s=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const x=s[EXTENSIONS.KHR_MATERIALS_UNLIT];d=x.getMaterialType(),u.push(x.extendParams(h,o,n))}else{const x=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(x.baseColorFactor)){const R=x.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}x.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",x.baseColorTexture,three.SRGBColorSpace)),h.metalness=x.metallicFactor!==void 0?x.metallicFactor:1,h.roughness=x.roughnessFactor!==void 0?x.roughnessFactor:1,x.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",x.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",x.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 x=o.normalTexture.scale;h.normalScale.set(x,x)}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 x=o.emissiveFactor;h.emissive=new three.Color().setRGB(x[0],x[1],x[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 x=new d(h);return o.name&&(x.name=o.name),assignExtrasToUserData(x,o),n.associations.set(x,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(s,x,o),x})}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,s=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),x=s[p];if(x)d.push(x.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),s[p]={primitive:u,promise:R},d.push(R)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,s=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],x=[];for(let _=0,S=p.length;_<S;_++){const g=p[_],v=d[_];let b;const T=u[_];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(s,b,v),n.assignFinalMaterial(b),x.push(b)}for(let _=0,S=x.length;_<S;_++)n.associations.set(x[_],{meshes:e,primitives:_});if(x.length===1)return o.extensions&&addUnknownExtensionsToUserData(s,x[0],o),x[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(s,R,o),n.associations.set(R,{meshes:e});for(let _=0,S=x.length;_<S;_++)R.add(x[_]);return R})}loadCamera(e){let n;const t=this.json.cameras[e],s=t[t.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.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 s=0,o=n.joints.length;s<o;s++)t.push(this._loadNodeShallow(n.joints[s]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(s){const o=s.pop(),d=s,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const x=d[u];if(x){h.push(x);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,s=n.animations[e],o=s.name?s.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let x=0,R=s.channels.length;x<R;x++){const _=s.channels[x],S=s.samplers[_.sampler],g=_.target,v=g.node,b=s.parameters!==void 0?s.parameters[S.input]:S.input,T=s.parameters!==void 0?s.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(x){const R=x[0],_=x[1],S=x[2],g=x[3],v=x[4],b=[];for(let T=0,y=R.length;T<y;T++){const w=R[T],C=_[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,s=n.nodes[e];return s.mesh===void 0?null:t.getDependency("mesh",s.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,s.mesh,o);return s.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=s.weights.length;f<u;f++)h.morphTargetInfluences[f]=s.weights[f]}),d})}loadNode(e){const n=this.json,t=this,s=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=s.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=s.skin===void 0?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],x=u[1],R=u[2];R!==null&&p.traverse(function(_){_.isSkinnedMesh&&_.bind(R,_identityMatrix)});for(let _=0,S=x.length;_<S;_++)p.add(x[_]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?s.createUniqueName(o.name):"",h=[],f=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(s.getDependency("camera",o.camera).then(function(u){return s._getNodeRef(s.cameraCache,o.camera,u)})),s._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 x=0,R=u.length;x<R;x++)p.add(u[x]);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 x=new three.Matrix4;x.fromArray(o.matrix),p.applyMatrix4(x)}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 s.associations.has(p)||s.associations.set(p,{}),s.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],s=this,o=new three.Group;t.name&&(o.name=s.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(s.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,x=f.length;p<x;p++)o.add(f[p]);const u=p=>{const x=new Map;for(const[R,_]of s.associations)(R instanceof three.Material||R instanceof three.Texture)&&x.set(R,_);return p.traverse(R=>{const _=s.associations.get(R);_!=null&&x.set(R,_)}),x};return s.associations=u(o),o})}_createAnimationTracks(e,n,t,s,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=s.interpolation!==void 0?INTERPOLATION[s.interpolation]:three.InterpolateLinear,x=this._getArrayFromAccessor(t);for(let R=0,_=f.length;R<_;R++){const S=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,x,p);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),s=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)s[o]=n[o]*t;n=s}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const s=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new s(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,s=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(s.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]);s.min.multiplyScalar(p),s.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 x=o[u];if(x.POSITION!==void 0){const R=n.json.accessors[x.POSITION],_=R.min,S=R.max;if(_!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(_[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(_[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(_[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.")}}s.expandByVector(h)}l.boundingBox=s;const d=new three.Sphere;s.getCenter(d.center),d.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,s=[];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||s.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)});s.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(s).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:s}){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,x]=React$2.useState(!1),R=React$2.useRef(),_=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,U=`${M}_talking`;j.getAction(U)?(j.mix(U,.1),u(!0)):loader$1.load(M,({animations:B})=>{if(!R.current)return;const X=j.getAction("idle").getClip();j.register(U,mixWithTalkingClip(B[0],X)),j.mix(U,.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=()=>{x(!0),s==null||s(),y.removeEventListener("update_bounds",C)};y.addEventListener("update_bounds",C)}else cameraFitAnyObject(y,o.current),o.current.zoom=1,x(!0);o.current.updateProjectionMatrix()},[l,s]);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:_.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:s,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 x=l.findIndex(R=>R&&R.uid===f.uid);if(x>=0){const R=t?x:u;return p={...l[x]},p.slot=R,jsxRuntimeExports.jsx(Panel,{character:p,active:s.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:s,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:T,slot:y})=>({character:b,active:T,emotion:T?s.emotion:"neutral",slot:y}),x=React$2.useMemo(()=>u({type:"currentLod"}),[u]),R=x==="divideby64",_=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=_.length&&_.some(b=>b),g=l.filter(b=>d.find(T=>b.uid===T.uid));function v(){return S?_.map((b,T)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:R,...p({character:b,active:s.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=s.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=s.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?_:g,slots:d,flex:o,currentMessage:s,lodSettings:n,ttsStarted:t,pause:f,lod:x,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:s,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=x=>{o?(f(x),setTimeout(()=>{t(x),f(null)},1e3)):t(x)},p=x=>!!(s&&(n==null?void 0:n.id)===x.id||(n==null?void 0:n.right)===!0||s&&!d);return e==null?void 0:e.filter(x=>x.text).map(x=>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 s(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 s(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=x();)g!==!1&&S.push(g);return S}function x(){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,s(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(x(),!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 _(){var S=[];p(S);for(var g;g=R();)g!==!1&&(S.push(g),p(S));return S}return u(),_()};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,s=parse(l),o=typeof e=="function",d,h,f=0,u=s.length;f<u;f++)t=s[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 s(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=s})(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,s=typeof e=="function",o={},d={};for(n in l){if(t=l[n],s&&(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,s,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(s=t.toLowerCase(),d=getPropName(s),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+s)),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,s=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,x,R,_=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)||_&&f)continue;d.push(h.data);continue}switch(x=h.attribs,skipAttributesToProps(h)?setStyleProp(x.style,x):x&&(x=attributesToProps$1(x)),R=null,h.type){case"script":case"style":h.children[0]&&(x.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?x.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(x.key=S),d.push(s(h.name,x,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,s){t.__proto__=s}||function(t,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(t[o]=s[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 s in e)Object.prototype.hasOwnProperty.call(e,s)&&(l[s]=e[s])}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 s=l.call(this,n)||this;return s.data=t,s}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 s=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return s.name=n,s}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var s=l.call(this,n)||this;return s.children=t,s}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,s,o){s===void 0&&(s=[]),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,s)||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 s,o;return{name:t,value:n.attribs[t],namespace:(s=n["x-attribsNamespace"])===null||s===void 0?void 0:s[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):[],s=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=s}),l.namespace!=null&&(s.namespace=l.namespace),l["x-attribsNamespace"]&&(s["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(s["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=s}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,s=l.length;t<s;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=[],s=0,o=l.length;s<o;s++){var d=l[s],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[s-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,s,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(s=t.getElementsByTagName(HEAD)[0],s&&s.parentNode.removeChild(s)),BODY_TAG_REGEX.test(l)||(s=t.getElementsByTagName(BODY)[0],s&&s.parentNode.removeChild(s)),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,x){x===void 0&&(x=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,x,R)}:function(f,u,p,x){x===void 0&&(x=p),f[x]=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(),s=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,x){this.dom=[],this.root=new s.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(x=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=x??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new s.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 x=this.options.xmlMode?t.ElementType.Tag:void 0,R=new s.Element(u,p,void 0,x);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,x=this.lastNode;if(x&&x.type===t.ElementType.Text)p?x.data=(x.data+u).replace(o," "):x.data+=u,this.options.withEndIndices&&(x.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new s.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 s.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new s.Text(""),p=new s.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 x=new s.ProcessingInstruction(u,p);this.addNode(x)},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],x=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),x&&(u.prev=x,x.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:s}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":s,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:s=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onMute:p=noop$1,onError:x=noop$1,onStart:R=noop$1,pauseTTS:_})=>{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:U="base"})=>{var re;const B=N("usedVoices"),X=N("gameCharacters");return U==="base"?B==null?void 0:B[j]:U==="character"?(re=X==null?void 0:X[j])==null?void 0:re.voiceId:null},[N]),k=React$2.useCallback((j,U="tts")=>{if(D.current.url!==j)return D.current={url:j,cc:U},S(j,U,t,f,u,R,p,x)},[S,t,f,u,R,p,x]),F=React$2.useCallback(async j=>{if(w&&j.voiceId&&j.text){let U=ttsCache[`${j.voiceId}_${j.text}`];try{U||(U=await h({type:"getSpeech",payload:j}),U?ttsCache[`${j.voiceId}_${j.text}`]=U:x()),U&&(y.current=k(U))}catch{x()}}else x()},[h,w,x,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(()=>{_?v():b()},[v,_,b]),React$2.useEffect(()=>{T&&M()},[T,M]),React$2.useEffect(()=>{if(w&&s)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):x()},[o,n,P,w,x,F,k,s,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:s,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:x,hideBackgroundImageTheme:R=!1,keyboardControl:_,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=!s||s&&P>=M||s&&!h,[U]=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&&(U("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,j,t,d,U]),se=_({disabled:u,forward:re,escape:re});React$2.useEffect(()=>se(),[se]),React$2.useEffect(()=>{if(!h&&!D&&(re(),N(!0)),s&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[re,s,D,h]),React$2.useEffect(()=>{P===M&&clearInterval(w)},[w,P,M]);const Z=M-P,K=Math.floor(Z/60),te=Z%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",y&&(J+=` lectures--container--${y}`),x!=null&&x.url&&(J+=" lectures--container--with-custom-bg"),y&&R&&(J+=" disable-background-image")),J},[x==null?void 0:x.url,R,y,u]),me={backgroundImage:x!=null&&x.url?`url('${x.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:te,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 s=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=()=>s?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>s?"contain":o||d?"auto 95%":"",p=()=>s?"center":o||d?"center bottom":"",x=s||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:x,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,s=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)s.push(n.getX(0)),s.push(n.getX(d)),s.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(s.push(n.getX(d)),s.push(n.getX(d+1)),s.push(n.getX(d+2))):(s.push(n.getX(d+2)),s.push(n.getX(d+1)),s.push(n.getX(d)));s.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(s),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,s){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){s?s(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,s){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(x){s&&s(x);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){s&&s(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 x=this.pluginCallbacks[p](u);x.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[x.name]=x,d[x.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const x=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(x){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[x]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[x]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[x]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[x]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(x)>=0&&h[x]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+x+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,s)}parseAsync(e,n){const t=this;return new Promise(function(s,o){t.parse(e,n,s,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,s=n.length;t<s;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 s=n.cache.get(t);if(s)return s;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 x=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=x;break;case"spot":u=new three.SpotLight(p),u.distance=x,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),s=Promise.resolve(u),n.cache.add(t,s),s}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 s=[];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&&s.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(s)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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 s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],d=s.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,s=t.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.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,s=t.json,o=s.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=s.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(s.extensionsRequired&&s.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,s=t.json,o=s.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=s.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(s.extensionsRequired&&s.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 s=t.extensions[this.name],o=this.parser.getDependency("buffer",s.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=s.byteOffset||0,u=s.byteLength||0,p=s.count,x=s.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,x,R,s.mode,s.filter).then(function(_){return _.buffer}):d.ready.then(function(){const _=new ArrayBuffer(p*x);return d.decodeGltfBuffer(new Uint8Array(_),p,x,R,s.mode,s.filter),_})})}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 s=n.meshes[t.mesh];for(const u of s.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(),x=p.isGroup?p.children:[p],R=u[0].count,_=[];for(const S of x){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),_.push(y)}return p.isGroup?(p.clear(),p.add(..._),p):_[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 s=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<s;){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,s=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const x=ATTRIBUTES[p]||p.toLowerCase();h[x]=d[p]}for(const p in e.attributes){const x=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],_=WEBGL_COMPONENT_TYPES[R.componentType];u[x]=_.name,f[x]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(x,R){s.decodeDracoFile(p,function(_){for(const S in _.attributes){const g=_.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,s){super(e,n,t,s)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let d=0;d!==s;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,s){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=s-n,x=(t-n)/p,R=x*x,_=R*x,S=e*u,g=S-u,v=-2*_+3*R,b=_-R,T=1-v,y=b-R+x;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,s){const o=super.interpolate_(e,n,t,s);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,s=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const x=e[u];if(x.POSITION!==void 0&&(t=!0),x.NORMAL!==void 0&&(s=!0),x.COLOR_0!==void 0&&(o=!0),t&&s&&o)break}if(!t&&!s&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const x=e[u];if(t){const R=x.POSITION!==void 0?n.getDependency("accessor",x.POSITION):l.attributes.position;d.push(R)}if(s){const R=x.NORMAL!==void 0?n.getDependency("accessor",x.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=x.COLOR_0!==void 0?n.getDependency("accessor",x.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],x=u[1],R=u[2];return t&&(l.morphAttributes.position=p),s&&(l.morphAttributes.normal=x),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,s=n.length;t<s;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,s=l.targets.length;t<s;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,s=n.length;t<s;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,s=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||s&&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,s=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][s.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:s.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,s),assignExtrasToUserData(h,s),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 s=0,o=n.length;s<o;s++){const d=n[s].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const d=e[s];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 s=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,s),s.name+="_instance_"+e.uses[n]++,s}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const s=e(n[t]);if(s)return s}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let s=0;s<n.length;s++){const o=e(n[s]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let s=this.cache.get(t);if(!s){switch(e){case"scene":s=this.loadScene(n);break;case"node":s=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":s=this.loadAccessor(n);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":s=this.loadBuffer(n);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":s=this.loadSkin(n);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":s=this.loadCamera(n);break;default:if(s=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(t,s)}return s}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(s.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 s=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,s.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 s=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+s)})}loadAccessor(e){const n=this,t=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const d=WEBGL_TYPE_SIZES[s.type],h=WEBGL_COMPONENT_TYPES[s.componentType],f=s.normalized===!0,u=new h(s.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[s.type],u=WEBGL_COMPONENT_TYPES[s.componentType],p=u.BYTES_PER_ELEMENT,x=p*f,R=s.byteOffset||0,_=s.bufferView!==void 0?t.bufferViews[s.bufferView].byteStride:void 0,S=s.normalized===!0;let g,v;if(_&&_!==x){const b=Math.floor(R/_),T="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+b+":"+s.count;let y=n.cache.get(T);y||(g=new u(h,b*_,s.count*_/p),y=new three.InterleavedBuffer(g,_/p),n.cache.add(T,y)),v=new three.InterleavedBufferAttribute(y,f,R%_/p,S)}else h===null?g=new u(s.count*f):g=new u(h,R,s.count*f),v=new three.BufferAttribute(g,f,S);if(s.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,T=WEBGL_COMPONENT_TYPES[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,w=s.sparse.values.byteOffset||0,C=new T(d[1],y,s.sparse.count*b),D=new u(d[2],w,s.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 s=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,s.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(x=>x.clone());const d=s.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(x){u=!0;const R=new Blob([x],{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(x){return new Promise(function(R,_){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(x,o.path),S,void 0,_)})}).then(function(x){return u===!0&&h.revokeObjectURL(f),x.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),x}).catch(function(x){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),x});return this.sourceCache[e]=p,p}assignTexture(e,n,t,s){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 s!==void 0&&(d.colorSpace=s),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const s=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(s||o||d){let h="ClonedMaterial:"+t.uuid+":";s&&(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),s&&(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,s=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const x=s[EXTENSIONS.KHR_MATERIALS_UNLIT];d=x.getMaterialType(),u.push(x.extendParams(h,o,n))}else{const x=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(x.baseColorFactor)){const R=x.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}x.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",x.baseColorTexture,three.SRGBColorSpace)),h.metalness=x.metallicFactor!==void 0?x.metallicFactor:1,h.roughness=x.roughnessFactor!==void 0?x.roughnessFactor:1,x.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",x.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",x.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 x=o.normalTexture.scale;h.normalScale.set(x,x)}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 x=o.emissiveFactor;h.emissive=new three.Color().setRGB(x[0],x[1],x[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 x=new d(h);return o.name&&(x.name=o.name),assignExtrasToUserData(x,o),n.associations.set(x,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(s,x,o),x})}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,s=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),x=s[p];if(x)d.push(x.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),s[p]={primitive:u,promise:R},d.push(R)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,s=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],x=[];for(let _=0,S=p.length;_<S;_++){const g=p[_],v=d[_];let b;const T=u[_];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(s,b,v),n.assignFinalMaterial(b),x.push(b)}for(let _=0,S=x.length;_<S;_++)n.associations.set(x[_],{meshes:e,primitives:_});if(x.length===1)return o.extensions&&addUnknownExtensionsToUserData(s,x[0],o),x[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(s,R,o),n.associations.set(R,{meshes:e});for(let _=0,S=x.length;_<S;_++)R.add(x[_]);return R})}loadCamera(e){let n;const t=this.json.cameras[e],s=t[t.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.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 s=0,o=n.joints.length;s<o;s++)t.push(this._loadNodeShallow(n.joints[s]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(s){const o=s.pop(),d=s,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const x=d[u];if(x){h.push(x);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,s=n.animations[e],o=s.name?s.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let x=0,R=s.channels.length;x<R;x++){const _=s.channels[x],S=s.samplers[_.sampler],g=_.target,v=g.node,b=s.parameters!==void 0?s.parameters[S.input]:S.input,T=s.parameters!==void 0?s.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(x){const R=x[0],_=x[1],S=x[2],g=x[3],v=x[4],b=[];for(let T=0,y=R.length;T<y;T++){const w=R[T],C=_[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,s=n.nodes[e];return s.mesh===void 0?null:t.getDependency("mesh",s.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,s.mesh,o);return s.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=s.weights.length;f<u;f++)h.morphTargetInfluences[f]=s.weights[f]}),d})}loadNode(e){const n=this.json,t=this,s=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=s.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=s.skin===void 0?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],x=u[1],R=u[2];R!==null&&p.traverse(function(_){_.isSkinnedMesh&&_.bind(R,_identityMatrix)});for(let _=0,S=x.length;_<S;_++)p.add(x[_]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?s.createUniqueName(o.name):"",h=[],f=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(s.getDependency("camera",o.camera).then(function(u){return s._getNodeRef(s.cameraCache,o.camera,u)})),s._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 x=0,R=u.length;x<R;x++)p.add(u[x]);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 x=new three.Matrix4;x.fromArray(o.matrix),p.applyMatrix4(x)}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 s.associations.has(p)||s.associations.set(p,{}),s.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],s=this,o=new three.Group;t.name&&(o.name=s.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(s.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,x=f.length;p<x;p++)o.add(f[p]);const u=p=>{const x=new Map;for(const[R,_]of s.associations)(R instanceof three.Material||R instanceof three.Texture)&&x.set(R,_);return p.traverse(R=>{const _=s.associations.get(R);_!=null&&x.set(R,_)}),x};return s.associations=u(o),o})}_createAnimationTracks(e,n,t,s,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=s.interpolation!==void 0?INTERPOLATION[s.interpolation]:three.InterpolateLinear,x=this._getArrayFromAccessor(t);for(let R=0,_=f.length;R<_;R++){const S=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,x,p);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),s=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)s[o]=n[o]*t;n=s}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const s=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new s(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,s=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(s.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]);s.min.multiplyScalar(p),s.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 x=o[u];if(x.POSITION!==void 0){const R=n.json.accessors[x.POSITION],_=R.min,S=R.max;if(_!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(_[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(_[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(_[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.")}}s.expandByVector(h)}l.boundingBox=s;const d=new three.Sphere;s.getCenter(d.center),d.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,s=[];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||s.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)});s.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(s).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:s}){var S,g,v;const o=React$2.useRef(null),d=React$2.useRef(null),h=l.type==="character",[f,u]=React$2.useState(!1),p=React$2.useRef(),x=React$2.useMemo(()=>{var b,T,y,w,C,D,N,P;return h?l.animationId&&((b=l.animation)!=null&&b.url)?l.animation:(w=(y=(T=l==null?void 0:l.resource)==null?void 0:T.animations)==null?void 0:y[l.emotion])!=null&&w.url?(D=(C=l==null?void 0:l.resource)==null?void 0:C.animations)==null?void 0:D[l.emotion]:(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(S=l==null?void 0:l.resource)==null?void 0:S.animations,h]),R=React$2.useCallback(()=>{if(p.current){const b=p.current.userData.animator;b.getAction("idle")&&b.mix("idle",.1)}},[]);React$2.useEffect(()=>{var b,T,y,w,C,D;if(n&&f)if(e){const N=(y=(T=(b=l==null?void 0:l.resource)==null?void 0:b.animations)==null?void 0:T.talking)==null?void 0:y.url,k=((D=(C=(w=l==null?void 0:l.resource)==null?void 0:w.animations)==null?void 0:C["talking-short"])==null?void 0:D.url)||N;if(k&&p.current){const F=p.current.userData.animator,M=`${k}_talking`;F.getAction(M)?F.mix(M,.1):loader$1.load(k,({animations:j})=>{if(!p.current)return;const U=F.getAction("idle").getClip();F.register(M,mixWithTalkingClip(j[0],U)),F.mix(M,.1)})}}else R()},[e,n,R,(g=l==null?void 0:l.resource)==null?void 0:g.animations,f]);const _=React$2.useCallback(b=>{if(l.type==="character"){const T=b.getObjectByName("Head_M",!0);T?(T.updateMatrixWorld(!0),box.setFromObject(b),box.getSize(size),T.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5;const y=()=>{u(!0),s==null||s(),b.removeEventListener("update_bounds",y)};b.addEventListener("update_bounds",y)}else cameraFitAnyObject(b,o.current),o.current.zoom=1,u(!0);o.current.updateProjectionMatrix()},[l,s]);return fiber.useFrame(({gl:b,scene:T})=>{if(o.current&&d.current){const y=document.querySelectorAll(".conversation--character__item")[l.slot];if(y){const w=y.getBoundingClientRect(),C=y.parentNode.getBoundingClientRect(),[D,N]=[w.right-w.left,w.bottom-w.top];if(o.current.aspect=D/N,o.current.updateProjectionMatrix(),h&&p.current){box.setFromObject(p.current),box.getSize(size);const F=p.current.getObjectByName("Head_M",!0);F?(F.getWorldPosition(worldPos),o.current.lookAt(worldPos)):o.current.position.setY(size.y-1.5*1.3),o.current.zoom=1.5}const P={top:w.top-C.top,right:w.right-C.right,left:w.left-C.left,bottom:w.bottom-C.bottom},k=isMobile?24:40;P.bottom+=n?-k:k,b.setViewport(P.left,P.bottom,D,N),b.setScissor(P.left,P.bottom,D,N),d.current.environment=T.environment,b.render(d.current,o.current)}}},1),!((v=l.resource)!=null&&v.url)||l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:d,children:[jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:p,name:`char_${l.uid}`,url:l.resource.url,animationStates:{idle:x.url},type:l.type,onRender:_,texturable:!0,interactive:!1,generate:!1,merge:l.type!=="character",visible:f&&t}),jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:o,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:b=>{b.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:s,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 x=l.findIndex(R=>R&&R.uid===f.uid);if(x>=0){const R=t?x:u;return p={...l[x]},p.slot=R,jsxRuntimeExports.jsx(Panel,{character:p,active:s.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:s,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:T,slot:y})=>({character:b,active:T,emotion:T?s.emotion:"neutral",slot:y}),x=React$2.useMemo(()=>u({type:"currentLod"}),[u]),R=x==="divideby64",_=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=_.length&&_.some(b=>b),g=l.filter(b=>d.find(T=>b.uid===T.uid));function v(){return S?_.map((b,T)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:R,...p({character:b,active:s.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=s.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=s.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?_:g,slots:d,flex:o,currentMessage:s,lodSettings:n,ttsStarted:t,pause:f,lod:x,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:s,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=x=>{o?(f(x),setTimeout(()=>{t(x),f(null)},1e3)):t(x)},p=x=>!!(s&&(n==null?void 0:n.id)===x.id||(n==null?void 0:n.right)===!0||s&&!d);return e==null?void 0:e.filter(x=>x.text).map(x=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
|
|
67
67
|
${(h==null?void 0:h.id)===x.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(x)},className:"radio",type:"radio",id:x.text_labelId,name:x.id,checked:(n==null?void 0:n.id)===x.id,disabled:p(x)}),jsxRuntimeExports.jsx("label",{className:`${x.right?"radio-text-success":"radio-text-fail"}`,htmlFor:x.text_labelId,children:HTMLReactParser$1(x.text)})]},`${x.id}_${x.text_labelId}`))}const noop=()=>{};function BasicDecision({children:l,question:e,showingResults:n,selected:t,required:s,failed:o,onNext:d,translate:h,hasRewards:f,options:u}){const[p,x]=React$2.useState(!1);function R(){(t==null?void 0:t.id)!==void 0&&!p&&(x(!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:(s?!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:s,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)}),s]}),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:s,onNext:o,failed:d,showingResults:h,currentSelectedChoice:f,children:u,translate:p,hasRewards:x,inScene:R,required:_,simplifiedOptions:S}){const g=T=>{h&&d&&s(T),o(T)},v=!h&&(f==null?void 0:f.id)!==void 0||!d,b={inherited:n,selectedChoice:f,selectChoice:(!_||t)&&(f==null?void 0:f.id)!==void 0||_&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:S,required:_};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:_,failed:d,onNext:()=>o(f),translate:p,hasRewards:x,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:s,...o}){var j,U;const{inheritProps:d={},decisionNumber:h,required:f,question:u,onAddPoints:p,onFinish:x,branched:R,simplifiedOptions:_}=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),x(B,()=>{T({}),v("options")})):(p&&p(B),P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!1,complex:!0,onFinish:()=>{x?x(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"),_)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:()=>{x?x(B,()=>{T({}),v("options")}):l({type:"success"}),T({}),v("options")}})}else P({...B,simplified:!0}),x(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:s,required:f,simplifiedOptions:_,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 ${s?"conversation--inScene":""}`,style:(j=d.background)!=null&&j.img?{backgroundImage:`url("${(U=d.background.img)==null?void 0:U.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:s,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[x,R]=React$2.useState(!1),_=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(()=>{!s&&!x&&(R(!0),g())},[g,s,x]),s?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:[_&&jsxRuntimeExports.jsx("img",{src:_,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:_?"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,s;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,(s=l==null?void 0:l.emotion)!=null&&s.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:s,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:x,autoEnd:R,progress:_}){var Be,ot,ft;const S=s.length-1<=(_==null?void 0:_.line)?s.length-1:(_==null?void 0:_.line)||0,[g,v]=React$2.useState(!1),[b,T]=React$2.useState(!0),[y,w]=React$2.useState(!!x),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:j,stop:U}=useTimeout(),B=((Be=f==null?void 0:f.img)==null?void 0:Be.url)||null,X=s[N],{voiceOver:re,decision:se}=X;let{flex:Z}=X,K=[];const te=!!o,ue=re||X.type==="conversationalNarration",me=se||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(te){const Ge=s.filter(Ne=>!o.find(Re=>Re.toId===Ne.id));if(Ge.length){const Ne=Ge[0],Re=s.indexOf(Ne);if(Re>=0)return Re}}return-1},[te,s,o]),Y=React$2.useCallback(()=>{const Ge=o.find(Re=>Re.fromId===V)||o.find(Re=>Re.toId===V),Ne=s.find(Re=>Re.id===(Ge==null?void 0:Ge.fromId));return!V&&(_==null?void 0:_.line)>=0?{decision:!0}:Ne},[o,s,V,_==null?void 0:_.line]),ie=React$2.useCallback(()=>{if(te){const Ne=Y();return Ne==null?void 0:Ne.decision}const Ge=s[N-1]?s[N-1]:{};return N>0&&(Ge==null?void 0:Ge.decision)},[te,Y,s,N]),le=React$2.useCallback(()=>{if(te){const Ne=Y();return(Ne==null?void 0:Ne.type)==="conversationalCamera"}const Ge=s[N-1]?s[N-1]:{};return N>0&&(Ge==null?void 0:Ge.type)==="conversationalCamera"},[te,s,N,Y]),fe=React$2.useCallback(Ge=>n({type:"translate",payload:Ge}),[n]),ce=React$2.useMemo(()=>{var Ne,Re;if(me)return{};if(ue)return X;const Ge=(Ne=X==null?void 0:X.slots)==null?void 0:Ne.find(_e=>_e.uid&&_e.talking);return Ge||((Re=X==null?void 0:X.slots)==null?void 0:Re.find(_e=>_e.uid&&_e.text))},[X,ue,me]),ge=s.slice(0,N+1).reverse().find(Ge=>Ge.slots),Se=!me&&((ot=X.slots)==null?void 0:ot.filter(Ge=>Ge.uid).length),Ae=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 De=Fe.filter(Ge=>Ge.uid).map(Ge=>{const Ne=(d||h||[]).find(Re=>Re.uid===Ge.uid);return Ne&&(Ge.resource=Ne.resource,Ge.type=Ne.type),Ge.resource||(Ge.resource={}),Ge}),Je={characters:De,lodSettings:p,actors:h,currentMessage:ce||{},slots:ue?K:X.slots,flex:Z,pause:t,getEvent:n};if(ue){const Ge=s.slice(N).find(Re=>Re.slots),Ne=ge||Ge;Ne&&(K=Ne.slots,Z=Ne.flex)}else if(!me&&Se&&(X.slots.forEach(Ge=>{const Ne=De.findIndex(Re=>Re.uid===Ge.uid);Ne>=0&&(De[Ne].emotion=Ge.emotion)}),ce&&ce.uid)){const Ge=X.slots.findIndex(Re=>Re.uid===ce.uid),Ne=De.findIndex(Re=>Re.uid===ce.uid);De.forEach(Re=>{Re.uid===ce.uid&&(Re.name=ce.alias)}),ce.position=Z?Ne:Ge}const ut=React$2.useCallback(()=>{e({type:"success"})},[e]),et=React$2.useCallback((Ge,Ne)=>{const Re=[3,2,1][Ge.id],Oe=o.filter(Ke=>Ke.fromId===X.id).find(Ke=>parseInt(Ke.fromPointIndex)===Re);if(Oe){const Ke=s.findIndex(Ft=>Ft.id===Oe.toId);Oe.fromId===Oe.toId?Ne():Ke>=0?(P(Ke),e({type:"notifyProgress",payload:{line:Ke}})):ut()}else ut()},[X.id,o,e,ut,s]),xt=React$2.useCallback((Ge=!0)=>{const Ne=Ge?["fromId","toId"]:["toId","fromId"],Re=o.filter(Ke=>Ke[Ne[0]]===X.id),_e=Re.length===1?Re[0]:Re.find(Ke=>Ke[Ne[1]]===V);if(!(_e!=null&&_e[Ne[0]])){ut();return}Ge||W(H.slice(0,-1));const Oe=s.findIndex(Ke=>Ke.id===_e[Ne[1]]);Oe>=0?(P(Oe),e({type:"notifyProgress",payload:{line:Oe}})):ut()},[X.id,o,H,e,ut,V,s]),Ve=React$2.useCallback(Ge=>{if(te){if(Ge){const Ne=[3,2,1][Ge.id],_e=o.filter(Oe=>Oe.fromId===X.id).find(Oe=>parseInt(Oe.fromPointIndex)===Ne);if(_e){const Oe=s.findIndex(Ke=>Ke.id===_e.toId);Oe>=0&&e({type:"notifyProgress",payload:{line:Oe}})}else e({type:"saveNode"})}}else if(N<s.length-1){const Re=N+1;e({type:"notifyProgress",payload:{line:Re}})}else e({type:"saveNode"})},[o,s,e,N,X.id,te]),Me=React$2.useCallback((Ge,Ne)=>{let Re=!1;if(F(!1),T(!1),D(!1),te)W([...H,X.id]),Ge?et(Ge,Ne):xt();else if(N<s.length-1){const Oe=N+1;P(Oe),e({type:"notifyProgress",payload:{line:Oe}}),Ne&&Ne()}else R||me||J?ut():Re=!0;Re||T(!0)},[H,X.id,te,N,s.length,R,me,J,et,xt,e,ut]),Le=()=>{if(T(!1),F(!1),D(!1),te)xt(!1);else if(!ie()){const Ge=N-1;P(Ge),e({type:"notifyProgress",payload:{line:Ge}})}T(!0)},Ye=React$2.useCallback(()=>te?X&&X.type!=="conversationalDecision"&&!o.find(Ge=>Ge.fromId===X.id):N===s.length-1,[N,X,o,te,s.length]),ke=()=>{M("click-ui"),Ye()?ut():(w(!1),Me())},Qe=()=>{M("click-ui"),w(!1),Le()},bt=y&&!me&&!t&&!J,qe=React$2.useMemo(()=>z()>=0&&H.length===0&&te||N===0&&!te||ie()||le(),[z,H.length,te,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),bt&&Me()}}),React$2.useEffect(()=>{var Ne;let Ge;return me?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((Ne=ce==null?void 0:ce.emotion)!=null&&Ne.includes("think"))&&(F(!0),Ge=setTimeout(()=>{F(!1)},Ae<minMs$1?minMs$1:Ae)),()=>{Ge&&clearTimeout(Ge)})},[C,X,ce==null?void 0:ce.emotion,Ae,me]),React$2.useEffect(()=>(bt&&((X==null?void 0:X.audioType)==="none"||C)&&(!Ye()||Ye()&&R)&&j(Me,Ae<minMs$1?minMs$1:Ae),()=>{U()}),[ce,j,U,Me,X==null?void 0:X.audioType,bt,C,R,s,Ye,Ae]),React$2.useEffect(()=>{if(te&&!g){const Ge=_==null?void 0:_.line;if(Ge>=0){v(!0),P(Ge);return}const Ne=z();Ne>=0&&(v(!0),P(Ne))}},[o,z,te,s,g,_==null?void 0:_.line]);const ct=l({disabled:me,repeat:!1,forward:ke,rewind:qe?null:Qe});if(React$2.useEffect(()=>ct(),[ct]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:Me},`change-camera-${N}`);if(me){const Ge=s[N].id?s.filter(Re=>Re.decision).findIndex(Re=>Re.id===s[N].id)+1:s.filter(Re=>Re.decision).findIndex(Re=>Re===s[N])+1,Ne={...X.payload,decisionNumber:Ge,required:!te,branched:te,onAddPoints:Ve,onFinish:Me,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:De,background:f,flex:ge?ge.flex:!0,slots:ge?ge.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...Ne})})}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,{...Je,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 ${qe?"disabled":""}`,disabled:qe?!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&&Ye()?"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:s,alias:o,background:d,lodSettings:h}){var v;const[f,u]=React$2.useState(0),[p]=n,x=((v=d==null?void 0:d.img)==null?void 0:v.url)||null,R=t[f],_=s.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:x?{backgroundImage:`url("${x}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:_,lodSettings:h,currentMessage:R,slots:_,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 x;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"})]}),(x=l==null?void 0:l.textData)!=null&&x.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
|
|
@@ -271,5 +271,5 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
271
271
|
${l.thinkful?"speech-bubble--italic":""}
|
|
272
272
|
`,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader,MIX_TIME=.25;function useStateMachine(l){const e=fiber.useThree(p=>p.scene),n=React$2.useMemo(()=>{var x;const p={};for(const R of l)if(R.slots)for(const _ of R.slots){if(!_.uid)continue;const S=(x=_.character)==null?void 0:x.resource.animations;S&&(p[_.uid]||(p[_.uid]=Object.keys(S).reduce((g,v)=>(g[v]=S[v].url,g),{})))}return p},[l]),t=React$2.useMemo(()=>{const p=new Set;for(const x of l)if(x.slots)for(const R of x.slots)R.uid&&p.add(R.uid);return Array.from(p)},[l]),s=async(p,x)=>{if(p&&!cache[p]){const{animations:R}=await loader.loadAsync(p);R[0].name=x,cache[p]=R[0]}},o=async p=>{const x=n[p],R=x.talking,_=x["talking-short"];await Promise.all([s(_,"talking-short"),s(R,"talking")])},d=()=>{t.forEach(p=>{u(p,"idle")})},h=()=>{t.forEach(p=>{const x=e.getObjectByProperty("uid",p);x&&(delete x.userData._active,u(p,"idle"))})},f=async(p,x,R=!1,_=!1)=>{const S=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!S)return new Promise(v=>v(!1));const g=S.userData.animator;if(x){const v=n[p],b=v["talking-short"]||v.talking;let T=cache[b],y=x,w=cache[x];if(!w){const{animations:C}=await loader.loadAsync(x);w=cache[x]=C[0]}if(R&&b!==x&&(T?(w=mixWithTalkingClip(T,w),y+="_talking"):o(p).then(()=>{T=cache[b],w=mixWithTalkingClip(T,w),y+="_talking"})),!S.userData._active||S.userData._active!==y){S.userData._active=y;const C=g.register(y,w,S);return new Promise(D=>{_&&g.setTime(0),g.mix(y,MIX_TIME).then(N=>D(N?C:!1))})}}return new Promise(v=>v(!1))},u=async(p,x)=>{const R=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!R)return new Promise(S=>S(!1));const _=R.userData.animator;if(x==="idle")return _.mix("idle",MIX_TIME),_.getAction("idle");{const S=n[p],g=x.split("_")[0],v=S[g],b=x.includes("talking");if(v){const T=`${v}${b?"_talking":""}`;let y=cache[T];if(!y){let w=cache[v];if(!w){const{animations:C}=await loader.loadAsync(v);w=cache[v]=C[0],w.name=g}if(y=w.clone(),b&&x!=="talking"){const C=S["talking-short"]||S.talking,D=cache[C];D&&(y=mixWithTalkingClip(D,w))}cache[T]=y}if(!R.userData._active||R.userData._active!==x){R.userData._active=x;const w=_.register(x,y,R);return new Promise(C=>{_.mix(x,MIX_TIME).then(D=>C(D?w:!1))})}}}return new Promise(S=>S(!1))};return{startAnimation:u,startAnimationUrl:f,preloadTalking:o,resetActives:d,unmountActives:h}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:s,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:x}){var Et;const R=t.length-1<=(x==null?void 0:x.line)?t.length-1:(x==null?void 0:x.line)||0,[_,S]=React$2.useState(R),[g,v]=React$2.useState(!!f),[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!1),C=fiber.useThree(Te=>Te.scene),D=fiber.useThree(Te=>Te.camera),{start:N,stop:P}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>D.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),j=t[_],U=t[_-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:se}=j||{},Z=React$2.useRef({}),K=(Et=j==null?void 0:j.slots)==null?void 0:Et.find(Te=>Te.talking),te=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:me,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),z=Object.keys((j==null?void 0:j.audio)||{}).length,Y=Object.keys((j==null?void 0:j.voice)||{}).length,ie=re||(j==null?void 0:j.type)==="conversationalNarration",le=se||(j==null?void 0:j.type)==="conversationalDecision",fe=(j==null?void 0:j.type)==="conversationalCamera",ce=g&&!le&&!fe,[ge,Se]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Ae=React$2.useMemo(()=>t.reduce((Te,at)=>(at.slots&&at.slots.filter(ve=>ve.uid).forEach(ve=>{Te.includes(ve.uid)||Te.push(ve.uid)}),Te),[]),[t]),Fe=React$2.useCallback(Te=>n({type:"translate",payload:Te}),[n]),[De,Je]=React$2.useState([]),ut=React$2.useMemo(()=>De[De.length-1],[De]),et=React$2.useCallback(()=>{const Te=o.find(rt=>rt.fromId===ut)||o.find(rt=>rt.toId===ut),at=t.find(rt=>rt.id===(Te==null?void 0:Te.fromId));return!ut&&(x==null?void 0:x.line)>=0?{decision:!0}:at},[o,t,ut]),xt=React$2.useCallback(()=>{if(X){const Te=t.filter(at=>!o.find(rt=>rt.toId===at.id));if(Te.length){const at=Te[0],rt=t.indexOf(at);if(rt>=0)return rt}}return-1},[X,t,o]),Ve=React$2.useCallback(()=>{if(X){const at=et();return at==null?void 0:at.decision}const Te=t[_-1]?t[_-1]:{};return _>0&&(Te==null?void 0:Te.decision)},[j,X,t,ut,o]),Me=React$2.useCallback(()=>{if(X){const at=et();return(at==null?void 0:at.type)==="conversationalCamera"}const Te=t[_-1]?t[_-1]:{};return _>0&&(Te==null?void 0:Te.type)==="conversationalCamera"},[j,X,t,ut,o]),Le=React$2.useCallback(Te=>{var rt,ve;const at=s.find(ee=>(ee==null?void 0:ee.uid)===(Te==null?void 0:Te.uid)?ee:"");return((ve=(rt=Te==null?void 0:Te.character)==null?void 0:rt.resource)==null?void 0:ve.url)||(at==null?void 0:at.completeUrl)||""},[s]),Ye=(Te=()=>{})=>{if(te.current)te.current&&(te.current=!1);else{D.updateProjectionMatrix(),D.updateMatrixWorld(!0);const at=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(at),M.current.parent){animationTarget.quaternion.equals(D.quaternion)||animationTarget.applyQuaternion(D.quaternion);const rt=M.current.isLeft?-1:1,ve=headSize*rt;animationTarget.translateX(-10*rt+ve),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(D.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{te.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(rt=>{const{object:ve}=rt;ve.material.visible=!0})},onComplete:()=>{Te(),raycast.set(D.getWorldPosition(new three.Vector3(0,0,0)),D.getWorldDirection(new three.Vector3));const rt=raycast.intersectObjects(C.children,!0);k.current=rt.filter(ve=>ve.distance<10),k.current.length&&k.current.forEach(ve=>{const{object:ee}=ve;ee.material.side=0}),te.current=!1,B.current&&e({type:"success"}),M.current.child||D.copy(F)},...animationTarget.position})}},ke=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Ye()},[h]),Qe=(Te,at,rt,ve=!1)=>{const ee=at.includes("seated");if(rt){const pe=BASIC_ACTIONS_TYPES_WHITELIST.includes(rt.animationId);pe&&at.includes("talking")&&(V.current=Te),me(Te,rt.url,at.includes("talking"),pe).then(Ee=>{if(Ee&&pe)if(B.current)ue(Te,"idle");else{const we=V.current===Te?"neutral_talking":"neutral";ue(Te,we)}})}else{const pe=ve&&!ee?`${at}-seated`:at;ue(Te,pe)}},bt=()=>{if(!(K!=null&&K.uid)||!(K!=null&&K.emotion)||B.current)return;const{emotion:Te,uid:at,animation:rt}=K,ve=getCurrentVisible(at,C);if(ve){const{isSeated:ee}=ve;H(at).then(()=>{Qe(at,ee&&!Te.includes("seated")?`${Te}-seated_talking`:`${Te}_talking`,rt,ee)}).catch(pe=>{console.error(pe)})}},qe=()=>{if(!(K!=null&&K.uid)||B.current)return;const{emotion:Te,uid:at,animation:rt}=K,ve=getCurrentVisible(at,C);if(ve){delete ve.userData._active;const{isSeated:ee}=ve;if(V.current===at)Qe(at,"neutral",null,ee),V.current=null;else{const pe=Te.includes("talking");Qe(at,pe?"neutral":Te,pe?null:rt,ee)}}},ct=React$2.useCallback(()=>{B.current=!0,Se({show:!1}),ke(),J(),h||e({type:"success"})},[D,e,ke,h]);React$2.useEffect(()=>()=>{Z.current={},W()},[]);const Be=Te=>{Se({show:!1}),S(Te),e({type:"notifyProgress",payload:{line:Te}})},ot=React$2.useCallback((Te=!0)=>{const at=Te?["fromId","toId"]:["toId","fromId"],rt=o.filter(pe=>pe[at[0]]===j.id),ve=rt.length===1?rt[0]:rt.find(pe=>pe[at[1]]===ut);if(!(ve!=null&&ve[at[0]])){ct();return}Te||Je(De.slice(0,De.length-1));const ee=t.findIndex(pe=>pe.id===ve[at[1]]);ee>=0?Be(ee):ct()},[j==null?void 0:j.id,e,o,ct,t]),ft=React$2.useCallback((Te,at)=>{const rt=[3,2,1][Te.id],ee=o.filter(Ee=>Ee.fromId===(j==null?void 0:j.id)).find(Ee=>parseInt(Ee.fromPointIndex)===rt),pe=t.findIndex(Ee=>Ee.id===(ee==null?void 0:ee.toId));pe>=0?(ee==null?void 0:ee.fromId)===(ee==null?void 0:ee.toId)?at():Be(pe):ct()},[j==null?void 0:j.id,o,ct,t]),Ge=React$2.useCallback(()=>{if(Z.current={...K},w(!1),qe(),X)ot(!1);else if(!Ve()){const Te=_-1;Se({show:!1}),S(Te),e({type:"notifyProgress",payload:{line:Te}})}},[ot,e,X,U,_,K]),Ne=React$2.useCallback(Te=>{if(X){if(Te){const at=[3,2,1][Te.id],ve=o.filter(ee=>ee.fromId===j.id).find(ee=>parseInt(ee.fromPointIndex)===at);if(ve){const ee=t.findIndex(pe=>pe.id===ve.toId);ee>=0&&e({type:"notifyProgress",payload:{line:ee}})}else e({type:"saveNode"})}}else if(_<t.length-1){const at=_+1;e({type:"notifyProgress",payload:{line:at}})}else e({type:"saveNode"})},[o,_,t,e,j==null?void 0:j.id,X]),Re=React$2.useCallback((Te,at)=>{if(Z.current={...K},w(!1),qe(),X)Je([...De,j.id]),Te?ft(Te,at):ot();else if(_<t.length-1){const rt=_+1;Be(rt)}else(u||le||fe)&&ct()},[e,j==null?void 0:j.id,X,le,fe,_,t.length,ft,ot,ct,K]),_e=()=>{v(!1),Ge()},Oe=()=>X?j&&j.type!=="conversationalDecision"&&!o.find(Te=>Te.fromId===j.id):_===t.length-1,Ke=()=>{Oe()?ct():(v(!1),Re())};React$2.useEffect(()=>{if(X&&!b){const Te=x==null?void 0:x.line;if(Te>=0){T(!0),S(Te);return}const at=xt();at>=0&&(T(!0),S(at))}},[o,X,t,b,xt]);const Ft=Te=>{if(Z.current.uid===Te.uid||M.current.parent===Te)return;const at=new three.Object3D,rt=Te.getObjectByName("Head_M");rt.updateMatrixWorld(!0),at.applyMatrix4(rt.matrixWorld),at.applyQuaternion(D.quaternion);const ve=h?2.5:2,ee=h?1.2:1.5;at.translateY(ve),at.translateX(ee);const pe=new three.Vector3;pe.setFromMatrixPosition(rt.matrixWorld);const we=pe.project(D).x<0;M.current={pos:at.position.toArray(),child:rt,parent:Te,isLeft:we}},Nt=Te=>{e({type:"resetZIndexUIContainer",payload:Te})};React$2.useEffect(()=>{var Te;if(ie)ke(),Se({text:j==null?void 0:j.text,name:(j==null?void 0:j.alias)||(j==null?void 0:j.name)||`[ ${Fe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Le(K),show:!0});else if(!B.current&&!le&&!fe){const at=j==null?void 0:j.slots.filter(ee=>ee.uid&&!ee.talking),rt=[...at.map(ee=>ee.uid)||[],K==null?void 0:K.uid];if(Ae.filter(ee=>!rt.includes(ee)).forEach(ee=>{ue(ee,"idle")}),at.forEach(ee=>{const pe=getCurrentVisible(ee.uid,C);if(pe){const{isSeated:Ee}=pe;Qe(ee.uid,ee.emotion,ee.animation,Ee)}}),K){const ee=getCurrentVisible(K.uid,C),pe=s.find(Ee=>Ee.uid===K.uid);ee&&!B.current?setTimeout(()=>{var Ee,we;if(K.uid===ee.uid){Ft(ee);const{isSeated:de,userData:be}=ee,{emotion:Ue,animation:tt}=K;!((Ee=be._active)!=null&&Ee.includes("talking"))&&!((we=be._active)!=null&&we.includes(Ue))&&Qe(K.uid,Ue,tt,de);const gt=()=>{var Dt;Se({text:K.text,name:K.alias||((Dt=K.character)==null?void 0:Dt.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0})};h?(te.current=!1,Ye(gt)):gt()}},150):(ke(),Se({text:K.text,name:K.alias||((Te=K.character)==null?void 0:Te.name)||(pe==null?void 0:pe.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0}))}else ke(),Se({show:!0})}},[s,j,h,C,Fe,Le,ke,le,ie,Ae]);const je=cleanTextOfHtmlTags(ge==null?void 0:ge.text),[vt,Pt]=useEkho({audioType:j==null?void 0:j.audioType,volume:j==null?void 0:j.audioVolume,voice:j==null?void 0:j.voice,started:ge.show,text:je,audio:j==null?void 0:j.audio,soundActions:d,getEvent:n,pauseTTS:p,onStart:()=>{var Te;(Te=K==null?void 0:K.emotion)!=null&&Te.includes("think")||bt()},onError:()=>{w(!0)},onFinish:()=>{qe(),ce&&!p&&Re()}});React$2.useEffect(()=>(Pt(),()=>{Pt()}),[_,Pt]),React$2.useEffect(()=>{var Te;if(((j==null?void 0:j.audioType)==="none"||y)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){bt();const at=characterMs*(((Te=ge==null?void 0:ge.text)==null?void 0:Te.length)||0);setTimeout(()=>{qe()},at<minMs?minMs:at)}},[y,j==null?void 0:j.audioType,qe,bt,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var Te;if(ce&&ge.show&&((j==null?void 0:j.audioType)==="none"||y)&&!p){const at=characterMs*(((Te=ge==null?void 0:ge.text)==null?void 0:Te.length)||0);(!Oe()||Oe()&&u)&&N(Re,at<minMs?minMs:at)}return()=>{P()}},[ge,Re,N,u,P,j==null?void 0:j.audioType,ce,z,Y,y]);const lt=React$2.useMemo(()=>xt()>=0&&De.length===0&&X||!X&&_===0||Ve()||Me(),[_,Ve,Me,xt,De]),ze=l({disabled:le||!ge.show,repeat:!1,forward:Ke,rewind:lt?null:_e});React$2.useEffect(()=>ze(),[ze]);const Ze=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...j,emitEvent:e,success:!1,onFinish:Re},`change-camera-${_}`);if(le){const Te=j.id?t.filter(rt=>rt.decision).findIndex(rt=>rt.id===j.id)+1:t.filter(rt=>rt.decision).findIndex(rt=>rt===j)+1,at={...j.payload,decisionNumber:Te,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:Ne,onFinish:Re,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{ke(),Nt(!0)},onUnMount:()=>{te.current=!1,Nt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...at})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Fe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Ze?{current:Ze}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:_e,disabled:lt||!ge.show,className:`gat--btn__round ${lt||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.forward"):Fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Ke,disabled:!ge.show,className:`gat--btn__round
|
|
273
273
|
${ge.show?"":"disabled"}
|
|
274
|
-
${g&&Oe()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.rewind"):Fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:s,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(0);return React$2.useEffect(()=>{h(!1)},[s.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",s.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:s.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const x=p.userData.animator,R=()=>{const _=x.getAction(l.url);_.setLoop(three.LoopRepeat,1/0),_.reset();function S(){u.current+=1,u.current>=e&&g()}function g(){x.mix("idle"),n(),x.removeEventListener("loop",S)}x.mix(l==null?void 0:l.url).then(v=>{v&&(u.current=1,u.current>=e?g():x.addEventListener("loop",S))}),h(!0)};x.getAction(l==null?void 0:l.url)?(x.setTime(0),R()):assetLoader.load(l==null?void 0:l.url,_=>{x.register(l==null?void 0:l.url,_.animations[0]),x.setTime(0),R()},void 0,_=>{console.error(`Asset loader failed with: ${l.url}`,_),n()})}else n()}},[f,l==null?void 0:l.url,e,d,s.uid,o,l,s,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,s=React$2.useRef(0),o=()=>{s.current+=1,s.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{s.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[s,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),x=(g,v,b)=>{g.stopPropagation(),o(s.filter(T=>T!==s[b])),v.error&&h(d-1),v.isRepeat&&u(f-1)},R=()=>{p.current&&p.current.focus()},_=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],T=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(T.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?s.find(w=>w.text===v)?(u(f+1),o([...s,{text:v,error:!0,isRepeat:!0}])):o([...s,{text:v}]):(o([...s,{text:v,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:R,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[s&&s.map((g,v)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>x(b,g,v),emailPillIndex:v},`${s.indexOf(g)}`)),s.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:_,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[s.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||s.length===0?" disabled":""}`,type:"button",disabled:d>0||s.length===0,onClick:()=>l(s),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[s,o]=React$2.useState(!1),d=()=>{o(!s)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),s?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:s}){const o=_=>e({type:"translate",payload:_}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async _=>{const S=_.map(v=>v.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!s)return l({type:"success"}),null;const x=()=>{l({type:"success"})},R=()=>{if(f.current){const _=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:_})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:x,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:R,valid:f,invalid:u})]})})}function PseudoNoEvaluationEvent({onPass:l}){return React$2.useEffect(()=>{const e=setTimeout(l,0);return()=>clearTimeout(e)},[l]),null}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:s,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u,noEvaluation:p}){const[x]=f,[R,_]=React$2.useState(!1),[S,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),T=N=>h({type:"translate",payload:N}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(s.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(k=>k.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),_({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(k=>k.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],_({...P,success:!1})}},[s,l,t,e,o,d,n]),C=React$2.useCallback(()=>{if(s.find(P=>P===(l==null?void 0:l.uid))){let P;t?P=[...o.resolvers.rights.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.resolvers.rights[0].rewards.filter(F=>F.type==="var")],e&&d({type:"consumeItem",payload:{uid:l==null?void 0:l.uid,targetId:l==null?void 0:l.uid,name:l==null?void 0:l.name}}),b({varsPoints:[...P],success:!0})}else{let P;n?P=[...o.notResolvers.wrongs.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.notResolvers.wrongs[0].rewards.filter(F=>F.type==="var")],b({varsPoints:[...P],success:!1})}},[e,d,o.notResolvers.wrongs,o.resolvers.rights,n,t,l==null?void 0:l.name,l==null?void 0:l.uid,s]),D=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:D}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:x,hasTimeout:!R.desc,delay:2e3,translate:T,keyboardControl:u,functionOnClose:y}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver:s}){const[o,d]=React$2.useState(l),[h,f]=React$2.useState(!1),u=React$2.useRef();React$2.useEffect(()=>{t&&(d(l),f(!1))},[t,l]),React$2.useEffect(()=>{e&&f(!1)},[e]),React$2.useEffect(()=>{n&&f(!0)},[n]),React$2.useEffect(()=>(h&&o>0?u.current=setInterval(()=>{d(x=>x-1),o===1&&s()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,s,o]);const p=x=>{const R=Math.floor(x/60),_=x%60,S=String(R).padStart(2,"0"),g=String(_).padStart(2,"0");return`${S}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:s,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:x,timer:R=0,keyboardControl:_,backgroundImage:S}){const g=ke=>n({type:"translate",payload:ke}),v=`match-puzzle_${d}`,[b,T]=React$2.useState([]),[y,w]=React$2.useState(null),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[U,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=ke=>{X("click-ui");const Qe=ft=>ft==null?void 0:ft.startsWith("source-item"),bt=ft=>ft==null?void 0:ft.startsWith("destination-item");if(ke.id===y){w(null);return}const qe=Qe(ke.id),ct=Qe(y),Be=bt(ke.id),ot=bt(y);if(qe&&ot||Be&&ct){K(ke);return}w(ke.id)},se=ke=>{let Qe;return ke.startsWith("destination-item")?Qe={[y]:ke}:Qe={[ke]:y},x.some(bt=>{const qe=JSON.stringify(bt),ct=JSON.stringify(Qe);return qe===ct})},Z=(ke,Qe)=>{const bt=new Map(ke.map(qe=>[qe.id,{...qe}]));return Qe.forEach(qe=>{bt.has(qe.id)?bt.get(qe.id).points+=qe.points:bt.set(qe.id,{...qe})}),Array.from(bt.values())},K=ke=>{var Qe,bt;if(X("click-ui"),se(ke.id)){const qe=ke.id.startsWith("source-item")?ke.id:y,ct=ke.id.startsWith("destination-item")?ke.id:y,Be=[...b,{[qe]:ct}];if(T(Be),s.specificCorrectFeedbacks){const ot=s==null?void 0:s.correctFeedbacks.find(Ne=>Ne.id===`${qe}-${ct}`),ft=Z(U,ot.rewards);B([...ft]),te(Be)&&(et(),j(!0)),ot.desc&&(F(ot==null?void 0:ot.desc),P(!0),D(!0),et());const Ge=te(Be);!ot.desc&&Ge&&ue(ft)}else if(te(Be)&&(et(),j(!0)),te(Be)){P(!0),t.solution.right.desc&&(et(),F(t.solution.right.desc)),D(!0),j(!0);const ft=Z(U,t.solution.right.rewards);B([...ft]),t.solution.right.desc===""&&setTimeout(()=>{ue(ft)},3e3)}w(null)}else if(document.querySelector(`#${ke.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${ke.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),s.specificWrongFeedbacks){const qe=ke.id.startsWith("destination-item")?ke.id:y,ct=s==null?void 0:s.wrongFeedbacks.find(ot=>ot.id===qe),Be=Z(U,ct.rewards);B([...Be]),ct!=null&&ct.desc&&(F(ct.desc),P(!1),D(!0),et())}else{const qe=Z(U,t.solution.wrong.rewards);B([...qe]),(bt=(Qe=t.solution)==null?void 0:Qe.wrong)!=null&&bt.desc&&(F(t.solution.wrong.desc),D(!0),et())}},te=ke=>{if(x.length!==ke.length)return!1;const Qe=new Set(x.map(qe=>JSON.stringify(qe))),bt=new Set(ke.map(qe=>JSON.stringify(qe)));for(const qe of bt)if(!Qe.has(qe))return!1;return!0},ue=ke=>{X("score");const Qe=ke?[...ke]:[...U];l({type:"addPoints",complex:!0,finish:!0,payload:Qe}),l({type:"passPuzzle"})},me=()=>{D(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&xt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(ke,Qe)=>J[ke]===Qe;React$2.useEffect(()=>{o(()=>{X("score"),et(),P(!0),F(t.solution.right.desc);const ke=[...U,...t.resolve.rewards],Qe=[...x];T(Qe),setTimeout(()=>{P(!1),D(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ke,finish:!0}})},5e3)})},[U,x,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(ke,Qe)=>b.findIndex(bt=>{const qe=Object.keys(bt)[0],ct=Object.values(bt)[0];return qe===ke&&ct===Qe}),[V,z]=React$2.useState(!0),[Y,ie]=React$2.useState("storylines.misc.start"),[le,fe]=React$2.useState(!1),ce=()=>{ie("storylines.misc.retry"),z(!1),fe(!1),xt()},[ge,Se]=React$2.useState(!1),[Ae,Fe]=React$2.useState(!1),[De,Je]=React$2.useState(!1),ut=()=>{let ke=Z(U,t.timerFeedback.rewards);if(s.specificCorrectFeedbacks){const Qe=new Map(ke.map(bt=>[bt.id,{...bt}]));b.forEach(bt=>{const qe=Object.keys(bt)[0],ct=bt[qe],Be=s.correctFeedbacks.find(ot=>ot.id===`${qe}-${ct}`);Be!=null&&Be.rewards&&Be.rewards.forEach(ot=>{if(Qe.has(ot.id)){const ft=Qe.get(ot.id);ft.points-=ot.points,Qe.set(ot.id,ft)}})}),ke=Array.from(Qe.values())}B(ke),T([]),fe(!0),F(t.timerFeedback.desc),D(!0)},et=()=>{Se(!0),Fe(!1),Je(!1)},xt=()=>{Se(!1),Fe(!0),Je(!1)},Ve=()=>{Se(!1),Fe(!1),Je(!0)},Me=React$2.useCallback(()=>{const ke=document.querySelector('button[id^="source-item"]'),Qe=document.querySelector('button[id^="destination-item"]'),bt=ke.getBoundingClientRect().right,ct=Qe.getBoundingClientRect().left+6-bt;u.items.forEach((Be,ot)=>{if(Be.matchDestinationId!==void 0&&Be.matchDestinationId!==null){const ft=document.querySelector(`#${Be.id}`),Ge=document.querySelector(`#${Be.matchDestinationId}`),Ne=ft.getBoundingClientRect().top,Re=Ge.getBoundingClientRect().top,_e=Re>Ne,Oe=Math.abs(Re-Ne),Ke=Math.sqrt(ct*ct+Oe*Oe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Ke}px`);const Nt=Math.atan(Oe/ct),je=_e?Nt*(180/Math.PI):-Nt*(180/Math.PI);Ft.style.setProperty("transform",`rotate(${je}deg)`)}})},[u.items]);React$2.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>{window.removeEventListener("resize",Me)}),[Me]);const Le=React$2.useMemo(()=>{let ke="";return ke="match ",S!=null&&S.url&&(ke+="match--with-custom-bg"),ke},[S==null?void 0:S.url]),Ye={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Le,style:Ye,children:[(f||R>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[jsxRuntimeExports.jsx("div",{}),f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:HTMLReactParser$1(f)}),R>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:ge,shouldStart:Ae,shouldReset:De,onTimeOver:ut})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(u.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.id,ke.matchDestinationId)&&"match-button--success",W(ke.id,ke.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.id,ke.matchDestinationId)+1})`},disabled:H(ke.id,ke.matchDestinationId),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},ke.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.matchSourceId,ke.id)&&"match-button--success",W(ke.matchSourceId,ke.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.matchSourceId,ke.id)+1})`},disabled:H(ke.matchSourceId,ke.id),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},ke.id))})]})]})})]}),R>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:N,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:me,keyboardControl:_})]})}function SortPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:s,setResolveAction:o,nodeId:d,destinationAreas:h,draggableItems:f,noDraggableItems:u,background:p,showDestinationAreas:x,timer:R,viewMode:_,keyboardControl:S}){var Pt,lt;const g=ze=>n({type:"translate",payload:ze}),v=`sort-puzzle_${d}`,[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!1),[C,D]=React$2.useState(""),[N,P]=React$2.useState(!1),[k,F]=React$2.useState([]),[M]=e;useEkho({soundActions:e});const j=(ze,Ze)=>{const Et=rt=>rt.current.flatMap(ee=>{const pe=ee.acceptedItems;return pe||[]}).sort(),Te=Et(ze),at=Et(Ze);return Te.length!==at.length?!1:Te.join(",")===at.join(",")},U=React$2.useRef(0),B=React$2.useRef([]),X=React$2.useRef([]);React$2.useEffect(()=>{_==="matchMode"&&!U.current&&h.forEach(ze=>{U.current+=1,B.current.push({id:ze.id,acceptedItems:ze.acceptedItems}),X.current.push({id:ze.id,acceptedItems:[]})})},[h,_]);const re=React$2.useRef(null),se=React$2.useRef(null),[Z,K]=React$2.useState(),te=React$2.useCallback(()=>{const ze=re.current.clientHeight,Ze=se.current.clientHeight;K(ze/Ze),se.current.style.transform=`scale(${ze/Ze})`},[]);React$2.useEffect(()=>(te(),window.addEventListener("resize",te),()=>{window.removeEventListener("resize",te)}),[te]);const ue=React$2.useRef([]),me=React$2.useCallback(()=>{const ze=document.querySelectorAll(".sort-destination-area");ue.current=[],ze&&ze.forEach(Ze=>{ue.current.push({id:Ze.id,top:Ze.getBoundingClientRect().top,left:Ze.getBoundingClientRect().left,right:Ze.getBoundingClientRect().right,bottom:Ze.getBoundingClientRect().bottom})})},[]);React$2.useEffect(()=>(me(),window.addEventListener("resize",me),()=>{window.removeEventListener("resize",me)}),[me]);const J=(ze,Ze)=>{const Et=new Map(ze.map(Te=>[Te.id,{...Te}]));return Ze.forEach(Te=>{Et.has(Te.id)?Et.get(Te.id).points+=Te.points:Et.set(Te.id,{...Te})}),Array.from(Et.values())},H=ze=>{M("score");const Ze=ze?[...ze]:[...k];l({type:"addPoints",complex:!0,finish:!0,payload:Ze}),l({type:"passPuzzle"})},W=()=>{t.solution.right.desc&&(Ke(),D(t.solution.right.desc));const ze=J(k,t.solution.right.rewards);F([...ze]),ie(null,!0),t.solution.right.desc===""&&setTimeout(()=>{Y(),H(ze)},3e3)},V=(ze,Ze)=>{const Et=s==null?void 0:s.correctFeedbacks.find(at=>at.id===ze.id),Te=J(k,Et.rewards);F([...Te]),Et.desc&&ie(Et.desc,!0),!Et.desc&&Ze&&(ie(null,!0),setTimeout(()=>{Y(),H(Te)},3e3))},z=()=>{var Ze;const ze=J(k,t.solution.wrong.rewards);F([...ze]),t.solution.wrong.desc&&ie((Ze=t.solution.wrong)==null?void 0:Ze.desc,!1)},Y=React$2.useCallback(()=>{D(""),w(!1),T(!1),l({type:"hidePuzzleButtons",payload:!1})},[l]),ie=(ze,Ze=!1)=>{ze&&D(ze),Ze&&w(!0),T(!0),l({type:"hidePuzzleButtons",payload:!0}),Ke()},le=(ze,Ze)=>{setTimeout(()=>{Ze.classList.remove("sort-draggable-item--error"),Ze.classList.add("sort-draggable-item--resetting"),Ze.style.setProperty("transform",ze.transform),setTimeout(()=>Ze.classList.remove("sort-draggable-item--resetting"),1e3)},1e3)},fe=ze=>{if(ze==="none")return{x:0,y:0};const Et=ze.replace("matrix(","").replace("matrix3d(","").replace(")","").split(", ");return Et.length===6?{x:parseFloat(Et[4]),y:parseFloat(Et[5])}:Et.length===16?{x:parseFloat(Et[12]),y:parseFloat(Et[13])}:{x:0,y:0}},ce=React$2.useRef(!1),[ge,Se]=React$2.useState(),[Ae,Fe]=React$2.useState(),[De,Je]=React$2.useState(),ut=(ze,Ze)=>{ce.current=Ze,Se(ze.nativeEvent.x||ze.touches[0].pageX),Fe(ze.nativeEvent.y||ze.touches[0].pageY);const Et=document.querySelector(`#${Ze}`),at=window.getComputedStyle(Et).getPropertyValue("transform");Et.classList.add("sort-draggable-item--dragging"),Je(fe(at))},et=(ze,Ze)=>{const Et=document.querySelector(`#${Ze}`),Te=Et.getBoundingClientRect().width,at=Et.getBoundingClientRect().height,rt=Et.offsetLeft,ve=Et.offsetTop,ee=Et.parentElement.getBoundingClientRect().width,pe=Et.parentElement.getBoundingClientRect().height,Ee=Et.parentElement.getBoundingClientRect().left,we=Et.parentElement.getBoundingClientRect().right,de=Et.parentElement.getBoundingClientRect().top,be=Et.parentElement.getBoundingClientRect().bottom;if(ce&&ge&&Ae&&(ze.nativeEvent.x||ze.touches[0].pageX)>Ee&&(ze.nativeEvent.x||ze.touches[0].pageX)<we){const Ue=(ze.nativeEvent.x||ze.touches[0].pageX)-ge,tt=(ze.nativeEvent.y||ze.touches[0].pageY)-Ae;Et.style.transform=`translate(${De.x+Ue/Z}px, ${De.y+tt/Z}px)`,Et.getBoundingClientRect().left>=Ee&&Et.getBoundingClientRect().right<=we&&Et.getBoundingClientRect().top>=de&&Et.getBoundingClientRect().bottom<=be&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().left<=Ee&&(Et.style.transform=`translate(${-rt}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().right>=we&&(Et.style.transform=`translate(${(ee-Te)/Z-rt}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().top<=de&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${-ve}px)`),Et.getBoundingClientRect().bottom>=be&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${(pe-at)/Z-ve}px)`)}},xt=(ze,Ze)=>{const Te=document.querySelector(`#${ze}`).getBoundingClientRect(),at=ue.current.find(ve=>ve.id===Ze&&!(Te.left>=ve.right||Te.right<=ve.left||Te.top>=ve.bottom||Te.bottom<=ve.top)),rt=ue.current.find(ve=>ve.id!==Ze&&!(Te.left>=ve.right||Te.right<=ve.left||Te.top>=ve.bottom||Te.bottom<=ve.top));return at?"correctArea":rt?"incorrectArea":"neutral"},Ve=(ze,Ze)=>{if(ce.current===Ze){M("click-ui");const Et=document.querySelector(`#${Ze}`),Te=f.find(at=>Ze===at.id);if(Et.classList.remove("sort-draggable-item--dragging"),ce.current=null,Se(null),Fe(null),Je(null),_!=="resolveMode"){const at=xt(Ze,Te.destination.id);if(at==="correctArea"){if(_==="anyItemResolver"&&(M("score"),Ke(),Et.classList.add("sort-draggable-item--success"),s.specificCorrectFeedbacks?(P(!0),V(Te,!0)):W()),_==="matchMode")if(M("score"),Et.classList.add("sort-draggable-item--success"),X.current.find(ve=>ve.id===Te.destination.id).acceptedItems.push(Te.id),s.specificCorrectFeedbacks){const ve=j(X,B);ve&&P(!0),V(Te,ve)}else j(X,B)&&W();return}else if(at==="incorrectArea"){if(_==="anyItemResolver"||_==="matchMode"){if(M("fail"),Et.classList.add("sort-draggable-item--error"),s.specificWrongFeedbacks){const rt=s==null?void 0:s.wrongFeedbacks.find(ee=>ee.id===Te.id),ve=J(k,rt.rewards);F([...ve]),rt.desc&&ie(rt.desc,!1)}else z();le(Te,Et)}return}}}},Me=()=>{let ze=!1;Ke(),f.forEach(Ze=>{const Et=document.querySelector(`#${Ze.id}`);if(Ze.destination.id)xt(Ze.id,Ze.destination.id)!=="correctArea"?(ze=!0,Et.classList.add("sort-draggable-item--error"),le(Ze,Et)):Et.classList.add("sort-draggable-item--success");else if(!Ze.destination.id){const Te=document.querySelector(`#${Ze.id}`),at=Te.getBoundingClientRect();ue.current.find(ve=>!(at.left>=ve.right||at.right<=ve.left||at.top>=ve.bottom||at.bottom<=ve.top))&&(ze=!0,Te.classList.add("sort-draggable-item--error"),le(Ze,Te))}}),ze?(M("fail"),z()):(M("score"),W())},Le=()=>{f.forEach(ze=>{const Ze=document.querySelector(`#${ze.id}`);Ze.classList.remove("sort-draggable-item--error"),Ze.classList.remove("sort-draggable-item--success"),Ze.classList.add("sort-draggable-item--resetting"),Ze.style.setProperty("transform",ze.transform),setTimeout(()=>Ze.classList.remove("sort-draggable-item--resetting"),1e3)})},Ye=()=>{Y(),ct&&(Nt(),Le(),Qe(!0)),!ct&&!N&&Ft(),N&&H()},[ke,Qe]=React$2.useState(!0),[bt,qe]=React$2.useState("storylines.misc.start"),[ct,Be]=React$2.useState(!1),[ot,ft]=React$2.useState(!1),[Ge,Ne]=React$2.useState(!1),[Re,_e]=React$2.useState(!1),Oe=()=>{let ze=J(k,t.timerFeedback.rewards);if(s.specificCorrectFeedbacks){const Ze=new Map(ze.map(Et=>[Et.id,{...Et}]));ze=Array.from(Ze.values())}_==="matchMode"&&X.current.forEach(Ze=>{Ze.acceptedItems=[]}),F(ze),Be(!0),ie(t.timerFeedback.desc,!1)},Ke=()=>{ft(!0),Ne(!1),_e(!1)},Ft=()=>{ft(!1),Ne(!0),_e(!1)},Nt=()=>{ft(!1),Ne(!1),_e(!0)},je=()=>{qe("storylines.misc.retry"),Qe(!1),Be(!1),Ft()};React$2.useEffect(()=>{o(()=>{M("score"),Ke(),w(!0),D(t.solution.right.desc);const ze=[...k,...t.resolve.rewards];Y(),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ze,finish:!0}})})},[k,l,t.resolve.rewards,t.solution.right.desc,M,v,Y,o]);const vt={backgroundImage:(Pt=p==null?void 0:p.img)!=null&&Pt.url?`url('${(lt=p==null?void 0:p.img)==null?void 0:lt.url}')`:""};return jsxRuntimeExports.jsxs("div",{ref:re,className:"sort-wrapper",children:[jsxRuntimeExports.jsxs("div",{ref:se,className:"sort-puzzle",style:vt,children:[u.map(ze=>jsxRuntimeExports.jsxs("div",{id:`${ze.id}`,className:"sort-no-draggable-item",style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`,"--backgroundColor":`${ze.backgroundColor}`},children:[ze.imgId&&jsxRuntimeExports.jsx("img",{src:ze.img.url,alt:ze.img.name}),ze.text&&HTMLReactParser$1(ze.text)]},ze.id)),h.map(ze=>jsxRuntimeExports.jsx("div",{id:ze.id,className:`sort-destination-area ${x?"sort-destination-area--revelable":""}`,style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`}},ze.id)),f.map(ze=>jsxRuntimeExports.jsxs("div",{id:`${ze.id}`,className:"sort-draggable-item",onMouseDown:Ze=>ut(Ze,ze.id),onTouchStart:Ze=>ut(Ze,ze.id),onMouseMove:Ze=>et(Ze,ze.id),onTouchMove:Ze=>et(Ze,ze.id),onMouseUp:Ze=>Ve(Ze,ze.id),onMouseLeave:Ze=>Ve(Ze,ze.id),onTouchEnd:Ze=>Ve(Ze,ze.id),style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`,"--backgroundColor":`${ze.backgroundColor}`},children:[ze.imgId&&jsxRuntimeExports.jsx("img",{src:ze.img.url,alt:ze.img.name}),ze.text&&HTMLReactParser$1(ze.text)]},ze.id))]}),_==="resolveMode"&&jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Me()},className:"gat--btn gat--btn__primary sort-resolve-button",children:jsxRuntimeExports.jsx("span",{children:g("storylines.misc.check")})}),R>0&&ke&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:bt,translate:g,onClose:je}),b&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:y,text:C,hasTimeout:!C,translate:g,timeExpired:ct,functionOnClose:Ye,keyboardControl:S}),R>0&&jsxRuntimeExports.jsx("div",{className:"sort-timer",children:jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:ot,shouldStart:Ge,shouldReset:Re,onTimeOver:Oe})})]})}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.MatchPuzzleComponent=MatchPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SortPuzzleComponent=SortPuzzleComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
|
|
274
|
+
${g&&Oe()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.rewind"):Fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:s,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(0);return React$2.useEffect(()=>{h(!1)},[s.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",s.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:s.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const x=p.userData.animator,R=()=>{const _=x.getAction(l.url);_.setLoop(three.LoopRepeat,1/0),_.reset();function S(){u.current+=1,u.current>=e&&g()}function g(){x.mix("idle"),n(),x.removeEventListener("loop",S)}x.mix(l==null?void 0:l.url).then(v=>{v&&(u.current=1,u.current>=e?g():x.addEventListener("loop",S))}),h(!0)};x.getAction(l==null?void 0:l.url)?(x.setTime(0),R()):assetLoader.load(l==null?void 0:l.url,_=>{x.register(l==null?void 0:l.url,_.animations[0]),x.setTime(0),R()},void 0,_=>{console.error(`Asset loader failed with: ${l.url}`,_),n()})}else n()}},[f,l==null?void 0:l.url,e,d,s.uid,o,l,s,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,s=React$2.useRef(0),o=()=>{s.current+=1,s.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{s.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[s,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),x=(g,v,b)=>{g.stopPropagation(),o(s.filter(T=>T!==s[b])),v.error&&h(d-1),v.isRepeat&&u(f-1)},R=()=>{p.current&&p.current.focus()},_=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],T=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(T.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?s.find(w=>w.text===v)?(u(f+1),o([...s,{text:v,error:!0,isRepeat:!0}])):o([...s,{text:v}]):(o([...s,{text:v,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:R,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[s&&s.map((g,v)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>x(b,g,v),emailPillIndex:v},`${s.indexOf(g)}`)),s.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:_,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[s.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||s.length===0?" disabled":""}`,type:"button",disabled:d>0||s.length===0,onClick:()=>l(s),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[s,o]=React$2.useState(!1),d=()=>{o(!s)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),s?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:s}){const o=_=>e({type:"translate",payload:_}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async _=>{const S=_.map(v=>v.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!s)return l({type:"success"}),null;const x=()=>{l({type:"success"})},R=()=>{if(f.current){const _=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:_})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:x,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:R,valid:f,invalid:u})]})})}function PseudoNoEvaluationEvent({onPass:l}){return React$2.useEffect(()=>{const e=setTimeout(l,0);return()=>clearTimeout(e)},[l]),null}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:s,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u,noEvaluation:p}){const[x]=f,[R,_]=React$2.useState(!1),[S,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),T=N=>h({type:"translate",payload:N}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(s.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(k=>k.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),_({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(k=>k.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],_({...P,success:!1})}},[s,l,t,e,o,d,n]),C=React$2.useCallback(()=>{if(s.find(P=>P===(l==null?void 0:l.uid))){let P;t?P=[...o.resolvers.rights.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.resolvers.rights[0].rewards.filter(F=>F.type==="var")],e&&d({type:"consumeItem",payload:{uid:l==null?void 0:l.uid,targetId:l==null?void 0:l.uid,name:l==null?void 0:l.name}}),b({varsPoints:[...P],success:!0})}else{let P;n?P=[...o.notResolvers.wrongs.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.notResolvers.wrongs[0].rewards.filter(F=>F.type==="var")],b({varsPoints:[...P],success:!1})}},[e,d,o.notResolvers.wrongs,o.resolvers.rights,n,t,l==null?void 0:l.name,l==null?void 0:l.uid,s]),D=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:D}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:x,hasTimeout:!R.desc,delay:2e3,translate:T,keyboardControl:u,functionOnClose:y}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver:s}){const[o,d]=React$2.useState(l),[h,f]=React$2.useState(!1),u=React$2.useRef();React$2.useEffect(()=>{t&&(d(l),f(!1))},[t,l]),React$2.useEffect(()=>{e&&f(!1)},[e]),React$2.useEffect(()=>{n&&f(!0)},[n]),React$2.useEffect(()=>(h&&o>0?u.current=setInterval(()=>{d(x=>x-1),o===1&&s()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,s,o]);const p=x=>{const R=Math.floor(x/60),_=x%60,S=String(R).padStart(2,"0"),g=String(_).padStart(2,"0");return`${S}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:s,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:x,timer:R=0,keyboardControl:_,backgroundImage:S}){const g=ke=>n({type:"translate",payload:ke}),v=`match-puzzle_${d}`,[b,T]=React$2.useState([]),[y,w]=React$2.useState(null),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[U,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=ke=>{X("click-ui");const Qe=ft=>ft==null?void 0:ft.startsWith("source-item"),bt=ft=>ft==null?void 0:ft.startsWith("destination-item");if(ke.id===y){w(null);return}const qe=Qe(ke.id),ct=Qe(y),Be=bt(ke.id),ot=bt(y);if(qe&&ot||Be&&ct){K(ke);return}w(ke.id)},se=ke=>{let Qe;return ke.startsWith("destination-item")?Qe={[y]:ke}:Qe={[ke]:y},x.some(bt=>{const qe=JSON.stringify(bt),ct=JSON.stringify(Qe);return qe===ct})},Z=(ke,Qe)=>{const bt=new Map(ke.map(qe=>[qe.id,{...qe}]));return Qe.forEach(qe=>{bt.has(qe.id)?bt.get(qe.id).points+=qe.points:bt.set(qe.id,{...qe})}),Array.from(bt.values())},K=ke=>{var Qe,bt;if(X("click-ui"),se(ke.id)){const qe=ke.id.startsWith("source-item")?ke.id:y,ct=ke.id.startsWith("destination-item")?ke.id:y,Be=[...b,{[qe]:ct}];if(T(Be),s.specificCorrectFeedbacks){const ot=s==null?void 0:s.correctFeedbacks.find(Ne=>Ne.id===`${qe}-${ct}`),ft=Z(U,ot.rewards);B([...ft]),te(Be)&&(et(),j(!0)),ot.desc&&(F(ot==null?void 0:ot.desc),P(!0),D(!0),et());const Ge=te(Be);!ot.desc&&Ge&&ue(ft)}else if(te(Be)&&(et(),j(!0)),te(Be)){P(!0),t.solution.right.desc&&(et(),F(t.solution.right.desc)),D(!0),j(!0);const ft=Z(U,t.solution.right.rewards);B([...ft]),t.solution.right.desc===""&&setTimeout(()=>{ue(ft)},3e3)}w(null)}else if(document.querySelector(`#${ke.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${ke.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),s.specificWrongFeedbacks){const qe=ke.id.startsWith("destination-item")?ke.id:y,ct=s==null?void 0:s.wrongFeedbacks.find(ot=>ot.id===qe),Be=Z(U,ct.rewards);B([...Be]),ct!=null&&ct.desc&&(F(ct.desc),P(!1),D(!0),et())}else{const qe=Z(U,t.solution.wrong.rewards);B([...qe]),(bt=(Qe=t.solution)==null?void 0:Qe.wrong)!=null&&bt.desc&&(F(t.solution.wrong.desc),D(!0),et())}},te=ke=>{if(x.length!==ke.length)return!1;const Qe=new Set(x.map(qe=>JSON.stringify(qe))),bt=new Set(ke.map(qe=>JSON.stringify(qe)));for(const qe of bt)if(!Qe.has(qe))return!1;return!0},ue=ke=>{X("score");const Qe=ke?[...ke]:[...U];l({type:"addPoints",complex:!0,finish:!0,payload:Qe}),l({type:"passPuzzle"})},me=()=>{D(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&xt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(ke,Qe)=>J[ke]===Qe;React$2.useEffect(()=>{o(()=>{X("score"),et(),P(!0),F(t.solution.right.desc);const ke=[...U,...t.resolve.rewards],Qe=[...x];T(Qe),setTimeout(()=>{P(!1),D(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ke,finish:!0}})},5e3)})},[U,x,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(ke,Qe)=>b.findIndex(bt=>{const qe=Object.keys(bt)[0],ct=Object.values(bt)[0];return qe===ke&&ct===Qe}),[V,z]=React$2.useState(!0),[Y,ie]=React$2.useState("storylines.misc.start"),[le,fe]=React$2.useState(!1),ce=()=>{ie("storylines.misc.retry"),z(!1),fe(!1),xt()},[ge,Se]=React$2.useState(!1),[Ae,Fe]=React$2.useState(!1),[De,Je]=React$2.useState(!1),ut=()=>{let ke=Z(U,t.timerFeedback.rewards);if(s.specificCorrectFeedbacks){const Qe=new Map(ke.map(bt=>[bt.id,{...bt}]));b.forEach(bt=>{const qe=Object.keys(bt)[0],ct=bt[qe],Be=s.correctFeedbacks.find(ot=>ot.id===`${qe}-${ct}`);Be!=null&&Be.rewards&&Be.rewards.forEach(ot=>{if(Qe.has(ot.id)){const ft=Qe.get(ot.id);ft.points-=ot.points,Qe.set(ot.id,ft)}})}),ke=Array.from(Qe.values())}B(ke),T([]),fe(!0),F(t.timerFeedback.desc),D(!0)},et=()=>{Se(!0),Fe(!1),Je(!1)},xt=()=>{Se(!1),Fe(!0),Je(!1)},Ve=()=>{Se(!1),Fe(!1),Je(!0)},Me=React$2.useCallback(()=>{const ke=document.querySelector('button[id^="source-item"]'),Qe=document.querySelector('button[id^="destination-item"]'),bt=ke.getBoundingClientRect().right,ct=Qe.getBoundingClientRect().left+6-bt;u.items.forEach((Be,ot)=>{if(Be.matchDestinationId!==void 0&&Be.matchDestinationId!==null){const ft=document.querySelector(`#${Be.id}`),Ge=document.querySelector(`#${Be.matchDestinationId}`),Ne=ft.getBoundingClientRect().top,Re=Ge.getBoundingClientRect().top,_e=Re>Ne,Oe=Math.abs(Re-Ne),Ke=Math.sqrt(ct*ct+Oe*Oe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Ke}px`);const Nt=Math.atan(Oe/ct),je=_e?Nt*(180/Math.PI):-Nt*(180/Math.PI);Ft.style.setProperty("transform",`rotate(${je}deg)`)}})},[u.items]);React$2.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>{window.removeEventListener("resize",Me)}),[Me]);const Le=React$2.useMemo(()=>{let ke="";return ke="match ",S!=null&&S.url&&(ke+="match--with-custom-bg"),ke},[S==null?void 0:S.url]),Ye={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Le,style:Ye,children:[(f||R>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[jsxRuntimeExports.jsx("div",{}),f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:HTMLReactParser$1(f)}),R>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:ge,shouldStart:Ae,shouldReset:De,onTimeOver:ut})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(u.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.id,ke.matchDestinationId)&&"match-button--success",W(ke.id,ke.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.id,ke.matchDestinationId)+1})`},disabled:H(ke.id,ke.matchDestinationId),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},ke.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.matchSourceId,ke.id)&&"match-button--success",W(ke.matchSourceId,ke.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.matchSourceId,ke.id)+1})`},disabled:H(ke.matchSourceId,ke.id),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},ke.id))})]})]})})]}),R>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:N,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:me,keyboardControl:_})]})}function SortPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:s,setResolveAction:o,nodeId:d,destinationAreas:h,draggableItems:f,noDraggableItems:u,background:p,showDestinationAreas:x,timer:R,viewMode:_,keyboardControl:S}){var Pt,lt;const g=ze=>n({type:"translate",payload:ze}),v=`sort-puzzle_${d}`,[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!1),[C,D]=React$2.useState(""),[N,P]=React$2.useState(!1),[k,F]=React$2.useState([]),[M]=e;useEkho({soundActions:e});const j=(ze,Ze)=>{const Et=rt=>rt.current.flatMap(ee=>{const pe=ee.acceptedItems;return pe||[]}).sort(),Te=Et(ze),at=Et(Ze);return Te.length!==at.length?!1:Te.join(",")===at.join(",")},U=React$2.useRef(0),B=React$2.useRef([]),X=React$2.useRef([]);React$2.useEffect(()=>{_==="matchMode"&&!U.current&&h.forEach(ze=>{U.current+=1,B.current.push({id:ze.id,acceptedItems:ze.acceptedItems}),X.current.push({id:ze.id,acceptedItems:[]})})},[h,_]);const re=React$2.useRef(null),se=React$2.useRef(null),[Z,K]=React$2.useState(),te=React$2.useCallback(()=>{const ze=re.current.clientHeight,Ze=se.current.clientHeight;K(ze/Ze),se.current.style.transform=`scale(${ze/Ze})`},[]);React$2.useEffect(()=>(te(),window.addEventListener("resize",te),()=>{window.removeEventListener("resize",te)}),[te]);const ue=React$2.useRef([]),me=React$2.useCallback(()=>{const ze=document.querySelectorAll(".sort-destination-area");ue.current=[],ze&&ze.forEach(Ze=>{ue.current.push({id:Ze.id,top:Ze.getBoundingClientRect().top,left:Ze.getBoundingClientRect().left,right:Ze.getBoundingClientRect().right,bottom:Ze.getBoundingClientRect().bottom})})},[]);React$2.useEffect(()=>(me(),window.addEventListener("resize",me),()=>{window.removeEventListener("resize",me)}),[me]);const J=(ze,Ze)=>{const Et=new Map(ze.map(Te=>[Te.id,{...Te}]));return Ze.forEach(Te=>{Et.has(Te.id)?Et.get(Te.id).points+=Te.points:Et.set(Te.id,{...Te})}),Array.from(Et.values())},H=ze=>{M("score");const Ze=ze?[...ze]:[...k];l({type:"addPoints",complex:!0,finish:!0,payload:Ze}),l({type:"passPuzzle"})},W=()=>{t.solution.right.desc&&(Ke(),D(t.solution.right.desc));const ze=J(k,t.solution.right.rewards);F([...ze]),ie(null,!0),t.solution.right.desc===""&&setTimeout(()=>{Y(),H(ze)},3e3)},V=(ze,Ze)=>{const Et=s==null?void 0:s.correctFeedbacks.find(at=>at.id===ze.id),Te=J(k,Et.rewards);F([...Te]),Et.desc&&ie(Et.desc,!0),!Et.desc&&Ze&&(ie(null,!0),setTimeout(()=>{Y(),H(Te)},3e3))},z=()=>{var Ze;const ze=J(k,t.solution.wrong.rewards);F([...ze]),t.solution.wrong.desc&&ie((Ze=t.solution.wrong)==null?void 0:Ze.desc,!1)},Y=React$2.useCallback(()=>{D(""),w(!1),T(!1),l({type:"hidePuzzleButtons",payload:!1})},[l]),ie=(ze,Ze=!1)=>{ze&&D(ze),Ze&&w(!0),T(!0),l({type:"hidePuzzleButtons",payload:!0}),Ke()},le=(ze,Ze)=>{setTimeout(()=>{Ze.classList.remove("sort-draggable-item--error"),Ze.classList.add("sort-draggable-item--resetting"),Ze.style.setProperty("transform",ze.transform),setTimeout(()=>Ze.classList.remove("sort-draggable-item--resetting"),1e3)},1e3)},fe=ze=>{if(ze==="none")return{x:0,y:0};const Et=ze.replace("matrix(","").replace("matrix3d(","").replace(")","").split(", ");return Et.length===6?{x:parseFloat(Et[4]),y:parseFloat(Et[5])}:Et.length===16?{x:parseFloat(Et[12]),y:parseFloat(Et[13])}:{x:0,y:0}},ce=React$2.useRef(!1),[ge,Se]=React$2.useState(),[Ae,Fe]=React$2.useState(),[De,Je]=React$2.useState(),ut=(ze,Ze)=>{ce.current=Ze,Se(ze.nativeEvent.x||ze.touches[0].pageX),Fe(ze.nativeEvent.y||ze.touches[0].pageY);const Et=document.querySelector(`#${Ze}`),at=window.getComputedStyle(Et).getPropertyValue("transform");Et.classList.add("sort-draggable-item--dragging"),Je(fe(at))},et=(ze,Ze)=>{const Et=document.querySelector(`#${Ze}`),Te=Et.getBoundingClientRect().width,at=Et.getBoundingClientRect().height,rt=Et.offsetLeft,ve=Et.offsetTop,ee=Et.parentElement.getBoundingClientRect().width,pe=Et.parentElement.getBoundingClientRect().height,Ee=Et.parentElement.getBoundingClientRect().left,we=Et.parentElement.getBoundingClientRect().right,de=Et.parentElement.getBoundingClientRect().top,be=Et.parentElement.getBoundingClientRect().bottom;if(ce&&ge&&Ae&&(ze.nativeEvent.x||ze.touches[0].pageX)>Ee&&(ze.nativeEvent.x||ze.touches[0].pageX)<we){const Ue=(ze.nativeEvent.x||ze.touches[0].pageX)-ge,tt=(ze.nativeEvent.y||ze.touches[0].pageY)-Ae;Et.style.transform=`translate(${De.x+Ue/Z}px, ${De.y+tt/Z}px)`,Et.getBoundingClientRect().left>=Ee&&Et.getBoundingClientRect().right<=we&&Et.getBoundingClientRect().top>=de&&Et.getBoundingClientRect().bottom<=be&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().left<=Ee&&(Et.style.transform=`translate(${-rt}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().right>=we&&(Et.style.transform=`translate(${(ee-Te)/Z-rt}px, ${De.y+tt/Z}px)`),Et.getBoundingClientRect().top<=de&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${-ve}px)`),Et.getBoundingClientRect().bottom>=be&&(Et.style.transform=`translate(${De.x+Ue/Z}px, ${(pe-at)/Z-ve}px)`)}},xt=(ze,Ze)=>{const Te=document.querySelector(`#${ze}`).getBoundingClientRect(),at=ue.current.find(ve=>ve.id===Ze&&!(Te.left>=ve.right||Te.right<=ve.left||Te.top>=ve.bottom||Te.bottom<=ve.top)),rt=ue.current.find(ve=>ve.id!==Ze&&!(Te.left>=ve.right||Te.right<=ve.left||Te.top>=ve.bottom||Te.bottom<=ve.top));return at?"correctArea":rt?"incorrectArea":"neutral"},Ve=(ze,Ze)=>{if(ce.current===Ze){M("click-ui");const Et=document.querySelector(`#${Ze}`),Te=f.find(at=>Ze===at.id);if(Et.classList.remove("sort-draggable-item--dragging"),ce.current=null,Se(null),Fe(null),Je(null),_!=="resolveMode"){const at=xt(Ze,Te.destination.id);if(at==="correctArea"){if(_==="anyItemResolver"&&(M("score"),Ke(),Et.classList.add("sort-draggable-item--success"),s.specificCorrectFeedbacks?(P(!0),V(Te,!0)):W()),_==="matchMode")if(M("score"),Et.classList.add("sort-draggable-item--success"),X.current.find(ve=>ve.id===Te.destination.id).acceptedItems.push(Te.id),s.specificCorrectFeedbacks){const ve=j(X,B);ve&&P(!0),V(Te,ve)}else j(X,B)&&W();return}else if(at==="incorrectArea"){if(_==="anyItemResolver"||_==="matchMode"){if(M("fail"),Et.classList.add("sort-draggable-item--error"),s.specificWrongFeedbacks){const rt=s==null?void 0:s.wrongFeedbacks.find(ee=>ee.id===Te.id),ve=J(k,rt.rewards);F([...ve]),rt.desc&&ie(rt.desc,!1)}else z();le(Te,Et)}return}}}},Me=()=>{let ze=!1;Ke(),f.forEach(Ze=>{const Et=document.querySelector(`#${Ze.id}`);if(Ze.destination.id)xt(Ze.id,Ze.destination.id)!=="correctArea"?(ze=!0,Et.classList.add("sort-draggable-item--error"),le(Ze,Et)):Et.classList.add("sort-draggable-item--success");else if(!Ze.destination.id){const Te=document.querySelector(`#${Ze.id}`),at=Te.getBoundingClientRect();ue.current.find(ve=>!(at.left>=ve.right||at.right<=ve.left||at.top>=ve.bottom||at.bottom<=ve.top))&&(ze=!0,Te.classList.add("sort-draggable-item--error"),le(Ze,Te))}}),ze?(M("fail"),z()):(M("score"),P(!0),W())},Le=()=>{f.forEach(ze=>{const Ze=document.querySelector(`#${ze.id}`);Ze.classList.remove("sort-draggable-item--error"),Ze.classList.remove("sort-draggable-item--success"),Ze.classList.add("sort-draggable-item--resetting"),Ze.style.setProperty("transform",ze.transform),setTimeout(()=>Ze.classList.remove("sort-draggable-item--resetting"),1e3)})},Ye=()=>{Y(),ct&&(Nt(),Le(),Qe(!0)),!ct&&!N&&Ft(),N&&H()},[ke,Qe]=React$2.useState(!0),[bt,qe]=React$2.useState("storylines.misc.start"),[ct,Be]=React$2.useState(!1),[ot,ft]=React$2.useState(!1),[Ge,Ne]=React$2.useState(!1),[Re,_e]=React$2.useState(!1),Oe=()=>{let ze=J(k,t.timerFeedback.rewards);if(s.specificCorrectFeedbacks){const Ze=new Map(ze.map(Et=>[Et.id,{...Et}]));ze=Array.from(Ze.values())}_==="matchMode"&&X.current.forEach(Ze=>{Ze.acceptedItems=[]}),F(ze),Be(!0),ie(t.timerFeedback.desc,!1)},Ke=()=>{ft(!0),Ne(!1),_e(!1)},Ft=()=>{ft(!1),Ne(!0),_e(!1)},Nt=()=>{ft(!1),Ne(!1),_e(!0)},je=()=>{qe("storylines.misc.retry"),Qe(!1),Be(!1),Ft()};React$2.useEffect(()=>{o(()=>{M("score"),Ke(),w(!0),D(t.solution.right.desc);const ze=[...k,...t.resolve.rewards];Y(),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ze,finish:!0}})})},[k,l,t.resolve.rewards,t.solution.right.desc,M,v,Y,o]);const vt={backgroundImage:(Pt=p==null?void 0:p.img)!=null&&Pt.url?`url('${(lt=p==null?void 0:p.img)==null?void 0:lt.url}')`:""};return jsxRuntimeExports.jsxs("div",{ref:re,className:"sort-wrapper",children:[jsxRuntimeExports.jsxs("div",{ref:se,className:"sort-puzzle",style:vt,children:[u.map(ze=>jsxRuntimeExports.jsxs("div",{id:`${ze.id}`,className:"sort-no-draggable-item",style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`,"--backgroundColor":`${ze.backgroundColor}`},children:[ze.imgId&&jsxRuntimeExports.jsx("img",{src:ze.img.url,alt:ze.img.name}),ze.text&&HTMLReactParser$1(ze.text)]},ze.id)),h.map(ze=>jsxRuntimeExports.jsx("div",{id:ze.id,className:`sort-destination-area ${x?"sort-destination-area--revelable":""}`,style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`}},ze.id)),f.map(ze=>jsxRuntimeExports.jsxs("div",{id:`${ze.id}`,className:"sort-draggable-item",onMouseDown:Ze=>ut(Ze,ze.id),onTouchStart:Ze=>ut(Ze,ze.id),onMouseMove:Ze=>et(Ze,ze.id),onTouchMove:Ze=>et(Ze,ze.id),onMouseUp:Ze=>Ve(Ze,ze.id),onMouseLeave:Ze=>Ve(Ze,ze.id),onTouchEnd:Ze=>Ve(Ze,ze.id),style:{"--height":`${ze.heightInPercentage}%`,"--width":`${ze.widthInPercentage}%`,"--transform":`${ze.transform}`,"--backgroundColor":`${ze.backgroundColor}`},children:[ze.imgId&&jsxRuntimeExports.jsx("img",{src:ze.img.url,alt:ze.img.name}),ze.text&&HTMLReactParser$1(ze.text)]},ze.id))]}),_==="resolveMode"&&jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Me()},className:"gat--btn gat--btn__primary sort-resolve-button",children:jsxRuntimeExports.jsx("span",{children:g("storylines.misc.check")})}),R>0&&ke&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:bt,translate:g,onClose:je}),b&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:y,text:C,hasTimeout:!C,translate:g,timeExpired:ct,functionOnClose:Ye,keyboardControl:S}),R>0&&jsxRuntimeExports.jsx("div",{className:"sort-timer",children:jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:ot,shouldStart:Ge,shouldReset:Re,onTimeOver:Oe})})]})}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.MatchPuzzleComponent=MatchPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SortPuzzleComponent=SortPuzzleComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
|
|
275
275
|
//# sourceMappingURL=arcade-components.cjs.map
|