@gamelearn/arcade-components 3.41.0 → 3.42.0
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.
|
@@ -41,7 +41,7 @@ object-assign
|
|
|
41
41
|
*/var oO,HP;function EY(){if(HP)return oO;HP=1;var u=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function i(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var o={},l=0;l<10;l++)o["_"+String.fromCharCode(l)]=l;var c=Object.getOwnPropertyNames(o).map(function(f){return o[f]});if(c.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(f){d[f]=f}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return oO=i()?Object.assign:function(s,o){for(var l,c=n(s),d,f=1;f<arguments.length;f++){l=Object(arguments[f]);for(var m in l)t.call(l,m)&&(c[m]=l[m]);if(u){d=u(l);for(var _=0;_<d.length;_++)e.call(l,d[_])&&(c[d[_]]=l[d[_]])}}return c},oO}var lO,GP;function p9(){if(GP)return lO;GP=1;var u="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return lO=u,lO}var uO,VP;function TY(){if(VP)return uO;VP=1;var u=function(){};if(process.env.NODE_ENV!=="production"){var t=p9(),e={},n=Function.call.bind(Object.prototype.hasOwnProperty);u=function(s){var o="Warning: "+s;typeof console<"u"&&console.error(o);try{throw new Error(o)}catch{}}}function i(s,o,l,c,d){if(process.env.NODE_ENV!=="production"){for(var f in s)if(n(s,f)){var m;try{if(typeof s[f]!="function"){var _=Error((c||"React class")+": "+l+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof s[f]+"`.");throw _.name="Invariant Violation",_}m=s[f](o,f,c,l,null,t)}catch(S){m=S}if(m&&!(m instanceof Error)&&u((c||"React class")+": type specification of "+l+" `"+f+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in e)){e[m.message]=!0;var g=d?d():"";u("Failed "+l+" type: "+m.message+(g??""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(e={})},uO=i,uO}var cO,YP;function AY(){if(YP)return cO;YP=1;var u=uF(),t=EY(),e=p9(),n=TY(),i=Function.call.bind(Object.prototype.hasOwnProperty),s=function(){};process.env.NODE_ENV!=="production"&&(s=function(l){var c="Warning: "+l;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}});function o(){return null}return cO=function(l,c){var d=typeof Symbol=="function"&&Symbol.iterator,f="@@iterator";function m(Q){var tt=Q&&(d&&Q[d]||Q[f]);if(typeof tt=="function")return tt}var _="<<anonymous>>",g={array:T("array"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:A(),arrayOf:E,element:C(),elementType:R(),instanceOf:N,node:L(),objectOf:M,oneOf:O,oneOfType:B,shape:F,exact:I};function S(Q,tt){return Q===tt?Q!==0||1/Q===1/tt:Q!==Q&&tt!==tt}function y(Q){this.message=Q,this.stack=""}y.prototype=Error.prototype;function x(Q){if(process.env.NODE_ENV!=="production")var tt={},rt=0;function ut(ot,ht,vt,it,lt,dt,Et){if(it=it||_,dt=dt||vt,Et!==e){if(c){var _t=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 _t.name="Invariant Violation",_t}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var pt=it+":"+vt;!tt[pt]&&rt<3&&(s("You are manually calling a React.PropTypes validation function for the `"+dt+"` prop on `"+it+"`. 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."),tt[pt]=!0,rt++)}}return ht[vt]==null?ot?ht[vt]===null?new y("The "+lt+" `"+dt+"` is marked as required "+("in `"+it+"`, but its value is `null`.")):new y("The "+lt+" `"+dt+"` is marked as required in "+("`"+it+"`, but its value is `undefined`.")):null:Q(ht,vt,it,lt,dt)}var st=ut.bind(null,!1);return st.isRequired=ut.bind(null,!0),st}function T(Q){function tt(rt,ut,st,ot,ht,vt){var it=rt[ut],lt=Z(it);if(lt!==Q){var dt=X(it);return new y("Invalid "+ot+" `"+ht+"` of type "+("`"+dt+"` supplied to `"+st+"`, expected ")+("`"+Q+"`."))}return null}return x(tt)}function A(){return x(o)}function E(Q){function tt(rt,ut,st,ot,ht){if(typeof Q!="function")return new y("Property `"+ht+"` of component `"+st+"` has invalid PropType notation inside arrayOf.");var vt=rt[ut];if(!Array.isArray(vt)){var it=Z(vt);return new y("Invalid "+ot+" `"+ht+"` of type "+("`"+it+"` supplied to `"+st+"`, expected an array."))}for(var lt=0;lt<vt.length;lt++){var dt=Q(vt,lt,st,ot,ht+"["+lt+"]",e);if(dt instanceof Error)return dt}return null}return x(tt)}function C(){function Q(tt,rt,ut,st,ot){var ht=tt[rt];if(!l(ht)){var vt=Z(ht);return new y("Invalid "+st+" `"+ot+"` of type "+("`"+vt+"` supplied to `"+ut+"`, expected a single ReactElement."))}return null}return x(Q)}function R(){function Q(tt,rt,ut,st,ot){var ht=tt[rt];if(!u.isValidElementType(ht)){var vt=Z(ht);return new y("Invalid "+st+" `"+ot+"` of type "+("`"+vt+"` supplied to `"+ut+"`, expected a single ReactElement type."))}return null}return x(Q)}function N(Q){function tt(rt,ut,st,ot,ht){if(!(rt[ut]instanceof Q)){var vt=Q.name||_,it=nt(rt[ut]);return new y("Invalid "+ot+" `"+ht+"` of type "+("`"+it+"` supplied to `"+st+"`, expected ")+("instance of `"+vt+"`."))}return null}return x(tt)}function O(Q){if(!Array.isArray(Q))return process.env.NODE_ENV!=="production"&&(arguments.length>1?s("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])."):s("Invalid argument supplied to oneOf, expected an array.")),o;function tt(rt,ut,st,ot,ht){for(var vt=rt[ut],it=0;it<Q.length;it++)if(S(vt,Q[it]))return null;var lt=JSON.stringify(Q,function(Et,_t){var pt=X(_t);return pt==="symbol"?String(_t):_t});return new y("Invalid "+ot+" `"+ht+"` of value `"+String(vt)+"` "+("supplied to `"+st+"`, expected one of "+lt+"."))}return x(tt)}function M(Q){function tt(rt,ut,st,ot,ht){if(typeof Q!="function")return new y("Property `"+ht+"` of component `"+st+"` has invalid PropType notation inside objectOf.");var vt=rt[ut],it=Z(vt);if(it!=="object")return new y("Invalid "+ot+" `"+ht+"` of type "+("`"+it+"` supplied to `"+st+"`, expected an object."));for(var lt in vt)if(i(vt,lt)){var dt=Q(vt,lt,st,ot,ht+"."+lt,e);if(dt instanceof Error)return dt}return null}return x(tt)}function B(Q){if(!Array.isArray(Q))return process.env.NODE_ENV!=="production"&&s("Invalid argument supplied to oneOfType, expected an instance of array."),o;for(var tt=0;tt<Q.length;tt++){var rt=Q[tt];if(typeof rt!="function")return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+$(rt)+" at index "+tt+"."),o}function ut(st,ot,ht,vt,it){for(var lt=0;lt<Q.length;lt++){var dt=Q[lt];if(dt(st,ot,ht,vt,it,e)==null)return null}return new y("Invalid "+vt+" `"+it+"` supplied to "+("`"+ht+"`."))}return x(ut)}function L(){function Q(tt,rt,ut,st,ot){return H(tt[rt])?null:new y("Invalid "+st+" `"+ot+"` supplied to "+("`"+ut+"`, expected a ReactNode."))}return x(Q)}function F(Q){function tt(rt,ut,st,ot,ht){var vt=rt[ut],it=Z(vt);if(it!=="object")return new y("Invalid "+ot+" `"+ht+"` of type `"+it+"` "+("supplied to `"+st+"`, expected `object`."));for(var lt in Q){var dt=Q[lt];if(dt){var Et=dt(vt,lt,st,ot,ht+"."+lt,e);if(Et)return Et}}return null}return x(tt)}function I(Q){function tt(rt,ut,st,ot,ht){var vt=rt[ut],it=Z(vt);if(it!=="object")return new y("Invalid "+ot+" `"+ht+"` of type `"+it+"` "+("supplied to `"+st+"`, expected `object`."));var lt=t({},rt[ut],Q);for(var dt in lt){var Et=Q[dt];if(!Et)return new y("Invalid "+ot+" `"+ht+"` key `"+dt+"` supplied to `"+st+"`.\nBad object: "+JSON.stringify(rt[ut],null," ")+`
|
|
42
42
|
Valid keys: `+JSON.stringify(Object.keys(Q),null," "));var _t=Et(vt,dt,st,ot,ht+"."+dt,e);if(_t)return _t}return null}return x(tt)}function H(Q){switch(typeof Q){case"number":case"string":case"undefined":return!0;case"boolean":return!Q;case"object":if(Array.isArray(Q))return Q.every(H);if(Q===null||l(Q))return!0;var tt=m(Q);if(tt){var rt=tt.call(Q),ut;if(tt!==Q.entries){for(;!(ut=rt.next()).done;)if(!H(ut.value))return!1}else for(;!(ut=rt.next()).done;){var st=ut.value;if(st&&!H(st[1]))return!1}}else return!1;return!0;default:return!1}}function W(Q,tt){return Q==="symbol"?!0:tt?tt["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&tt instanceof Symbol:!1}function Z(Q){var tt=typeof Q;return Array.isArray(Q)?"array":Q instanceof RegExp?"object":W(tt,Q)?"symbol":tt}function X(Q){if(typeof Q>"u"||Q===null)return""+Q;var tt=Z(Q);if(tt==="object"){if(Q instanceof Date)return"date";if(Q instanceof RegExp)return"regexp"}return tt}function $(Q){var tt=X(Q);switch(tt){case"array":case"object":return"an "+tt;case"boolean":case"date":case"regexp":return"a "+tt;default:return tt}}function nt(Q){return!Q.constructor||!Q.constructor.name?_:Q.constructor.name}return g.checkPropTypes=n,g.resetWarningCache=n.resetWarningCache,g.PropTypes=g,g},cO}var dO,KP;function CY(){if(KP)return dO;KP=1;var u=p9();function t(){}function e(){}return e.resetWarningCache=t,dO=function(){function n(o,l,c,d,f,m){if(m!==u){var _=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 _.name="Invariant Violation",_}}n.isRequired=n;function i(){return n}var s={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:i,element:n,elementType:n,instanceOf:i,node:n,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:e,resetWarningCache:t};return s.PropTypes=s,s},dO}if(process.env.NODE_ENV!=="production"){var RY=uF(),wY=!0;fN.exports=AY()(RY.isElement,wY)}else fN.exports=CY()();var DY=fN.exports;const $t=ay(DY);function cF({time:u={current:0,duration:0},setTimePoint:t=()=>{},mandatory:e,mandatoryHasBeenViewed:n,viewed:i}){const s=Math.trunc(u.current*1e3/u.duration)/10,o=G.useRef(),[l,c]=G.useState(!1),d=Math.trunc(u.current/60)<10?["0",Math.trunc(u.current/60)].join("").trim():Math.trunc(u.current/60),f=Math.trunc(u.current%60)<10?["0",Math.trunc(u.current%60)].join("").trim():Math.trunc(u.current%60),m=(y,x)=>{c(!0);let T=y.offsetX;y.changedTouches&&(T=y.changedTouches[0].clientX);const A=x.offsetWidth+x.offsetLeft;T<=A&&T>=x.offsetLeft&&t(T,x.offsetWidth,x.offsetLeft)},_=()=>{window.onmousemove=null,window.onmouseup=null,c(!1)},g=y=>{window.onmousemove=x=>m(x,y),window.onmouseup=x=>_()},S=(y,x)=>{(!e||e&&n||i)&&(y.preventDefault(),t(y.clientX,x.offsetWidth,x.offsetLeft),g(x),c(!0))};return P.jsx("div",{id:"buffer",ref:o,className:"video--controls__bar",onMouseDown:y=>{const x=o.current;S(y,x)},onTouchMove:y=>{const x=o.current;m(y,x)},onTouchStart:y=>{const x=o.current;c(!0),t(y.changedTouches[0].clientX,x.offsetWidth,x.offsetLeft)},children:P.jsx("div",{className:"video--controls__progress",style:{width:`${s}%`},children:P.jsx("span",{className:l?"video--controls__handle active":"video--controls__handle",children:l?P.jsxs("div",{className:"video--current__time active",children:[d,":",f]}):null})})})}cF.propTypes={time:$t.shape({current:$t.number,duration:$t.number}),setTimePoint:$t.func};function dF({time:u={current:0,duration:0}}){const t=Math.trunc(u.current/60)<10?["0",Math.trunc(u.current/60)].join("").trim():Math.trunc(u.current/60),e=Math.trunc(u.current%60)<10?["0",Math.trunc(u.current%60)].join("").trim():Math.trunc(u.current%60),n=Math.trunc(u.duration/60)<10?["0",Math.trunc(u.duration/60)].join("").trim():Math.trunc(u.duration/60),i=Math.trunc(u.duration%60)<10?["0",Math.trunc(u.duration%60)].join("").trim():Math.trunc(u.duration%60);return P.jsxs("div",{className:"video--time",children:[P.jsxs("span",{className:"time",children:[t,":",e]}),P.jsxs("span",{className:"duration",children:[n,":",i]})]})}dF.propTypes={time:$t.shape({current:$t.number,duration:$t.number})};function OY({pauseVideo:u=()=>{},paused:t=!1,translate:e}){return P.jsx("div",{className:"video--controls__buttons",children:P.jsx("button",{id:"playPause","aria-label":e(t?"storylines.misc.play":"storylines.misc.pause"),className:t?"unset-button icon-play":"unset-button icon-pause",type:"button",onClick:()=>{u(),document.querySelector("#playPause").blur()}})})}function MY({restart:u=()=>{},translate:t,finished:e=!1}){return P.jsx("div",{className:"video--extra__actions video--extra__actions--widthTransparencyLayer position--absolute z-index1",children:P.jsxs("button",{type:"button",onClick:()=>{u()},className:"gat--btn gat--btn__secondary","aria-label":t("video.replay"),children:[P.jsx("span",{className:"icon-rewind"}),P.jsx("span",{id:"video.replay"})]})})}function NY({play:u=()=>{},finished:t=!1,paused:e=!1}){return t||!e?P.jsx("div",{}):P.jsx("div",{className:"video--extra__actions position--absolute z-index1",children:P.jsx("div",{role:"button",tabIndex:0,"aria-label":"play video",onKeyUp:()=>{},onClick:()=>{u()},className:"play--video__button",children:P.jsx("span",{className:"icon-play-outline"})})})}function LY({viewed:u=!1,mandatory:t=!1,finished:e=!1,skip:n=()=>{},mandatoryHasBeenViewed:i,translate:s}){return P.jsx(P.Fragment,{children:t&&u||!t||e||i?P.jsx("div",{className:"position--absolute right top z-index2",children:P.jsx("button",{className:"gat--btn__round gat--btn__close",type:"button","aria-label":s("storylines.misc.closePiece"),onKeyUp:()=>{},onClick:()=>{n()},children:P.jsx("span",{className:"icon-close"})})}):null})}function hF({volume:u=0,muted:t=!1,setVolume:e=()=>{},mute:n=()=>{}}){const i=G.useRef(),s=t?0:Math.floor(u*100),o=(f,m)=>{const _=m.offsetWidth+m.offsetLeft;let g=f.clientX;f.changedTouches&&(g=f.changedTouches[0].clientX),g<=_&&g>=m.offsetLeft&&e(g,m.offsetWidth,m.offsetLeft)},l=()=>{window.onmousemove=null,window.onmouseup=null},c=f=>{window.onmousemove=m=>o(m,f),window.onmouseup=m=>l()},d=(f,m)=>{f.preventDefault(),e(f.clientX,m.offsetWidth,m.offsetLeft),c(m)};return P.jsxs("div",{className:"video--sound",children:[P.jsx("span",{onClick:()=>n(),className:s===0?"icon-sound-off":"icon-sound"}),P.jsx("div",{ref:i,onMouseDown:f=>{const m=i.current;d(f,m)},onTouchMove:f=>{const m=i.current;o(f,m)},onTouchStart:f=>{const m=i.current;e(f.changedTouches[0].clientX,m.offsetWidth,m.offsetLeft)},id:"volume",className:"video--sound__level",children:P.jsx("span",{style:{width:`${s<10?10:s}%`},className:"video--sound__progress",children:P.jsx("span",{className:"video--handle"})})})]})}hF.propTypes={volume:$t.number,setVolume:$t.func,mute:$t.func,muted:$t.bool};function fF({pause:u=()=>{},mandatory:t=!1,viewed:e=!1,skip:n=()=>{},rewind:i=()=>{},paused:s=!1,time:o={current:0,duration:0},finished:l=!1,restart:c=()=>{},volume:d=0,muted:f=!1,mute:m=()=>{},setVolume:_=()=>{},setTimePoint:g=()=>{},audioAnimation:S=!1,mandatoryHasBeenViewed:y,translate:x,visibility:T,withoutControls:A,documentType:E}){return P.jsxs(P.Fragment,{children:[P.jsx(LY,{mandatory:t,finished:l,viewed:e,skip:n,rewind:i,mandatoryHasBeenViewed:y,translate:x}),A?null:P.jsxs("div",{className:`video--controls-wrap ${T?"video--controls-wrap--hidden":""}`,children:[S?null:P.jsx(NY,{play:u,paused:s,finished:l}),l&&(E==="document"||E==="lesson")?P.jsx(MY,{restart:c,translate:x}):null,P.jsxs("div",{className:"video--controls",children:[P.jsx(cF,{mandatory:t,mandatoryHasBeenViewed:y,time:o,setTimePoint:g,finished:l,viewed:e}),P.jsxs("div",{className:"video--controls__actions",children:[P.jsx(dF,{time:o}),S?P.jsx("div",{className:"audio-animation-wrap",children:P.jsx("div",{className:`audio-animation ${s?"audio-animation--notAnimate ":null}`})}):null,P.jsx(OY,{paused:s,pauseVideo:u,translate:x}),P.jsx(hF,{muted:f,mute:m,volume:d,setVolume:_})]})]})]})]})}fF.propTypes={audioAnimation:$t.bool,paused:$t.bool,mandatory:$t.bool,muted:$t.bool,volume:$t.number,viewed:$t.bool,pause:$t.func,finished:$t.bool,restart:$t.func,skip:$t.func,rewind:$t.func,mute:$t.func,setTimePoint:$t.func,setVolume:$t.func,time:$t.shape({current:$t.number,duration:$t.number})};const XP="https://min.gamelearn.io/css-resources/gamelearn/resources/bgAudioPiece.jpg";function y5({documentType:u="",url:t="",required:e=!1,viewed:n=!1,backgroundImage:i=null,soundActions:s,endVideo:o=()=>{},translate:l,autoPlay:c,withoutControls:d,name:f=""}){const[m,_]=G.useState(!1),[g]=s,[S,y]=G.useState(0),[x,T]=G.useState(0),[A,E]=G.useState(!1),[C,R]=G.useState(!0),[N,O]=G.useState(!1),[M,B]=G.useState(),[L,F]=G.useState(0),[I,H]=G.useState(!1),W=t&&t.match(/\.m3u8(\?.+=.+)*$/i)&&rO.isSupported(),Z=t&&(t.match(/youtube/i)||t.match(/vimeo/i)),X=t&&(t.match(/.mp3/i)||t.match(/.ogg/i)||t.match(/.wav/i)||t.match(/.m4a/i)),$={ref:bt=>{B(bt)},src:t,style:{height:"100%",width:"100%"}},nt=()=>{e&&_(!0),E(!1),M.pause(),R(!0),O(!0),H(!1),u!=="document"&&u!=="lesson"&&o()},Q=()=>{o()},tt=()=>{R(!1),E(!1)},rt=()=>{E(!0)},ut=()=>{E(!1),y(M.duration)};G.useEffect(()=>{let bt;if(M){if(W){bt=new rO;const Tt=`${t}?v=${Math.floor(Math.random()*99999999)}`;bt.loadSource(Tt),bt.attachMedia(M),bt.on(rO.Events.FRAG_LOAD_PROGRESS,(Ct,Ft)=>{const{stats:It}=Ft;T(It.loaded*100/It.total)})}return()=>{bt&&bt.destroy(),bt=null}}},[W,t,M]);const st=()=>{M.currentTime-=15},ot=()=>{g("click-ui"),C?(M.play(),O(!1)):M.pause(),R(!C)},ht=(bt,Tt,Ct)=>{O(!1),M.currentTime=Tt?parseFloat((bt-Ct)/Tt*M.duration):0},vt=()=>{O(!1),M.currentTime=0,ot()},it=()=>{g("click-ui"),M.muted=!M.muted},lt=(bt,Tt,Ct)=>{M.muted=!1;const Ft=bt-Ct>=0?(bt-Ct)/Tt:0;M.volume=Ft*100>10?Ft:0,F(M.volume)};G.useEffect(()=>{let bt;return!I&&!C&&(bt=setTimeout(()=>{H(!0),clearTimeout(bt)},3e3)),()=>clearTimeout(bt)},[I,C]);const dt=()=>{I&&H(!1)},Et=i||XP,_t=Et===XP?"cover":"contain",pt={backgroundImage:`url("${Et}")`,backgroundSize:_t,backgroundRepeat:"no-repeat",backgroundPosition:"center center"};return P.jsx("div",{className:`video ${e&&!m&&!n?"forward-disabled":""}`,style:X?pt:null,children:Z?P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"position--absolute right top z-index2",children:P.jsx("button",{type:"button","aria-label":l("storylines.misc.closePiece"),className:"gat--btn__round gat--btn__close",onClick:()=>{g("click-ui"),o()},children:P.jsx("span",{className:"icon-close"})})}),P.jsx("iframe",{className:"embeddedVideo",title:"title",...$})]}):P.jsxs(P.Fragment,{children:[P.jsx(fF,{documentType:u,visibility:I,mandatoryHasBeenViewed:m,audioAnimation:!!X,skip:o,mandatory:e,viewed:n,volume:M?M.volume:0,mute:it,muted:M?M.muted:!1,paused:C,finished:N,restart:vt,setTimePoint:ht,time:{duration:S,current:M?M.currentTime:0},rewind:st,pause:ot,volumeState:L,setVolume:lt,translate:l,withoutControls:d}),P.jsx("video",{"data-testid":"video-visor-video",autoPlay:c,onMouseMove:()=>dt(),onClick:()=>{dt()},onFocus:()=>{dt()},onCanPlayThrough:ut,onWaiting:rt,onEnded:nt,onError:Q,onPlaying:tt,...$,children:P.jsx("track",{kind:"captions"})}),A?P.jsxs("div",{className:"video-loading-container",style:{top:0,left:0},children:[P.jsx("div",{className:"video-loading-container-bg opacity-wrapper"}),P.jsx("div",{className:"popup-alert warning",children:P.jsx("div",{className:"popup-message",children:P.jsx("p",{children:Math.floor(x)})})})]}):null]})})}function PY({emitEvent:u,getEvent:t,name:e,documentType:n,document:i,documentId_labelId:s,soundActions:o,required:l,viewed:c,visible:d,img:f,imgId_labelId:m,withoutControls:_,autoPlay:g,keyboardControl:S}){const y=C=>t({type:"translate",payload:C}),{url:x}=i,T=G.useMemo(()=>({documentId:s,imgId:m,required:l,name:e,type:"video",viewed:c,documentType:n}),[s,m,l,e,c,n]),A=G.useCallback(()=>{u({type:"finishMedia",payload:T})},[u,T]);G.useEffect(()=>{d||A()},[A,d]);const E=S({disabled:c,forward:A,escape:A});return G.useEffect(()=>E(),[E]),d?P.jsx(y5,{autoPlay:g,withoutControls:_,backgroundImage:f==null?void 0:f.url,url:x,soundActions:o,documentType:n,required:l,viewed:c,endVideo:()=>A(),translate:y}):null}function m9({targetUid:u,emitEvent:t,success:e=!0,onFinish:n=()=>{},transition:i={type:"pan",speed:10}}){const{change:s}=Va.CameraControls.useStore(),o=$h.useThree(c=>c.camera),l=G.useRef();return G.useEffect(()=>{const c=()=>{t({type:"changeCamera",payload:{targetUid:u,transition:i}}),setTimeout(()=>{e&&t({type:"success"}),n()},200)};return o.addEventListener("transitionEnd",c),()=>{o.removeEventListener("transitionEnd",c)}},[o,t,n,e,u,i]),G.useEffect(()=>{s&&l.current!==u&&(s(u,i),l.current=u)},[s,u,i]),null}var pF={},g9={},v9={},T0={},y9={},_9={};(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.Doctype=u.CDATA=u.Tag=u.Style=u.Script=u.Comment=u.Directive=u.Text=u.Root=u.isTag=u.ElementType=void 0;var t;(function(n){n.Root="root",n.Text="text",n.Directive="directive",n.Comment="comment",n.Script="script",n.Style="style",n.Tag="tag",n.CDATA="cdata",n.Doctype="doctype"})(t=u.ElementType||(u.ElementType={}));function e(n){return n.type===t.Tag||n.type===t.Script||n.type===t.Style}u.isTag=e,u.Root=t.Root,u.Text=t.Text,u.Directive=t.Directive,u.Comment=t.Comment,u.Script=t.Script,u.Style=t.Style,u.Tag=t.Tag,u.CDATA=t.CDATA,u.Doctype=t.Doctype})(_9);var dn={},A0=Ki&&Ki.__extends||function(){var u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},u(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");u(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}}(),jE=Ki&&Ki.__assign||function(){return jE=Object.assign||function(u){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(u[i]=t[i])}return u},jE.apply(this,arguments)};Object.defineProperty(dn,"__esModule",{value:!0});dn.cloneNode=dn.hasChildren=dn.isDocument=dn.isDirective=dn.isComment=dn.isText=dn.isCDATA=dn.isTag=dn.Element=dn.Document=dn.CDATA=dn.NodeWithChildren=dn.ProcessingInstruction=dn.Comment=dn.Text=dn.DataNode=dn.Node=void 0;var Zr=_9,b9=function(){function u(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(u.prototype,"parentNode",{get:function(){return this.parent},set:function(t){this.parent=t},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"previousSibling",{get:function(){return this.prev},set:function(t){this.prev=t},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"nextSibling",{get:function(){return this.next},set:function(t){this.next=t},enumerable:!1,configurable:!0}),u.prototype.cloneNode=function(t){return t===void 0&&(t=!1),S9(this,t)},u}();dn.Node=b9;var jw=function(u){A0(t,u);function t(e){var n=u.call(this)||this;return n.data=e,n}return Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(b9);dn.DataNode=jw;var mF=function(u){A0(t,u);function t(){var e=u!==null&&u.apply(this,arguments)||this;return e.type=Zr.ElementType.Text,e}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),t}(jw);dn.Text=mF;var gF=function(u){A0(t,u);function t(){var e=u!==null&&u.apply(this,arguments)||this;return e.type=Zr.ElementType.Comment,e}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),t}(jw);dn.Comment=gF;var vF=function(u){A0(t,u);function t(e,n){var i=u.call(this,n)||this;return i.name=e,i.type=Zr.ElementType.Directive,i}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),t}(jw);dn.ProcessingInstruction=vF;var zw=function(u){A0(t,u);function t(e){var n=u.call(this)||this;return n.children=e,n}return Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return(e=this.children[0])!==null&&e!==void 0?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(b9);dn.NodeWithChildren=zw;var yF=function(u){A0(t,u);function t(){var e=u!==null&&u.apply(this,arguments)||this;return e.type=Zr.ElementType.CDATA,e}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),t}(zw);dn.CDATA=yF;var _F=function(u){A0(t,u);function t(){var e=u!==null&&u.apply(this,arguments)||this;return e.type=Zr.ElementType.Root,e}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),t}(zw);dn.Document=_F;var bF=function(u){A0(t,u);function t(e,n,i,s){i===void 0&&(i=[]),s===void 0&&(s=e==="script"?Zr.ElementType.Script:e==="style"?Zr.ElementType.Style:Zr.ElementType.Tag);var o=u.call(this,i)||this;return o.name=e,o.attribs=n,o.type=s,o}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map(function(n){var i,s;return{name:n,value:e.attribs[n],namespace:(i=e["x-attribsNamespace"])===null||i===void 0?void 0:i[n],prefix:(s=e["x-attribsPrefix"])===null||s===void 0?void 0:s[n]}})},enumerable:!1,configurable:!0}),t}(zw);dn.Element=bF;function SF(u){return(0,Zr.isTag)(u)}dn.isTag=SF;function xF(u){return u.type===Zr.ElementType.CDATA}dn.isCDATA=xF;function EF(u){return u.type===Zr.ElementType.Text}dn.isText=EF;function TF(u){return u.type===Zr.ElementType.Comment}dn.isComment=TF;function AF(u){return u.type===Zr.ElementType.Directive}dn.isDirective=AF;function CF(u){return u.type===Zr.ElementType.Root}dn.isDocument=CF;function jY(u){return Object.prototype.hasOwnProperty.call(u,"children")}dn.hasChildren=jY;function S9(u,t){t===void 0&&(t=!1);var e;if(EF(u))e=new mF(u.data);else if(TF(u))e=new gF(u.data);else if(SF(u)){var n=t?hO(u.children):[],i=new bF(u.name,jE({},u.attribs),n);n.forEach(function(c){return c.parent=i}),u.namespace!=null&&(i.namespace=u.namespace),u["x-attribsNamespace"]&&(i["x-attribsNamespace"]=jE({},u["x-attribsNamespace"])),u["x-attribsPrefix"]&&(i["x-attribsPrefix"]=jE({},u["x-attribsPrefix"])),e=i}else if(xF(u)){var n=t?hO(u.children):[],s=new yF(n);n.forEach(function(d){return d.parent=s}),e=s}else if(CF(u)){var n=t?hO(u.children):[],o=new _F(n);n.forEach(function(d){return d.parent=o}),u["x-mode"]&&(o["x-mode"]=u["x-mode"]),e=o}else if(AF(u)){var l=new vF(u.name,u.data);u["x-name"]!=null&&(l["x-name"]=u["x-name"],l["x-publicId"]=u["x-publicId"],l["x-systemId"]=u["x-systemId"]),e=l}else throw new Error("Not implemented yet: ".concat(u.type));return e.startIndex=u.startIndex,e.endIndex=u.endIndex,u.sourceCodeLocation!=null&&(e.sourceCodeLocation=u.sourceCodeLocation),e}dn.cloneNode=S9;function hO(u){for(var t=u.map(function(n){return S9(n,!0)}),e=1;e<t.length;e++)t[e].prev=t[e-1],t[e-1].next=t[e];return t}(function(u){var t=Ki&&Ki.__createBinding||(Object.create?function(l,c,d,f){f===void 0&&(f=d);var m=Object.getOwnPropertyDescriptor(c,d);(!m||("get"in m?!c.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return c[d]}}),Object.defineProperty(l,f,m)}:function(l,c,d,f){f===void 0&&(f=d),l[f]=c[d]}),e=Ki&&Ki.__exportStar||function(l,c){for(var d in l)d!=="default"&&!Object.prototype.hasOwnProperty.call(c,d)&&t(c,l,d)};Object.defineProperty(u,"__esModule",{value:!0}),u.DomHandler=void 0;var n=_9,i=dn;e(dn,u);var s={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function l(c,d,f){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof d=="function"&&(f=d,d=s),typeof c=="object"&&(d=c,c=void 0),this.callback=c??null,this.options=d??s,this.elementCB=f??null}return l.prototype.onparserinit=function(c){this.parser=c},l.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},l.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},l.prototype.onerror=function(c){this.handleCallback(c)},l.prototype.onclosetag=function(){this.lastNode=null;var c=this.tagStack.pop();this.options.withEndIndices&&(c.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(c)},l.prototype.onopentag=function(c,d){var f=this.options.xmlMode?n.ElementType.Tag:void 0,m=new i.Element(c,d,void 0,f);this.addNode(m),this.tagStack.push(m)},l.prototype.ontext=function(c){var d=this.lastNode;if(d&&d.type===n.ElementType.Text)d.data+=c,this.options.withEndIndices&&(d.endIndex=this.parser.endIndex);else{var f=new i.Text(c);this.addNode(f),this.lastNode=f}},l.prototype.oncomment=function(c){if(this.lastNode&&this.lastNode.type===n.ElementType.Comment){this.lastNode.data+=c;return}var d=new i.Comment(c);this.addNode(d),this.lastNode=d},l.prototype.oncommentend=function(){this.lastNode=null},l.prototype.oncdatastart=function(){var c=new i.Text(""),d=new i.CDATA([c]);this.addNode(d),c.parent=d,this.lastNode=c},l.prototype.oncdataend=function(){this.lastNode=null},l.prototype.onprocessinginstruction=function(c,d){var f=new i.ProcessingInstruction(c,d);this.addNode(f)},l.prototype.handleCallback=function(c){if(typeof this.callback=="function")this.callback(c,this.dom);else if(c)throw c},l.prototype.addNode=function(c){var d=this.tagStack[this.tagStack.length-1],f=d.children[d.children.length-1];this.options.withStartIndices&&(c.startIndex=this.parser.startIndex),this.options.withEndIndices&&(c.endIndex=this.parser.endIndex),d.children.push(c),f&&(c.prev=f,f.next=c),c.parent=d,this.lastNode=null},l}();u.DomHandler=o,u.default=o})(y9);var RF={};(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.CARRIAGE_RETURN_PLACEHOLDER_REGEX=u.CARRIAGE_RETURN_PLACEHOLDER=u.CARRIAGE_RETURN_REGEX=u.CARRIAGE_RETURN=u.CASE_SENSITIVE_TAG_NAMES_MAP=u.CASE_SENSITIVE_TAG_NAMES=void 0,u.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],u.CASE_SENSITIVE_TAG_NAMES_MAP=u.CASE_SENSITIVE_TAG_NAMES.reduce(function(t,e){return t[e.toLowerCase()]=e,t},{}),u.CARRIAGE_RETURN="\r",u.CARRIAGE_RETURN_REGEX=new RegExp(u.CARRIAGE_RETURN,"g"),u.CARRIAGE_RETURN_PLACEHOLDER="__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now().toString(),"__"),u.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(u.CARRIAGE_RETURN_PLACEHOLDER,"g")})(RF);Object.defineProperty(T0,"__esModule",{value:!0});T0.formatAttributes=wF;T0.hasOpenTag=kY;T0.escapeSpecialCharacters=FY;T0.revertEscapedCharacters=DF;T0.formatDOM=OF;var nR=y9,qE=RF;function zY(u){return qE.CASE_SENSITIVE_TAG_NAMES_MAP[u]}function wF(u){for(var t={},e=0,n=u.length;e<n;e++){var i=u[e];t[i.name]=i.value}return t}function BY(u){u=u.toLowerCase();var t=zY(u);return t||u}function kY(u,t){var e="<"+t,n=u.toLowerCase().indexOf(e);if(n===-1)return!1;var i=u[n+e.length];return i===">"||i===" "||i===" "||i===`
|
|
43
43
|
`||i==="\r"||i==="/"}function FY(u){return u.replace(qE.CARRIAGE_RETURN_REGEX,qE.CARRIAGE_RETURN_PLACEHOLDER)}function DF(u){return u.replace(qE.CARRIAGE_RETURN_PLACEHOLDER_REGEX,qE.CARRIAGE_RETURN)}function OF(u,t,e){var n,i,s,o;t===void 0&&(t=null);for(var l=[],c,d=0,f=u.length;d<f;d++){var m=u[d];switch(m.nodeType){case 1:{var _=BY(m.nodeName);c=new nR.Element(_,wF(m.attributes)),c.children=OF(_==="template"?m.content.childNodes:m.childNodes,c);break}case 3:c=new nR.Text(DF((n=m.nodeValue)!==null&&n!==void 0?n:""));break;case 8:c=new nR.Comment((i=m.nodeValue)!==null&&i!==void 0?i:"");break;default:continue}var g=(s=l[d-1])!==null&&s!==void 0?s:null;g&&(g.next=c),c.parent=t,c.prev=g,c.next=null,l.push(c)}return e&&(c=new nR.ProcessingInstruction(e.substring(0,e.indexOf(" ")).toLowerCase(),e),c.next=(o=l[0])!==null&&o!==void 0?o:null,c.parent=t,l.unshift(c),l[1]&&(l[1].prev=l[0])),l}Object.defineProperty(v9,"__esModule",{value:!0});v9.default=GY;var aE=T0,qP="html",iR="head",__="body",IY=/<([a-zA-Z]+[0-9]?)/,_5=function(u,t){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},pN=function(u,t){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},QP=typeof window=="object"&&window.DOMParser;if(typeof QP=="function"){var UY=new QP,HY="text/html";pN=function(u,t){return t&&(u="<".concat(t,">").concat(u,"</").concat(t,">")),UY.parseFromString(u,HY)},_5=pN}if(typeof document=="object"&&document.implementation){var aR=document.implementation.createHTMLDocument();_5=function(u,t){if(t){var e=aR.documentElement.querySelector(t);return e&&(e.innerHTML=u),aR}return aR.documentElement.innerHTML=u,aR}}var sR=typeof document=="object"&&document.createElement("template"),mN;sR&&sR.content&&(mN=function(u){return sR.innerHTML=u,sR.content.childNodes});var WP=function(){return document.createDocumentFragment().childNodes};function GY(u){var t,e,n,i,s,o;u=(0,aE.escapeSpecialCharacters)(u);var l=IY.exec(u),c=(t=l==null?void 0:l[1])===null||t===void 0?void 0:t.toLowerCase();switch(c){case qP:{var d=pN(u);if(!(0,aE.hasOpenTag)(u,iR)){var f=d.querySelector(iR);(e=f==null?void 0:f.parentNode)===null||e===void 0||e.removeChild(f)}if(!(0,aE.hasOpenTag)(u,__)){var f=d.querySelector(__);(n=f==null?void 0:f.parentNode)===null||n===void 0||n.removeChild(f)}return d.querySelectorAll(qP)}case iR:case __:{var m=_5(u).querySelectorAll(c);return(0,aE.hasOpenTag)(u,__)&&(0,aE.hasOpenTag)(u,iR)?(s=(i=m[0].parentNode)===null||i===void 0?void 0:i.childNodes)!==null&&s!==void 0?s:WP():m}default:{if(mN)return mN(u);var f=_5(u,__).querySelector(__);return(o=f==null?void 0:f.childNodes)!==null&&o!==void 0?o:WP()}}}var VY=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g9,"__esModule",{value:!0});g9.default=qY;var YY=VY(v9),KY=T0,XY=/<(![a-zA-Z\s]+)>/;function qY(u){if(typeof u!="string")throw new TypeError("First argument must be a string");if(!u)return[];var t=XY.exec(u),e=t?t[1]:void 0;return(0,KY.formatDOM)((0,YY.default)(u),null,e)}var Bw={},nc={},kw={},QY=0;kw.SAME=QY;var WY=1;kw.CAMELCASE=WY;kw.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};const MF=0,C0=1,Fw=2,Iw=3,x9=4,NF=5,LF=6;function ZY(u){return Os.hasOwnProperty(u)?Os[u]:null}function Er(u,t,e,n,i,s,o){this.acceptsBooleans=t===Fw||t===Iw||t===x9,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=e,this.propertyName=u,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}const Os={},JY=["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"];JY.forEach(u=>{Os[u]=new Er(u,MF,!1,u,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(([u,t])=>{Os[u]=new Er(u,C0,!1,t,null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(u=>{Os[u]=new Er(u,Fw,!1,u.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(u=>{Os[u]=new Er(u,Fw,!1,u,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(u=>{Os[u]=new Er(u,Iw,!1,u.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(u=>{Os[u]=new Er(u,Iw,!0,u,null,!1,!1)});["capture","download"].forEach(u=>{Os[u]=new Er(u,x9,!1,u,null,!1,!1)});["cols","rows","size","span"].forEach(u=>{Os[u]=new Er(u,LF,!1,u,null,!1,!1)});["rowSpan","start"].forEach(u=>{Os[u]=new Er(u,NF,!1,u.toLowerCase(),null,!1,!1)});const E9=/[\-\:]([a-z])/g,T9=u=>u[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(u=>{const t=u.replace(E9,T9);Os[t]=new Er(t,C0,!1,u,null,!1,!1)});["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(u=>{const t=u.replace(E9,T9);Os[t]=new Er(t,C0,!1,u,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(u=>{const t=u.replace(E9,T9);Os[t]=new Er(t,C0,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(u=>{Os[u]=new Er(u,C0,!1,u.toLowerCase(),null,!1,!1)});const $Y="xlinkHref";Os[$Y]=new Er("xlinkHref",C0,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(u=>{Os[u]=new Er(u,C0,!1,u.toLowerCase(),null,!0,!0)});const{CAMELCASE:tK,SAME:eK,possibleStandardNames:ZP}=kw,nK=":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",iK=nK+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",aK=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+iK+"]*$")),sK=Object.keys(ZP).reduce((u,t)=>{const e=ZP[t];return e===eK?u[t]=t:e===tK?u[t.toLowerCase()]=t:u[t]=e,u},{});nc.BOOLEAN=Iw;nc.BOOLEANISH_STRING=Fw;nc.NUMERIC=NF;nc.OVERLOADED_BOOLEAN=x9;nc.POSITIVE_NUMERIC=LF;nc.RESERVED=MF;nc.STRING=C0;nc.getPropertyInfo=ZY;nc.isCustomAttribute=aK;nc.possibleStandardNames=sK;var A9={},C9={},JP=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,rK=/\n/g,oK=/^\s*/,lK=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,uK=/^:\s*/,cK=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,dK=/^[;\s]*/,hK=/^\s+|\s+$/g,fK=`
|
|
44
|
-
`,$P="/",tj="*",hg="",pK="comment",mK="declaration";function gK(u,t){if(typeof u!="string")throw new TypeError("First argument must be a string");if(!u)return[];t=t||{};var e=1,n=1;function i(S){var y=S.match(rK);y&&(e+=y.length);var x=S.lastIndexOf(fK);n=~x?S.length-x:n+S.length}function s(){var S={line:e,column:n};return function(y){return y.position=new o(S),d(),y}}function o(S){this.start=S,this.end={line:e,column:n},this.source=t.source}o.prototype.content=u;function l(S){var y=new Error(t.source+":"+e+":"+n+": "+S);if(y.reason=S,y.filename=t.source,y.line=e,y.column=n,y.source=u,!t.silent)throw y}function c(S){var y=S.exec(u);if(y){var x=y[0];return i(x),u=u.slice(x.length),y}}function d(){c(oK)}function f(S){var y;for(S=S||[];y=m();)y!==!1&&S.push(y);return S}function m(){var S=s();if(!($P!=u.charAt(0)||tj!=u.charAt(1))){for(var y=2;hg!=u.charAt(y)&&(tj!=u.charAt(y)||$P!=u.charAt(y+1));)++y;if(y+=2,hg===u.charAt(y-1))return l("End of comment missing");var x=u.slice(2,y-2);return n+=2,i(x),u=u.slice(y),n+=2,S({type:pK,comment:x})}}function _(){var S=s(),y=c(lK);if(y){if(m(),!c(uK))return l("property missing ':'");var x=c(cK),T=S({type:mK,property:ej(y[0].replace(JP,hg)),value:x?ej(x[0].replace(JP,hg)):hg});return c(dK),T}}function g(){var S=[];f(S);for(var y;y=_();)y!==!1&&(S.push(y),f(S));return S}return d(),g()}function ej(u){return u?u.replace(hK,hg):hg}var vK=gK,yK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C9,"__esModule",{value:!0});C9.default=bK;const _K=yK(vK);function bK(u,t){let e=null;if(!u||typeof u!="string")return e;const n=(0,_K.default)(u),i=typeof t=="function";return n.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:l}=s;i?t(o,l,s):l&&(e=e||{},e[o]=l)}),e}var Uw={};Object.defineProperty(Uw,"__esModule",{value:!0});Uw.camelCase=void 0;var SK=/^--[a-zA-Z0-9_-]+$/,xK=/-([a-z])/g,EK=/^[^-]+$/,TK=/^-(webkit|moz|ms|o|khtml)-/,AK=/^-(ms)-/,CK=function(u){return!u||EK.test(u)||SK.test(u)},RK=function(u,t){return t.toUpperCase()},nj=function(u,t){return"".concat(t,"-")},wK=function(u,t){return t===void 0&&(t={}),CK(u)?u:(u=u.toLowerCase(),t.reactCompat?u=u.replace(AK,nj):u=u.replace(TK,nj),u.replace(xK,RK))};Uw.camelCase=wK;var DK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}},OK=DK(C9),MK=Uw;function gN(u,t){var e={};return!u||typeof u!="string"||(0,OK.default)(u,function(n,i){n&&i&&(e[(0,MK.camelCase)(n,t)]=i)}),e}gN.default=gN;var NK=gN;(function(u){var t=Ki&&Ki.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(u,"__esModule",{value:!0}),u.returnFirstArg=u.canTextBeChildOfNode=u.ELEMENTS_WITH_NO_TEXT_CHILDREN=u.PRESERVE_CUSTOM_ATTRIBUTES=void 0,u.isCustomComponent=s,u.setStyleProp=l;var e=G,n=t(NK),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function s(f,m){return f.includes("-")?!i.has(f):!!(m&&typeof m.is=="string")}var o={reactCompat:!0};function l(f,m){if(typeof f=="string"){if(!f.trim()){m.style={};return}try{m.style=(0,n.default)(f,o)}catch{m.style={}}}}u.PRESERVE_CUSTOM_ATTRIBUTES=Number(e.version.split(".")[0])>=16,u.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var c=function(f){return!u.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(f.name)};u.canTextBeChildOfNode=c;var d=function(f){return f};u.returnFirstArg=d})(A9);Object.defineProperty(Bw,"__esModule",{value:!0});Bw.default=zK;var ME=nc,ij=A9,LK=["checked","value"],PK=["input","select","textarea"],jK={reset:!0,submit:!0};function zK(u,t){u===void 0&&(u={});var e={},n=!!(u.type&&jK[u.type]);for(var i in u){var s=u[i];if((0,ME.isCustomAttribute)(i)){e[i]=s;continue}var o=i.toLowerCase(),l=aj(o);if(l){var c=(0,ME.getPropertyInfo)(l);switch(LK.includes(l)&&PK.includes(t)&&!n&&(l=aj("default"+o)),e[l]=s,c==null?void 0:c.type){case ME.BOOLEAN:e[l]=!0;break;case ME.OVERLOADED_BOOLEAN:s===""&&(e[l]=!0);break}continue}ij.PRESERVE_CUSTOM_ATTRIBUTES&&(e[i]=s)}return(0,ij.setStyleProp)(u.style,e),e}function aj(u){return ME.possibleStandardNames[u]}var R9={},BK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(R9,"__esModule",{value:!0});R9.default=PF;var fO=G,kK=BK(Bw),zE=A9,FK={cloneElement:fO.cloneElement,createElement:fO.createElement,isValidElement:fO.isValidElement};function PF(u,t){var e,n,i,s,o;t===void 0&&(t={});for(var l=[],c=typeof t.replace=="function",d=(e=t.transform)!==null&&e!==void 0?e:zE.returnFirstArg,f=(n=t.library)!==null&&n!==void 0?n:FK,m=f.cloneElement,_=f.createElement,g=f.isValidElement,S=u.length,y=0;y<S;y++){var x=u[y];if(c){var T=(i=t.replace)===null||i===void 0?void 0:i.call(t,x,y);if(g(T)){S>1&&(T=m(T,{key:(s=T.key)!==null&&s!==void 0?s:y})),l.push(d(T,x,y));continue}}if(x.type==="text"){var A=!x.data.trim().length;if(A&&x.parent&&!(0,zE.canTextBeChildOfNode)(x.parent)||t.trim&&A)continue;l.push(d(x.data,x,y));continue}var E=x,C={};IK(E)?((0,zE.setStyleProp)(E.attribs.style,E.attribs),C=E.attribs):E.attribs&&(C=(0,kK.default)(E.attribs,E.name));var R=void 0;switch(x.type){case"script":case"style":x.children[0]&&(C.dangerouslySetInnerHTML={__html:x.children[0].data});break;case"tag":x.name==="textarea"&&x.children[0]?C.defaultValue=x.children[0].data:!((o=x.children)===null||o===void 0)&&o.length&&(R=PF(x.children,t));break;default:continue}S>1&&(C.key=y),l.push(d(_(x.name,C,R),x,y))}return l.length===1?l[0]:l}function IK(u){return zE.PRESERVE_CUSTOM_ATTRIBUTES&&u.type==="tag"&&(0,zE.isCustomComponent)(u.name,u.attribs)}(function(u){var t=Ki&&Ki.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(u,"__esModule",{value:!0}),u.htmlToDOM=u.domToReact=u.attributesToProps=u.Text=u.ProcessingInstruction=u.Element=u.Comment=void 0,u.default=l;var e=t(g9);u.htmlToDOM=e.default;var n=t(Bw);u.attributesToProps=n.default;var i=t(R9);u.domToReact=i.default;var s=y9;Object.defineProperty(u,"Comment",{enumerable:!0,get:function(){return s.Comment}}),Object.defineProperty(u,"Element",{enumerable:!0,get:function(){return s.Element}}),Object.defineProperty(u,"ProcessingInstruction",{enumerable:!0,get:function(){return s.ProcessingInstruction}}),Object.defineProperty(u,"Text",{enumerable:!0,get:function(){return s.Text}});var o={lowerCaseAttributeNames:!1};function l(c,d){var f;if(typeof c!="string")throw new TypeError("First argument must be a string");return c?(0,i.default)((0,e.default)(c,(f=d==null?void 0:d.htmlparser2)!==null&&f!==void 0?f:o),d):[]}})(pF);const sj=ay(pF),bi=sj.default||sj;function UK({goToLecture:u=!1,close:t=()=>{},minutes:e=0,seconds:n=0,btnText:i}){return P.jsx("div",{className:"lectures--buttons",children:u?P.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>t(),"aria-label":i,children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})}):P.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:P.jsxs("span",{children:[e<10?`0${e}`:e,":",n<10?`0${n}`:n]})})})}const rR=()=>{},rj={},sy=({voice:u,text:t,audioType:e,loop:n=!1,started:i=!0,audio:s,soundActions:o,getEvent:l,volume:c=.5,onFinish:d=rR,onMute:f=rR,onError:m=rR,onStart:_=rR,pauseTTS:g})=>{const[S,y,x,T]=o,A=!s&&!u,[E,C]=G.useState(!1),R=G.useRef({url:"",cc:"tts"}),N=G.useCallback(F=>l({type:"translate",payload:F}),[l]),O=G.useCallback(({id:F,type:I="base"})=>{var Z;const H=N("usedVoices"),W=N("gameCharacters");return I==="base"?H==null?void 0:H[F]:I==="character"?(Z=W==null?void 0:W[F])==null?void 0:Z.voiceId:null},[N]),M=G.useCallback((F,I="tts")=>{if(R.current.url!==F)return R.current={url:F,cc:I},S(F,I,n,c,d,_,f,m)},[S,n,c,d,_,f,m]),B=G.useCallback(async F=>{if(E&&F.voiceId&&F.text){let I=rj[`${F.voiceId}_${F.text}`];try{I||(I=await l({type:"getSpeech",payload:F}),I?rj[`${F.voiceId}_${F.text}`]=I:m()),I&&M(I)}catch{m()}}else m()},[l,E,m,M]),L=G.useCallback(()=>{R.current.url&&y(R.current.cc)},[y]);return G.useEffect(()=>(C(!0),()=>{C(!1),L()}),[L]),G.useEffect(()=>{g?x():T()},[x,g,T]),G.useEffect(()=>{A&&L()},[A,L]),G.useEffect(()=>{if(E&&i)if(e==="voice"&&(u!=null&&u.id)){const F=O(u);B({voiceId:F,text:t})}else(e==="file"||!e)&&s?M(s==null?void 0:s.url):m()},[s,e,O,E,m,B,M,i,t,u]),[L]},Hw=u=>{const t=document.createElement("div");return t.innerHTML=u,t.textContent||t.innerText||""},HK=.2;function GK({emitEvent:u=()=>{},getEvent:t,name:e="",name_labelId:n,required:i=!1,text:s="",text_labelId:o,visible:l=!1,documentType:c="",viewed:d=!1,soundActions:f,backgroundImage:m,hideBackgroundImageTheme:_=!1,keyboardControl:g,audio:S,audioType:y,audioVolume:x,voice:T,pause:A,styles:E="",context:C={}}){const[R,N]=G.useState(),[O,M]=G.useState(!1),[B,L]=G.useState(0),F=s,I=Math.trunc(F.split(" ").length*HK),H=!i||i&&B>=I||i&&!l,[W]=f,Z=`${e}. ${Hw(s)}`;sy({audioType:y,voice:T,text:Z,audio:S,soundActions:f,getEvent:t,volume:x,pauseTTS:A});const X=ot=>t({type:"translate",payload:ot}),$=G.useCallback(()=>{H&&(W("click-ui"),u({type:"finishMedia",payload:{name:n,type:"text",text:o,documentType:c}}))},[c,u,H,n,o,W]),nt=g({disabled:d,forward:$,escape:$});G.useEffect(()=>nt(),[nt]),G.useEffect(()=>{if(!l&&!O&&($(),M(!0)),i&&l){const ot=setInterval(()=>{L(ht=>ht+1)},1e3);return N(ot),()=>{clearInterval(ot)}}},[$,i,O,l]),G.useEffect(()=>{B===I&&clearInterval(R)},[R,B,I]);const Q=I-B,tt=Math.floor(Q/60),rt=Q%60,ut=G.useMemo(()=>{let ot="";return d?ot="notes--results":(ot="lectures--container",E&&(ot+=` lectures--container--${E}`),m!=null&&m.url&&(ot+=" lectures--container--with-custom-bg"),E&&_&&(ot+=" disable-background-image")),ot},[m==null?void 0:m.url,_,E,d]),st={backgroundImage:m!=null&&m.url?`url('${m.url}')`:""};return l?P.jsx("div",{className:ut,style:st,children:P.jsx("div",{className:d?"":"lectures__overlay",children:P.jsxs("div",{className:d?"notes--results__text":`lectures lectures--${E}`,children:[P.jsx("div",{className:"lectures--title",children:e}),P.jsxs("div",{className:"lectures--text",dir:"auto",children:[P.jsx("div",{children:F?bi(F):null}),d?null:P.jsx(UK,{goToLecture:H,close:$,minutes:tt,seconds:rt,btnText:X("screens.continue")})]})]})})}):null}function $R({character:u={name:"",url:"",type:"",resource:{resourceId:""}},active:t=!1,slot:e=0,lowQuality:n}){var _;const i=u.type==="image",s=u.type==="character",o=u.type==="object",l=(_=u==null?void 0:u.resource)==null?void 0:_.url,c=()=>i?`url(${l})`:s&&n?`url(${l.replace("character.glb","face.png")})`:o&&n?`url(${l.replace("object.glb","thumbnail.png")})`:"",d=()=>i?"contain":s||o?"auto 95%":"",f=()=>i?"center":s||o?"center bottom":"",m=i||n?{backgroundImage:c(),backgroundRepeat:"no-repeat",backgroundPosition:f(),backgroundSize:d()}:{};return P.jsx("div",{className:`conversation--character__item ${t?"active":""} ${e}`,style:m,children:t&&u.name?P.jsx("span",{className:"conversation--character__name",children:u.name}):null},u.name)}$R.propTypes={character:$t.shape({name:$t.string,url:$t.string,type:$t.string,emotion:$t.string,uid:$t.string,resource:$t.shape({resourceId:$t.string,url:$t.string})}),active:$t.bool,slot:$t.number};const VK=new Oa.Vector3(0,14.63,16),YK=rF(),KK=new _H.GLTFLoader,oj=new Oa.Box3,oR=new Oa.Vector3,lj=new Oa.Vector3;function XK({character:u,ttsStarted:t,active:e,onLoad:n}){var _,g,S;const i=G.useRef(null),s=G.useRef(null),o=u.type==="character",l=G.useRef(),c=G.useMemo(()=>{var y,x,T,A,E,C,R,N;if(o){if(u.animationId&&((y=u.animation)!=null&&y.url))return u.animation;const O=u.emotion==="neutral"?"idle":c;return(A=(T=(x=u==null?void 0:u.resource)==null?void 0:x.animations)==null?void 0:T[O])!=null&&A.url?(C=(E=u==null?void 0:u.resource)==null?void 0:E.animations)==null?void 0:C[O]:(N=(R=u==null?void 0:u.resource)==null?void 0:R.animations)==null?void 0:N.idle}return{}},[u.emotion,u==null?void 0:u.animationId,u==null?void 0:u.animation,(_=u==null?void 0:u.resource)==null?void 0:_.animations,o]),d=G.useCallback(()=>{if(!l.current)return;const y=l.current.userData.animator;if(!y)return;const x=y.getAction("talking");x&&x.setEffectiveWeight(0)},[]),f=G.useCallback(()=>{var R,N,O,M,B,L;const y=l.current;if(!y)return;const x=(O=(N=(R=u==null?void 0:u.resource)==null?void 0:R.animations)==null?void 0:N.talking)==null?void 0:O.url,A=((L=(B=(M=u==null?void 0:u.resource)==null?void 0:M.animations)==null?void 0:B["talking-short"])==null?void 0:L.url)||x,E=y.userData.animator;if(!E)return;const C=E.getAction("talking");C?C.setEffectiveWeight(1):KK.load(A,({animations:F})=>{const I=E.register("talking",F[0]);I.play(),I.setEffectiveWeight(1)})},[(g=u==null?void 0:u.resource)==null?void 0:g.animations]),m=G.useCallback(y=>{if(u.type==="character"){const x=y.getObjectByName("Head_M",!0);x?(x.updateMatrixWorld(!0),oj.setFromObject(y),oj.getSize(lj),x.getWorldPosition(oR),i.current.lookAt(oR)):i.current.position.setY(lj.y-1.5*1.3),i.current.zoom=1.5;const T=()=>{n==null||n(),y.removeEventListener("update_bounds",T)};y.addEventListener("update_bounds",T)}else Mz(y,i.current),i.current.zoom=1;i.current.updateProjectionMatrix()},[u,n]);return $h.useFrame(({gl:y,scene:x})=>{if(t&&e?f():d(),i.current&&s.current){const T=document.querySelectorAll(".conversation--character__item")[u.slot];if(T){const A=T.getBoundingClientRect(),E=T.parentNode.getBoundingClientRect(),[C,R]=[A.right-A.left,A.bottom-A.top];if(i.current.aspect=C/R,i.current.updateProjectionMatrix(),o&&l.current){const M=l.current.getObjectByName("Head_M",!0);M&&(M.getWorldPosition(oR),i.current.lookAt(oR))}const N={top:A.top-E.top,right:A.right-E.right,left:A.left-E.left,bottom:A.bottom-E.bottom},O=YK?24:40;y.isWebGPURenderer?N.bottom+=e?0:O:N.bottom+=e?-O:O,y.setViewport(N.left,N.bottom,C,R),y.setScissor(N.left,N.bottom,C,R),s.current.environment=x.environment,y.render(s.current,i.current)}}},1),!((S=u.resource)!=null&&S.url)||u.type==="image"?null:P.jsxs("scene",{ref:s,children:[P.jsx(Va.SceneResource,{ref:l,name:`char_${u.uid}`,url:u.resource.url,animationStates:{idle:c.url},type:u.type,onRender:m,texturable:!0,interactive:!1,generate:!1,merge:!1}),P.jsx(WN.PerspectiveCamera,{ref:i,fov:35,position:VK,rotation:[0,0,0],onUpdate:y=>{y.layers.enableAll()},manual:!0}),P.jsx(Lz,{})]})}function qK({characters:u,slots:t,ttsStarted:e,flex:n,currentMessage:i,lod:s}){const[o,l]=G.useState(!1);return G.useEffect(()=>{const c=()=>{l(!0)};return Va.ProgressManager.addEventListener("loaded",c),()=>{Va.ProgressManager.removeEventListener("loaded",c)}},[]),$h.useFrame(({gl:c})=>{c.setScissorTest(!1),c.clear(!0,!0),c.setScissorTest(!0)}),P.jsx(Va.QualityManager,{lod:s,active:o,children:t.map((c,d)=>{let f=null;const m=u.findIndex(_=>_&&_.uid===c.uid);if(m>=0){const _=n?m:d;return f={...u[m]},f.slot=_,P.jsx(XK,{character:f,active:i.position===_,ttsStarted:e},`${`${f.uid}_${d}`}`)}return null})})}function QK(u){return u.lowQuality?null:P.jsxs(Va.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:t})=>{t.setClearColor("white",0)},children:[P.jsx(Va.SettingsController,{current:{animate:u.pause}}),P.jsx(WN.Environment,{files:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),P.jsx(qK,{...u})]})}function w9({characters:u=[],actors:t,lodSettings:e,ttsStarted:n,currentMessage:i={},flex:s=!0,slots:o=[],children:l,pause:c,getEvent:d}){const f=({character:T,active:A,slot:E})=>({character:T,active:A,emotion:A?i.emotion:"neutral",slot:E}),m=G.useMemo(()=>d({type:"currentLod"}),[d]),_=m==="divideby64",g=o.reduce((T,A)=>{var R,N;const E=t==null?void 0:t.find(O=>O.uid===A.uid),C={...A};if(A.character)C.name=A.alias||A.character.name,C.resource=C.character.resource,C.position=C.position>=0?C.position:-1,delete C.character,C.type="character",T.push(C);else if(E){const{resource:O}=E;C.name=A.alias||A.name,C.position=C.position>=0?C.position:-1,C.resource=O,C.type=E.type,T.push(C)}else A.type?(C.name=A.alias||((R=A.character)==null?void 0:R.name)||A.name,C.resource=((N=C.character)==null?void 0:N.resource)||A.resource,C.position=C.position>=0?C.position:-1,delete C.character,C.type=A.type,T.push(C)):s||T.push(null);return T},[]),S=g.length&&g.some(T=>T),y=u.filter(T=>o.find(A=>T.uid===A.uid));function x(){return S?g.map((T,A)=>T?P.jsx($R,{lowQuality:_,...f({character:T,active:i.position===T.position,slot:A})},`${T.uid+A}`):P.jsx("div",{className:`conversation--character__item void ${A}`},`void_${0+A}`)):s?y.map((T,A)=>{const E=i.position===A;return P.jsx($R,{...f({character:T,active:E,slot:A})},`${T.uid+A}`)}):o.length>0?o.map((T,A)=>{const E=u.find(C=>C.uid===T.uid);if(E){const C=i.position===A;return E.name=T.alias||E.name,P.jsx($R,{...f({character:E,active:C,slot:A})},`${E.uid+A}`)}return P.jsx("div",{className:`conversation--character__item void ${A}`},`${0+A}`)}):null}return P.jsxs("div",{className:"conversation--characters",children:[P.jsx(QK,{characters:S?g:y,slots:o,flex:s,currentMessage:i,lodSettings:e,ttsStarted:n,pause:c,lod:m,lowQuality:_}),l||P.jsx(x,{})]})}function uj({inherited:u,options:t,selectedChoice:e,selectChoice:n,showingResults:i,simplifiedOptions:s,required:o}){const[l,c]=G.useState(null),d=m=>{s?(c(m),setTimeout(()=>{n(m),c(null)},1e3)):n(m)},f=m=>!!(i&&(e==null?void 0:e.id)===m.id||(e==null?void 0:e.right)===!0||i&&!o);return t==null?void 0:t.filter(m=>m.text).map(m=>P.jsxs("div",{className:`${u?"conversation--question custom-radio":"custom-radio"}
|
|
44
|
+
`,$P="/",tj="*",hg="",pK="comment",mK="declaration";function gK(u,t){if(typeof u!="string")throw new TypeError("First argument must be a string");if(!u)return[];t=t||{};var e=1,n=1;function i(S){var y=S.match(rK);y&&(e+=y.length);var x=S.lastIndexOf(fK);n=~x?S.length-x:n+S.length}function s(){var S={line:e,column:n};return function(y){return y.position=new o(S),d(),y}}function o(S){this.start=S,this.end={line:e,column:n},this.source=t.source}o.prototype.content=u;function l(S){var y=new Error(t.source+":"+e+":"+n+": "+S);if(y.reason=S,y.filename=t.source,y.line=e,y.column=n,y.source=u,!t.silent)throw y}function c(S){var y=S.exec(u);if(y){var x=y[0];return i(x),u=u.slice(x.length),y}}function d(){c(oK)}function f(S){var y;for(S=S||[];y=m();)y!==!1&&S.push(y);return S}function m(){var S=s();if(!($P!=u.charAt(0)||tj!=u.charAt(1))){for(var y=2;hg!=u.charAt(y)&&(tj!=u.charAt(y)||$P!=u.charAt(y+1));)++y;if(y+=2,hg===u.charAt(y-1))return l("End of comment missing");var x=u.slice(2,y-2);return n+=2,i(x),u=u.slice(y),n+=2,S({type:pK,comment:x})}}function _(){var S=s(),y=c(lK);if(y){if(m(),!c(uK))return l("property missing ':'");var x=c(cK),T=S({type:mK,property:ej(y[0].replace(JP,hg)),value:x?ej(x[0].replace(JP,hg)):hg});return c(dK),T}}function g(){var S=[];f(S);for(var y;y=_();)y!==!1&&(S.push(y),f(S));return S}return d(),g()}function ej(u){return u?u.replace(hK,hg):hg}var vK=gK,yK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C9,"__esModule",{value:!0});C9.default=bK;const _K=yK(vK);function bK(u,t){let e=null;if(!u||typeof u!="string")return e;const n=(0,_K.default)(u),i=typeof t=="function";return n.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:l}=s;i?t(o,l,s):l&&(e=e||{},e[o]=l)}),e}var Uw={};Object.defineProperty(Uw,"__esModule",{value:!0});Uw.camelCase=void 0;var SK=/^--[a-zA-Z0-9_-]+$/,xK=/-([a-z])/g,EK=/^[^-]+$/,TK=/^-(webkit|moz|ms|o|khtml)-/,AK=/^-(ms)-/,CK=function(u){return!u||EK.test(u)||SK.test(u)},RK=function(u,t){return t.toUpperCase()},nj=function(u,t){return"".concat(t,"-")},wK=function(u,t){return t===void 0&&(t={}),CK(u)?u:(u=u.toLowerCase(),t.reactCompat?u=u.replace(AK,nj):u=u.replace(TK,nj),u.replace(xK,RK))};Uw.camelCase=wK;var DK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}},OK=DK(C9),MK=Uw;function gN(u,t){var e={};return!u||typeof u!="string"||(0,OK.default)(u,function(n,i){n&&i&&(e[(0,MK.camelCase)(n,t)]=i)}),e}gN.default=gN;var NK=gN;(function(u){var t=Ki&&Ki.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(u,"__esModule",{value:!0}),u.returnFirstArg=u.canTextBeChildOfNode=u.ELEMENTS_WITH_NO_TEXT_CHILDREN=u.PRESERVE_CUSTOM_ATTRIBUTES=void 0,u.isCustomComponent=s,u.setStyleProp=l;var e=G,n=t(NK),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function s(f,m){return f.includes("-")?!i.has(f):!!(m&&typeof m.is=="string")}var o={reactCompat:!0};function l(f,m){if(typeof f=="string"){if(!f.trim()){m.style={};return}try{m.style=(0,n.default)(f,o)}catch{m.style={}}}}u.PRESERVE_CUSTOM_ATTRIBUTES=Number(e.version.split(".")[0])>=16,u.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var c=function(f){return!u.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(f.name)};u.canTextBeChildOfNode=c;var d=function(f){return f};u.returnFirstArg=d})(A9);Object.defineProperty(Bw,"__esModule",{value:!0});Bw.default=zK;var ME=nc,ij=A9,LK=["checked","value"],PK=["input","select","textarea"],jK={reset:!0,submit:!0};function zK(u,t){u===void 0&&(u={});var e={},n=!!(u.type&&jK[u.type]);for(var i in u){var s=u[i];if((0,ME.isCustomAttribute)(i)){e[i]=s;continue}var o=i.toLowerCase(),l=aj(o);if(l){var c=(0,ME.getPropertyInfo)(l);switch(LK.includes(l)&&PK.includes(t)&&!n&&(l=aj("default"+o)),e[l]=s,c==null?void 0:c.type){case ME.BOOLEAN:e[l]=!0;break;case ME.OVERLOADED_BOOLEAN:s===""&&(e[l]=!0);break}continue}ij.PRESERVE_CUSTOM_ATTRIBUTES&&(e[i]=s)}return(0,ij.setStyleProp)(u.style,e),e}function aj(u){return ME.possibleStandardNames[u]}var R9={},BK=Ki&&Ki.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(R9,"__esModule",{value:!0});R9.default=PF;var fO=G,kK=BK(Bw),zE=A9,FK={cloneElement:fO.cloneElement,createElement:fO.createElement,isValidElement:fO.isValidElement};function PF(u,t){var e,n,i,s,o;t===void 0&&(t={});for(var l=[],c=typeof t.replace=="function",d=(e=t.transform)!==null&&e!==void 0?e:zE.returnFirstArg,f=(n=t.library)!==null&&n!==void 0?n:FK,m=f.cloneElement,_=f.createElement,g=f.isValidElement,S=u.length,y=0;y<S;y++){var x=u[y];if(c){var T=(i=t.replace)===null||i===void 0?void 0:i.call(t,x,y);if(g(T)){S>1&&(T=m(T,{key:(s=T.key)!==null&&s!==void 0?s:y})),l.push(d(T,x,y));continue}}if(x.type==="text"){var A=!x.data.trim().length;if(A&&x.parent&&!(0,zE.canTextBeChildOfNode)(x.parent)||t.trim&&A)continue;l.push(d(x.data,x,y));continue}var E=x,C={};IK(E)?((0,zE.setStyleProp)(E.attribs.style,E.attribs),C=E.attribs):E.attribs&&(C=(0,kK.default)(E.attribs,E.name));var R=void 0;switch(x.type){case"script":case"style":x.children[0]&&(C.dangerouslySetInnerHTML={__html:x.children[0].data});break;case"tag":x.name==="textarea"&&x.children[0]?C.defaultValue=x.children[0].data:!((o=x.children)===null||o===void 0)&&o.length&&(R=PF(x.children,t));break;default:continue}S>1&&(C.key=y),l.push(d(_(x.name,C,R),x,y))}return l.length===1?l[0]:l}function IK(u){return zE.PRESERVE_CUSTOM_ATTRIBUTES&&u.type==="tag"&&(0,zE.isCustomComponent)(u.name,u.attribs)}(function(u){var t=Ki&&Ki.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(u,"__esModule",{value:!0}),u.htmlToDOM=u.domToReact=u.attributesToProps=u.Text=u.ProcessingInstruction=u.Element=u.Comment=void 0,u.default=l;var e=t(g9);u.htmlToDOM=e.default;var n=t(Bw);u.attributesToProps=n.default;var i=t(R9);u.domToReact=i.default;var s=y9;Object.defineProperty(u,"Comment",{enumerable:!0,get:function(){return s.Comment}}),Object.defineProperty(u,"Element",{enumerable:!0,get:function(){return s.Element}}),Object.defineProperty(u,"ProcessingInstruction",{enumerable:!0,get:function(){return s.ProcessingInstruction}}),Object.defineProperty(u,"Text",{enumerable:!0,get:function(){return s.Text}});var o={lowerCaseAttributeNames:!1};function l(c,d){var f;if(typeof c!="string")throw new TypeError("First argument must be a string");return c?(0,i.default)((0,e.default)(c,(f=d==null?void 0:d.htmlparser2)!==null&&f!==void 0?f:o),d):[]}})(pF);const sj=ay(pF),bi=sj.default||sj;function UK({goToLecture:u=!1,close:t=()=>{},minutes:e=0,seconds:n=0,btnText:i}){return P.jsx("div",{className:"lectures--buttons",children:u?P.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>t(),"aria-label":i,children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})}):P.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:P.jsxs("span",{children:[e<10?`0${e}`:e,":",n<10?`0${n}`:n]})})})}const rR=()=>{},rj={},sy=({voice:u,text:t,audioType:e,loop:n=!1,started:i=!0,audio:s,soundActions:o,getEvent:l,volume:c=.5,onFinish:d=rR,onMute:f=rR,onError:m=rR,onStart:_=rR,pauseTTS:g})=>{const[S,y,x,T]=o,A=!s&&!u,[E,C]=G.useState(!1),R=G.useRef({url:"",cc:"tts"}),N=G.useCallback(F=>l({type:"translate",payload:F}),[l]),O=G.useCallback(({id:F,type:I="base"})=>{var Z;const H=N("usedVoices"),W=N("gameCharacters");return I==="base"?H==null?void 0:H[F]:I==="character"?(Z=W==null?void 0:W[F])==null?void 0:Z.voiceId:null},[N]),M=G.useCallback((F,I="tts")=>{if(R.current.url!==F)return R.current={url:F,cc:I},S(F,I,n,c,d,_,f,m)},[S,n,c,d,_,f,m]),B=G.useCallback(async F=>{if(E&&F.voiceId&&F.text){let I=rj[`${F.voiceId}_${F.text}`];try{I||(I=await l({type:"getSpeech",payload:F}),I?rj[`${F.voiceId}_${F.text}`]=I:m()),I&&M(I)}catch{m()}}else m()},[l,E,m,M]),L=G.useCallback(()=>{R.current.url&&y(R.current.cc)},[y]);return G.useEffect(()=>(C(!0),()=>{C(!1),L()}),[L]),G.useEffect(()=>{g?x():T()},[x,g,T]),G.useEffect(()=>{A&&L()},[A,L]),G.useEffect(()=>{if(E&&i)if(e==="voice"&&(u!=null&&u.id)){const F=O(u);B({voiceId:F,text:t})}else(e==="file"||!e)&&s?M(s==null?void 0:s.url):m()},[s,e,O,E,m,B,M,i,t,u]),[L]},Hw=u=>{const t=document.createElement("div");return t.innerHTML=u,t.textContent||t.innerText||""},HK=.2;function GK({emitEvent:u=()=>{},getEvent:t,name:e="",name_labelId:n,required:i=!1,text:s="",text_labelId:o,visible:l=!1,documentType:c="",viewed:d=!1,soundActions:f,backgroundImage:m,hideBackgroundImageTheme:_=!1,keyboardControl:g,audio:S,audioType:y,audioVolume:x,voice:T,pause:A,styles:E="",context:C={}}){const[R,N]=G.useState(),[O,M]=G.useState(!1),[B,L]=G.useState(0),F=s,I=Math.trunc(F.split(" ").length*HK),H=!i||i&&B>=I||i&&!l,[W]=f,Z=`${e}. ${Hw(s)}`;sy({audioType:y,voice:T,text:Z,audio:S,soundActions:f,getEvent:t,volume:x,pauseTTS:A});const X=ot=>t({type:"translate",payload:ot}),$=G.useCallback(()=>{H&&(W("click-ui"),u({type:"finishMedia",payload:{name:n,type:"text",text:o,documentType:c}}))},[c,u,H,n,o,W]),nt=g({disabled:d,forward:$,escape:$});G.useEffect(()=>nt(),[nt]),G.useEffect(()=>{if(!l&&!O&&($(),M(!0)),i&&l){const ot=setInterval(()=>{L(ht=>ht+1)},1e3);return N(ot),()=>{clearInterval(ot)}}},[$,i,O,l]),G.useEffect(()=>{B===I&&clearInterval(R)},[R,B,I]);const Q=I-B,tt=Math.floor(Q/60),rt=Q%60,ut=G.useMemo(()=>{let ot="";return d?ot="notes--results":(ot="lectures--container",E&&(ot+=` lectures--container--${E}`),m!=null&&m.url&&(ot+=" lectures--container--with-custom-bg"),E&&_&&(ot+=" disable-background-image")),ot},[m==null?void 0:m.url,_,E,d]),st={backgroundImage:m!=null&&m.url?`url('${m.url}')`:""};return l?P.jsx("div",{className:ut,style:st,children:P.jsx("div",{className:d?"":"lectures__overlay",children:P.jsxs("div",{className:d?"notes--results__text":`lectures lectures--${E}`,children:[P.jsx("div",{className:"lectures--title",children:e}),P.jsxs("div",{className:"lectures--text",dir:"auto",children:[P.jsx("div",{children:F?bi(F):null}),d?null:P.jsx(UK,{goToLecture:H,close:$,minutes:tt,seconds:rt,btnText:X("screens.continue")})]})]})})}):null}function $R({character:u={name:"",url:"",type:"",resource:{resourceId:""}},active:t=!1,slot:e=0,lowQuality:n}){var _;const i=u.type==="image",s=u.type==="character",o=u.type==="object",l=(_=u==null?void 0:u.resource)==null?void 0:_.url,c=()=>i?`url(${l})`:s&&n?`url(${l.replace("character.glb","face.png")})`:o&&n?`url(${l.replace("object.glb","thumbnail.png")})`:"",d=()=>i?"contain":s||o?"auto 95%":"",f=()=>i?"center":s||o?"center bottom":"",m=i||n?{backgroundImage:c(),backgroundRepeat:"no-repeat",backgroundPosition:f(),backgroundSize:d()}:{};return P.jsx("div",{className:`conversation--character__item ${t?"active":""} ${e}`,style:m,children:t&&u.name?P.jsx("span",{className:"conversation--character__name",children:u.name}):null},u.name)}$R.propTypes={character:$t.shape({name:$t.string,url:$t.string,type:$t.string,emotion:$t.string,uid:$t.string,resource:$t.shape({resourceId:$t.string,url:$t.string})}),active:$t.bool,slot:$t.number};const VK=new Oa.Vector3(0,14.63,16),YK=rF(),KK=new _H.GLTFLoader,oj=new Oa.Box3,oR=new Oa.Vector3,lj=new Oa.Vector3;function XK({character:u,ttsStarted:t,active:e,onLoad:n}){var _,g,S;const i=G.useRef(null),s=G.useRef(null),o=u.type==="character",l=G.useRef(),c=G.useMemo(()=>{var y,x,T,A,E,C,R,N;if(o){if(u.animationId&&((y=u.animation)!=null&&y.url))return u.animation;const O=u.emotion==="neutral"?"idle":c;return(A=(T=(x=u==null?void 0:u.resource)==null?void 0:x.animations)==null?void 0:T[O])!=null&&A.url?(C=(E=u==null?void 0:u.resource)==null?void 0:E.animations)==null?void 0:C[O]:(N=(R=u==null?void 0:u.resource)==null?void 0:R.animations)==null?void 0:N.idle}return{}},[u.emotion,u==null?void 0:u.animationId,u==null?void 0:u.animation,(_=u==null?void 0:u.resource)==null?void 0:_.animations,o]),d=G.useCallback(()=>{if(!l.current)return;const y=l.current.animator;if(!y)return;const x=y.getAction("talking");x&&x.setEffectiveWeight(0)},[]),f=G.useCallback(()=>{var R,N,O,M,B,L;const y=l.current;if(!y)return;const x=(O=(N=(R=u==null?void 0:u.resource)==null?void 0:R.animations)==null?void 0:N.talking)==null?void 0:O.url,A=((L=(B=(M=u==null?void 0:u.resource)==null?void 0:M.animations)==null?void 0:B["talking-short"])==null?void 0:L.url)||x,E=y.animator;if(!E)return;const C=E.getAction("talking");C?C.setEffectiveWeight(1):KK.load(A,({animations:F})=>{const I=E.register("talking",F[0]);I.play(),I.setEffectiveWeight(1)})},[(g=u==null?void 0:u.resource)==null?void 0:g.animations]),m=G.useCallback(y=>{if(u.type==="character"){const x=y.getObjectByName("Head_M",!0);x?(x.updateMatrixWorld(!0),oj.setFromObject(y),oj.getSize(lj),x.getWorldPosition(oR),i.current.lookAt(oR)):i.current.position.setY(lj.y-1.5*1.3),i.current.zoom=1.5;const T=()=>{n==null||n(),y.removeEventListener("update_bounds",T)};y.addEventListener("update_bounds",T)}else Mz(y,i.current),i.current.zoom=1;i.current.updateProjectionMatrix()},[u,n]);return $h.useFrame(({gl:y,scene:x})=>{if(t&&e?f():d(),i.current&&s.current){const T=document.querySelectorAll(".conversation--character__item")[u.slot];if(T){const A=T.getBoundingClientRect(),E=T.parentNode.getBoundingClientRect(),[C,R]=[A.right-A.left,A.bottom-A.top];if(i.current.aspect=C/R,i.current.updateProjectionMatrix(),o&&l.current){const M=l.current.getObjectByName("Head_M",!0);M&&(M.getWorldPosition(oR),i.current.lookAt(oR))}const N={top:A.top-E.top,right:A.right-E.right,left:A.left-E.left,bottom:A.bottom-E.bottom},O=YK?24:40;y.isWebGPURenderer?N.bottom+=e?0:O:N.bottom+=e?-O:O,y.setViewport(N.left,N.bottom,C,R),y.setScissor(N.left,N.bottom,C,R),s.current.environment=x.environment,y.render(s.current,i.current)}}},1),!((S=u.resource)!=null&&S.url)||u.type==="image"?null:P.jsxs("scene",{ref:s,children:[P.jsx(Va.SceneResource,{ref:l,name:`char_${u.uid}`,url:u.resource.url,animationStates:{idle:c.url},type:u.type,onRender:m,texturable:!0,interactive:!1,generate:!1,merge:!1}),P.jsx(WN.PerspectiveCamera,{ref:i,fov:35,position:VK,rotation:[0,0,0],onUpdate:y=>{y.layers.enableAll()},manual:!0}),P.jsx(Lz,{})]})}function qK({characters:u,slots:t,ttsStarted:e,flex:n,currentMessage:i,lod:s}){const[o,l]=G.useState(!1);return G.useEffect(()=>{const c=()=>{l(!0)};return Va.ProgressManager.addEventListener("loaded",c),()=>{Va.ProgressManager.removeEventListener("loaded",c)}},[]),$h.useFrame(({gl:c})=>{c.setScissorTest(!1),c.clear(!0,!0),c.setScissorTest(!0)}),P.jsx(Va.QualityManager,{lod:s,active:o,children:t.map((c,d)=>{let f=null;const m=u.findIndex(_=>_&&_.uid===c.uid);if(m>=0){const _=n?m:d;return f={...u[m]},f.slot=_,P.jsx(XK,{character:f,active:i.position===_,ttsStarted:e},`${`${f.uid}_${d}`}`)}return null})})}function QK(u){return u.lowQuality?null:P.jsxs(Va.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:t})=>{t.setClearColor("white",0)},children:[P.jsx(Va.SettingsController,{current:{animate:u.pause}}),P.jsx(WN.Environment,{files:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),P.jsx(qK,{...u})]})}function w9({characters:u=[],actors:t,lodSettings:e,ttsStarted:n,currentMessage:i={},flex:s=!0,slots:o=[],children:l,pause:c,getEvent:d}){const f=({character:T,active:A,slot:E})=>({character:T,active:A,emotion:A?i.emotion:"neutral",slot:E}),m=G.useMemo(()=>d({type:"currentLod"}),[d]),_=m==="divideby64",g=o.reduce((T,A)=>{var R,N;const E=t==null?void 0:t.find(O=>O.uid===A.uid),C={...A};if(A.character)C.name=A.alias||A.character.name,C.resource=C.character.resource,C.position=C.position>=0?C.position:-1,delete C.character,C.type="character",T.push(C);else if(E){const{resource:O}=E;C.name=A.alias||A.name,C.position=C.position>=0?C.position:-1,C.resource=O,C.type=E.type,T.push(C)}else A.type?(C.name=A.alias||((R=A.character)==null?void 0:R.name)||A.name,C.resource=((N=C.character)==null?void 0:N.resource)||A.resource,C.position=C.position>=0?C.position:-1,delete C.character,C.type=A.type,T.push(C)):s||T.push(null);return T},[]),S=g.length&&g.some(T=>T),y=u.filter(T=>o.find(A=>T.uid===A.uid));function x(){return S?g.map((T,A)=>T?P.jsx($R,{lowQuality:_,...f({character:T,active:i.position===T.position,slot:A})},`${T.uid+A}`):P.jsx("div",{className:`conversation--character__item void ${A}`},`void_${0+A}`)):s?y.map((T,A)=>{const E=i.position===A;return P.jsx($R,{...f({character:T,active:E,slot:A})},`${T.uid+A}`)}):o.length>0?o.map((T,A)=>{const E=u.find(C=>C.uid===T.uid);if(E){const C=i.position===A;return E.name=T.alias||E.name,P.jsx($R,{...f({character:E,active:C,slot:A})},`${E.uid+A}`)}return P.jsx("div",{className:`conversation--character__item void ${A}`},`${0+A}`)}):null}return P.jsxs("div",{className:"conversation--characters",children:[P.jsx(QK,{characters:S?g:y,slots:o,flex:s,currentMessage:i,lodSettings:e,ttsStarted:n,pause:c,lod:m,lowQuality:_}),l||P.jsx(x,{})]})}function uj({inherited:u,options:t,selectedChoice:e,selectChoice:n,showingResults:i,simplifiedOptions:s,required:o}){const[l,c]=G.useState(null),d=m=>{s?(c(m),setTimeout(()=>{n(m),c(null)},1e3)):n(m)},f=m=>!!(i&&(e==null?void 0:e.id)===m.id||(e==null?void 0:e.right)===!0||i&&!o);return t==null?void 0:t.filter(m=>m.text).map(m=>P.jsxs("div",{className:`${u?"conversation--question custom-radio":"custom-radio"}
|
|
45
45
|
${(l==null?void 0:l.id)===m.id?"radio-text-clicked":""}`,children:[P.jsx("input",{onChange:()=>{d(m)},className:"radio",type:"radio",id:m.text_labelId,name:m.id,checked:(e==null?void 0:e.id)===m.id,disabled:f(m)}),P.jsx("label",{className:`${m.right?"radio-text-success":"radio-text-fail"}`,htmlFor:m.text_labelId,children:bi(m.text)})]},`${m.id}_${m.text_labelId}`))}const WK=()=>{};function ZK({children:u,question:t,showingResults:e,selected:n,required:i,failed:s,onNext:o,translate:l,hasRewards:c,options:d}){const[f,m]=G.useState(!1);function _(){(n==null?void 0:n.id)!==void 0&&!f&&(m(!0),o())}return P.jsxs("div",{className:`popup popup__large popup__basicDecision ${e&&(n!=null&&n.feedback)?"popup__feedback":""}`,children:[P.jsx("div",{className:"popup--info",children:e?P.jsxs(P.Fragment,{children:[u,!(n!=null&&n.feedback)&&c.length===0&&P.jsx("span",{className:"popup--info__title",children:t!==""&&P.jsx(P.Fragment,{children:t})}),!(n!=null&&n.feedback)&&c.length>0&&P.jsx("span",{className:"popup--info__title",children:t})]}):P.jsx("span",{className:"popup--info__title",children:t})}),P.jsx("div",{className:"popup__questions",dir:"auto",children:d}),P.jsx("div",{className:"popup--buttons",children:(i?!s:(n==null?void 0:n.id)!==void 0)?P.jsx("button",{"data-testid":"continueButtonDecision",type:"button",className:`gat--btn__navigation ${f||(n==null?void 0:n.id)===void 0?"disabled":""}`,onClick:()=>_(),"aria-label":l("storylines.misc.closePiece"),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})}):null})]})}function JK({question:u,inScene:t,disabled:e,onNext:n,children:i,simplifiedOptions:s}){return P.jsxs("div",{dir:"auto",className:`conversation--body ${t?"conversation--body--inScene":""}`,children:[P.jsxs("div",{className:"conversation--message",children:[u!==""&&P.jsx("div",{className:"conversation--main__text",children:bi(u)}),i]}),P.jsxs("div",{style:{visibility:s?"hidden":"visible"},className:"conversation--controls conversation--controls--fixedbottom",children:[P.jsx("div",{className:"gat--btn__round disabled",children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{"data-testid":"continueButtonComplexDecision",className:`gat--btn__round ${e?"disabled":""}`,type:"button",onClick:()=>!e&&n(),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})})]})]})}function cj({options:u,question:t,inherited:e,branched:n,changeOption:i,onNext:s,failed:o,showingResults:l,currentSelectedChoice:c,children:d,translate:f,hasRewards:m,inScene:_,required:g,simplifiedOptions:S}){const y=A=>{l&&o&&i(A),s(A)},x=!l&&(c==null?void 0:c.id)!==void 0||!o,T={inherited:e,selectedChoice:c,selectChoice:(!g||n)&&(c==null?void 0:c.id)!==void 0||g&&!o?WK:y,options:u,showingResults:l,simplifiedOptions:S,required:g};return e?P.jsx(JK,{disabled:!x,question:t,inScene:_,onNext:()=>s(c),simplifiedOptions:S,children:P.jsx(uj,{...T})}):P.jsx(ZK,{question:t,showingResults:l,selected:c,required:g,failed:o,onNext:()=>s(c),translate:f,hasRewards:m,options:P.jsx(uj,{...T}),children:d})}function $K({children:u,inherit:t}){return t?P.jsx("div",{className:"conversation--feedback",children:u}):u}function dj({choice:u,inherited:t,question:e}){return u.feedback?P.jsx($K,{inherit:t,children:u.feedback&&P.jsxs(P.Fragment,{children:[!t&&P.jsx("div",{className:"conversation--feedback__title",children:e}),P.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[u.right?P.jsx("span",{className:"icon-check-circle-black color--success"}):P.jsx("span",{className:"icon-error-circle-black color--error"}),P.jsx("div",{className:"conversation--feedback__wysiwyg",children:bi(u.feedback)})]})]})}):null}function D9({emitEvent:u,getEvent:t,soundActions:e,keyboardControl:n,inScene:i,...s}){var I,H;const{inheritProps:o={},decisionNumber:l,required:c,question:d,onAddPoints:f,onFinish:m,branched:_,simplifiedOptions:g}=s,S=Object.keys(o).length>0,[y,x]=G.useState("options"),[T,A]=G.useState({}),[E]=e,C=c&&!(T!=null&&T.right),R=G.useRef(),N=W=>{var Z;(Z=W.audio)!=null&&Z.url&&E(W.audio.url,"audio_file",!1,W.audioVolume)},O={...o,slots:o.slots?o.slots:o.characters,currentMessage:{position:null,emotion:""},emitEvent:u,getEvent:t};o&&o.flex&&O.slots&&(O.characters=O.characters.filter(W=>O.slots.find(Z=>Z.uid===W.uid)));const M=W=>{u({type:"decisionJournal",payload:{choice:W,decisionNumber:l}})},B=W=>{if(!C&&y==="results")E("click-ui"),S?g?m&&(M(W),m(W,()=>{A({}),x("options")})):(f&&f(W),M(W),u({type:"addPoints",payload:W==null?void 0:W.rewards,finish:!1,complex:!0,onFinish:()=>{m?m(W,()=>{A({}),x("options")}):u({type:"success"}),A({}),x("options")}})):(M(W),u({type:"addPoints",payload:W==null?void 0:W.rewards,finish:!0,complex:!0}));else if(Object.keys(W).length>0)if(E("click-ui"),g)if(W!=null&&W.rewards.filter(Z=>Z.type==="var").length){M({...W,simplified:!0});const Z=W==null?void 0:W.rewards.filter(X=>X.type==="var");u({type:"addPoints",payload:Z,finish:!1,complex:!0,onFinish:()=>{m?m(W,()=>{A({}),x("options")}):u({type:"success"}),A({}),x("options")}})}else M({...W,simplified:!0}),m(W,()=>{A({}),x("options")});else W.right?E("score"):(E("fail"),_||(S||c?(M(W),u({type:"addPoints",payload:W==null?void 0:W.rewards,finish:!1,complex:!0})):c||(A({}),x("options")))),A(W),N(W),x("results")},L={...s,selectView:x,selectedView:y,emitEvent:u,inherited:S,branched:_,soundActions:e,showingResults:y==="results",currentSelectedChoice:T,hasRewards:(T==null?void 0:T.rewards)||[],failed:C,inScene:i,required:c,simplifiedOptions:g,changeOption:W=>{E("click-ui"),A(W),x("options")},onNext:B,translate:W=>t({type:"translate",payload:W})},F=n({disabled:y!=="results",repeat:!1,forward:()=>{if(R.current!==T)R.current=T;else return;B(T)}});return G.useEffect(()=>F(),[F]),S?P.jsx("div",{className:`conversation--layer
|
|
46
46
|
${T!=null&&T.feedback?"":"conversation--layer__defaultFeedback"}
|
|
47
47
|
${y==="results"?"conversation--layer__feedback":""}`,children:P.jsxs("div",{className:`conversation ${i?"conversation--inScene":""}`,style:(I=o.background)!=null&&I.img?{backgroundImage:`url("${(H=o.background.img)==null?void 0:H.url}")`}:null,children:[P.jsx(w9,{...O,children:y==="results"&&(T!=null&&T.feedback)?P.jsx(dj,{question:d,soundActions:e,inherited:S,choice:T,rewards:(T==null?void 0:T.rewards)||[],emitEvent:u}):null}),P.jsx(cj,{...L})]})}):P.jsx("div",{className:"popup--layer popup--layer--transparent",children:P.jsx(cj,{...L,children:P.jsx(dj,{question:d,soundActions:e,inherited:S,choice:T,rewards:(T==null?void 0:T.rewards)||[],emitEvent:u})})})}function tX({emitEvent:u,img:t,imgName:e,documentType:n,visible:i,viewed:s,imgId_labelId:o,soundActions:l,keyboardControl:c,getEvent:d}){const f=T=>d({type:"translate",payload:T}),[m,_]=G.useState(!1),g=t.url,[S]=l,y=G.useCallback(()=>{S("click-ui"),u({type:"finishMedia",payload:{imgId:o,name:e,imgName:e,documentType:n,type:"image"}})},[S,o,e,n,u]),x=c({disabled:s,forward:y,escape:y});return G.useEffect(()=>x(),[x]),G.useEffect(()=>{!i&&!m&&(_(!0),y())},[y,i,m]),i?P.jsx("div",{className:s?"notes--results":"readings--container readings--container--darkopacity",children:P.jsxs("div",{className:s?"notes--results__text":"readings readings--image",children:[g&&P.jsx("img",{src:g,alt:e}),s?null:P.jsx("div",{className:g?"readings--image--closeBtn":"position--absolute top right",children:P.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:y,"aria-label":f("storylines.misc.closePiece"),children:P.jsx("span",{className:"icon-close"})})})]})}):null}function eX({name:u}){return P.jsx("div",{className:"conversation--voice__over",children:P.jsx("span",{children:u||"Voice-Over"})})}function nX({text:u}){return P.jsxs("div",{className:"conversation--voice__over",children:[P.jsx("span",{className:"icon-bubble-thinkful-black"}),P.jsxs("span",{children:["[",u,"]"]})]})}function jF({current:u={},translate:t,voiceOver:e=!1}){var i,s;const n=u.text;return P.jsxs("div",{className:`conversation--message ${u.voiceOver||(i=u==null?void 0:u.emotion)!=null&&i.includes("think")?"voice--over":""}`,children:[u.voiceOver?P.jsx(eX,{name:u.name}):null,(s=u==null?void 0:u.emotion)!=null&&s.includes("think")?P.jsx(nX,{text:t("emotion.thinking")}):null,P.jsx("div",{className:"conversation--main__text",children:bi(n)})]})}const iX={width:"100%",height:"100%",position:"static"};function vN(u){const t=document.querySelector(".screens--container");return G.useEffect(()=>(u.onMount&&u.onMount(),()=>{u.onUnMount&&u.onUnMount()}),[]),P.jsx(Va.HtmlPro,{zIndexRange:[6,6],style:iX,portal:t?{current:t}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:u.children})}const aX=75,lR=1400;function sX({keyboardControl:u,emitEvent:t=()=>{},getEvent:e,pause:n,lines:i,edges:s,characters:o,actors:l,background:c={},soundActions:d=[()=>{},()=>{}],lodSettings:f,autoPlay:m,autoEnd:_,progress:g}){var te,Ie,Je;const S=i.length-1<=(g==null?void 0:g.line)?i.length-1:(g==null?void 0:g.line)||0,[y,x]=G.useState(!1),[T,A]=G.useState(!0),[E,C]=G.useState(!!m),[R,N]=G.useState(!1),[O,M]=G.useState(S),[B,L]=G.useState(!1),[F]=d,{start:I,stop:H}=Tw(),W=((te=c==null?void 0:c.img)==null?void 0:te.url)||null,Z=i[O],{voiceOver:X,decision:$}=Z;let{flex:nt}=Z,Q=[];const tt=!!s,rt=X||Z.type==="conversationalNarration",ut=$||Z.type==="conversationalDecision",st=Z.type==="conversationalCamera",[ot,ht]=G.useState([]),vt=G.useMemo(()=>ot[ot.length-1],[ot]),it=G.useCallback(()=>{if(tt){const Gt=i.filter(ee=>!s.find(pe=>pe.toId===ee.id));if(Gt.length){const ee=Gt[0],pe=i.indexOf(ee);if(pe>=0)return pe}}return-1},[tt,i,s]),lt=G.useCallback(()=>{const Gt=s.find(pe=>pe.fromId===vt)||s.find(pe=>pe.toId===vt),ee=i.find(pe=>pe.id===(Gt==null?void 0:Gt.fromId));return!vt&&(g==null?void 0:g.line)>=0?{decision:!0}:ee},[s,i,vt,g==null?void 0:g.line]),dt=G.useCallback(()=>{if(tt){const ee=lt();return ee==null?void 0:ee.decision}const Gt=i[O-1]?i[O-1]:{};return O>0&&(Gt==null?void 0:Gt.decision)},[tt,lt,i,O]),Et=G.useCallback(()=>{if(tt){const ee=lt();return(ee==null?void 0:ee.type)==="conversationalCamera"}const Gt=i[O-1]?i[O-1]:{};return O>0&&(Gt==null?void 0:Gt.type)==="conversationalCamera"},[tt,i,O,lt]),_t=G.useCallback(Gt=>e({type:"translate",payload:Gt}),[e]),pt=G.useMemo(()=>{var ee,pe;if(ut)return{};if(rt)return Z;const Gt=(ee=Z==null?void 0:Z.slots)==null?void 0:ee.find(En=>En.uid&&En.talking);return Gt||((pe=Z==null?void 0:Z.slots)==null?void 0:pe.find(En=>En.uid&&En.text))},[Z,rt,ut]),bt=i.slice(0,O+1).reverse().find(Gt=>Gt.slots),Tt=!ut&&((Ie=Z.slots)==null?void 0:Ie.filter(Gt=>Gt.uid).length),Ct=aX*(((Je=pt==null?void 0:pt.text)==null?void 0:Je.length)||0);let Ft=[];Z.slots?Ft=Z.slots:bt&&(Ft=bt.slots);const It=Ft.filter(Gt=>Gt.uid).map(Gt=>{const ee=(o||l||[]).find(pe=>pe.uid===Gt.uid);return ee&&(Gt.resource=ee.resource,Gt.type=ee.type),Gt.resource||(Gt.resource={}),Gt}),Jt={characters:It,lodSettings:f,actors:l,currentMessage:pt||{},slots:rt?Q:Z.slots,flex:nt,pause:n,getEvent:e};if(rt){const Gt=i.slice(O).find(pe=>pe.slots),ee=bt||Gt;ee&&(Q=ee.slots,nt=ee.flex)}else if(!ut&&Tt&&(Z.slots.forEach(Gt=>{const ee=It.findIndex(pe=>pe.uid===Gt.uid);ee>=0&&(It[ee].emotion=Gt.emotion)}),pt&&pt.uid)){const Gt=Z.slots.findIndex(pe=>pe.uid===pt.uid),ee=It.findIndex(pe=>pe.uid===pt.uid);It.forEach(pe=>{pe.uid===pt.uid&&(pe.name=pt.alias)}),pt.position=nt?ee:Gt}const ne=G.useCallback(()=>{t({type:"success"})},[t]),Ae=G.useCallback((Gt,ee)=>{const pe=[3,2,1][Gt.id],ue=s.filter(me=>me.fromId===Z.id).find(me=>parseInt(me.fromPointIndex)===pe);if(ue){const me=i.findIndex(Dn=>Dn.id===ue.toId);ue.fromId===ue.toId?ee():me>=0?(M(me),t({type:"notifyProgress",payload:{line:me}})):ne()}else ne()},[Z.id,s,t,ne,i]),Ze=G.useCallback((Gt=!0)=>{const ee=Gt?["fromId","toId"]:["toId","fromId"],pe=s.filter(me=>me[ee[0]]===Z.id),En=pe.length===1?pe[0]:pe.find(me=>me[ee[1]]===vt);if(!(En!=null&&En[ee[0]])){ne();return}Gt||ht(ot.slice(0,-1));const ue=i.findIndex(me=>me.id===En[ee[1]]);ue>=0?(M(ue),t({type:"notifyProgress",payload:{line:ue}})):ne()},[Z.id,s,ot,t,ne,vt,i]),Re=G.useCallback(Gt=>{if(tt){if(Gt){const ee=[3,2,1][Gt.id],En=s.filter(ue=>ue.fromId===Z.id).find(ue=>parseInt(ue.fromPointIndex)===ee);if(En){const ue=i.findIndex(me=>me.id===En.toId);ue>=0&&t({type:"notifyProgress",payload:{line:ue}})}else t({type:"saveNode"})}}else if(O<i.length-1){const pe=O+1;t({type:"notifyProgress",payload:{line:pe}})}else t({type:"saveNode"})},[s,i,t,O,Z.id,tt]),Ee=G.useCallback((Gt,ee)=>{let pe=!1;if(L(!1),A(!1),N(!1),tt)ht([...ot,Z.id]),Gt?Ae(Gt,ee):Ze();else if(O<i.length-1){const ue=O+1;M(ue),t({type:"notifyProgress",payload:{line:ue}}),ee&&ee()}else _||ut||st?ne():pe=!0;pe||A(!0)},[ot,Z.id,tt,O,i.length,_,ut,st,Ae,Ze,t,ne]),xn=()=>{if(A(!1),L(!1),N(!1),tt)Ze(!1);else if(!dt()){const Gt=O-1;M(Gt),t({type:"notifyProgress",payload:{line:Gt}})}A(!0)},hn=G.useCallback(()=>tt?Z&&Z.type!=="conversationalDecision"&&!s.find(Gt=>Gt.fromId===Z.id):O===i.length-1,[O,Z,s,tt,i.length]),kt=()=>{F("click-ui"),hn()?ne():(C(!1),Ee())},ie=()=>{F("click-ui"),C(!1),xn()},he=E&&!ut&&!n&&!st,Lt=G.useMemo(()=>it()>=0&&ot.length===0&&tt||O===0&&!tt||dt()||Et(),[it,ot.length,tt,O,dt,Et]);sy({audioType:Z==null?void 0:Z.audioType,volume:Z==null?void 0:Z.audioVolume,voice:Z==null?void 0:Z.voice,started:T,slide:O,text:Hw(pt==null?void 0:pt.text),audio:Z==null?void 0:Z.audio,soundActions:d,getEvent:e,pauseTTS:n,onStart:()=>{var Gt;(Gt=pt==null?void 0:pt.emotion)!=null&&Gt.includes("think")||L(!0)},onError:()=>{N(!0)},onFinish:()=>{L(!1),he&&Ee()}}),G.useEffect(()=>{var ee;let Gt;return ut?()=>{}:(((Z==null?void 0:Z.audioType)==="none"||R)&&!((ee=pt==null?void 0:pt.emotion)!=null&&ee.includes("think"))&&(L(!0),Gt=setTimeout(()=>{L(!1)},Ct<lR?lR:Ct)),()=>{Gt&&clearTimeout(Gt)})},[R,Z,pt==null?void 0:pt.emotion,Ct,ut]),G.useEffect(()=>(he&&((Z==null?void 0:Z.audioType)==="none"||R)&&(!hn()||hn()&&_)&&I(Ee,Ct<lR?lR:Ct),()=>{H()}),[pt,I,H,Ee,Z==null?void 0:Z.audioType,he,R,_,i,hn,Ct]),G.useEffect(()=>{if(tt&&!y){const Gt=g==null?void 0:g.line;if(Gt>=0){x(!0),M(Gt);return}const ee=it();ee>=0&&(x(!0),M(ee))}},[s,it,tt,i,y,g==null?void 0:g.line]);const Xt=u({disabled:ut,repeat:!1,forward:kt,rewind:Lt?null:ie});if(G.useEffect(()=>Xt(),[Xt]),st)return P.jsx(m9,{...Z,transition:{type:"none"},emitEvent:t,success:!1,onFinish:Ee},`change-camera-${O}`);if(ut){const Gt=i[O].id?i.filter(pe=>pe.decision).findIndex(pe=>pe.id===i[O].id)+1:i.filter(pe=>pe.decision).findIndex(pe=>pe===i[O])+1,ee={...Z.payload,decisionNumber:Gt,required:!tt,branched:tt,onAddPoints:Re,onFinish:Ee,keyboardControl:u,emitEvent:t,getEvent:e,soundActions:d,inheritProps:{characters:It,background:c,flex:bt?bt.flex:!0,slots:bt?bt.slots:[]}};return P.jsx(vN,{children:P.jsx(D9,{...ee})})}return P.jsx(vN,{children:P.jsx("div",{className:"conversation--layer",children:P.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:W?{backgroundImage:`url("${W}")`}:null,children:[P.jsx(w9,{...Jt,ttsStarted:B}),P.jsxs("div",{className:"conversation--body",dir:"auto",children:[pt?P.jsx(jF,{current:pt,translate:_t}):null,P.jsxs("div",{className:"conversation--controls",children:[P.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Lt?"disabled":""}`,disabled:Lt?!0:"",type:"button",onClick:ie,"aria-label":Pe()?_t("storylines.misc.forward"):_t("storylines.misc.rewind"),children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${E&&hn()?"glowing-animation":""}`,type:"button",onClick:kt,"aria-label":Pe()?_t("storylines.misc.rewind"):_t("storylines.misc.forward"),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})})]})]})]})})})}function rX({emitEvent:u,getEvent:t,soundActions:e,messages:n,characters:i,alias:s,background:o,lodSettings:l}){var x;const[c,d]=G.useState(0),[f]=e,m=((x=o==null?void 0:o.img)==null?void 0:x.url)||null,_=n[c],g=i.map((T,A)=>({...T,name:s[A]?s[A]:T.name,uid:A})),S=()=>{const T=n.length-1;f("click-ui"),c+1<=T?d(c+1):u({type:"success"})},y=()=>{c>0&&(d(c-1),f("click-ui"))};return P.jsx("div",{className:"conversation--layer",children:P.jsxs("div",{"data-testid":"conversation-component",className:"conversation",style:m?{backgroundImage:`url("${m}")`}:{},children:[P.jsx(w9,{characters:g,lodSettings:l,currentMessage:_,slots:g,emitEvent:u,getEvent:t,flex:!0}),P.jsxs("div",{className:"conversation--body",children:[_?P.jsx(jF,{current:_,voiceOver:_.emotion===null}):P.jsx("div",{}),P.jsxs("div",{className:"conversation--controls",children:[P.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${c>0?"":"visibility--hidden"}`,type:"button",onClick:y,children:P.jsx("span",{className:"icon-back"})}),P.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:P.jsx("span",{className:"icon-next"})})]})]})]})})}function oX({vignette:u,alias:t,translate:e,backgroundImageCover:n}){var m;const s=(u.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[o,l]=G.useState(!0),c=_=>{document.querySelector(`#${_}`).focus(),l(!o)},d=/\.(mp4|mov|webm)$/i.test(s),f={src:s,style:n?{minHeight:"100%",minWidth:"100%",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}:{height:"100%",width:"100%"}};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{"data-testid":"comic-image",className:`comic-image ${n?"comic-image--cover":""}`,children:[d&&P.jsx("video",{"data-testid":"videoTestId",autoPlay:!0,...f}),s&&!d&&P.jsx("img",{src:s,alt:"comic pic"})]}),(m=u==null?void 0:u.textData)!=null&&m.text?P.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${o?"comic-collapsable--opened":""}`,children:[P.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>c("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":e("comic.toggleText"),children:P.jsx("span",{className:"icon-down-arrow"})}),P.jsxs("div",{className:"comic-collapsable__text",children:[t?P.jsxs("b",{children:[t,": "]}):null,bi(u.textData.text)]})]}):null,P.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:o?"-1":"0","aria-hidden":o,className:`unset-button comic-buttonup
|
|
@@ -329,7 +329,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
329
329
|
*/var vz,p0,Y_,o7,vg,yz,l7,wet=function(){return typeof window<"u"},af={},dg=180/Math.PI,K_=Math.PI/180,E_=Math.atan2,_z=1e8,u7=/([A-Z])/g,Det=/(left|right|width|margin|padding|x)/i,Oet=/[\s,\(]\S/,cd={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},YN=function(t,e){return e.set(e.t,e.p,Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},Met=function(t,e){return e.set(e.t,e.p,t===1?e.e:Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},Net=function(t,e){return e.set(e.t,e.p,t?Math.round((e.s+e.c*t)*1e4)/1e4+e.u:e.b,e)},Let=function(t,e){var n=e.s+e.c*t;e.set(e.t,e.p,~~(n+(n<0?-.5:.5))+e.u,e)},zU=function(t,e){return e.set(e.t,e.p,t?e.e:e.b,e)},BU=function(t,e){return e.set(e.t,e.p,t!==1?e.b:e.e,e)},Pet=function(t,e,n){return t.style[e]=n},jet=function(t,e,n){return t.style.setProperty(e,n)},zet=function(t,e,n){return t._gsap[e]=n},Bet=function(t,e,n){return t._gsap.scaleX=t._gsap.scaleY=n},ket=function(t,e,n,i,s){var o=t._gsap;o.scaleX=o.scaleY=n,o.renderTransform(s,o)},Fet=function(t,e,n,i,s){var o=t._gsap;o[e]=n,o.renderTransform(s,o)},Yi="transform",eo=Yi+"Origin",Iet=function u(t,e){var n=this,i=this.target,s=i.style,o=i._gsap;if(t in af&&s){if(this.tfm=this.tfm||{},t!=="transform")t=cd[t]||t,~t.indexOf(",")?t.split(",").forEach(function(l){return n.tfm[l]=ph(i,l)}):this.tfm[t]=o.x?o[t]:ph(i,t),t===eo&&(this.tfm.zOrigin=o.zOrigin);else return cd.transform.split(",").forEach(function(l){return u.call(n,l,e)});if(this.props.indexOf(Yi)>=0)return;o.svg&&(this.svgo=i.getAttribute("data-svg-origin"),this.props.push(eo,e,"")),t=Yi}(s||e)&&this.props.push(t,e,s[t])},kU=function(t){t.translate&&(t.removeProperty("translate"),t.removeProperty("scale"),t.removeProperty("rotate"))},Uet=function(){var t=this.props,e=this.target,n=e.style,i=e._gsap,s,o;for(s=0;s<t.length;s+=3)t[s+1]?e[t[s]]=t[s+2]:t[s+2]?n[t[s]]=t[s+2]:n.removeProperty(t[s].substr(0,2)==="--"?t[s]:t[s].replace(u7,"-$1").toLowerCase());if(this.tfm){for(o in this.tfm)i[o]=this.tfm[o];i.svg&&(i.renderTransform(),e.setAttribute("data-svg-origin",this.svgo||"")),s=l7(),(!s||!s.isStart)&&!n[Yi]&&(kU(n),i.zOrigin&&n[eo]&&(n[eo]+=" "+i.zOrigin+"px",i.zOrigin=0,i.renderTransform()),i.uncache=1)}},FU=function(t,e){var n={target:t,props:[],revert:Uet,save:Iet};return t._gsap||no.core.getCache(t),e&&e.split(",").forEach(function(i){return n.save(i)}),n},IU,KN=function(t,e){var n=p0.createElementNS?p0.createElementNS((e||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),t):p0.createElement(t);return n&&n.style?n:p0.createElement(t)},dd=function u(t,e,n){var i=getComputedStyle(t);return i[e]||i.getPropertyValue(e.replace(u7,"-$1").toLowerCase())||i.getPropertyValue(e)||!n&&u(t,n2(e)||e,1)||""},bz="O,Moz,ms,Ms,Webkit".split(","),n2=function(t,e,n){var i=e||vg,s=i.style,o=5;if(t in s&&!n)return t;for(t=t.charAt(0).toUpperCase()+t.substr(1);o--&&!(bz[o]+t in s););return o<0?null:(o===3?"ms":o>=0?bz[o]:"")+t},XN=function(){wet()&&window.document&&(vz=window,p0=vz.document,Y_=p0.documentElement,vg=KN("div")||{style:{}},KN("div"),Yi=n2(Yi),eo=Yi+"Origin",vg.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",IU=!!n2("perspective"),l7=no.core.reverting,o7=1)},BO=function u(t){var e=KN("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),n=this.parentNode,i=this.nextSibling,s=this.style.cssText,o;if(Y_.appendChild(e),e.appendChild(this),this.style.display="block",t)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=u}catch{}else this._gsapBBox&&(o=this._gsapBBox());return n&&(i?n.insertBefore(this,i):n.appendChild(this)),Y_.removeChild(e),this.style.cssText=s,o},Sz=function(t,e){for(var n=e.length;n--;)if(t.hasAttribute(e[n]))return t.getAttribute(e[n])},UU=function(t){var e;try{e=t.getBBox()}catch{e=BO.call(t,!0)}return e&&(e.width||e.height)||t.getBBox===BO||(e=BO.call(t,!0)),e&&!e.width&&!e.x&&!e.y?{x:+Sz(t,["x","cx","x1"])||0,y:+Sz(t,["y","cy","y1"])||0,width:0,height:0}:e},HU=function(t){return!!(t.getCTM&&(!t.parentNode||t.ownerSVGElement)&&UU(t))},ey=function(t,e){if(e){var n=t.style,i;e in af&&e!==eo&&(e=Yi),n.removeProperty?(i=e.substr(0,2),(i==="ms"||e.substr(0,6)==="webkit")&&(e="-"+e),n.removeProperty(i==="--"?e:e.replace(u7,"-$1").toLowerCase())):n.removeAttribute(e)}},m0=function(t,e,n,i,s,o){var l=new to(t._pt,e,n,0,1,o?BU:zU);return t._pt=l,l.b=i,l.e=s,t._props.push(n),l},xz={deg:1,rad:1,turn:1},Het={grid:1,flex:1},E0=function u(t,e,n,i){var s=parseFloat(n)||0,o=(n+"").trim().substr((s+"").length)||"px",l=vg.style,c=Det.test(e),d=t.tagName.toLowerCase()==="svg",f=(d?"client":"offset")+(c?"Width":"Height"),m=100,_=i==="px",g=i==="%",S,y,x,T;if(i===o||!s||xz[i]||xz[o])return s;if(o!=="px"&&!_&&(s=u(t,e,n,"px")),T=t.getCTM&&HU(t),(g||o==="%")&&(af[e]||~e.indexOf("adius")))return S=T?t.getBBox()[c?"width":"height"]:t[f],ga(g?s/S*m:s/100*S);if(l[c?"width":"height"]=m+(_?o:i),y=~e.indexOf("adius")||i==="em"&&t.appendChild&&!d?t:t.parentNode,T&&(y=(t.ownerSVGElement||{}).parentNode),(!y||y===p0||!y.appendChild)&&(y=p0.body),x=y._gsap,x&&g&&x.width&&c&&x.time===Jo.time&&!x.uncache)return ga(s/x.width*m);if(g&&(e==="height"||e==="width")){var A=t.style[e];t.style[e]=m+i,S=t[f],A?t.style[e]=A:ey(t,e)}else(g||o==="%")&&!Het[dd(y,"display")]&&(l.position=dd(t,"position")),y===t&&(l.position="static"),y.appendChild(vg),S=vg[f],y.removeChild(vg),l.position="absolute";return c&&g&&(x=Kv(y),x.time=Jo.time,x.width=y[f]),ga(_?S*s/m:S&&s?m/S*s:0)},ph=function(t,e,n,i){var s;return o7||XN(),e in cd&&e!=="transform"&&(e=cd[e],~e.indexOf(",")&&(e=e.split(",")[0])),af[e]&&e!=="transform"?(s=aT(t,i),s=e!=="transformOrigin"?s[e]:s.svg?s.origin:L5(dd(t,eo))+" "+s.zOrigin+"px"):(s=t.style[e],(!s||s==="auto"||i||~(s+"").indexOf("calc("))&&(s=N5[e]&&N5[e](t,e,n)||dd(t,e)||aU(t,e)||(e==="opacity"?1:0))),n&&!~(s+"").trim().indexOf(" ")?E0(t,e,s,n)+n:s},Get=function(t,e,n,i){if(!n||n==="none"){var s=n2(e,t,1),o=s&&dd(t,s,1);o&&o!==n?(e=s,n=o):e==="borderColor"&&(n=dd(t,"borderTopColor"))}var l=new to(this._pt,t.style,e,0,1,LU),c=0,d=0,f,m,_,g,S,y,x,T,A,E,C,R;if(l.b=n,l.e=i,n+="",i+="",i==="auto"&&(y=t.style[e],t.style[e]=i,i=dd(t,e)||i,y?t.style[e]=y:ey(t,e)),f=[n,i],EU(f),n=f[0],i=f[1],_=n.match(j_)||[],R=i.match(j_)||[],R.length){for(;m=j_.exec(i);)x=m[0],A=i.substring(c,m.index),S?S=(S+1)%5:(A.substr(-5)==="rgba("||A.substr(-5)==="hsla(")&&(S=1),x!==(y=_[d++]||"")&&(g=parseFloat(y)||0,C=y.substr((g+"").length),x.charAt(1)==="="&&(x=V_(g,x)+C),T=parseFloat(x),E=x.substr((T+"").length),c=j_.lastIndex-E.length,E||(E=E||tl.units[e]||C,c===i.length&&(i+=E,l.e+=E)),C!==E&&(g=E0(t,e,y,E)||0),l._pt={_next:l._pt,p:A||d===1?A:",",s:g,c:T-g,m:S&&S<4||e==="zIndex"?Math.round:0});l.c=c<i.length?i.substring(c,i.length):""}else l.r=e==="display"&&i==="none"?BU:zU;return JI.test(i)&&(l.e=0),this._pt=l,l},Ez={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},Vet=function(t){var e=t.split(" "),n=e[0],i=e[1]||"50%";return(n==="top"||n==="bottom"||i==="left"||i==="right")&&(t=n,n=i,i=t),e[0]=Ez[n]||n,e[1]=Ez[i]||i,e.join(" ")},Yet=function(t,e){if(e.tween&&e.tween._time===e.tween._dur){var n=e.t,i=n.style,s=e.u,o=n._gsap,l,c,d;if(s==="all"||s===!0)i.cssText="",c=1;else for(s=s.split(","),d=s.length;--d>-1;)l=s[d],af[l]&&(c=1,l=l==="transformOrigin"?eo:Yi),ey(n,l);c&&(ey(n,Yi),o&&(o.svg&&n.removeAttribute("transform"),aT(n,1),o.uncache=1,kU(i)))}},N5={clearProps:function(t,e,n,i,s){if(s.data!=="isFromStart"){var o=t._pt=new to(t._pt,e,n,0,0,Yet);return o.u=i,o.pr=-10,o.tween=s,t._props.push(n),1}}},iT=[1,0,0,1,0,0],GU={},VU=function(t){return t==="matrix(1, 0, 0, 1, 0, 0)"||t==="none"||!t},Tz=function(t){var e=dd(t,Yi);return VU(e)?iT:e.substr(7).match(ZI).map(ga)},c7=function(t,e){var n=t._gsap||Kv(t),i=t.style,s=Tz(t),o,l,c,d;return n.svg&&t.getAttribute("transform")?(c=t.transform.baseVal.consolidate().matrix,s=[c.a,c.b,c.c,c.d,c.e,c.f],s.join(",")==="1,0,0,1,0,0"?iT:s):(s===iT&&!t.offsetParent&&t!==Y_&&!n.svg&&(c=i.display,i.display="block",o=t.parentNode,(!o||!t.offsetParent)&&(d=1,l=t.nextElementSibling,Y_.appendChild(t)),s=Tz(t),c?i.display=c:ey(t,"display"),d&&(l?o.insertBefore(t,l):o?o.appendChild(t):Y_.removeChild(t))),e&&s.length>6?[s[0],s[1],s[4],s[5],s[12],s[13]]:s)},qN=function(t,e,n,i,s,o){var l=t._gsap,c=s||c7(t,!0),d=l.xOrigin||0,f=l.yOrigin||0,m=l.xOffset||0,_=l.yOffset||0,g=c[0],S=c[1],y=c[2],x=c[3],T=c[4],A=c[5],E=e.split(" "),C=parseFloat(E[0])||0,R=parseFloat(E[1])||0,N,O,M,B;n?c!==iT&&(O=g*x-S*y)&&(M=C*(x/O)+R*(-y/O)+(y*A-x*T)/O,B=C*(-S/O)+R*(g/O)-(g*A-S*T)/O,C=M,R=B):(N=UU(t),C=N.x+(~E[0].indexOf("%")?C/100*N.width:C),R=N.y+(~(E[1]||E[0]).indexOf("%")?R/100*N.height:R)),i||i!==!1&&l.smooth?(T=C-d,A=R-f,l.xOffset=m+(T*g+A*y)-T,l.yOffset=_+(T*S+A*x)-A):l.xOffset=l.yOffset=0,l.xOrigin=C,l.yOrigin=R,l.smooth=!!i,l.origin=e,l.originIsAbsolute=!!n,t.style[eo]="0px 0px",o&&(m0(o,l,"xOrigin",d,C),m0(o,l,"yOrigin",f,R),m0(o,l,"xOffset",m,l.xOffset),m0(o,l,"yOffset",_,l.yOffset)),t.setAttribute("data-svg-origin",C+" "+R)},aT=function(t,e){var n=t._gsap||new RU(t);if("x"in n&&!e&&!n.uncache)return n;var i=t.style,s=n.scaleX<0,o="px",l="deg",c=getComputedStyle(t),d=dd(t,eo)||"0",f,m,_,g,S,y,x,T,A,E,C,R,N,O,M,B,L,F,I,H,W,Z,X,$,nt,Q,tt,rt,ut,st,ot,ht;return f=m=_=y=x=T=A=E=C=0,g=S=1,n.svg=!!(t.getCTM&&HU(t)),c.translate&&((c.translate!=="none"||c.scale!=="none"||c.rotate!=="none")&&(i[Yi]=(c.translate!=="none"?"translate3d("+(c.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(c.rotate!=="none"?"rotate("+c.rotate+") ":"")+(c.scale!=="none"?"scale("+c.scale.split(" ").join(",")+") ":"")+(c[Yi]!=="none"?c[Yi]:"")),i.scale=i.rotate=i.translate="none"),O=c7(t,n.svg),n.svg&&(n.uncache?(nt=t.getBBox(),d=n.xOrigin-nt.x+"px "+(n.yOrigin-nt.y)+"px",$=""):$=!e&&t.getAttribute("data-svg-origin"),qN(t,$||d,!!$||n.originIsAbsolute,n.smooth!==!1,O)),R=n.xOrigin||0,N=n.yOrigin||0,O!==iT&&(F=O[0],I=O[1],H=O[2],W=O[3],f=Z=O[4],m=X=O[5],O.length===6?(g=Math.sqrt(F*F+I*I),S=Math.sqrt(W*W+H*H),y=F||I?E_(I,F)*dg:0,A=H||W?E_(H,W)*dg+y:0,A&&(S*=Math.abs(Math.cos(A*K_))),n.svg&&(f-=R-(R*F+N*H),m-=N-(R*I+N*W))):(ht=O[6],st=O[7],tt=O[8],rt=O[9],ut=O[10],ot=O[11],f=O[12],m=O[13],_=O[14],M=E_(ht,ut),x=M*dg,M&&(B=Math.cos(-M),L=Math.sin(-M),$=Z*B+tt*L,nt=X*B+rt*L,Q=ht*B+ut*L,tt=Z*-L+tt*B,rt=X*-L+rt*B,ut=ht*-L+ut*B,ot=st*-L+ot*B,Z=$,X=nt,ht=Q),M=E_(-H,ut),T=M*dg,M&&(B=Math.cos(-M),L=Math.sin(-M),$=F*B-tt*L,nt=I*B-rt*L,Q=H*B-ut*L,ot=W*L+ot*B,F=$,I=nt,H=Q),M=E_(I,F),y=M*dg,M&&(B=Math.cos(M),L=Math.sin(M),$=F*B+I*L,nt=Z*B+X*L,I=I*B-F*L,X=X*B-Z*L,F=$,Z=nt),x&&Math.abs(x)+Math.abs(y)>359.9&&(x=y=0,T=180-T),g=ga(Math.sqrt(F*F+I*I+H*H)),S=ga(Math.sqrt(X*X+ht*ht)),M=E_(Z,X),A=Math.abs(M)>2e-4?M*dg:0,C=ot?1/(ot<0?-ot:ot):0),n.svg&&($=t.getAttribute("transform"),n.forceCSS=t.setAttribute("transform","")||!VU(dd(t,Yi)),$&&t.setAttribute("transform",$))),Math.abs(A)>90&&Math.abs(A)<270&&(s?(g*=-1,A+=y<=0?180:-180,y+=y<=0?180:-180):(S*=-1,A+=A<=0?180:-180)),e=e||n.uncache,n.x=f-((n.xPercent=f&&(!e&&n.xPercent||(Math.round(t.offsetWidth/2)===Math.round(-f)?-50:0)))?t.offsetWidth*n.xPercent/100:0)+o,n.y=m-((n.yPercent=m&&(!e&&n.yPercent||(Math.round(t.offsetHeight/2)===Math.round(-m)?-50:0)))?t.offsetHeight*n.yPercent/100:0)+o,n.z=_+o,n.scaleX=ga(g),n.scaleY=ga(S),n.rotation=ga(y)+l,n.rotationX=ga(x)+l,n.rotationY=ga(T)+l,n.skewX=A+l,n.skewY=E+l,n.transformPerspective=C+o,(n.zOrigin=parseFloat(d.split(" ")[2])||!e&&n.zOrigin||0)&&(i[eo]=L5(d)),n.xOffset=n.yOffset=0,n.force3D=tl.force3D,n.renderTransform=n.svg?Xet:IU?YU:Ket,n.uncache=0,n},L5=function(t){return(t=t.split(" "))[0]+" "+t[1]},kO=function(t,e,n){var i=$s(e);return ga(parseFloat(e)+parseFloat(E0(t,"x",n+"px",i)))+i},Ket=function(t,e){e.z="0px",e.rotationY=e.rotationX="0deg",e.force3D=0,YU(t,e)},sg="0deg",uE="0px",rg=") ",YU=function(t,e){var n=e||this,i=n.xPercent,s=n.yPercent,o=n.x,l=n.y,c=n.z,d=n.rotation,f=n.rotationY,m=n.rotationX,_=n.skewX,g=n.skewY,S=n.scaleX,y=n.scaleY,x=n.transformPerspective,T=n.force3D,A=n.target,E=n.zOrigin,C="",R=T==="auto"&&t&&t!==1||T===!0;if(E&&(m!==sg||f!==sg)){var N=parseFloat(f)*K_,O=Math.sin(N),M=Math.cos(N),B;N=parseFloat(m)*K_,B=Math.cos(N),o=kO(A,o,O*B*-E),l=kO(A,l,-Math.sin(N)*-E),c=kO(A,c,M*B*-E+E)}x!==uE&&(C+="perspective("+x+rg),(i||s)&&(C+="translate("+i+"%, "+s+"%) "),(R||o!==uE||l!==uE||c!==uE)&&(C+=c!==uE||R?"translate3d("+o+", "+l+", "+c+") ":"translate("+o+", "+l+rg),d!==sg&&(C+="rotate("+d+rg),f!==sg&&(C+="rotateY("+f+rg),m!==sg&&(C+="rotateX("+m+rg),(_!==sg||g!==sg)&&(C+="skew("+_+", "+g+rg),(S!==1||y!==1)&&(C+="scale("+S+", "+y+rg),A.style[Yi]=C||"translate(0, 0)"},Xet=function(t,e){var n=e||this,i=n.xPercent,s=n.yPercent,o=n.x,l=n.y,c=n.rotation,d=n.skewX,f=n.skewY,m=n.scaleX,_=n.scaleY,g=n.target,S=n.xOrigin,y=n.yOrigin,x=n.xOffset,T=n.yOffset,A=n.forceCSS,E=parseFloat(o),C=parseFloat(l),R,N,O,M,B;c=parseFloat(c),d=parseFloat(d),f=parseFloat(f),f&&(f=parseFloat(f),d+=f,c+=f),c||d?(c*=K_,d*=K_,R=Math.cos(c)*m,N=Math.sin(c)*m,O=Math.sin(c-d)*-_,M=Math.cos(c-d)*_,d&&(f*=K_,B=Math.tan(d-f),B=Math.sqrt(1+B*B),O*=B,M*=B,f&&(B=Math.tan(f),B=Math.sqrt(1+B*B),R*=B,N*=B)),R=ga(R),N=ga(N),O=ga(O),M=ga(M)):(R=m,M=_,N=O=0),(E&&!~(o+"").indexOf("px")||C&&!~(l+"").indexOf("px"))&&(E=E0(g,"x",o,"px"),C=E0(g,"y",l,"px")),(S||y||x||T)&&(E=ga(E+S-(S*R+y*O)+x),C=ga(C+y-(S*N+y*M)+T)),(i||s)&&(B=g.getBBox(),E=ga(E+i/100*B.width),C=ga(C+s/100*B.height)),B="matrix("+R+","+N+","+O+","+M+","+E+","+C+")",g.setAttribute("transform",B),A&&(g.style[Yi]=B)},qet=function(t,e,n,i,s){var o=360,l=hs(s),c=parseFloat(s)*(l&&~s.indexOf("rad")?dg:1),d=c-i,f=i+d+"deg",m,_;return l&&(m=s.split("_")[1],m==="short"&&(d%=o,d!==d%(o/2)&&(d+=d<0?o:-o)),m==="cw"&&d<0?d=(d+o*_z)%o-~~(d/o)*o:m==="ccw"&&d>0&&(d=(d-o*_z)%o-~~(d/o)*o)),t._pt=_=new to(t._pt,e,n,i,d,Met),_.e=f,_.u="deg",t._props.push(n),_},Az=function(t,e){for(var n in e)t[n]=e[n];return t},Qet=function(t,e,n){var i=Az({},n._gsap),s="perspective,force3D,transformOrigin,svgOrigin",o=n.style,l,c,d,f,m,_,g,S;i.svg?(d=n.getAttribute("transform"),n.setAttribute("transform",""),o[Yi]=e,l=aT(n,1),ey(n,Yi),n.setAttribute("transform",d)):(d=getComputedStyle(n)[Yi],o[Yi]=e,l=aT(n,1),o[Yi]=d);for(c in af)d=i[c],f=l[c],d!==f&&s.indexOf(c)<0&&(g=$s(d),S=$s(f),m=g!==S?E0(n,c,d,S):parseFloat(d),_=parseFloat(f),t._pt=new to(t._pt,l,c,m,_-m,YN),t._pt.u=S||0,t._props.push(c));Az(l,i)};$r("padding,margin,Width,Radius",function(u,t){var e="Top",n="Right",i="Bottom",s="Left",o=(t<3?[e,n,i,s]:[e+s,e+n,i+n,i+s]).map(function(l){return t<2?u+l:"border"+l+u});N5[t>1?"border"+u:u]=function(l,c,d,f,m){var _,g;if(arguments.length<4)return _=o.map(function(S){return ph(l,S,d)}),g=_.join(" "),g.split(_[0]).length===5?_[0]:g;_=(f+"").split(" "),g={},o.forEach(function(S,y){return g[S]=_[y]=_[y]||_[(y-1)/2|0]}),l.init(c,g,m)}});var KU={name:"css",register:XN,targetTest:function(t){return t.style&&t.nodeType},init:function(t,e,n,i,s){var o=this._props,l=t.style,c=n.vars.startAt,d,f,m,_,g,S,y,x,T,A,E,C,R,N,O,M;o7||XN(),this.styles=this.styles||FU(t),M=this.styles.props,this.tween=n;for(y in e)if(y!=="autoRound"&&(f=e[y],!(Wo[y]&&wU(y,e,n,i,t,s)))){if(g=typeof f,S=N5[y],g==="function"&&(f=f.call(n,i,t,s),g=typeof f),g==="string"&&~f.indexOf("random(")&&(f=tT(f)),S)S(this,t,y,f,n)&&(O=1);else if(y.substr(0,2)==="--")d=(getComputedStyle(t).getPropertyValue(y)+"").trim(),f+="",v0.lastIndex=0,v0.test(d)||(x=$s(d),T=$s(f)),T?x!==T&&(d=E0(t,y,d,T)+T):x&&(f+=x),this.add(l,"setProperty",d,f,i,s,0,0,y),o.push(y),M.push(y,0,l[y]);else if(g!=="undefined"){if(c&&y in c?(d=typeof c[y]=="function"?c[y].call(n,i,t,s):c[y],hs(d)&&~d.indexOf("random(")&&(d=tT(d)),$s(d+"")||d==="auto"||(d+=tl.units[y]||$s(ph(t,y))||""),(d+"").charAt(1)==="="&&(d=ph(t,y))):d=ph(t,y),_=parseFloat(d),A=g==="string"&&f.charAt(1)==="="&&f.substr(0,2),A&&(f=f.substr(2)),m=parseFloat(f),y in cd&&(y==="autoAlpha"&&(_===1&&ph(t,"visibility")==="hidden"&&m&&(_=0),M.push("visibility",0,l.visibility),m0(this,l,"visibility",_?"inherit":"hidden",m?"inherit":"hidden",!m)),y!=="scale"&&y!=="transform"&&(y=cd[y],~y.indexOf(",")&&(y=y.split(",")[0]))),E=y in af,E){if(this.styles.save(y),C||(R=t._gsap,R.renderTransform&&!e.parseTransform||aT(t,e.parseTransform),N=e.smoothOrigin!==!1&&R.smooth,C=this._pt=new to(this._pt,l,Yi,0,1,R.renderTransform,R,0,-1),C.dep=1),y==="scale")this._pt=new to(this._pt,R,"scaleY",R.scaleY,(A?V_(R.scaleY,A+m):m)-R.scaleY||0,YN),this._pt.u=0,o.push("scaleY",y),y+="X";else if(y==="transformOrigin"){M.push(eo,0,l[eo]),f=Vet(f),R.svg?qN(t,f,0,N,0,this):(T=parseFloat(f.split(" ")[2])||0,T!==R.zOrigin&&m0(this,R,"zOrigin",R.zOrigin,T),m0(this,l,y,L5(d),L5(f)));continue}else if(y==="svgOrigin"){qN(t,f,1,N,0,this);continue}else if(y in GU){qet(this,R,y,_,A?V_(_,A+f):f);continue}else if(y==="smoothOrigin"){m0(this,R,"smooth",R.smooth,f);continue}else if(y==="force3D"){R[y]=f;continue}else if(y==="transform"){Qet(this,f,t);continue}}else y in l||(y=n2(y)||y);if(E||(m||m===0)&&(_||_===0)&&!Oet.test(f)&&y in l)x=(d+"").substr((_+"").length),m||(m=0),T=$s(f)||(y in tl.units?tl.units[y]:x),x!==T&&(_=E0(t,y,d,T)),this._pt=new to(this._pt,E?R:l,y,_,(A?V_(_,A+m):m)-_,!E&&(T==="px"||y==="zIndex")&&e.autoRound!==!1?Let:YN),this._pt.u=T||0,x!==T&&T!=="%"&&(this._pt.b=d,this._pt.r=Net);else if(y in l)Get.call(this,t,y,d,A?A+f:f);else if(y in t)this.add(t,y,d||t[y],A?A+f:f,i,s);else if(y!=="parseTransform"){J9(y,f);continue}E||(y in l?M.push(y,0,l[y]):M.push(y,1,d||t[y])),o.push(y)}}O&&PU(this)},render:function(t,e){if(e.tween._time||!l7())for(var n=e._pt;n;)n.r(t,n.d),n=n._next;else e.styles.revert()},get:ph,aliases:cd,getSetter:function(t,e,n){var i=cd[e];return i&&i.indexOf(",")<0&&(e=i),e in af&&e!==eo&&(t._gsap.x||ph(t,"x"))?n&&yz===n?e==="scale"?Bet:zet:(yz=n||{})&&(e==="scale"?ket:Fet):t.style&&!Q9(t.style[e])?Pet:~e.indexOf("-")?jet:s7(t,e)},core:{_removeProperty:ey,_getMatrix:c7}};no.utils.checkPrefix=n2;no.core.getStyleSaver=FU;(function(u,t,e,n){var i=$r(u+","+t+","+e,function(s){af[s]=1});$r(t,function(s){tl.units[s]="deg",GU[s]=1}),cd[i[13]]=u+","+t,$r(n,function(s){var o=s.split(":");cd[o[1]]=i[o[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");$r("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(u){tl.units[u]="px"});no.registerPlugin(KU);var XU=no.registerPlugin(KU)||no;XU.core.Tween;function Wet({message:u,translate:t},e){const[n,i]=G.useState(!1),s=()=>{const o=u.avatar,l=o.lastIndexOf("/");return o.includes("/object/")?o.slice(0,l).concat("/mini-thumbnail.png"):o.includes("/character/")?o.slice(0,l).concat("/mini-face.png"):o};return G.useLayoutEffect(()=>{n||i(!0)},[n]),P.jsxs("div",{dir:"auto",ref:e,className:`
|
|
330
330
|
speech-bubble
|
|
331
331
|
${u.thinkful?"speech-bubble--italic":""}
|
|
332
|
-
`,children:[P.jsxs("div",{className:`speech-bubble__header ${u.thinkful?"speech-bubble__header--thinking":""}`,children:[u.thinkful?P.jsx("div",{className:"thinking-icon-wrap",children:P.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,u.avatar?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("img",{src:s(),alt:u.name})}):null,u.voiceOver?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("div",{className:"icon-narrator"})}):null,P.jsxs("div",{className:"speech-bubble__name",children:[P.jsx("span",{children:u.name}),u.thinkful?P.jsxs("span",{children:["[ ",t("emotion.thinking")," ]"]}):null]})]}),u.text?P.jsx("div",{className:"speech-bubble__text",children:bi(u.text)}):null]})}const Zet=G.forwardRef(Wet);function Jet({currentMessage:u,translate:t}){const e=document.querySelector(".screens--container");return P.jsx("group",{children:P.jsx(Va.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:e?{current:e}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:P.jsx(Zet,{translate:t,message:u})})})}const wo={},FO=new xH.GLTFLoader,IO=.25,$et=.01;function tnt(u){const t=$h.useThree(m=>m.scene),e=G.useRef({root:null,howl:null});$h.useFrame((m,_)=>{var y;const g=e.current.root,S=(y=e.current.howl)==null?void 0:y.node;if(g&&S){const x=g.userData.animator;if(!x)return;const T=x.getAction("tts");if(!T)return;S.volume>$et?Va.ThreeUtils.setWeight(T,1):Va.ThreeUtils.setWeight(T,0)}});const n=G.useMemo(()=>{var _;const m={};for(const g of u)if(g.slots)for(const S of g.slots){if(!S.uid)continue;const y=(_=S.character)==null?void 0:_.resource.animations;y&&(m[S.uid]||(m[S.uid]=Object.keys(y).reduce((x,T)=>(x[T]=y[T].url,x),{})))}return m},[u]),i=G.useMemo(()=>{const m=new Set;for(const _ of u)if(_.slots)for(const g of _.slots)g.uid&&m.add(g.uid);return Array.from(m)},[u]),s=async(m,_)=>{if(m&&!wo[m]){const{animations:g}=await FO.loadAsync(m);g[0].name=_,wo[m]=g[0]}},o=async(m,_)=>{const g=n[m],S=g.talking,y=g["talking-short"];await Promise.all([s(y,"talking-short"),s(S,"talking")]);const x=gg(m,t);if(!x)return!1;const T=x.userData.animator;if(!T)return!1;const A=g["talking-short"]||g.talking,E=wo[A],C=wH(E),R=T.register("tts",C,x);R.setEffectiveTimeScale(2),_?e.current={root:x,howl:_}:Va.ThreeUtils.setWeight(R,1)},l=async m=>{const _=gg(m,t);if(!_)return!1;const g=_.userData.animator;if(!g)return!1;const S=g.getAction("tts");S&&Va.ThreeUtils.setWeight(S,0),e.current={root:null,howl:null}},c=()=>{i.forEach(m=>{const _=t.getObjectByProperty("uid",m);if(_){const g=_.userData.animator;if(!g)return;const S=g.getAction("tts");S&&Va.ThreeUtils.setWeight(S,0),delete _.userData._active,f(m,"idle")}})},d=async(m,_,g=!1)=>{const S=gg(m,t);if(wo[m]||(wo[m]={}),!S)return new Promise(x=>x(!1));const y=S.userData.animator;if(!y)return!1;if(_){const x=_;let T=wo[_];if(!T){const{animations:A}=await FO.loadAsync(_);T=wo[_]=A[0]}if(!S.userData._active||S.userData._active!==x){S.userData._active=x;const A=y.register(x,nP(T),S);return new Promise(E=>{g&&A.reset(),y.mix(x,IO,g).then(C=>E(C?A:!1))})}}return new Promise(x=>x(!1))},f=async(m,_)=>{const g=gg(m,t);if(wo[m]||(wo[m]={}),!g)return new Promise(y=>y(!1));const S=g.userData.animator;if(!S)return!1;if(_==="idle")return S.mix("idle",IO),S.getAction("idle");{const y=n[m],x=_.split("_")[0],T=y[x];if(T){const A=T;let E=wo[A];if(!E){let C=wo[T];if(!C){const{animations:R}=await FO.loadAsync(T);C=wo[T]=R[0],C.name=x}E=C,wo[A]=E}if(!g.userData._active||g.userData._active!==_){g.userData._active=_;const C=S.register(_,nP(E),g);return new Promise(R=>{S.mix(_,IO).then(N=>R(N?C:!1))})}}}return new Promise(y=>y(!1))};return{startEmotionUrl:d,startEmotion:f,startSpeech:o,stopSpeech:l,resetActives:c}}const Cz=75,_R=1400,ent=2,QN=new Oa.Raycaster,og=new Oa.Object3D,nnt=70;QN.firstHitOnly=!0;function int({keyboardControl:u,emitEvent:t,getEvent:e,lines:n,actors:i,edges:s,soundActions:o,zoomInActor:l,autoPlay:c,autoEnd:d,pause:f,progress:m}){var _e;const _=n.length-1<=(m==null?void 0:m.line)?n.length-1:(m==null?void 0:m.line)||0,[g,S]=G.useState(_),[y,x]=G.useState(!!c),[T,A]=G.useState(!1),[E,C]=G.useState(!1),R=$h.useThree(Pt=>Pt.scene),N=$h.useThree(Pt=>Pt.camera),{start:O,stop:M}=Tw(),B=G.useRef([]),L=G.useMemo(()=>N.clone(),[]),F=G.useRef({pos:[0,0,0],child:null}),I=n[g],H=n[g-1],W=G.useRef(!1),Z=!!s,{voiceOver:X,decision:$}=I||{},nt=G.useRef({}),Q=(_e=I==null?void 0:I.slots)==null?void 0:_e.find(Pt=>Pt.talking),tt=G.useRef(!1),{startEmotion:rt,startEmotionUrl:ut,resetActives:st,stopSpeech:ot,startSpeech:ht}=tnt(n);G.useRef();const vt=Object.keys((I==null?void 0:I.audio)||{}).length,it=Object.keys((I==null?void 0:I.voice)||{}).length,lt=X||(I==null?void 0:I.type)==="conversationalNarration",dt=$||(I==null?void 0:I.type)==="conversationalDecision",Et=(I==null?void 0:I.type)==="conversationalCamera",_t=y&&!dt&&!Et,[pt,bt]=G.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Tt=G.useMemo(()=>n.reduce((Pt,qt)=>(qt.slots&&qt.slots.filter(we=>we.uid).forEach(we=>{Pt.includes(we.uid)||Pt.push(we.uid)}),Pt),[]),[n]),Ct=G.useCallback(Pt=>e({type:"translate",payload:Pt}),[e]),[Ft,It]=G.useState([]),Jt=G.useMemo(()=>Ft[Ft.length-1],[Ft]),ne=G.useCallback(()=>{const Pt=s.find(Zt=>Zt.fromId===Jt)||s.find(Zt=>Zt.toId===Jt),qt=n.find(Zt=>Zt.id===(Pt==null?void 0:Pt.fromId));return!Jt&&(m==null?void 0:m.line)>=0?{decision:!0}:qt},[s,n,Jt]),Ae=G.useCallback(()=>{if(Z){const Pt=n.filter(qt=>!s.find(Zt=>Zt.toId===qt.id));if(Pt.length){const qt=Pt[0],Zt=n.indexOf(qt);if(Zt>=0)return Zt}}return-1},[Z,n,s]),Ze=G.useCallback(()=>{if(Z){const qt=ne();return qt==null?void 0:qt.decision}const Pt=n[g-1]?n[g-1]:{};return g>0&&(Pt==null?void 0:Pt.decision)},[I,Z,n,Jt,s]),Re=G.useCallback(()=>{if(Z){const qt=ne();return(qt==null?void 0:qt.type)==="conversationalCamera"}const Pt=n[g-1]?n[g-1]:{};return g>0&&(Pt==null?void 0:Pt.type)==="conversationalCamera"},[I,Z,n,Jt,s]),Ee=G.useCallback(Pt=>{var Zt,we;const qt=i.find(ce=>(ce==null?void 0:ce.uid)===(Pt==null?void 0:Pt.uid)?ce:"");return((we=(Zt=Pt==null?void 0:Pt.character)==null?void 0:Zt.resource)==null?void 0:we.url)||(qt==null?void 0:qt.completeUrl)||""},[i]),xn=(Pt=()=>{})=>{if(tt.current)tt.current&&(tt.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const qt=F.current.child?F.current.pos:L.position.toArray();if(og.position.fromArray(qt),F.current.parent){og.quaternion.equals(N.quaternion)||og.applyQuaternion(N.quaternion);const Zt=F.current.isLeft?-1:1,we=ent*Zt;og.translateX(-10*Zt+we),og.translateY(-2),og.translateZ(30)}XU.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{tt.current=!0},onUpdate:()=>{B.current.length&&B.current.forEach(Zt=>{const{object:we}=Zt;we.material.visible=!0})},onComplete:()=>{Pt(),QN.set(N.getWorldPosition(new Oa.Vector3(0,0,0)),N.getWorldDirection(new Oa.Vector3));const Zt=QN.intersectObjects(R.children,!0);B.current=Zt.filter(we=>we.distance<10),B.current.length&&B.current.forEach(we=>{const{object:ce}=we;ce.material.side=0}),tt.current=!1,W.current&&t({type:"success"}),F.current.child||N.copy(L)},...og.position})}},hn=G.useCallback(()=>{F.current.child=null,F.current.parent=null,l&&xn()},[l]),kt=(Pt,qt,Zt,we=!1)=>{const ce=qt.includes("seated");let fn=qt;if(qt==="neutral"&&!Zt&&(fn="idle"),we&&!ce&&(fn+="-seated"),Zt){const Si=CH.includes(Zt.animationId);ut(Pt,Zt.url,Si).then($n=>{$n&&Si&&rt(Pt,"idle")})}else rt(Pt,fn)},ie=Pt=>{if(!(Q!=null&&Q.uid)||!(Q!=null&&Q.emotion)||W.current)return;const{emotion:qt,uid:Zt,animation:we}=Q;gg(Zt,R)&&ht(Zt,Pt)},he=()=>{!(Q!=null&&Q.uid)||W.current||ot(Q==null?void 0:Q.uid)},Lt=G.useCallback(()=>{W.current=!0,bt({show:!1}),hn(),st(),l||t({type:"success"})},[N,t,hn,l]);G.useEffect(()=>()=>{nt.current={},st()},[]);const Xt=Pt=>{bt({show:!1}),S(Pt),t({type:"notifyProgress",payload:{line:Pt}})},te=G.useCallback((Pt=!0)=>{const qt=Pt?["fromId","toId"]:["toId","fromId"],Zt=s.filter(fn=>fn[qt[0]]===I.id),we=Zt.length===1?Zt[0]:Zt.find(fn=>fn[qt[1]]===Jt);if(!(we!=null&&we[qt[0]])){Lt();return}Pt||It(Ft.slice(0,Ft.length-1));const ce=n.findIndex(fn=>fn.id===we[qt[1]]);ce>=0?Xt(ce):Lt()},[I==null?void 0:I.id,t,s,Lt,n]),Ie=G.useCallback((Pt,qt)=>{const Zt=[3,2,1][Pt.id],ce=s.filter(Si=>Si.fromId===(I==null?void 0:I.id)).find(Si=>parseInt(Si.fromPointIndex)===Zt),fn=n.findIndex(Si=>Si.id===(ce==null?void 0:ce.toId));fn>=0?(ce==null?void 0:ce.fromId)===(ce==null?void 0:ce.toId)?qt():Xt(fn):Lt()},[I==null?void 0:I.id,s,Lt,n]),Je=G.useCallback(()=>{if(nt.current={...Q},C(!1),he(),Z)te(!1);else if(!Ze()){const Pt=g-1;bt({show:!1}),S(Pt),t({type:"notifyProgress",payload:{line:Pt}})}},[te,t,Z,H,g,Q]),Gt=G.useCallback(Pt=>{if(Z){if(Pt){const qt=[3,2,1][Pt.id],we=s.filter(ce=>ce.fromId===I.id).find(ce=>parseInt(ce.fromPointIndex)===qt);if(we){const ce=n.findIndex(fn=>fn.id===we.toId);ce>=0&&t({type:"notifyProgress",payload:{line:ce}})}else t({type:"saveNode"})}}else if(g<n.length-1){const qt=g+1;t({type:"notifyProgress",payload:{line:qt}})}else t({type:"saveNode"})},[s,g,n,t,I==null?void 0:I.id,Z]),ee=G.useCallback((Pt,qt)=>{if(nt.current={...Q},C(!1),he(),Z)It([...Ft,I.id]),Pt?Ie(Pt,qt):te();else if(g<n.length-1){const Zt=g+1;Xt(Zt)}else(d||dt||Et)&&Lt()},[t,I==null?void 0:I.id,Z,dt,Et,g,n.length,Ie,te,Lt,Q]),pe=()=>{x(!1),Je()},En=()=>Z?I&&I.type!=="conversationalDecision"&&!s.find(Pt=>Pt.fromId===I.id):g===n.length-1,ue=()=>{En()?Lt():(x(!1),ee())};G.useEffect(()=>{if(Z&&!T){const Pt=m==null?void 0:m.line;if(Pt>=0){A(!0),S(Pt);return}const qt=Ae();qt>=0&&(A(!0),S(qt))}},[s,Z,n,T,Ae]);const me=Pt=>{if(nt.current.uid===Pt.uid||F.current.parent===Pt)return;const qt=new Oa.Object3D,Zt=Pt.getObjectByName("Head_M");Zt.updateMatrixWorld(!0),qt.applyMatrix4(Zt.matrixWorld),qt.applyQuaternion(N.quaternion);const we=l?2.5:2,ce=l?1.2:1.5;qt.translateY(we),qt.translateX(ce);const fn=new Oa.Vector3;fn.setFromMatrixPosition(Zt.matrixWorld);const $n=fn.project(N).x<0;F.current={pos:qt.position.toArray(),child:Zt,parent:Pt,isLeft:$n}},Dn=Pt=>{t({type:"resetZIndexUIContainer",payload:Pt})};G.useEffect(()=>{var Pt;if(lt)hn(),bt({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Ct("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Ee(Q),show:!0});else if(!W.current&&!dt&&!Et){const qt=I==null?void 0:I.slots.filter(ce=>ce.uid&&!ce.talking),Zt=[...qt.map(ce=>ce.uid)||[],Q==null?void 0:Q.uid];if(Tt.filter(ce=>!Zt.includes(ce)).forEach(ce=>{rt(ce,"idle")}),qt.forEach(ce=>{const fn=gg(ce.uid,R);if(fn){const{isSeated:Si}=fn;kt(ce.uid,ce.emotion,ce.animation,Si)}}),Q){const ce=gg(Q.uid,R),fn=i.find(Si=>Si.uid===Q.uid);ce&&!W.current?setTimeout(()=>{var Si,$n;if(Q.uid===ce.uid){me(ce);const{isSeated:ir,userData:Tr}=ce,{emotion:io,animation:ac}=Q;!((Si=Tr._active)!=null&&Si.includes("talking"))&&!(($n=Tr._active)!=null&&$n.includes(io))&&kt(Q.uid,io,ac,ir);const il=()=>{var sc;bt({text:Q.text,name:Q.alias||((sc=Q.character)==null?void 0:sc.name),inScene:!0,thinkful:Q.emotion.includes("think"),avatar:Ee(Q),show:!0})};l?(tt.current=!1,xn(il)):il()}},150):(hn(),bt({text:Q.text,name:Q.alias||((Pt=Q.character)==null?void 0:Pt.name)||(fn==null?void 0:fn.name),left:!1,top:Q.text.length>nnt,inScene:!1,thinkful:Q.emotion.includes("think"),avatar:Ee(Q),show:!0}))}else hn(),bt({show:!0})}},[i,I,l,R,Ct,Ee,hn,dt,lt,Tt]);const jn=Hw(pt==null?void 0:pt.text),[Ni]=sy({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:pt.show,text:jn,audio:I==null?void 0:I.audio,soundActions:o,getEvent:e,pauseTTS:f,onStart:(Pt,qt)=>{var Zt;(Zt=Q==null?void 0:Q.emotion)!=null&&Zt.includes("think")||ie(qt)},onError:()=>{C(!0)},onFinish:()=>{he(),_t&&!f&&ee()}});G.useEffect(()=>(Ni(),()=>{Ni()}),[g,Ni]),G.useEffect(()=>{var Pt;if(((I==null?void 0:I.audioType)==="none"||E)&&(pt!=null&&pt.show)&&!(Q!=null&&Q.emotion.includes("think"))){ie();const qt=Cz*(((Pt=pt==null?void 0:pt.text)==null?void 0:Pt.length)||0);setTimeout(()=>{he()},qt<_R?_R:qt)}},[E,I==null?void 0:I.audioType,he,ie,Q==null?void 0:Q.emotion,pt]),G.useEffect(()=>{var Pt;if(_t&&pt.show&&((I==null?void 0:I.audioType)==="none"||E)&&!f){const qt=Cz*(((Pt=pt==null?void 0:pt.text)==null?void 0:Pt.length)||0);(!En()||En()&&d)&&O(ee,qt<_R?_R:qt)}return()=>{M()}},[pt,ee,O,d,M,I==null?void 0:I.audioType,_t,vt,it,E]);const zt=G.useMemo(()=>Ae()>=0&&Ft.length===0&&Z||!Z&&g===0||Ze()||Re(),[g,Ze,Re,Ae,Ft]),Qt=u({disabled:dt||!pt.show,repeat:!1,forward:ue,rewind:zt?null:pe});G.useEffect(()=>Qt(),[Qt]);const fe=document.querySelector(".screens--container");if(Et)return P.jsx(m9,{...I,emitEvent:t,success:!1,onFinish:ee},`change-camera-${g}`);if(dt){const Pt=I.id?n.filter(Zt=>Zt.decision).findIndex(Zt=>Zt.id===I.id)+1:n.filter(Zt=>Zt.decision).findIndex(Zt=>Zt===I)+1,qt={...I.payload,decisionNumber:Pt,inheritProps:{slots:[],disableBackground:!0},required:!Z,branched:Z,onAddPoints:Gt,onFinish:ee,emitEvent:t,getEvent:e,pause:f,soundActions:o,keyboardControl:u};return P.jsx(vN,{onMount:()=>{hn(),Dn(!0)},onUnMount:()=>{tt.current=!1,Dn(!1)},children:P.jsx(D9,{inScene:!0,...qt})})}return P.jsxs(P.Fragment,{children:[pt.text?P.jsx(Jet,{translate:Ct,currentMessage:pt}):null,P.jsx(Va.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:fe?{current:fe}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:P.jsxs("div",{dir:Pe()?"rtl":"ltr",className:"dialog-component-controls",children:[P.jsx("button",{type:"button",onClick:pe,disabled:zt||!pt.show,className:`gat--btn__round ${zt||!pt.show?"disabled":""}`,"aria-label":Pe()?Ct("storylines.misc.forward"):Ct("storylines.misc.rewind"),children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{type:"button",onClick:ue,disabled:!pt.show,className:`gat--btn__round
|
|
332
|
+
`,children:[P.jsxs("div",{className:`speech-bubble__header ${u.thinkful?"speech-bubble__header--thinking":""}`,children:[u.thinkful?P.jsx("div",{className:"thinking-icon-wrap",children:P.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,u.avatar?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("img",{src:s(),alt:u.name})}):null,u.voiceOver?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("div",{className:"icon-narrator"})}):null,P.jsxs("div",{className:"speech-bubble__name",children:[P.jsx("span",{children:u.name}),u.thinkful?P.jsxs("span",{children:["[ ",t("emotion.thinking")," ]"]}):null]})]}),u.text?P.jsx("div",{className:"speech-bubble__text",children:bi(u.text)}):null]})}const Zet=G.forwardRef(Wet);function Jet({currentMessage:u,translate:t}){const e=document.querySelector(".screens--container");return P.jsx("group",{children:P.jsx(Va.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:e?{current:e}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:P.jsx(Zet,{translate:t,message:u})})})}const wo={},FO=new xH.GLTFLoader,IO=.25,$et=.01;function tnt(u){const t=$h.useThree(m=>m.scene),e=G.useRef({root:null,howl:null});$h.useFrame((m,_)=>{var y;const g=e.current.root,S=(y=e.current.howl)==null?void 0:y.node;if(g&&S){const x=g.animator;if(!x)return;const T=x.getAction("tts");if(!T)return;S.volume>$et?Va.ThreeUtils.setWeight(T,1):Va.ThreeUtils.setWeight(T,0)}});const n=G.useMemo(()=>{var _;const m={};for(const g of u)if(g.slots)for(const S of g.slots){if(!S.uid)continue;const y=(_=S.character)==null?void 0:_.resource.animations;y&&(m[S.uid]||(m[S.uid]=Object.keys(y).reduce((x,T)=>(x[T]=y[T].url,x),{})))}return m},[u]),i=G.useMemo(()=>{const m=new Set;for(const _ of u)if(_.slots)for(const g of _.slots)g.uid&&m.add(g.uid);return Array.from(m)},[u]),s=async(m,_)=>{if(m&&!wo[m]){const{animations:g}=await FO.loadAsync(m);g[0].name=_,wo[m]=g[0]}},o=async(m,_)=>{const g=n[m],S=g.talking,y=g["talking-short"];await Promise.all([s(y,"talking-short"),s(S,"talking")]);const x=gg(m,t);if(!x)return!1;const T=x.animator;if(!T)return!1;const A=g["talking-short"]||g.talking,E=wo[A],C=wH(E),R=T.register("tts",C,x);R.setEffectiveTimeScale(2),_?e.current={root:x,howl:_}:Va.ThreeUtils.setWeight(R,1)},l=async m=>{const _=gg(m,t);if(!_)return!1;const g=_.animator;if(!g)return!1;const S=g.getAction("tts");S&&Va.ThreeUtils.setWeight(S,0),e.current={root:null,howl:null}},c=()=>{i.forEach(m=>{const _=t.getObjectByProperty("uid",m);if(_){const g=_.animator;if(!g)return;const S=g.getAction("tts");S&&Va.ThreeUtils.setWeight(S,0),delete _.userData._active,f(m,"idle")}})},d=async(m,_,g=!1)=>{const S=gg(m,t);if(wo[m]||(wo[m]={}),!S)return new Promise(x=>x(!1));const y=S.animator;if(!y)return!1;if(_){const x=_;let T=wo[_];if(!T){const{animations:A}=await FO.loadAsync(_);T=wo[_]=A[0]}if(!S.userData._active||S.userData._active!==x){S.userData._active=x;const A=y.register(x,nP(T),S);return new Promise(E=>{g&&A.reset(),y.mix(x,IO,g).then(C=>E(C?A:!1))})}}return new Promise(x=>x(!1))},f=async(m,_)=>{const g=gg(m,t);if(wo[m]||(wo[m]={}),!g)return new Promise(y=>y(!1));const S=g.animator;if(!S)return!1;if(_==="idle")return S.mix("idle",IO),S.getAction("idle");{const y=n[m],x=_.split("_")[0],T=y[x];if(T){const A=T;let E=wo[A];if(!E){let C=wo[T];if(!C){const{animations:R}=await FO.loadAsync(T);C=wo[T]=R[0],C.name=x}E=C,wo[A]=E}if(!g.userData._active||g.userData._active!==_){g.userData._active=_;const C=S.register(_,nP(E),g);return new Promise(R=>{S.mix(_,IO).then(N=>R(N?C:!1))})}}}return new Promise(y=>y(!1))};return{startEmotionUrl:d,startEmotion:f,startSpeech:o,stopSpeech:l,resetActives:c}}const Cz=75,_R=1400,ent=2,QN=new Oa.Raycaster,og=new Oa.Object3D,nnt=70;QN.firstHitOnly=!0;function int({keyboardControl:u,emitEvent:t,getEvent:e,lines:n,actors:i,edges:s,soundActions:o,zoomInActor:l,autoPlay:c,autoEnd:d,pause:f,progress:m}){var _e;const _=n.length-1<=(m==null?void 0:m.line)?n.length-1:(m==null?void 0:m.line)||0,[g,S]=G.useState(_),[y,x]=G.useState(!!c),[T,A]=G.useState(!1),[E,C]=G.useState(!1),R=$h.useThree(Pt=>Pt.scene),N=$h.useThree(Pt=>Pt.camera),{start:O,stop:M}=Tw(),B=G.useRef([]),L=G.useMemo(()=>N.clone(),[]),F=G.useRef({pos:[0,0,0],child:null}),I=n[g],H=n[g-1],W=G.useRef(!1),Z=!!s,{voiceOver:X,decision:$}=I||{},nt=G.useRef({}),Q=(_e=I==null?void 0:I.slots)==null?void 0:_e.find(Pt=>Pt.talking),tt=G.useRef(!1),{startEmotion:rt,startEmotionUrl:ut,resetActives:st,stopSpeech:ot,startSpeech:ht}=tnt(n);G.useRef();const vt=Object.keys((I==null?void 0:I.audio)||{}).length,it=Object.keys((I==null?void 0:I.voice)||{}).length,lt=X||(I==null?void 0:I.type)==="conversationalNarration",dt=$||(I==null?void 0:I.type)==="conversationalDecision",Et=(I==null?void 0:I.type)==="conversationalCamera",_t=y&&!dt&&!Et,[pt,bt]=G.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Tt=G.useMemo(()=>n.reduce((Pt,qt)=>(qt.slots&&qt.slots.filter(we=>we.uid).forEach(we=>{Pt.includes(we.uid)||Pt.push(we.uid)}),Pt),[]),[n]),Ct=G.useCallback(Pt=>e({type:"translate",payload:Pt}),[e]),[Ft,It]=G.useState([]),Jt=G.useMemo(()=>Ft[Ft.length-1],[Ft]),ne=G.useCallback(()=>{const Pt=s.find(Zt=>Zt.fromId===Jt)||s.find(Zt=>Zt.toId===Jt),qt=n.find(Zt=>Zt.id===(Pt==null?void 0:Pt.fromId));return!Jt&&(m==null?void 0:m.line)>=0?{decision:!0}:qt},[s,n,Jt]),Ae=G.useCallback(()=>{if(Z){const Pt=n.filter(qt=>!s.find(Zt=>Zt.toId===qt.id));if(Pt.length){const qt=Pt[0],Zt=n.indexOf(qt);if(Zt>=0)return Zt}}return-1},[Z,n,s]),Ze=G.useCallback(()=>{if(Z){const qt=ne();return qt==null?void 0:qt.decision}const Pt=n[g-1]?n[g-1]:{};return g>0&&(Pt==null?void 0:Pt.decision)},[I,Z,n,Jt,s]),Re=G.useCallback(()=>{if(Z){const qt=ne();return(qt==null?void 0:qt.type)==="conversationalCamera"}const Pt=n[g-1]?n[g-1]:{};return g>0&&(Pt==null?void 0:Pt.type)==="conversationalCamera"},[I,Z,n,Jt,s]),Ee=G.useCallback(Pt=>{var Zt,we;const qt=i.find(ce=>(ce==null?void 0:ce.uid)===(Pt==null?void 0:Pt.uid)?ce:"");return((we=(Zt=Pt==null?void 0:Pt.character)==null?void 0:Zt.resource)==null?void 0:we.url)||(qt==null?void 0:qt.completeUrl)||""},[i]),xn=(Pt=()=>{})=>{if(tt.current)tt.current&&(tt.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const qt=F.current.child?F.current.pos:L.position.toArray();if(og.position.fromArray(qt),F.current.parent){og.quaternion.equals(N.quaternion)||og.applyQuaternion(N.quaternion);const Zt=F.current.isLeft?-1:1,we=ent*Zt;og.translateX(-10*Zt+we),og.translateY(-2),og.translateZ(30)}XU.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{tt.current=!0},onUpdate:()=>{B.current.length&&B.current.forEach(Zt=>{const{object:we}=Zt;we.material.visible=!0})},onComplete:()=>{Pt(),QN.set(N.getWorldPosition(new Oa.Vector3(0,0,0)),N.getWorldDirection(new Oa.Vector3));const Zt=QN.intersectObjects(R.children,!0);B.current=Zt.filter(we=>we.distance<10),B.current.length&&B.current.forEach(we=>{const{object:ce}=we;ce.material.side=0}),tt.current=!1,W.current&&t({type:"success"}),F.current.child||N.copy(L)},...og.position})}},hn=G.useCallback(()=>{F.current.child=null,F.current.parent=null,l&&xn()},[l]),kt=(Pt,qt,Zt,we=!1)=>{const ce=qt.includes("seated");let fn=qt;if(qt==="neutral"&&!Zt&&(fn="idle"),we&&!ce&&(fn+="-seated"),Zt){const Si=CH.includes(Zt.animationId);ut(Pt,Zt.url,Si).then($n=>{$n&&Si&&rt(Pt,"idle")})}else rt(Pt,fn)},ie=Pt=>{if(!(Q!=null&&Q.uid)||!(Q!=null&&Q.emotion)||W.current)return;const{emotion:qt,uid:Zt,animation:we}=Q;gg(Zt,R)&&ht(Zt,Pt)},he=()=>{!(Q!=null&&Q.uid)||W.current||ot(Q==null?void 0:Q.uid)},Lt=G.useCallback(()=>{W.current=!0,bt({show:!1}),hn(),st(),l||t({type:"success"})},[N,t,hn,l]);G.useEffect(()=>()=>{nt.current={},st()},[]);const Xt=Pt=>{bt({show:!1}),S(Pt),t({type:"notifyProgress",payload:{line:Pt}})},te=G.useCallback((Pt=!0)=>{const qt=Pt?["fromId","toId"]:["toId","fromId"],Zt=s.filter(fn=>fn[qt[0]]===I.id),we=Zt.length===1?Zt[0]:Zt.find(fn=>fn[qt[1]]===Jt);if(!(we!=null&&we[qt[0]])){Lt();return}Pt||It(Ft.slice(0,Ft.length-1));const ce=n.findIndex(fn=>fn.id===we[qt[1]]);ce>=0?Xt(ce):Lt()},[I==null?void 0:I.id,t,s,Lt,n]),Ie=G.useCallback((Pt,qt)=>{const Zt=[3,2,1][Pt.id],ce=s.filter(Si=>Si.fromId===(I==null?void 0:I.id)).find(Si=>parseInt(Si.fromPointIndex)===Zt),fn=n.findIndex(Si=>Si.id===(ce==null?void 0:ce.toId));fn>=0?(ce==null?void 0:ce.fromId)===(ce==null?void 0:ce.toId)?qt():Xt(fn):Lt()},[I==null?void 0:I.id,s,Lt,n]),Je=G.useCallback(()=>{if(nt.current={...Q},C(!1),he(),Z)te(!1);else if(!Ze()){const Pt=g-1;bt({show:!1}),S(Pt),t({type:"notifyProgress",payload:{line:Pt}})}},[te,t,Z,H,g,Q]),Gt=G.useCallback(Pt=>{if(Z){if(Pt){const qt=[3,2,1][Pt.id],we=s.filter(ce=>ce.fromId===I.id).find(ce=>parseInt(ce.fromPointIndex)===qt);if(we){const ce=n.findIndex(fn=>fn.id===we.toId);ce>=0&&t({type:"notifyProgress",payload:{line:ce}})}else t({type:"saveNode"})}}else if(g<n.length-1){const qt=g+1;t({type:"notifyProgress",payload:{line:qt}})}else t({type:"saveNode"})},[s,g,n,t,I==null?void 0:I.id,Z]),ee=G.useCallback((Pt,qt)=>{if(nt.current={...Q},C(!1),he(),Z)It([...Ft,I.id]),Pt?Ie(Pt,qt):te();else if(g<n.length-1){const Zt=g+1;Xt(Zt)}else(d||dt||Et)&&Lt()},[t,I==null?void 0:I.id,Z,dt,Et,g,n.length,Ie,te,Lt,Q]),pe=()=>{x(!1),Je()},En=()=>Z?I&&I.type!=="conversationalDecision"&&!s.find(Pt=>Pt.fromId===I.id):g===n.length-1,ue=()=>{En()?Lt():(x(!1),ee())};G.useEffect(()=>{if(Z&&!T){const Pt=m==null?void 0:m.line;if(Pt>=0){A(!0),S(Pt);return}const qt=Ae();qt>=0&&(A(!0),S(qt))}},[s,Z,n,T,Ae]);const me=Pt=>{if(nt.current.uid===Pt.uid||F.current.parent===Pt)return;const qt=new Oa.Object3D,Zt=Pt.getObjectByName("Head_M");Zt.updateMatrixWorld(!0),qt.applyMatrix4(Zt.matrixWorld),qt.applyQuaternion(N.quaternion);const we=l?2.5:2,ce=l?1.2:1.5;qt.translateY(we),qt.translateX(ce);const fn=new Oa.Vector3;fn.setFromMatrixPosition(Zt.matrixWorld);const $n=fn.project(N).x<0;F.current={pos:qt.position.toArray(),child:Zt,parent:Pt,isLeft:$n}},Dn=Pt=>{t({type:"resetZIndexUIContainer",payload:Pt})};G.useEffect(()=>{var Pt;if(lt)hn(),bt({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Ct("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Ee(Q),show:!0});else if(!W.current&&!dt&&!Et){const qt=I==null?void 0:I.slots.filter(ce=>ce.uid&&!ce.talking),Zt=[...qt.map(ce=>ce.uid)||[],Q==null?void 0:Q.uid];if(Tt.filter(ce=>!Zt.includes(ce)).forEach(ce=>{rt(ce,"idle")}),qt.forEach(ce=>{const fn=gg(ce.uid,R);if(fn){const{isSeated:Si}=fn;kt(ce.uid,ce.emotion,ce.animation,Si)}}),Q){const ce=gg(Q.uid,R),fn=i.find(Si=>Si.uid===Q.uid);ce&&!W.current?setTimeout(()=>{var Si,$n;if(Q.uid===ce.uid){me(ce);const{isSeated:ir,userData:Tr}=ce,{emotion:io,animation:ac}=Q;!((Si=Tr._active)!=null&&Si.includes("talking"))&&!(($n=Tr._active)!=null&&$n.includes(io))&&kt(Q.uid,io,ac,ir);const il=()=>{var sc;bt({text:Q.text,name:Q.alias||((sc=Q.character)==null?void 0:sc.name),inScene:!0,thinkful:Q.emotion.includes("think"),avatar:Ee(Q),show:!0})};l?(tt.current=!1,xn(il)):il()}},150):(hn(),bt({text:Q.text,name:Q.alias||((Pt=Q.character)==null?void 0:Pt.name)||(fn==null?void 0:fn.name),left:!1,top:Q.text.length>nnt,inScene:!1,thinkful:Q.emotion.includes("think"),avatar:Ee(Q),show:!0}))}else hn(),bt({show:!0})}},[i,I,l,R,Ct,Ee,hn,dt,lt,Tt]);const jn=Hw(pt==null?void 0:pt.text),[Ni]=sy({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:pt.show,text:jn,audio:I==null?void 0:I.audio,soundActions:o,getEvent:e,pauseTTS:f,onStart:(Pt,qt)=>{var Zt;(Zt=Q==null?void 0:Q.emotion)!=null&&Zt.includes("think")||ie(qt)},onError:()=>{C(!0)},onFinish:()=>{he(),_t&&!f&&ee()}});G.useEffect(()=>(Ni(),()=>{Ni()}),[g,Ni]),G.useEffect(()=>{var Pt;if(((I==null?void 0:I.audioType)==="none"||E)&&(pt!=null&&pt.show)&&!(Q!=null&&Q.emotion.includes("think"))){ie();const qt=Cz*(((Pt=pt==null?void 0:pt.text)==null?void 0:Pt.length)||0);setTimeout(()=>{he()},qt<_R?_R:qt)}},[E,I==null?void 0:I.audioType,he,ie,Q==null?void 0:Q.emotion,pt]),G.useEffect(()=>{var Pt;if(_t&&pt.show&&((I==null?void 0:I.audioType)==="none"||E)&&!f){const qt=Cz*(((Pt=pt==null?void 0:pt.text)==null?void 0:Pt.length)||0);(!En()||En()&&d)&&O(ee,qt<_R?_R:qt)}return()=>{M()}},[pt,ee,O,d,M,I==null?void 0:I.audioType,_t,vt,it,E]);const zt=G.useMemo(()=>Ae()>=0&&Ft.length===0&&Z||!Z&&g===0||Ze()||Re(),[g,Ze,Re,Ae,Ft]),Qt=u({disabled:dt||!pt.show,repeat:!1,forward:ue,rewind:zt?null:pe});G.useEffect(()=>Qt(),[Qt]);const fe=document.querySelector(".screens--container");if(Et)return P.jsx(m9,{...I,emitEvent:t,success:!1,onFinish:ee},`change-camera-${g}`);if(dt){const Pt=I.id?n.filter(Zt=>Zt.decision).findIndex(Zt=>Zt.id===I.id)+1:n.filter(Zt=>Zt.decision).findIndex(Zt=>Zt===I)+1,qt={...I.payload,decisionNumber:Pt,inheritProps:{slots:[],disableBackground:!0},required:!Z,branched:Z,onAddPoints:Gt,onFinish:ee,emitEvent:t,getEvent:e,pause:f,soundActions:o,keyboardControl:u};return P.jsx(vN,{onMount:()=>{hn(),Dn(!0)},onUnMount:()=>{tt.current=!1,Dn(!1)},children:P.jsx(D9,{inScene:!0,...qt})})}return P.jsxs(P.Fragment,{children:[pt.text?P.jsx(Jet,{translate:Ct,currentMessage:pt}):null,P.jsx(Va.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:fe?{current:fe}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:P.jsxs("div",{dir:Pe()?"rtl":"ltr",className:"dialog-component-controls",children:[P.jsx("button",{type:"button",onClick:pe,disabled:zt||!pt.show,className:`gat--btn__round ${zt||!pt.show?"disabled":""}`,"aria-label":Pe()?Ct("storylines.misc.forward"):Ct("storylines.misc.rewind"),children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{type:"button",onClick:ue,disabled:!pt.show,className:`gat--btn__round
|
|
333
333
|
${pt.show?"":"disabled"}
|
|
334
|
-
${y&&En()?"glowing-animation":""}`,"aria-label":Pe()?Ct("storylines.misc.rewind"):Ct("storylines.misc.forward"),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})})]})})]})}const ant=Va.ProgressManager.request("AssetLoader").cache,snt=new Va.AssetLoader(void 0,ant);function rnt({animation:u,loopTimes:t,onAnimationFinish:e,onAnimationSave:n,resource:i,makeDefault:s}){const[o,l]=G.useState(!1),c=$h.useThree(f=>f.scene),d=G.useRef(0);return G.useEffect(()=>{l(!1)},[i.uid,u==null?void 0:u.url]),G.useEffect(()=>{if(!o){const f=c.getObjectByProperty("uid",i.uid);if(f&&u&&u.url&&f.skeletonId===(u==null?void 0:u.skeletonId))if(s)n({uid:i.uid,animation:u==null?void 0:u.id,index:f.index}),e();else{const m=f.userData.animator,_=()=>{const g=m.getAction(u.url);g.setLoop(Oa.LoopRepeat,1/0),g.reset();function S(){d.current+=1,d.current>=t&&y()}function y(){m.mix("idle"),e(),m.removeEventListener("loop",S)}m.mix(u==null?void 0:u.url).then(x=>{x&&(d.current=1,d.current>=t?y():m.addEventListener("loop",S))}),l(!0)};m.getAction(u==null?void 0:u.url)?(m.setTime(0),_()):snt.load(u==null?void 0:u.url,g=>{m.register(u==null?void 0:u.url,g.animations[0]),m.setTime(0),_()},void 0,g=>{console.error(`Asset loader failed with: ${u.url}`,g),e()})}else e()}},[c,u==null?void 0:u.url,t,o,i.uid,s,u,i,e,n]),null}function ont({animations:u=[],enableInteraction:t,emitEvent:e}){const n=u.length,i=G.useRef(0),s=()=>{i.current+=1,i.current>=n&&t&&e({type:"success"})},o=l=>{e({type:"saveAnimation",payload:l})};return G.useEffect(()=>{i.current=0},[u]),G.useEffect(()=>{t||e({type:"success"})},[e,t]),u.map(({animation:l,...c},d)=>{var f;return P.jsx(rnt,{animation:l,...c,onAnimationFinish:s,onAnimationSave:o},(l==null?void 0:l.id)||((f=c.resource)==null?void 0:f.uid)||d)})}function lnt({text:u,error:t,handleClick:e}){return P.jsxs("div",{"data-testid":`${t?" pill--error":"pill--ok"}`,className:`email-pill ${t?" email-pill--error":""}`,children:[P.jsx("div",{children:u}),P.jsx("div",{className:"email-pill__delete",children:P.jsx("button",{type:"button",onClick:e,className:"icon-close unset-button","aria-label":"icon click"})})]})}function unt({handleContinue:u,handleCancel:t,translate:e,text:n}){const[i,s]=G.useState([]),[o,l]=G.useState(0),[c,d]=G.useState(0),f=G.useRef(null),m=(y,x,T)=>{y.stopPropagation(),s(i.filter(A=>A!==i[T])),x.error&&l(o-1),x.isRepeat&&d(c-1)},_=()=>{f.current&&f.current.focus()},g=()=>{[" ",",",";","."].includes(f.current.value)&&(f.current.value="")},S=y=>{const x=f.current.value,T=["Space","Comma","Period","Enter"],A=["Space","Comma","Enter","Tab"];x===""&&(T.includes(y.code)||y.keyCode==="186"||y.key==="Enter"||y.key===" ")?y.preventDefault():f.current.value.length>1&&(A.includes(y.code)||y.type==="blur")&&(y.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(x)?i.find(C=>C.text===x)?(d(c+1),s([...i,{text:x,error:!0,isRepeat:!0}])):s([...i,{text:x}]):(s([...i,{text:x,error:!0}]),l(o+1)),f.current.value="")};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",children:[P.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep1")}),P.jsx("div",{className:"referrals-piece__subtitle",children:n}),P.jsxs("div",{className:"referrals-piece__form",children:[P.jsxs("div",{className:"referrals-piece__instructions",children:[P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.instructions")}),P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.limit")})]}),P.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:_,"aria-labelledby":"list of emails",children:P.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[i&&i.map((y,x)=>P.jsx(lnt,{text:y.text,error:y.error,handleClick:T=>m(T,y,x),emailPillIndex:x},`${i.indexOf(y)}`)),i.length<=9?P.jsxs(P.Fragment,{children:[P.jsx("input",{id:"email",ref:f,className:"referrals-piece__inputemail",onChange:g,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),P.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:P.jsx("span",{children:e("puzzles.referrals.inviter.skipButton")})})]}):null]})}),P.jsxs("div",{dir:Pe()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[P.jsxs("div",{className:"referrals-piece__errormessage",children:[P.jsx("div",{children:c>0?e("puzzles.referrals.inviter.errorEmailRepeat"):null}),P.jsx("div",{children:o>0?e("puzzles.referrals.inviter.errorMessage"):null})]}),P.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[i.length,"/10"]})]})]})]}),P.jsxs("div",{className:"referrals-piece__buttons",children:[P.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:t,children:e("puzzles.referrals.inviter.skipButton")}),P.jsx("button",{className:`gat--btn gat--btn__primary ${c>0||o>0||i.length===0?" disabled":""}`,type:"button",disabled:o>0||i.length===0,onClick:()=>u(i),children:e("puzzles.referrals.inviter.inviteButton")})]})]})}function cnt({handleFinish:u,translate:t,valid:e,invalid:n}){const[i,s]=G.useState(!1),o=()=>{s(!i)},l=e.current===1?"invitationSend":"invitationsSend",c=n===1?"invitationNotSend":"invitationsNotSend";return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[P.jsx("div",{className:"referrals-piece__title",children:t("puzzles.referrals.inviter.titleStep2")}),P.jsxs("ul",{className:"referrals-piece__feedback",children:[e.current!==0&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),P.jsxs("div",{children:[P.jsx("strong",{children:e.current})," ",t(`puzzles.referrals.inviter.${l}`)]})]}),!!n.current&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),P.jsxs("div",{children:[P.jsx("strong",{children:n.current})," ",t(`puzzles.referrals.inviter.${c}`)]}),P.jsx("button",{className:"un-button",type:"button",onClick:o,children:t("puzzles.referrals.inviter.whyFail")})]})]}),i?P.jsxs("ul",{className:"referrals-piece__failsreasons",children:[P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons1")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons2")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons3")})]}):null]}),P.jsx("div",{className:"referrals-piece__buttons",children:P.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:u,children:t("puzzles.referrals.inviter.continueButton")})})]})}function dnt({emitEvent:u,getEvent:t,text:e,rewards:n,referrals:i}){const s=g=>t({type:"translate",payload:g}),[o,l]=G.useState("step1"),c=G.useRef(0),d=G.useRef(0),f=async g=>{const S=g.map(x=>x.text),y=await u({type:"sendReferrals",payload:S});c.current=y&&y.data?y.data.valid.length:0,d.current=S.length-c.current,l("step2")};if(!i)return u({type:"success"}),null;const m=()=>{u({type:"success"})},_=()=>{if(c.current){const g=n.map(S=>(S.points*=c.current,S));u({type:"addPoints",complex:!0,finish:!0,payload:g})}else u({type:"success"})};return P.jsx("div",{className:"referrals-piece",children:P.jsxs("div",{className:"referrals-piece__center",children:[o==="step1"&&P.jsx(unt,{translate:s,handleContinue:f,handleCancel:m,text:e}),o==="step2"&&P.jsx(cnt,{translate:s,handleFinish:_,valid:c,invalid:d})]})})}function hnt({onPass:u}){return G.useEffect(()=>{const t=setTimeout(u,0);return()=>clearTimeout(t)},[u]),null}function fnt({itemResolver:u,consume:t,hasComplexNotResolvers:e,hasComplexResolvers:n,resolverObjects:i,feedback:s,emitEvent:o,getEvent:l,soundActions:c,keyboardControl:d,noEvaluation:f}){const[m]=c,[_,g]=G.useState(!1),[S,y]=G.useState(!1),[x,T]=G.useState(!1),A=O=>l({type:"translate",payload:O}),E=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:_.success,onFinish:()=>{_.success?o({type:"success"}):o({type:"closeScreen"})},payload:_.rewards})},[o,_]),C=G.useCallback(()=>{if(i.find(M=>M===u.uid)){let M;n?(M=s.resolvers.rights.find(B=>B.uidObject===u.uid),M||(M=s.resolvers.rights[0])):M=s.resolvers.rights[0],t&&o({type:"consumeItem",payload:{uid:u.uid,targetId:u.uid,name:u.name}}),g({...M,success:!0})}else{let M;e?(M=s.notResolvers.wrongs.find(B=>B.uidObject===u.uid),M||(M=s.notResolvers.wrongs[0])):M=s.notResolvers.wrongs[0],g({...M,success:!1})}},[i,u,n,t,s,o,e]),R=G.useCallback(()=>{if(i.find(M=>M===(u==null?void 0:u.uid))){let M;n?M=[...s.resolvers.rights.find(F=>F.uidObject===(u==null?void 0:u.uid)).rewards.filter(F=>F.type==="var")]:M=[...s.resolvers.rights[0].rewards.filter(L=>L.type==="var")],t&&o({type:"consumeItem",payload:{uid:u==null?void 0:u.uid,targetId:u==null?void 0:u.uid,name:u==null?void 0:u.name}}),T({varsPoints:[...M],success:!0})}else{let M;e?M=[...s.notResolvers.wrongs.find(F=>F.uidObject===(u==null?void 0:u.uid)).rewards.filter(F=>F.type==="var")]:M=[...s.notResolvers.wrongs[0].rewards.filter(L=>L.type==="var")],T({varsPoints:[...M],success:!1})}},[t,o,s.notResolvers.wrongs,s.resolvers.rights,e,n,u==null?void 0:u.name,u==null?void 0:u.uid,i]),N=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:x==null?void 0:x.success,onFinish:()=>{x!=null&&x.success?o({type:"success"}):o({type:"closeScreen"})},payload:x!=null&&x.varsPoints?x==null?void 0:x.varsPoints:[]}),y(!1)},[o,x==null?void 0:x.success,x==null?void 0:x.varsPoints]);return G.useEffect(()=>{u?f?R():C():o({type:"closeScreen"})},[C,R,o,u,f]),G.useEffect(()=>{x&&(x!=null&&x.success?y(!0):o({type:"closeScreen"}))},[o,x]),S?P.jsx(hnt,{onPass:N}):_?P.jsx(fd,{text:_.desc,success:_.success,playSound:m,translate:A,keyboardControl:d,functionOnClose:E}):null}function Rz({item:u,viewMode:t}){var e,n;return P.jsxs(P.Fragment,{children:[t==="text"&&P.jsx("div",{className:"match-item-text",children:bi(u==null?void 0:u.content)}),t==="card"&&P.jsx("div",{className:"match-item-image",children:P.jsxs("figure",{children:[((e=u==null?void 0:u.img)==null?void 0:e.url)&&P.jsx("img",{src:(n=u==null?void 0:u.img)==null?void 0:n.url,alt:u==null?void 0:u.imgName}),(u==null?void 0:u.content)&&P.jsx("figcaption",{children:bi(u==null?void 0:u.content)})]})})]})}function qU({translate:u,onClose:t,buttonLabel:e}){return P.jsx("div",{className:"timer-dialog",children:P.jsxs("div",{className:"timer-dialog__container",children:[P.jsx("div",{className:"timer-dialog__title",children:u("storylines.misc.ready")}),P.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:t,children:P.jsx("span",{children:u(`${e}`)})})]})})}function QU({topRight:u=!1,initialSeconds:t=10,isPaused:e,shouldStart:n,shouldReset:i,onTimeOver:s}){const[o,l]=G.useState(t),[c,d]=G.useState(!1),f=G.useRef();G.useEffect(()=>{i&&(l(t),d(!1))},[i,t]),G.useEffect(()=>{e&&d(!1)},[e]),G.useEffect(()=>{n&&d(!0)},[n]),G.useEffect(()=>(c&&o>0?f.current=setInterval(()=>{l(_=>_-1),o===1&&s()},1e3):o===0&&(clearInterval(f.current),d(!1)),()=>clearInterval(f.current)),[c,s,o]);const m=_=>{const g=Math.floor(_/60),S=_%60,y=String(g).padStart(2,"0"),x=String(S).padStart(2,"0");return`${y}:${x}`};return P.jsx("div",{className:["count-down",o<10&&"count-down--finalseconds",u&&"count-down--top-right"].filter(Boolean).join(" "),children:P.jsx("div",{children:m(o)})})}function pnt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:s,nodeId:o,viewMode:l,title:c,sources:d,destinations:f,correctPairings:m,timer:_=0,keyboardControl:g,backgroundImage:S}){const y=kt=>e({type:"translate",payload:kt}),x=`match-puzzle_${o}`,[T,A]=G.useState([]),[E,C]=G.useState(null),[R,N]=G.useState(!1),[O,M]=G.useState(!1),[B,L]=G.useState(""),[F,I]=G.useState(!1),[H,W]=G.useState([]),[Z]=t;sy({soundActions:t});const X=kt=>{Z("click-ui");const ie=Je=>Je==null?void 0:Je.startsWith("source-item"),he=Je=>Je==null?void 0:Je.startsWith("destination-item");if(kt.id===E){C(null);return}const Lt=ie(kt.id),Xt=ie(E),te=he(kt.id),Ie=he(E);if(Lt&&Ie||te&&Xt){Q(kt);return}C(kt.id)},$=kt=>{let ie;return kt.startsWith("destination-item")?ie={[E]:kt}:ie={[kt]:E},m.some(he=>{const Lt=JSON.stringify(he),Xt=JSON.stringify(ie);return Lt===Xt})},nt=(kt,ie)=>{const he=new Map(kt.map(Lt=>[Lt.id,{...Lt}]));return ie.forEach(Lt=>{he.has(Lt.id)?he.get(Lt.id).points+=Lt.points:he.set(Lt.id,{...Lt})}),Array.from(he.values())},Q=kt=>{var ie,he;if(Z("click-ui"),$(kt.id)){const Lt=kt.id.startsWith("source-item")?kt.id:E,Xt=kt.id.startsWith("destination-item")?kt.id:E,te=[...T,{[Lt]:Xt}];if(A(te),i.specificCorrectFeedbacks){const Ie=i==null?void 0:i.correctFeedbacks.find(ee=>ee.id===`${Lt}-${Xt}`),Je=nt(H,Ie.rewards);W([...Je]),tt(te)&&(Ae(),I(!0)),Ie.desc&&(L(Ie==null?void 0:Ie.desc),M(!0),N(!0),Ae());const Gt=tt(te);!Ie.desc&&Gt&&rt(Je)}else if(tt(te)&&(Ae(),I(!0)),tt(te)){M(!0),n.solution.right.desc&&(Ae(),L(n.solution.right.desc)),N(!0),I(!0);const Je=nt(H,n.solution.right.rewards);W([...Je])}C(null)}else if(document.querySelector(`#${kt.id}`).classList.add("match-button--error"),document.querySelector(`#${E}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${kt.id}`).classList.remove("match-button--error"),document.querySelector(`#${E}`).classList.remove("match-button--error"),C(null)},1e3),i.specificWrongFeedbacks){const Lt=kt.id.startsWith("destination-item")?kt.id:E,Xt=i==null?void 0:i.wrongFeedbacks.find(Ie=>Ie.id===Lt),te=nt(H,Xt.rewards);W([...te]),Xt!=null&&Xt.desc&&(L(Xt.desc),M(!1),N(!0),Ae())}else{const Lt=nt(H,n.solution.wrong.rewards);W([...Lt]),(he=(ie=n.solution)==null?void 0:ie.wrong)!=null&&he.desc&&(L(n.solution.wrong.desc),N(!0),Ae())}},tt=kt=>{if(m.length!==kt.length)return!1;const ie=new Set(m.map(Lt=>JSON.stringify(Lt))),he=new Set(kt.map(Lt=>JSON.stringify(Lt)));for(const Lt of he)if(!ie.has(Lt))return!1;return!0},rt=G.useCallback(kt=>{Z("score");const ie=kt?[...kt]:[...H];u({type:"addPoints",complex:!0,finish:!0,payload:ie}),u({type:"passPuzzle"})},[H,u,Z]),ut=()=>{N(!1),M(!1),L(""),Et&&(Re(),it(!0)),!Et&&!F&&Ze(),F&&rt()},st=G.useMemo(()=>Object.assign({},...T),[T]),ot=(kt,ie)=>st[kt]===ie;G.useEffect(()=>{s(()=>{Z("score"),Ae(),M(!0),L(n.solution.right.desc);const kt=[...H,...n.resolve.rewards],ie=[...m];A(ie),setTimeout(()=>{M(!1),N(!1),u({type:"hidePuzzleButtons",payload:!1}),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:kt,finish:!0}})},5e3)})},[H,m,u,n.resolve.rewards,n.solution.right.desc,Z,x,s]);const ht=(kt,ie)=>T.findIndex(he=>{const Lt=Object.keys(he)[0],Xt=Object.values(he)[0];return Lt===kt&&Xt===ie}),[vt,it]=G.useState(!0),[lt,dt]=G.useState("storylines.misc.start"),[Et,_t]=G.useState(!1),pt=()=>{dt("storylines.misc.retry"),it(!1),_t(!1),Ze()},[bt,Tt]=G.useState(!1),[Ct,Ft]=G.useState(!1),[It,Jt]=G.useState(!1),ne=()=>{let kt=nt(H,n.timerFeedback.rewards);if(i.specificCorrectFeedbacks){const ie=new Map(kt.map(he=>[he.id,{...he}]));T.forEach(he=>{const Lt=Object.keys(he)[0],Xt=he[Lt],te=i.correctFeedbacks.find(Ie=>Ie.id===`${Lt}-${Xt}`);te!=null&&te.rewards&&te.rewards.forEach(Ie=>{if(ie.has(Ie.id)){const Je=ie.get(Ie.id);Je.points-=Ie.points,ie.set(Ie.id,Je)}})}),kt=Array.from(ie.values())}W(kt),A([]),_t(!0),L(n.timerFeedback.desc),N(!0),Z("fail")},Ae=()=>{Tt(!0),Ft(!1),Jt(!1)},Ze=()=>{Tt(!1),Ft(!0),Jt(!1)},Re=()=>{Tt(!1),Ft(!1),Jt(!0)},Ee=G.useCallback(()=>{const kt=document.querySelector('button[id^="source-item"]'),ie=document.querySelector('button[id^="destination-item"]'),he=kt.getBoundingClientRect().right,Xt=ie.getBoundingClientRect().left+6-he;d.items.forEach((te,Ie)=>{if(te.matchDestinationId!==void 0&&te.matchDestinationId!==null){const Je=document.querySelector(`#${te.id}`),Gt=document.querySelector(`#${te.matchDestinationId}`),ee=Je.getBoundingClientRect().top,pe=Gt.getBoundingClientRect().top,En=pe>ee,ue=Math.abs(pe-ee),me=Math.sqrt(Xt*Xt+ue*ue),Dn=Je.querySelector(".match-line__hipotenuse");Dn.style.setProperty("width",`${me}px`);const jn=Math.atan(ue/Xt),Ni=En?jn*(180/Math.PI):-jn*(180/Math.PI);Dn.style.setProperty("transform",`rotate(${Ni}deg)`)}})},[d.items]);G.useEffect(()=>(Ee(),window.addEventListener("resize",Ee),()=>{window.removeEventListener("resize",Ee)}),[Ee]);const xn=G.useMemo(()=>{let kt="";return kt="match ",S!=null&&S.url&&(kt+="match--with-custom-bg"),kt},[S==null?void 0:S.url]),hn={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:xn,style:hn,children:[(c||_>0)&&P.jsxs("header",{className:"match__header",children:[P.jsx("div",{}),c&&P.jsx("div",{className:"match__title","data-testid":"match__title",children:bi(c)}),_>0&&P.jsx(QU,{topRight:!0,initialSeconds:_,isPaused:bt,shouldStart:Ct,shouldReset:It,onTimeOver:ne})]}),P.jsx("div",{className:"match__columns",children:P.jsxs("div",{className:"match__columns-scroll scroll-shadow-container",children:[P.jsxs("div",{className:"match__column-wrap",children:[d.title&&P.jsx("div",{className:"match__subtitle",children:bi(d.title)}),P.jsx("div",{className:"match__column",children:d.items.map(kt=>P.jsxs("button",{id:kt.id,"data-testid":kt.id,className:["unset-button match-button",E===kt.id&&"match-button--marked",ot(kt.id,kt.matchDestinationId)&&"match-button--success",ht(kt.id,kt.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${ht(kt.id,kt.matchDestinationId)+1})`},disabled:ot(kt.id,kt.matchDestinationId),type:"button",onClick:()=>X(kt),children:[P.jsx(Rz,{item:kt,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"}),P.jsx("div",{className:"match-line__hipotenuse"})]},kt.id))})]}),P.jsxs("div",{className:"match__column-wrap",children:[f.title&&P.jsx("div",{className:"match__subtitle",children:bi(f.title)}),P.jsx("div",{className:"match__column",children:f.items.map(kt=>P.jsxs("button",{id:kt.id,"data-testid":kt.id,className:["unset-button match-button",E===kt.id&&"match-button--marked",ot(kt.matchSourceId,kt.id)&&"match-button--success",ht(kt.matchSourceId,kt.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${ht(kt.matchSourceId,kt.id)+1})`},disabled:ot(kt.matchSourceId,kt.id),type:"button",onClick:()=>X(kt),children:[P.jsx(Rz,{item:kt,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"})]},kt.id))})]})]})})]}),_>0&&vt&&P.jsx(qU,{buttonLabel:lt,translate:y,onClose:pt}),R&&P.jsx(fd,{success:O,text:B,translate:y,timeExpired:Et,functionOnClose:ut,keyboardControl:g,delay:3e3})]})}function mnt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:s,nodeId:o,destinationAreas:l,draggableItems:c,noDraggableItems:d,background:f,showDestinationAreas:m,timer:_,viewMode:g,keyboardControl:S}){var jn,Ni;const y=zt=>e({type:"translate",payload:zt}),x=`sort-puzzle_${o}`,[T,A]=G.useState(!1),[E,C]=G.useState(!1),[R,N]=G.useState(""),[O,M]=G.useState(!1),[B,L]=G.useState([]),[F]=t;sy({soundActions:t});const I=G.useRef({}),H=G.useRef({}),[W,Z]=G.useState(!0),[X,$]=G.useState("storylines.misc.start"),[nt,Q]=G.useState(!1),[tt,rt]=G.useState(!1),[ut,st]=G.useState(!1),[ot,ht]=G.useState(!1),vt=()=>{const zt=i.specificCorrectFeedbacks?[]:B,Qt=Ae(zt,n.timerFeedback.rewards);g==="matchMode"&&Tt.current.forEach(fe=>{fe.acceptedItems=[]}),L(Qt),Q(!0),Ee(n.timerFeedback.desc,!1),F("fail")},it=G.useCallback(()=>{rt(!0),st(!1),ht(!1)},[]),lt=()=>{rt(!1),st(!0),ht(!1)},dt=()=>{rt(!1),st(!1),ht(!0)},Et=()=>{$("storylines.misc.retry"),Z(!1),Q(!1),lt()},_t=(zt,Qt)=>{const fe=qt=>qt.current.flatMap(we=>{const ce=we.acceptedItems;return ce||[]}).sort(),_e=fe(zt),Pt=fe(Qt);return _e.length!==Pt.length?!1:_e.join(",")===Pt.join(",")},pt=G.useRef(0),bt=G.useRef([]),Tt=G.useRef([]);G.useEffect(()=>{g==="matchMode"&&!pt.current&&l.forEach(zt=>{pt.current+=1,bt.current.push({id:zt.id,acceptedItems:zt.acceptedItems}),Tt.current.push({id:zt.id,acceptedItems:[]})})},[l,g]);const Ct=G.useRef(null),Ft=G.useRef(null),It=G.useCallback(()=>{const zt=Ct.current.clientHeight,Qt=Ft.current.clientHeight;Ft.current.style.transform=`scale(${zt/Qt})`},[]);G.useEffect(()=>(It(),window.addEventListener("resize",It),()=>{window.removeEventListener("resize",It)}),[It]);const Jt=G.useRef([]),ne=G.useCallback(()=>{Jt.current=Object.values(H.current).filter(Boolean).map(zt=>{const Qt=zt.getBoundingClientRect();return{id:zt.id,top:Qt.top,left:Qt.left,right:Qt.right,bottom:Qt.bottom}})},[]);G.useEffect(()=>(ne(),window.addEventListener("resize",ne),()=>{window.removeEventListener("resize",ne)}),[ne]);const Ae=(zt,Qt)=>{const fe=new Map(zt.map(_e=>[_e.id,{..._e}]));return Qt.forEach(_e=>{fe.has(_e.id)?fe.get(_e.id).points+=_e.points:fe.set(_e.id,{..._e})}),Array.from(fe.values())},Ze=G.useCallback(zt=>{F("score");const Qt=zt?[...zt]:[...B];u({type:"addPoints",complex:!0,finish:!0,payload:Qt}),u({type:"passPuzzle"})},[B,u,F]),Re=G.useCallback(()=>{N(""),C(!1),A(!1),u({type:"hidePuzzleButtons",payload:!1})},[u]),Ee=G.useCallback((zt,Qt=!1)=>{zt&&N(zt),Qt&&C(!0),A(!0),u({type:"hidePuzzleButtons",payload:!0}),it()},[u,it]),xn=G.useCallback(()=>{n.solution.right.desc&&(it(),N(n.solution.right.desc));const zt=Ae(B,n.solution.right.rewards);L([...zt]),Ee(null,!0)},[B,n.solution.right.desc,n.solution.right.rewards,it,Ee]),hn=G.useCallback((zt,Qt)=>{const fe=i==null?void 0:i.correctFeedbacks.find(Pt=>Pt.id===zt.id),_e=Ae(B,fe.rewards);L([..._e]),fe.desc&&Ee(fe.desc,!0),!fe.desc&&Qt&&Ee(null,!0)},[B,Ee,i==null?void 0:i.correctFeedbacks]),kt=G.useCallback(()=>{var Qt;const zt=Ae(B,n.solution.wrong.rewards);L([...zt]),n.solution.wrong.desc&&Ee((Qt=n.solution.wrong)==null?void 0:Qt.desc,!1)},[B,n.solution.wrong.desc,n.solution.wrong.rewards,Ee]),ie=(zt,Qt)=>{setTimeout(()=>{Qt.classList.remove("sort-draggable-item--error"),Qt.classList.add("sort-draggable-item--resetting"),Qt.style.setProperty("transform",zt.transform),setTimeout(()=>Qt.classList.remove("sort-draggable-item--resetting"),1e3)},1e3)},he=zt=>{if(zt==="none")return{x:0,y:0};const fe=zt.replace("matrix(","").replace("matrix3d(","").replace(")","").split(", ");return fe.length===6?{x:parseFloat(fe[4]),y:parseFloat(fe[5])}:fe.length===16?{x:parseFloat(fe[12]),y:parseFloat(fe[13])}:{x:0,y:0}},Lt=G.useRef(),Xt=G.useRef(),te=G.useRef(),Ie=G.useRef(),Je=(zt,Qt)=>{Lt.current=Qt;const fe=zt.currentTarget;fe.classList.add("sort-draggable-item--dragging");const _e=zt.touches?zt.touches[0].clientX:zt.clientX,Pt=zt.touches?zt.touches[0].clientY:zt.clientY;Xt.current=_e,te.current=Pt;const qt=window.getComputedStyle(fe).getPropertyValue("transform");Ie.current=he(qt)},Gt=G.useCallback((zt,Qt)=>{if(Lt.current&&Lt.current===Qt){const fe=Ct.current.clientHeight/Ft.current.clientHeight,_e=I.current[Qt],Pt=_e.getBoundingClientRect(),Zt=_e.parentElement.getBoundingClientRect(),we=(zt.touches?zt.touches[0].clientX:zt.clientX)-Xt.current,ce=(zt.touches?zt.touches[0].clientY:zt.clientY)-te.current,fn=(Zt.width-Pt.width)/fe,Si=(Zt.height-Pt.height)/fe,$n=Math.min(Math.max(Ie.current.x+we/fe,0),fn),ir=Math.min(Math.max(Ie.current.y+ce/fe,0),Si);_e.style.transform=`translate(${$n}px, ${ir}px)`}},[]),ee=(zt,Qt)=>{const _e=I.current[zt].getBoundingClientRect(),Pt=Jt.current.find(Zt=>Zt.id===Qt&&!(_e.left>=Zt.right||_e.right<=Zt.left||_e.top>=Zt.bottom||_e.bottom<=Zt.top)),qt=Jt.current.find(Zt=>Zt.id!==Qt&&!(_e.left>=Zt.right||_e.right<=Zt.left||_e.top>=Zt.bottom||_e.bottom<=Zt.top));return Pt?"correctArea":qt?"incorrectArea":"neutral"},pe=G.useCallback(zt=>{if(Lt.current&&Lt.current===zt){F("click-ui");const Qt=I.current[zt],fe=c.find(_e=>zt===_e.id);if(Xt.current=null,te.current=null,Qt.classList.remove("sort-draggable-item--dragging"),Lt.current=null,g!=="resolveMode"){const _e=ee(zt,fe.destination.id);if(_e==="correctArea"){if(g==="anyItemResolver"){F("score"),it(),Qt.classList.add("sort-draggable-item--success");const Pt=!0;M(Pt),i.specificCorrectFeedbacks?hn(fe,Pt):xn()}if(g==="matchMode")if(F("score"),Qt.classList.add("sort-draggable-item--success"),Tt.current.find(qt=>qt.id===fe.destination.id).acceptedItems.push(fe.id),i.specificCorrectFeedbacks){const qt=_t(Tt,bt);qt&&M(!0),hn(fe,qt)}else _t(Tt,bt)&&(M(!0),xn())}else if(_e==="incorrectArea"&&(g==="anyItemResolver"||g==="matchMode")){if(F("fail"),Qt.classList.add("sort-draggable-item--error"),i.specificWrongFeedbacks){const Pt=i==null?void 0:i.wrongFeedbacks.find(Zt=>Zt.id===fe.id),qt=Ae(B,Pt.rewards);L([...qt]),Pt.desc&&Ee(Pt.desc,!1)}else kt();ie(fe,Qt)}}}},[B,c,xn,kt,hn,it,F,Ee,i.specificCorrectFeedbacks,i.specificWrongFeedbacks,i==null?void 0:i.wrongFeedbacks,g]),En=()=>{let zt=!1;it(),c.forEach(Qt=>{const fe=I.current[Qt.id];if(Qt.destination.id)ee(Qt.id,Qt.destination.id)!=="correctArea"?(zt=!0,fe.classList.add("sort-draggable-item--error"),ie(Qt,fe)):fe.classList.add("sort-draggable-item--success");else{const _e=fe.getBoundingClientRect();Jt.current.find(qt=>!(_e.left>=qt.right||_e.right<=qt.left||_e.top>=qt.bottom||_e.bottom<=qt.top))&&(zt=!0,fe.classList.add("sort-draggable-item--error"),ie(Qt,fe))}}),zt?(F("fail"),kt()):(F("score"),M(!0),xn())},ue=()=>{c.forEach(zt=>{const Qt=I.current[zt.id];Qt.classList.remove("sort-draggable-item--error"),Qt.classList.remove("sort-draggable-item--success"),Qt.classList.add("sort-draggable-item--resetting"),Qt.style.setProperty("transform",zt.transform),setTimeout(()=>Qt.classList.remove("sort-draggable-item--resetting"),1e3)})},me=()=>{Re(),nt&&(dt(),ue(),Z(!0)),!nt&&!O&<(),O&&Ze()};G.useEffect(()=>{s(()=>{F("score"),it(),C(!0),N(n.solution.right.desc);const zt=[...B,...n.resolve.rewards];Re(),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:zt,finish:!0}})})},[B,u,n.resolve.rewards,n.solution.right.desc,it,F,x,Re,s]),G.useEffect(()=>{if(!Ct.current||!Ft.current)return;const zt=fe=>Gt(fe,Lt.current),Qt=()=>pe(Lt.current);return document.addEventListener("mousemove",zt),document.addEventListener("mouseup",Qt),document.addEventListener("touchmove",zt,{passive:!1}),document.addEventListener("touchend",Qt),()=>{document.removeEventListener("mousemove",zt),document.removeEventListener("mouseup",Qt),document.removeEventListener("touchmove",zt),document.removeEventListener("touchend",Qt)}},[pe,Gt]);const Dn={backgroundImage:(jn=f==null?void 0:f.img)!=null&&jn.url?`url('${(Ni=f==null?void 0:f.img)==null?void 0:Ni.url}')`:""};return P.jsxs("div",{ref:Ct,className:"sort-wrapper",children:[P.jsxs("div",{ref:Ft,className:"sort-puzzle",style:Dn,children:[d.map(zt=>P.jsxs("div",{id:`${zt.id}`,className:"sort-no-draggable-item",style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`,"--backgroundColor":`${zt.backgroundColor}`,borderRadius:`${zt.borderRadius}`},children:[zt.imgId&&P.jsx("img",{src:zt.img.url,alt:zt.img.name}),zt.text&&bi(zt.text)]},zt.id)),l.map(zt=>P.jsx("div",{ref:Qt=>{H.current[zt.id]=Qt},id:zt.id,className:`sort-destination-area ${m?"sort-destination-area--revelable":""}`,style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`}},zt.id)),c.map(zt=>P.jsxs("div",{ref:Qt=>{I.current[zt.id]=Qt},id:`${zt.id}`,className:"sort-draggable-item",onMouseDown:Qt=>Je(Qt,zt.id),onTouchStart:Qt=>Je(Qt,zt.id),style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`,"--backgroundColor":`${zt.backgroundColor}`,borderRadius:`${zt.borderRadius}`},children:[zt.imgId&&P.jsx("img",{src:zt.img.url,alt:zt.img.name}),zt.text&&bi(zt.text)]},zt.id))]}),g==="resolveMode"&&P.jsx("button",{type:"button",onClick:()=>{En()},className:"gat--btn gat--btn__primary sort-resolve-button",children:P.jsx("span",{children:y("storylines.misc.check")})}),_>0&&W&&P.jsx(qU,{buttonLabel:X,translate:y,onClose:Et}),T&&P.jsx(fd,{success:E,text:R,translate:y,timeExpired:nt,functionOnClose:me,keyboardControl:S}),_>0&&P.jsx(QU,{topRight:!0,initialSeconds:_,isPaused:tt,shouldStart:ut,shouldReset:ot,onTimeOver:vt})]})}exports.AnimationComponent=ont;exports.AutoEvaluationComponent=Mtt;exports.CardsSelectorPuzzleComponent=ttt;exports.CartelComponent=hX;exports.ChainedImageClickPuzzleComponent=E$;exports.ChangeCamera=m9;exports.ComicComponent=cX;exports.ConversationalComponent=rX;exports.ConversationalProComponent=sX;exports.CrackerPuzzleComponent=f$;exports.DecisionComponent=D9;exports.DialogComponent=int;exports.DragItemPuzzleComponent=gtt;exports.DragToSceneComponent=fnt;exports.FrameImageClickComponent=R$;exports.HackerPuzzleComponent=vX;exports.HangedPuzzleComponent=S$;exports.ImageClickPuzzleComponent=n$;exports.ImageComponent=tX;exports.InventoryItem=MH;exports.KeyboardPuzzleComponent=bX;exports.LecturesComponent=GK;exports.LoginPuzzleComponent=_X;exports.MatchPuzzleComponent=pnt;exports.NoticeComponent=TH;exports.PatternComponent=Ntt;exports.PdfComponent=yY;exports.PdfVisor=v5;exports.ReferralComponent=dnt;exports.SortPuzzleComponent=mnt;exports.SurveyComponent=wtt;exports.TerminalPuzzleComponent=mtt;exports.TestComponent=xtt;exports.TextClickPuzzleComponent=Ltt;exports.UrlComponent=_Y;exports.VideoComponent=PY;exports.VideoVisor=y5;exports.WebBuilderPuzzleComponent=K$;exports.WriterPuzzleComponent=utt;
|
|
334
|
+
${y&&En()?"glowing-animation":""}`,"aria-label":Pe()?Ct("storylines.misc.rewind"):Ct("storylines.misc.forward"),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})})]})})]})}const ant=Va.ProgressManager.request("AssetLoader").cache,snt=new Va.AssetLoader(void 0,ant);function rnt({animation:u,loopTimes:t,onAnimationFinish:e,onAnimationSave:n,resource:i,makeDefault:s}){const[o,l]=G.useState(!1),c=$h.useThree(f=>f.scene),d=G.useRef(0);return G.useEffect(()=>{l(!1)},[i.uid,u==null?void 0:u.url]),G.useEffect(()=>{if(!o){const f=c.getObjectByProperty("uid",i.uid);if(f&&u&&u.url&&f.skeletonId===(u==null?void 0:u.skeletonId))if(s)n({uid:i.uid,animation:u==null?void 0:u.id,index:f.index}),e();else{const m=f.animator;m||console.error("[Animation]: Current Object ",i.uid," does not have an animator.");const _=()=>{const g=m==null?void 0:m.getAction(u.url);g.setLoop(Oa.LoopRepeat,1/0),g.reset();function S(){d.current+=1,d.current>=t&&y()}function y(){m.mix("idle"),e(),m.removeEventListener("loop",S)}m.mix(u==null?void 0:u.url).then(x=>{x&&(d.current=1,d.current>=t?y():m.addEventListener("loop",S))}),l(!0)};m!=null&&m.getAction(u==null?void 0:u.url)?(m.setTime(0),_()):snt.load(u==null?void 0:u.url,g=>{m.register(u==null?void 0:u.url,g.animations[0]),m.setTime(0),_()},void 0,g=>{console.error(`Asset loader failed with: ${u.url}`,g),e()})}else e()}},[c,u==null?void 0:u.url,t,o,i.uid,s,u,i,e,n]),null}function ont({animations:u=[],enableInteraction:t,emitEvent:e}){const n=u.length,i=G.useRef(0),s=()=>{i.current+=1,i.current>=n&&t&&e({type:"success"})},o=l=>{e({type:"saveAnimation",payload:l})};return G.useEffect(()=>{i.current=0},[u]),G.useEffect(()=>{t||e({type:"success"})},[e,t]),u.map(({animation:l,...c},d)=>{var f;return P.jsx(rnt,{animation:l,...c,onAnimationFinish:s,onAnimationSave:o},(l==null?void 0:l.id)||((f=c.resource)==null?void 0:f.uid)||d)})}function lnt({text:u,error:t,handleClick:e}){return P.jsxs("div",{"data-testid":`${t?" pill--error":"pill--ok"}`,className:`email-pill ${t?" email-pill--error":""}`,children:[P.jsx("div",{children:u}),P.jsx("div",{className:"email-pill__delete",children:P.jsx("button",{type:"button",onClick:e,className:"icon-close unset-button","aria-label":"icon click"})})]})}function unt({handleContinue:u,handleCancel:t,translate:e,text:n}){const[i,s]=G.useState([]),[o,l]=G.useState(0),[c,d]=G.useState(0),f=G.useRef(null),m=(y,x,T)=>{y.stopPropagation(),s(i.filter(A=>A!==i[T])),x.error&&l(o-1),x.isRepeat&&d(c-1)},_=()=>{f.current&&f.current.focus()},g=()=>{[" ",",",";","."].includes(f.current.value)&&(f.current.value="")},S=y=>{const x=f.current.value,T=["Space","Comma","Period","Enter"],A=["Space","Comma","Enter","Tab"];x===""&&(T.includes(y.code)||y.keyCode==="186"||y.key==="Enter"||y.key===" ")?y.preventDefault():f.current.value.length>1&&(A.includes(y.code)||y.type==="blur")&&(y.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(x)?i.find(C=>C.text===x)?(d(c+1),s([...i,{text:x,error:!0,isRepeat:!0}])):s([...i,{text:x}]):(s([...i,{text:x,error:!0}]),l(o+1)),f.current.value="")};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",children:[P.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep1")}),P.jsx("div",{className:"referrals-piece__subtitle",children:n}),P.jsxs("div",{className:"referrals-piece__form",children:[P.jsxs("div",{className:"referrals-piece__instructions",children:[P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.instructions")}),P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.limit")})]}),P.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:_,"aria-labelledby":"list of emails",children:P.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[i&&i.map((y,x)=>P.jsx(lnt,{text:y.text,error:y.error,handleClick:T=>m(T,y,x),emailPillIndex:x},`${i.indexOf(y)}`)),i.length<=9?P.jsxs(P.Fragment,{children:[P.jsx("input",{id:"email",ref:f,className:"referrals-piece__inputemail",onChange:g,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),P.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:P.jsx("span",{children:e("puzzles.referrals.inviter.skipButton")})})]}):null]})}),P.jsxs("div",{dir:Pe()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[P.jsxs("div",{className:"referrals-piece__errormessage",children:[P.jsx("div",{children:c>0?e("puzzles.referrals.inviter.errorEmailRepeat"):null}),P.jsx("div",{children:o>0?e("puzzles.referrals.inviter.errorMessage"):null})]}),P.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[i.length,"/10"]})]})]})]}),P.jsxs("div",{className:"referrals-piece__buttons",children:[P.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:t,children:e("puzzles.referrals.inviter.skipButton")}),P.jsx("button",{className:`gat--btn gat--btn__primary ${c>0||o>0||i.length===0?" disabled":""}`,type:"button",disabled:o>0||i.length===0,onClick:()=>u(i),children:e("puzzles.referrals.inviter.inviteButton")})]})]})}function cnt({handleFinish:u,translate:t,valid:e,invalid:n}){const[i,s]=G.useState(!1),o=()=>{s(!i)},l=e.current===1?"invitationSend":"invitationsSend",c=n===1?"invitationNotSend":"invitationsNotSend";return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[P.jsx("div",{className:"referrals-piece__title",children:t("puzzles.referrals.inviter.titleStep2")}),P.jsxs("ul",{className:"referrals-piece__feedback",children:[e.current!==0&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),P.jsxs("div",{children:[P.jsx("strong",{children:e.current})," ",t(`puzzles.referrals.inviter.${l}`)]})]}),!!n.current&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),P.jsxs("div",{children:[P.jsx("strong",{children:n.current})," ",t(`puzzles.referrals.inviter.${c}`)]}),P.jsx("button",{className:"un-button",type:"button",onClick:o,children:t("puzzles.referrals.inviter.whyFail")})]})]}),i?P.jsxs("ul",{className:"referrals-piece__failsreasons",children:[P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons1")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons2")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons3")})]}):null]}),P.jsx("div",{className:"referrals-piece__buttons",children:P.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:u,children:t("puzzles.referrals.inviter.continueButton")})})]})}function dnt({emitEvent:u,getEvent:t,text:e,rewards:n,referrals:i}){const s=g=>t({type:"translate",payload:g}),[o,l]=G.useState("step1"),c=G.useRef(0),d=G.useRef(0),f=async g=>{const S=g.map(x=>x.text),y=await u({type:"sendReferrals",payload:S});c.current=y&&y.data?y.data.valid.length:0,d.current=S.length-c.current,l("step2")};if(!i)return u({type:"success"}),null;const m=()=>{u({type:"success"})},_=()=>{if(c.current){const g=n.map(S=>(S.points*=c.current,S));u({type:"addPoints",complex:!0,finish:!0,payload:g})}else u({type:"success"})};return P.jsx("div",{className:"referrals-piece",children:P.jsxs("div",{className:"referrals-piece__center",children:[o==="step1"&&P.jsx(unt,{translate:s,handleContinue:f,handleCancel:m,text:e}),o==="step2"&&P.jsx(cnt,{translate:s,handleFinish:_,valid:c,invalid:d})]})})}function hnt({onPass:u}){return G.useEffect(()=>{const t=setTimeout(u,0);return()=>clearTimeout(t)},[u]),null}function fnt({itemResolver:u,consume:t,hasComplexNotResolvers:e,hasComplexResolvers:n,resolverObjects:i,feedback:s,emitEvent:o,getEvent:l,soundActions:c,keyboardControl:d,noEvaluation:f}){const[m]=c,[_,g]=G.useState(!1),[S,y]=G.useState(!1),[x,T]=G.useState(!1),A=O=>l({type:"translate",payload:O}),E=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:_.success,onFinish:()=>{_.success?o({type:"success"}):o({type:"closeScreen"})},payload:_.rewards})},[o,_]),C=G.useCallback(()=>{if(i.find(M=>M===u.uid)){let M;n?(M=s.resolvers.rights.find(B=>B.uidObject===u.uid),M||(M=s.resolvers.rights[0])):M=s.resolvers.rights[0],t&&o({type:"consumeItem",payload:{uid:u.uid,targetId:u.uid,name:u.name}}),g({...M,success:!0})}else{let M;e?(M=s.notResolvers.wrongs.find(B=>B.uidObject===u.uid),M||(M=s.notResolvers.wrongs[0])):M=s.notResolvers.wrongs[0],g({...M,success:!1})}},[i,u,n,t,s,o,e]),R=G.useCallback(()=>{if(i.find(M=>M===(u==null?void 0:u.uid))){let M;n?M=[...s.resolvers.rights.find(F=>F.uidObject===(u==null?void 0:u.uid)).rewards.filter(F=>F.type==="var")]:M=[...s.resolvers.rights[0].rewards.filter(L=>L.type==="var")],t&&o({type:"consumeItem",payload:{uid:u==null?void 0:u.uid,targetId:u==null?void 0:u.uid,name:u==null?void 0:u.name}}),T({varsPoints:[...M],success:!0})}else{let M;e?M=[...s.notResolvers.wrongs.find(F=>F.uidObject===(u==null?void 0:u.uid)).rewards.filter(F=>F.type==="var")]:M=[...s.notResolvers.wrongs[0].rewards.filter(L=>L.type==="var")],T({varsPoints:[...M],success:!1})}},[t,o,s.notResolvers.wrongs,s.resolvers.rights,e,n,u==null?void 0:u.name,u==null?void 0:u.uid,i]),N=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:x==null?void 0:x.success,onFinish:()=>{x!=null&&x.success?o({type:"success"}):o({type:"closeScreen"})},payload:x!=null&&x.varsPoints?x==null?void 0:x.varsPoints:[]}),y(!1)},[o,x==null?void 0:x.success,x==null?void 0:x.varsPoints]);return G.useEffect(()=>{u?f?R():C():o({type:"closeScreen"})},[C,R,o,u,f]),G.useEffect(()=>{x&&(x!=null&&x.success?y(!0):o({type:"closeScreen"}))},[o,x]),S?P.jsx(hnt,{onPass:N}):_?P.jsx(fd,{text:_.desc,success:_.success,playSound:m,translate:A,keyboardControl:d,functionOnClose:E}):null}function Rz({item:u,viewMode:t}){var e,n;return P.jsxs(P.Fragment,{children:[t==="text"&&P.jsx("div",{className:"match-item-text",children:bi(u==null?void 0:u.content)}),t==="card"&&P.jsx("div",{className:"match-item-image",children:P.jsxs("figure",{children:[((e=u==null?void 0:u.img)==null?void 0:e.url)&&P.jsx("img",{src:(n=u==null?void 0:u.img)==null?void 0:n.url,alt:u==null?void 0:u.imgName}),(u==null?void 0:u.content)&&P.jsx("figcaption",{children:bi(u==null?void 0:u.content)})]})})]})}function qU({translate:u,onClose:t,buttonLabel:e}){return P.jsx("div",{className:"timer-dialog",children:P.jsxs("div",{className:"timer-dialog__container",children:[P.jsx("div",{className:"timer-dialog__title",children:u("storylines.misc.ready")}),P.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:t,children:P.jsx("span",{children:u(`${e}`)})})]})})}function QU({topRight:u=!1,initialSeconds:t=10,isPaused:e,shouldStart:n,shouldReset:i,onTimeOver:s}){const[o,l]=G.useState(t),[c,d]=G.useState(!1),f=G.useRef();G.useEffect(()=>{i&&(l(t),d(!1))},[i,t]),G.useEffect(()=>{e&&d(!1)},[e]),G.useEffect(()=>{n&&d(!0)},[n]),G.useEffect(()=>(c&&o>0?f.current=setInterval(()=>{l(_=>_-1),o===1&&s()},1e3):o===0&&(clearInterval(f.current),d(!1)),()=>clearInterval(f.current)),[c,s,o]);const m=_=>{const g=Math.floor(_/60),S=_%60,y=String(g).padStart(2,"0"),x=String(S).padStart(2,"0");return`${y}:${x}`};return P.jsx("div",{className:["count-down",o<10&&"count-down--finalseconds",u&&"count-down--top-right"].filter(Boolean).join(" "),children:P.jsx("div",{children:m(o)})})}function pnt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:s,nodeId:o,viewMode:l,title:c,sources:d,destinations:f,correctPairings:m,timer:_=0,keyboardControl:g,backgroundImage:S}){const y=kt=>e({type:"translate",payload:kt}),x=`match-puzzle_${o}`,[T,A]=G.useState([]),[E,C]=G.useState(null),[R,N]=G.useState(!1),[O,M]=G.useState(!1),[B,L]=G.useState(""),[F,I]=G.useState(!1),[H,W]=G.useState([]),[Z]=t;sy({soundActions:t});const X=kt=>{Z("click-ui");const ie=Je=>Je==null?void 0:Je.startsWith("source-item"),he=Je=>Je==null?void 0:Je.startsWith("destination-item");if(kt.id===E){C(null);return}const Lt=ie(kt.id),Xt=ie(E),te=he(kt.id),Ie=he(E);if(Lt&&Ie||te&&Xt){Q(kt);return}C(kt.id)},$=kt=>{let ie;return kt.startsWith("destination-item")?ie={[E]:kt}:ie={[kt]:E},m.some(he=>{const Lt=JSON.stringify(he),Xt=JSON.stringify(ie);return Lt===Xt})},nt=(kt,ie)=>{const he=new Map(kt.map(Lt=>[Lt.id,{...Lt}]));return ie.forEach(Lt=>{he.has(Lt.id)?he.get(Lt.id).points+=Lt.points:he.set(Lt.id,{...Lt})}),Array.from(he.values())},Q=kt=>{var ie,he;if(Z("click-ui"),$(kt.id)){const Lt=kt.id.startsWith("source-item")?kt.id:E,Xt=kt.id.startsWith("destination-item")?kt.id:E,te=[...T,{[Lt]:Xt}];if(A(te),i.specificCorrectFeedbacks){const Ie=i==null?void 0:i.correctFeedbacks.find(ee=>ee.id===`${Lt}-${Xt}`),Je=nt(H,Ie.rewards);W([...Je]),tt(te)&&(Ae(),I(!0)),Ie.desc&&(L(Ie==null?void 0:Ie.desc),M(!0),N(!0),Ae());const Gt=tt(te);!Ie.desc&&Gt&&rt(Je)}else if(tt(te)&&(Ae(),I(!0)),tt(te)){M(!0),n.solution.right.desc&&(Ae(),L(n.solution.right.desc)),N(!0),I(!0);const Je=nt(H,n.solution.right.rewards);W([...Je])}C(null)}else if(document.querySelector(`#${kt.id}`).classList.add("match-button--error"),document.querySelector(`#${E}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${kt.id}`).classList.remove("match-button--error"),document.querySelector(`#${E}`).classList.remove("match-button--error"),C(null)},1e3),i.specificWrongFeedbacks){const Lt=kt.id.startsWith("destination-item")?kt.id:E,Xt=i==null?void 0:i.wrongFeedbacks.find(Ie=>Ie.id===Lt),te=nt(H,Xt.rewards);W([...te]),Xt!=null&&Xt.desc&&(L(Xt.desc),M(!1),N(!0),Ae())}else{const Lt=nt(H,n.solution.wrong.rewards);W([...Lt]),(he=(ie=n.solution)==null?void 0:ie.wrong)!=null&&he.desc&&(L(n.solution.wrong.desc),N(!0),Ae())}},tt=kt=>{if(m.length!==kt.length)return!1;const ie=new Set(m.map(Lt=>JSON.stringify(Lt))),he=new Set(kt.map(Lt=>JSON.stringify(Lt)));for(const Lt of he)if(!ie.has(Lt))return!1;return!0},rt=G.useCallback(kt=>{Z("score");const ie=kt?[...kt]:[...H];u({type:"addPoints",complex:!0,finish:!0,payload:ie}),u({type:"passPuzzle"})},[H,u,Z]),ut=()=>{N(!1),M(!1),L(""),Et&&(Re(),it(!0)),!Et&&!F&&Ze(),F&&rt()},st=G.useMemo(()=>Object.assign({},...T),[T]),ot=(kt,ie)=>st[kt]===ie;G.useEffect(()=>{s(()=>{Z("score"),Ae(),M(!0),L(n.solution.right.desc);const kt=[...H,...n.resolve.rewards],ie=[...m];A(ie),setTimeout(()=>{M(!1),N(!1),u({type:"hidePuzzleButtons",payload:!1}),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:kt,finish:!0}})},5e3)})},[H,m,u,n.resolve.rewards,n.solution.right.desc,Z,x,s]);const ht=(kt,ie)=>T.findIndex(he=>{const Lt=Object.keys(he)[0],Xt=Object.values(he)[0];return Lt===kt&&Xt===ie}),[vt,it]=G.useState(!0),[lt,dt]=G.useState("storylines.misc.start"),[Et,_t]=G.useState(!1),pt=()=>{dt("storylines.misc.retry"),it(!1),_t(!1),Ze()},[bt,Tt]=G.useState(!1),[Ct,Ft]=G.useState(!1),[It,Jt]=G.useState(!1),ne=()=>{let kt=nt(H,n.timerFeedback.rewards);if(i.specificCorrectFeedbacks){const ie=new Map(kt.map(he=>[he.id,{...he}]));T.forEach(he=>{const Lt=Object.keys(he)[0],Xt=he[Lt],te=i.correctFeedbacks.find(Ie=>Ie.id===`${Lt}-${Xt}`);te!=null&&te.rewards&&te.rewards.forEach(Ie=>{if(ie.has(Ie.id)){const Je=ie.get(Ie.id);Je.points-=Ie.points,ie.set(Ie.id,Je)}})}),kt=Array.from(ie.values())}W(kt),A([]),_t(!0),L(n.timerFeedback.desc),N(!0),Z("fail")},Ae=()=>{Tt(!0),Ft(!1),Jt(!1)},Ze=()=>{Tt(!1),Ft(!0),Jt(!1)},Re=()=>{Tt(!1),Ft(!1),Jt(!0)},Ee=G.useCallback(()=>{const kt=document.querySelector('button[id^="source-item"]'),ie=document.querySelector('button[id^="destination-item"]'),he=kt.getBoundingClientRect().right,Xt=ie.getBoundingClientRect().left+6-he;d.items.forEach((te,Ie)=>{if(te.matchDestinationId!==void 0&&te.matchDestinationId!==null){const Je=document.querySelector(`#${te.id}`),Gt=document.querySelector(`#${te.matchDestinationId}`),ee=Je.getBoundingClientRect().top,pe=Gt.getBoundingClientRect().top,En=pe>ee,ue=Math.abs(pe-ee),me=Math.sqrt(Xt*Xt+ue*ue),Dn=Je.querySelector(".match-line__hipotenuse");Dn.style.setProperty("width",`${me}px`);const jn=Math.atan(ue/Xt),Ni=En?jn*(180/Math.PI):-jn*(180/Math.PI);Dn.style.setProperty("transform",`rotate(${Ni}deg)`)}})},[d.items]);G.useEffect(()=>(Ee(),window.addEventListener("resize",Ee),()=>{window.removeEventListener("resize",Ee)}),[Ee]);const xn=G.useMemo(()=>{let kt="";return kt="match ",S!=null&&S.url&&(kt+="match--with-custom-bg"),kt},[S==null?void 0:S.url]),hn={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:xn,style:hn,children:[(c||_>0)&&P.jsxs("header",{className:"match__header",children:[P.jsx("div",{}),c&&P.jsx("div",{className:"match__title","data-testid":"match__title",children:bi(c)}),_>0&&P.jsx(QU,{topRight:!0,initialSeconds:_,isPaused:bt,shouldStart:Ct,shouldReset:It,onTimeOver:ne})]}),P.jsx("div",{className:"match__columns",children:P.jsxs("div",{className:"match__columns-scroll scroll-shadow-container",children:[P.jsxs("div",{className:"match__column-wrap",children:[d.title&&P.jsx("div",{className:"match__subtitle",children:bi(d.title)}),P.jsx("div",{className:"match__column",children:d.items.map(kt=>P.jsxs("button",{id:kt.id,"data-testid":kt.id,className:["unset-button match-button",E===kt.id&&"match-button--marked",ot(kt.id,kt.matchDestinationId)&&"match-button--success",ht(kt.id,kt.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${ht(kt.id,kt.matchDestinationId)+1})`},disabled:ot(kt.id,kt.matchDestinationId),type:"button",onClick:()=>X(kt),children:[P.jsx(Rz,{item:kt,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"}),P.jsx("div",{className:"match-line__hipotenuse"})]},kt.id))})]}),P.jsxs("div",{className:"match__column-wrap",children:[f.title&&P.jsx("div",{className:"match__subtitle",children:bi(f.title)}),P.jsx("div",{className:"match__column",children:f.items.map(kt=>P.jsxs("button",{id:kt.id,"data-testid":kt.id,className:["unset-button match-button",E===kt.id&&"match-button--marked",ot(kt.matchSourceId,kt.id)&&"match-button--success",ht(kt.matchSourceId,kt.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${ht(kt.matchSourceId,kt.id)+1})`},disabled:ot(kt.matchSourceId,kt.id),type:"button",onClick:()=>X(kt),children:[P.jsx(Rz,{item:kt,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"})]},kt.id))})]})]})})]}),_>0&&vt&&P.jsx(qU,{buttonLabel:lt,translate:y,onClose:pt}),R&&P.jsx(fd,{success:O,text:B,translate:y,timeExpired:Et,functionOnClose:ut,keyboardControl:g,delay:3e3})]})}function mnt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:s,nodeId:o,destinationAreas:l,draggableItems:c,noDraggableItems:d,background:f,showDestinationAreas:m,timer:_,viewMode:g,keyboardControl:S}){var jn,Ni;const y=zt=>e({type:"translate",payload:zt}),x=`sort-puzzle_${o}`,[T,A]=G.useState(!1),[E,C]=G.useState(!1),[R,N]=G.useState(""),[O,M]=G.useState(!1),[B,L]=G.useState([]),[F]=t;sy({soundActions:t});const I=G.useRef({}),H=G.useRef({}),[W,Z]=G.useState(!0),[X,$]=G.useState("storylines.misc.start"),[nt,Q]=G.useState(!1),[tt,rt]=G.useState(!1),[ut,st]=G.useState(!1),[ot,ht]=G.useState(!1),vt=()=>{const zt=i.specificCorrectFeedbacks?[]:B,Qt=Ae(zt,n.timerFeedback.rewards);g==="matchMode"&&Tt.current.forEach(fe=>{fe.acceptedItems=[]}),L(Qt),Q(!0),Ee(n.timerFeedback.desc,!1),F("fail")},it=G.useCallback(()=>{rt(!0),st(!1),ht(!1)},[]),lt=()=>{rt(!1),st(!0),ht(!1)},dt=()=>{rt(!1),st(!1),ht(!0)},Et=()=>{$("storylines.misc.retry"),Z(!1),Q(!1),lt()},_t=(zt,Qt)=>{const fe=qt=>qt.current.flatMap(we=>{const ce=we.acceptedItems;return ce||[]}).sort(),_e=fe(zt),Pt=fe(Qt);return _e.length!==Pt.length?!1:_e.join(",")===Pt.join(",")},pt=G.useRef(0),bt=G.useRef([]),Tt=G.useRef([]);G.useEffect(()=>{g==="matchMode"&&!pt.current&&l.forEach(zt=>{pt.current+=1,bt.current.push({id:zt.id,acceptedItems:zt.acceptedItems}),Tt.current.push({id:zt.id,acceptedItems:[]})})},[l,g]);const Ct=G.useRef(null),Ft=G.useRef(null),It=G.useCallback(()=>{const zt=Ct.current.clientHeight,Qt=Ft.current.clientHeight;Ft.current.style.transform=`scale(${zt/Qt})`},[]);G.useEffect(()=>(It(),window.addEventListener("resize",It),()=>{window.removeEventListener("resize",It)}),[It]);const Jt=G.useRef([]),ne=G.useCallback(()=>{Jt.current=Object.values(H.current).filter(Boolean).map(zt=>{const Qt=zt.getBoundingClientRect();return{id:zt.id,top:Qt.top,left:Qt.left,right:Qt.right,bottom:Qt.bottom}})},[]);G.useEffect(()=>(ne(),window.addEventListener("resize",ne),()=>{window.removeEventListener("resize",ne)}),[ne]);const Ae=(zt,Qt)=>{const fe=new Map(zt.map(_e=>[_e.id,{..._e}]));return Qt.forEach(_e=>{fe.has(_e.id)?fe.get(_e.id).points+=_e.points:fe.set(_e.id,{..._e})}),Array.from(fe.values())},Ze=G.useCallback(zt=>{F("score");const Qt=zt?[...zt]:[...B];u({type:"addPoints",complex:!0,finish:!0,payload:Qt}),u({type:"passPuzzle"})},[B,u,F]),Re=G.useCallback(()=>{N(""),C(!1),A(!1),u({type:"hidePuzzleButtons",payload:!1})},[u]),Ee=G.useCallback((zt,Qt=!1)=>{zt&&N(zt),Qt&&C(!0),A(!0),u({type:"hidePuzzleButtons",payload:!0}),it()},[u,it]),xn=G.useCallback(()=>{n.solution.right.desc&&(it(),N(n.solution.right.desc));const zt=Ae(B,n.solution.right.rewards);L([...zt]),Ee(null,!0)},[B,n.solution.right.desc,n.solution.right.rewards,it,Ee]),hn=G.useCallback((zt,Qt)=>{const fe=i==null?void 0:i.correctFeedbacks.find(Pt=>Pt.id===zt.id),_e=Ae(B,fe.rewards);L([..._e]),fe.desc&&Ee(fe.desc,!0),!fe.desc&&Qt&&Ee(null,!0)},[B,Ee,i==null?void 0:i.correctFeedbacks]),kt=G.useCallback(()=>{var Qt;const zt=Ae(B,n.solution.wrong.rewards);L([...zt]),n.solution.wrong.desc&&Ee((Qt=n.solution.wrong)==null?void 0:Qt.desc,!1)},[B,n.solution.wrong.desc,n.solution.wrong.rewards,Ee]),ie=(zt,Qt)=>{setTimeout(()=>{Qt.classList.remove("sort-draggable-item--error"),Qt.classList.add("sort-draggable-item--resetting"),Qt.style.setProperty("transform",zt.transform),setTimeout(()=>Qt.classList.remove("sort-draggable-item--resetting"),1e3)},1e3)},he=zt=>{if(zt==="none")return{x:0,y:0};const fe=zt.replace("matrix(","").replace("matrix3d(","").replace(")","").split(", ");return fe.length===6?{x:parseFloat(fe[4]),y:parseFloat(fe[5])}:fe.length===16?{x:parseFloat(fe[12]),y:parseFloat(fe[13])}:{x:0,y:0}},Lt=G.useRef(),Xt=G.useRef(),te=G.useRef(),Ie=G.useRef(),Je=(zt,Qt)=>{Lt.current=Qt;const fe=zt.currentTarget;fe.classList.add("sort-draggable-item--dragging");const _e=zt.touches?zt.touches[0].clientX:zt.clientX,Pt=zt.touches?zt.touches[0].clientY:zt.clientY;Xt.current=_e,te.current=Pt;const qt=window.getComputedStyle(fe).getPropertyValue("transform");Ie.current=he(qt)},Gt=G.useCallback((zt,Qt)=>{if(Lt.current&&Lt.current===Qt){const fe=Ct.current.clientHeight/Ft.current.clientHeight,_e=I.current[Qt],Pt=_e.getBoundingClientRect(),Zt=_e.parentElement.getBoundingClientRect(),we=(zt.touches?zt.touches[0].clientX:zt.clientX)-Xt.current,ce=(zt.touches?zt.touches[0].clientY:zt.clientY)-te.current,fn=(Zt.width-Pt.width)/fe,Si=(Zt.height-Pt.height)/fe,$n=Math.min(Math.max(Ie.current.x+we/fe,0),fn),ir=Math.min(Math.max(Ie.current.y+ce/fe,0),Si);_e.style.transform=`translate(${$n}px, ${ir}px)`}},[]),ee=(zt,Qt)=>{const _e=I.current[zt].getBoundingClientRect(),Pt=Jt.current.find(Zt=>Zt.id===Qt&&!(_e.left>=Zt.right||_e.right<=Zt.left||_e.top>=Zt.bottom||_e.bottom<=Zt.top)),qt=Jt.current.find(Zt=>Zt.id!==Qt&&!(_e.left>=Zt.right||_e.right<=Zt.left||_e.top>=Zt.bottom||_e.bottom<=Zt.top));return Pt?"correctArea":qt?"incorrectArea":"neutral"},pe=G.useCallback(zt=>{if(Lt.current&&Lt.current===zt){F("click-ui");const Qt=I.current[zt],fe=c.find(_e=>zt===_e.id);if(Xt.current=null,te.current=null,Qt.classList.remove("sort-draggable-item--dragging"),Lt.current=null,g!=="resolveMode"){const _e=ee(zt,fe.destination.id);if(_e==="correctArea"){if(g==="anyItemResolver"){F("score"),it(),Qt.classList.add("sort-draggable-item--success");const Pt=!0;M(Pt),i.specificCorrectFeedbacks?hn(fe,Pt):xn()}if(g==="matchMode")if(F("score"),Qt.classList.add("sort-draggable-item--success"),Tt.current.find(qt=>qt.id===fe.destination.id).acceptedItems.push(fe.id),i.specificCorrectFeedbacks){const qt=_t(Tt,bt);qt&&M(!0),hn(fe,qt)}else _t(Tt,bt)&&(M(!0),xn())}else if(_e==="incorrectArea"&&(g==="anyItemResolver"||g==="matchMode")){if(F("fail"),Qt.classList.add("sort-draggable-item--error"),i.specificWrongFeedbacks){const Pt=i==null?void 0:i.wrongFeedbacks.find(Zt=>Zt.id===fe.id),qt=Ae(B,Pt.rewards);L([...qt]),Pt.desc&&Ee(Pt.desc,!1)}else kt();ie(fe,Qt)}}}},[B,c,xn,kt,hn,it,F,Ee,i.specificCorrectFeedbacks,i.specificWrongFeedbacks,i==null?void 0:i.wrongFeedbacks,g]),En=()=>{let zt=!1;it(),c.forEach(Qt=>{const fe=I.current[Qt.id];if(Qt.destination.id)ee(Qt.id,Qt.destination.id)!=="correctArea"?(zt=!0,fe.classList.add("sort-draggable-item--error"),ie(Qt,fe)):fe.classList.add("sort-draggable-item--success");else{const _e=fe.getBoundingClientRect();Jt.current.find(qt=>!(_e.left>=qt.right||_e.right<=qt.left||_e.top>=qt.bottom||_e.bottom<=qt.top))&&(zt=!0,fe.classList.add("sort-draggable-item--error"),ie(Qt,fe))}}),zt?(F("fail"),kt()):(F("score"),M(!0),xn())},ue=()=>{c.forEach(zt=>{const Qt=I.current[zt.id];Qt.classList.remove("sort-draggable-item--error"),Qt.classList.remove("sort-draggable-item--success"),Qt.classList.add("sort-draggable-item--resetting"),Qt.style.setProperty("transform",zt.transform),setTimeout(()=>Qt.classList.remove("sort-draggable-item--resetting"),1e3)})},me=()=>{Re(),nt&&(dt(),ue(),Z(!0)),!nt&&!O&<(),O&&Ze()};G.useEffect(()=>{s(()=>{F("score"),it(),C(!0),N(n.solution.right.desc);const zt=[...B,...n.resolve.rewards];Re(),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:zt,finish:!0}})})},[B,u,n.resolve.rewards,n.solution.right.desc,it,F,x,Re,s]),G.useEffect(()=>{if(!Ct.current||!Ft.current)return;const zt=fe=>Gt(fe,Lt.current),Qt=()=>pe(Lt.current);return document.addEventListener("mousemove",zt),document.addEventListener("mouseup",Qt),document.addEventListener("touchmove",zt,{passive:!1}),document.addEventListener("touchend",Qt),()=>{document.removeEventListener("mousemove",zt),document.removeEventListener("mouseup",Qt),document.removeEventListener("touchmove",zt),document.removeEventListener("touchend",Qt)}},[pe,Gt]);const Dn={backgroundImage:(jn=f==null?void 0:f.img)!=null&&jn.url?`url('${(Ni=f==null?void 0:f.img)==null?void 0:Ni.url}')`:""};return P.jsxs("div",{ref:Ct,className:"sort-wrapper",children:[P.jsxs("div",{ref:Ft,className:"sort-puzzle",style:Dn,children:[d.map(zt=>P.jsxs("div",{id:`${zt.id}`,className:"sort-no-draggable-item",style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`,"--backgroundColor":`${zt.backgroundColor}`,borderRadius:`${zt.borderRadius}`},children:[zt.imgId&&P.jsx("img",{src:zt.img.url,alt:zt.img.name}),zt.text&&bi(zt.text)]},zt.id)),l.map(zt=>P.jsx("div",{ref:Qt=>{H.current[zt.id]=Qt},id:zt.id,className:`sort-destination-area ${m?"sort-destination-area--revelable":""}`,style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`}},zt.id)),c.map(zt=>P.jsxs("div",{ref:Qt=>{I.current[zt.id]=Qt},id:`${zt.id}`,className:"sort-draggable-item",onMouseDown:Qt=>Je(Qt,zt.id),onTouchStart:Qt=>Je(Qt,zt.id),style:{"--height":`${zt.heightInPercentage}%`,"--width":`${zt.widthInPercentage}%`,"--transform":`${zt.transform}`,"--backgroundColor":`${zt.backgroundColor}`,borderRadius:`${zt.borderRadius}`},children:[zt.imgId&&P.jsx("img",{src:zt.img.url,alt:zt.img.name}),zt.text&&bi(zt.text)]},zt.id))]}),g==="resolveMode"&&P.jsx("button",{type:"button",onClick:()=>{En()},className:"gat--btn gat--btn__primary sort-resolve-button",children:P.jsx("span",{children:y("storylines.misc.check")})}),_>0&&W&&P.jsx(qU,{buttonLabel:X,translate:y,onClose:Et}),T&&P.jsx(fd,{success:E,text:R,translate:y,timeExpired:nt,functionOnClose:me,keyboardControl:S}),_>0&&P.jsx(QU,{topRight:!0,initialSeconds:_,isPaused:tt,shouldStart:ut,shouldReset:ot,onTimeOver:vt})]})}exports.AnimationComponent=ont;exports.AutoEvaluationComponent=Mtt;exports.CardsSelectorPuzzleComponent=ttt;exports.CartelComponent=hX;exports.ChainedImageClickPuzzleComponent=E$;exports.ChangeCamera=m9;exports.ComicComponent=cX;exports.ConversationalComponent=rX;exports.ConversationalProComponent=sX;exports.CrackerPuzzleComponent=f$;exports.DecisionComponent=D9;exports.DialogComponent=int;exports.DragItemPuzzleComponent=gtt;exports.DragToSceneComponent=fnt;exports.FrameImageClickComponent=R$;exports.HackerPuzzleComponent=vX;exports.HangedPuzzleComponent=S$;exports.ImageClickPuzzleComponent=n$;exports.ImageComponent=tX;exports.InventoryItem=MH;exports.KeyboardPuzzleComponent=bX;exports.LecturesComponent=GK;exports.LoginPuzzleComponent=_X;exports.MatchPuzzleComponent=pnt;exports.NoticeComponent=TH;exports.PatternComponent=Ntt;exports.PdfComponent=yY;exports.PdfVisor=v5;exports.ReferralComponent=dnt;exports.SortPuzzleComponent=mnt;exports.SurveyComponent=wtt;exports.TerminalPuzzleComponent=mtt;exports.TestComponent=xtt;exports.TextClickPuzzleComponent=Ltt;exports.UrlComponent=_Y;exports.VideoComponent=PY;exports.VideoVisor=y5;exports.WebBuilderPuzzleComponent=K$;exports.WriterPuzzleComponent=utt;
|
|
335
335
|
//# sourceMappingURL=arcade-components.cjs.map
|