@gamelearn/arcade-components 3.30.8 → 3.30.11
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.
|
@@ -269,7 +269,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
269
269
|
*/var _win,_doc,_docElement,_pluginInitted,_tempDiv,_recentSetterPlugin,_reverting,_windowExists=function l(){return typeof window<"u"},_transformProps={},_RAD2DEG=180/Math.PI,_DEG2RAD=Math.PI/180,_atan2=Math.atan2,_bigNum=1e8,_capsExp=/([A-Z])/g,_horizontalExp=/(left|right|width|margin|padding|x)/i,_complexExp=/[\s,\(]\S/,_propertyAliases={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},_renderCSSProp=function l(e,n){return n.set(n.t,n.p,Math.round((n.s+n.c*e)*1e4)/1e4+n.u,n)},_renderPropWithEnd=function l(e,n){return n.set(n.t,n.p,e===1?n.e:Math.round((n.s+n.c*e)*1e4)/1e4+n.u,n)},_renderCSSPropWithBeginning=function l(e,n){return n.set(n.t,n.p,e?Math.round((n.s+n.c*e)*1e4)/1e4+n.u:n.b,n)},_renderRoundedCSSProp=function l(e,n){var t=n.s+n.c*e;n.set(n.t,n.p,~~(t+(t<0?-.5:.5))+n.u,n)},_renderNonTweeningValue=function l(e,n){return n.set(n.t,n.p,e?n.e:n.b,n)},_renderNonTweeningValueOnlyAtEnd=function l(e,n){return n.set(n.t,n.p,e!==1?n.b:n.e,n)},_setterCSSStyle=function l(e,n,t){return e.style[n]=t},_setterCSSProp=function l(e,n,t){return e.style.setProperty(n,t)},_setterTransform=function l(e,n,t){return e._gsap[n]=t},_setterScale=function l(e,n,t){return e._gsap.scaleX=e._gsap.scaleY=t},_setterScaleWithRender=function l(e,n,t,a,o){var d=e._gsap;d.scaleX=d.scaleY=t,d.renderTransform(o,d)},_setterTransformWithRender=function l(e,n,t,a,o){var d=e._gsap;d[n]=t,d.renderTransform(o,d)},_transformProp="transform",_transformOriginProp=_transformProp+"Origin",_saveStyle=function l(e,n){var t=this,a=this.target,o=a.style,d=a._gsap;if(e in _transformProps&&o){if(this.tfm=this.tfm||{},e!=="transform")e=_propertyAliases[e]||e,~e.indexOf(",")?e.split(",").forEach(function(h){return t.tfm[h]=_get(a,h)}):this.tfm[e]=d.x?d[e]:_get(a,e),e===_transformOriginProp&&(this.tfm.zOrigin=d.zOrigin);else return _propertyAliases.transform.split(",").forEach(function(h){return l.call(t,h,n)});if(this.props.indexOf(_transformProp)>=0)return;d.svg&&(this.svgo=a.getAttribute("data-svg-origin"),this.props.push(_transformOriginProp,n,"")),e=_transformProp}(o||n)&&this.props.push(e,n,o[e])},_removeIndependentTransforms=function l(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},_revertStyle=function l(){var e=this.props,n=this.target,t=n.style,a=n._gsap,o,d;for(o=0;o<e.length;o+=3)e[o+1]?n[e[o]]=e[o+2]:e[o+2]?t[e[o]]=e[o+2]:t.removeProperty(e[o].substr(0,2)==="--"?e[o]:e[o].replace(_capsExp,"-$1").toLowerCase());if(this.tfm){for(d in this.tfm)a[d]=this.tfm[d];a.svg&&(a.renderTransform(),n.setAttribute("data-svg-origin",this.svgo||"")),o=_reverting(),(!o||!o.isStart)&&!t[_transformProp]&&(_removeIndependentTransforms(t),a.zOrigin&&t[_transformOriginProp]&&(t[_transformOriginProp]+=" "+a.zOrigin+"px",a.zOrigin=0,a.renderTransform()),a.uncache=1)}},_getStyleSaver=function l(e,n){var t={target:e,props:[],revert:_revertStyle,save:_saveStyle};return e._gsap||gsap.core.getCache(e),n&&n.split(",").forEach(function(a){return t.save(a)}),t},_supports3D,_createElement=function l(e,n){var t=_doc.createElementNS?_doc.createElementNS((n||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),e):_doc.createElement(e);return t&&t.style?t:_doc.createElement(e)},_getComputedProperty=function l(e,n,t){var a=getComputedStyle(e);return a[n]||a.getPropertyValue(n.replace(_capsExp,"-$1").toLowerCase())||a.getPropertyValue(n)||!t&&l(e,_checkPropPrefix(n)||n,1)||""},_prefixes="O,Moz,ms,Ms,Webkit".split(","),_checkPropPrefix=function l(e,n,t){var a=n||_tempDiv,o=a.style,d=5;if(e in o&&!t)return e;for(e=e.charAt(0).toUpperCase()+e.substr(1);d--&&!(_prefixes[d]+e in o););return d<0?null:(d===3?"ms":d>=0?_prefixes[d]:"")+e},_initCore=function l(){_windowExists()&&window.document&&(_win=window,_doc=_win.document,_docElement=_doc.documentElement,_tempDiv=_createElement("div")||{style:{}},_createElement("div"),_transformProp=_checkPropPrefix(_transformProp),_transformOriginProp=_transformProp+"Origin",_tempDiv.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",_supports3D=!!_checkPropPrefix("perspective"),_reverting=gsap.core.reverting,_pluginInitted=1)},_getBBoxHack=function l(e){var n=_createElement("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),t=this.parentNode,a=this.nextSibling,o=this.style.cssText,d;if(_docElement.appendChild(n),n.appendChild(this),this.style.display="block",e)try{d=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=l}catch{}else this._gsapBBox&&(d=this._gsapBBox());return t&&(a?t.insertBefore(this,a):t.appendChild(this)),_docElement.removeChild(n),this.style.cssText=o,d},_getAttributeFallbacks=function l(e,n){for(var t=n.length;t--;)if(e.hasAttribute(n[t]))return e.getAttribute(n[t])},_getBBox=function l(e){var n;try{n=e.getBBox()}catch{n=_getBBoxHack.call(e,!0)}return n&&(n.width||n.height)||e.getBBox===_getBBoxHack||(n=_getBBoxHack.call(e,!0)),n&&!n.width&&!n.x&&!n.y?{x:+_getAttributeFallbacks(e,["x","cx","x1"])||0,y:+_getAttributeFallbacks(e,["y","cy","y1"])||0,width:0,height:0}:n},_isSVG=function l(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&_getBBox(e))},_removeProperty=function l(e,n){if(n){var t=e.style,a;n in _transformProps&&n!==_transformOriginProp&&(n=_transformProp),t.removeProperty?(a=n.substr(0,2),(a==="ms"||n.substr(0,6)==="webkit")&&(n="-"+n),t.removeProperty(a==="--"?n:n.replace(_capsExp,"-$1").toLowerCase())):t.removeAttribute(n)}},_addNonTweeningPT=function l(e,n,t,a,o,d){var h=new PropTween(e._pt,n,t,0,1,d?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue);return e._pt=h,h.b=a,h.e=o,e._props.push(t),h},_nonConvertibleUnits={deg:1,rad:1,turn:1},_nonStandardLayouts={grid:1,flex:1},_convertToUnit=function l(e,n,t,a){var o=parseFloat(t)||0,d=(t+"").trim().substr((o+"").length)||"px",h=_tempDiv.style,f=_horizontalExp.test(n),u=e.tagName.toLowerCase()==="svg",p=(u?"client":"offset")+(f?"Width":"Height"),S=100,R=a==="px",y=a==="%",E,g,v,b;if(a===d||!o||_nonConvertibleUnits[a]||_nonConvertibleUnits[d])return o;if(d!=="px"&&!R&&(o=l(e,n,t,"px")),b=e.getCTM&&_isSVG(e),(y||d==="%")&&(_transformProps[n]||~n.indexOf("adius")))return E=b?e.getBBox()[f?"width":"height"]:e[p],_round(y?o/E*S:o/100*E);if(h[f?"width":"height"]=S+(R?d:a),g=~n.indexOf("adius")||a==="em"&&e.appendChild&&!u?e:e.parentNode,b&&(g=(e.ownerSVGElement||{}).parentNode),(!g||g===_doc||!g.appendChild)&&(g=_doc.body),v=g._gsap,v&&y&&v.width&&f&&v.time===_ticker.time&&!v.uncache)return _round(o/v.width*S);if(y&&(n==="height"||n==="width")){var T=e.style[n];e.style[n]=S+a,E=e[p],T?e.style[n]=T:_removeProperty(e,n)}else(y||d==="%")&&!_nonStandardLayouts[_getComputedProperty(g,"display")]&&(h.position=_getComputedProperty(e,"position")),g===e&&(h.position="static"),g.appendChild(_tempDiv),E=_tempDiv[p],g.removeChild(_tempDiv),h.position="absolute";return f&&y&&(v=_getCache(g),v.time=_ticker.time,v.width=g[p]),_round(R?E*o/S:E&&o?S/E*o:0)},_get=function l(e,n,t,a){var o;return _pluginInitted||_initCore(),n in _propertyAliases&&n!=="transform"&&(n=_propertyAliases[n],~n.indexOf(",")&&(n=n.split(",")[0])),_transformProps[n]&&n!=="transform"?(o=_parseTransform(e,a),o=n!=="transformOrigin"?o[n]:o.svg?o.origin:_firstTwoOnly(_getComputedProperty(e,_transformOriginProp))+" "+o.zOrigin+"px"):(o=e.style[n],(!o||o==="auto"||a||~(o+"").indexOf("calc("))&&(o=_specialProps[n]&&_specialProps[n](e,n,t)||_getComputedProperty(e,n)||_getProperty(e,n)||(n==="opacity"?1:0))),t&&!~(o+"").trim().indexOf(" ")?_convertToUnit(e,n,o,t)+t:o},_tweenComplexCSSString=function l(e,n,t,a){if(!t||t==="none"){var o=_checkPropPrefix(n,e,1),d=o&&_getComputedProperty(e,o,1);d&&d!==t?(n=o,t=d):n==="borderColor"&&(t=_getComputedProperty(e,"borderTopColor"))}var h=new PropTween(this._pt,e.style,n,0,1,_renderComplexString),f=0,u=0,p,S,R,y,E,g,v,b,T,_,w,C;if(h.b=t,h.e=a,t+="",a+="",a==="auto"&&(g=e.style[n],e.style[n]=a,a=_getComputedProperty(e,n)||a,g?e.style[n]=g:_removeProperty(e,n)),p=[t,a],_colorStringFilter(p),t=p[0],a=p[1],R=t.match(_numWithUnitExp)||[],C=a.match(_numWithUnitExp)||[],C.length){for(;S=_numWithUnitExp.exec(a);)v=S[0],T=a.substring(f,S.index),E?E=(E+1)%5:(T.substr(-5)==="rgba("||T.substr(-5)==="hsla(")&&(E=1),v!==(g=R[u++]||"")&&(y=parseFloat(g)||0,w=g.substr((y+"").length),v.charAt(1)==="="&&(v=_parseRelative(y,v)+w),b=parseFloat(v),_=v.substr((b+"").length),f=_numWithUnitExp.lastIndex-_.length,_||(_=_||_config.units[n]||w,f===a.length&&(a+=_,h.e+=_)),w!==_&&(y=_convertToUnit(e,n,g,_)||0),h._pt={_next:h._pt,p:T||u===1?T:",",s:y,c:b-y,m:E&&E<4||n==="zIndex"?Math.round:0});h.c=f<a.length?a.substring(f,a.length):""}else h.r=n==="display"&&a==="none"?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue;return _relExp.test(a)&&(h.e=0),this._pt=h,h},_keywordToPercent={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},_convertKeywordsToPercentages=function l(e){var n=e.split(" "),t=n[0],a=n[1]||"50%";return(t==="top"||t==="bottom"||a==="left"||a==="right")&&(e=t,t=a,a=e),n[0]=_keywordToPercent[t]||t,n[1]=_keywordToPercent[a]||a,n.join(" ")},_renderClearProps=function l(e,n){if(n.tween&&n.tween._time===n.tween._dur){var t=n.t,a=t.style,o=n.u,d=t._gsap,h,f,u;if(o==="all"||o===!0)a.cssText="",f=1;else for(o=o.split(","),u=o.length;--u>-1;)h=o[u],_transformProps[h]&&(f=1,h=h==="transformOrigin"?_transformOriginProp:_transformProp),_removeProperty(t,h);f&&(_removeProperty(t,_transformProp),d&&(d.svg&&t.removeAttribute("transform"),_parseTransform(t,1),d.uncache=1,_removeIndependentTransforms(a)))}},_specialProps={clearProps:function l(e,n,t,a,o){if(o.data!=="isFromStart"){var d=e._pt=new PropTween(e._pt,n,t,0,0,_renderClearProps);return d.u=a,d.pr=-10,d.tween=o,e._props.push(t),1}}},_identity2DMatrix=[1,0,0,1,0,0],_rotationalProperties={},_isNullTransform=function l(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},_getComputedTransformMatrixAsArray=function l(e){var n=_getComputedProperty(e,_transformProp);return _isNullTransform(n)?_identity2DMatrix:n.substr(7).match(_numExp).map(_round)},_getMatrix=function l(e,n){var t=e._gsap||_getCache(e),a=e.style,o=_getComputedTransformMatrixAsArray(e),d,h,f,u;return t.svg&&e.getAttribute("transform")?(f=e.transform.baseVal.consolidate().matrix,o=[f.a,f.b,f.c,f.d,f.e,f.f],o.join(",")==="1,0,0,1,0,0"?_identity2DMatrix:o):(o===_identity2DMatrix&&!e.offsetParent&&e!==_docElement&&!t.svg&&(f=a.display,a.display="block",d=e.parentNode,(!d||!e.offsetParent)&&(u=1,h=e.nextElementSibling,_docElement.appendChild(e)),o=_getComputedTransformMatrixAsArray(e),f?a.display=f:_removeProperty(e,"display"),u&&(h?d.insertBefore(e,h):d?d.appendChild(e):_docElement.removeChild(e))),n&&o.length>6?[o[0],o[1],o[4],o[5],o[12],o[13]]:o)},_applySVGOrigin=function l(e,n,t,a,o,d){var h=e._gsap,f=o||_getMatrix(e,!0),u=h.xOrigin||0,p=h.yOrigin||0,S=h.xOffset||0,R=h.yOffset||0,y=f[0],E=f[1],g=f[2],v=f[3],b=f[4],T=f[5],_=n.split(" "),w=parseFloat(_[0])||0,C=parseFloat(_[1])||0,N,D,P,O;t?f!==_identity2DMatrix&&(D=y*v-E*g)&&(P=w*(v/D)+C*(-g/D)+(g*T-v*b)/D,O=w*(-E/D)+C*(y/D)-(y*T-E*b)/D,w=P,C=O):(N=_getBBox(e),w=N.x+(~_[0].indexOf("%")?w/100*N.width:w),C=N.y+(~(_[1]||_[0]).indexOf("%")?C/100*N.height:C)),a||a!==!1&&h.smooth?(b=w-u,T=C-p,h.xOffset=S+(b*y+T*g)-b,h.yOffset=R+(b*E+T*v)-T):h.xOffset=h.yOffset=0,h.xOrigin=w,h.yOrigin=C,h.smooth=!!a,h.origin=n,h.originIsAbsolute=!!t,e.style[_transformOriginProp]="0px 0px",d&&(_addNonTweeningPT(d,h,"xOrigin",u,w),_addNonTweeningPT(d,h,"yOrigin",p,C),_addNonTweeningPT(d,h,"xOffset",S,h.xOffset),_addNonTweeningPT(d,h,"yOffset",R,h.yOffset)),e.setAttribute("data-svg-origin",w+" "+C)},_parseTransform=function l(e,n){var t=e._gsap||new GSCache(e);if("x"in t&&!n&&!t.uncache)return t;var a=e.style,o=t.scaleX<0,d="px",h="deg",f=getComputedStyle(e),u=_getComputedProperty(e,_transformOriginProp)||"0",p,S,R,y,E,g,v,b,T,_,w,C,N,D,P,O,F,M,I,$,B,X,re,ae,te,W,ne,ce,me,J,H,K;return p=S=R=g=v=b=T=_=w=0,y=E=1,t.svg=!!(e.getCTM&&_isSVG(e)),f.translate&&((f.translate!=="none"||f.scale!=="none"||f.rotate!=="none")&&(a[_transformProp]=(f.translate!=="none"?"translate3d("+(f.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(f.rotate!=="none"?"rotate("+f.rotate+") ":"")+(f.scale!=="none"?"scale("+f.scale.split(" ").join(",")+") ":"")+(f[_transformProp]!=="none"?f[_transformProp]:"")),a.scale=a.rotate=a.translate="none"),D=_getMatrix(e,t.svg),t.svg&&(t.uncache?(te=e.getBBox(),u=t.xOrigin-te.x+"px "+(t.yOrigin-te.y)+"px",ae=""):ae=!n&&e.getAttribute("data-svg-origin"),_applySVGOrigin(e,ae||u,!!ae||t.originIsAbsolute,t.smooth!==!1,D)),C=t.xOrigin||0,N=t.yOrigin||0,D!==_identity2DMatrix&&(M=D[0],I=D[1],$=D[2],B=D[3],p=X=D[4],S=re=D[5],D.length===6?(y=Math.sqrt(M*M+I*I),E=Math.sqrt(B*B+$*$),g=M||I?_atan2(I,M)*_RAD2DEG:0,T=$||B?_atan2($,B)*_RAD2DEG+g:0,T&&(E*=Math.abs(Math.cos(T*_DEG2RAD))),t.svg&&(p-=C-(C*M+N*$),S-=N-(C*I+N*B))):(K=D[6],J=D[7],ne=D[8],ce=D[9],me=D[10],H=D[11],p=D[12],S=D[13],R=D[14],P=_atan2(K,me),v=P*_RAD2DEG,P&&(O=Math.cos(-P),F=Math.sin(-P),ae=X*O+ne*F,te=re*O+ce*F,W=K*O+me*F,ne=X*-F+ne*O,ce=re*-F+ce*O,me=K*-F+me*O,H=J*-F+H*O,X=ae,re=te,K=W),P=_atan2(-$,me),b=P*_RAD2DEG,P&&(O=Math.cos(-P),F=Math.sin(-P),ae=M*O-ne*F,te=I*O-ce*F,W=$*O-me*F,H=B*F+H*O,M=ae,I=te,$=W),P=_atan2(I,M),g=P*_RAD2DEG,P&&(O=Math.cos(P),F=Math.sin(P),ae=M*O+I*F,te=X*O+re*F,I=I*O-M*F,re=re*O-X*F,M=ae,X=te),v&&Math.abs(v)+Math.abs(g)>359.9&&(v=g=0,b=180-b),y=_round(Math.sqrt(M*M+I*I+$*$)),E=_round(Math.sqrt(re*re+K*K)),P=_atan2(X,re),T=Math.abs(P)>2e-4?P*_RAD2DEG:0,w=H?1/(H<0?-H:H):0),t.svg&&(ae=e.getAttribute("transform"),t.forceCSS=e.setAttribute("transform","")||!_isNullTransform(_getComputedProperty(e,_transformProp)),ae&&e.setAttribute("transform",ae))),Math.abs(T)>90&&Math.abs(T)<270&&(o?(y*=-1,T+=g<=0?180:-180,g+=g<=0?180:-180):(E*=-1,T+=T<=0?180:-180)),n=n||t.uncache,t.x=p-((t.xPercent=p&&(!n&&t.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-p)?-50:0)))?e.offsetWidth*t.xPercent/100:0)+d,t.y=S-((t.yPercent=S&&(!n&&t.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-S)?-50:0)))?e.offsetHeight*t.yPercent/100:0)+d,t.z=R+d,t.scaleX=_round(y),t.scaleY=_round(E),t.rotation=_round(g)+h,t.rotationX=_round(v)+h,t.rotationY=_round(b)+h,t.skewX=T+h,t.skewY=_+h,t.transformPerspective=w+d,(t.zOrigin=parseFloat(u.split(" ")[2])||!n&&t.zOrigin||0)&&(a[_transformOriginProp]=_firstTwoOnly(u)),t.xOffset=t.yOffset=0,t.force3D=_config.force3D,t.renderTransform=t.svg?_renderSVGTransforms:_supports3D?_renderCSSTransforms:_renderNon3DTransforms,t.uncache=0,t},_firstTwoOnly=function l(e){return(e=e.split(" "))[0]+" "+e[1]},_addPxTranslate=function l(e,n,t){var a=getUnit(n);return _round(parseFloat(n)+parseFloat(_convertToUnit(e,"x",t+"px",a)))+a},_renderNon3DTransforms=function l(e,n){n.z="0px",n.rotationY=n.rotationX="0deg",n.force3D=0,_renderCSSTransforms(e,n)},_zeroDeg="0deg",_zeroPx="0px",_endParenthesis=") ",_renderCSSTransforms=function l(e,n){var t=n||this,a=t.xPercent,o=t.yPercent,d=t.x,h=t.y,f=t.z,u=t.rotation,p=t.rotationY,S=t.rotationX,R=t.skewX,y=t.skewY,E=t.scaleX,g=t.scaleY,v=t.transformPerspective,b=t.force3D,T=t.target,_=t.zOrigin,w="",C=b==="auto"&&e&&e!==1||b===!0;if(_&&(S!==_zeroDeg||p!==_zeroDeg)){var N=parseFloat(p)*_DEG2RAD,D=Math.sin(N),P=Math.cos(N),O;N=parseFloat(S)*_DEG2RAD,O=Math.cos(N),d=_addPxTranslate(T,d,D*O*-_),h=_addPxTranslate(T,h,-Math.sin(N)*-_),f=_addPxTranslate(T,f,P*O*-_+_)}v!==_zeroPx&&(w+="perspective("+v+_endParenthesis),(a||o)&&(w+="translate("+a+"%, "+o+"%) "),(C||d!==_zeroPx||h!==_zeroPx||f!==_zeroPx)&&(w+=f!==_zeroPx||C?"translate3d("+d+", "+h+", "+f+") ":"translate("+d+", "+h+_endParenthesis),u!==_zeroDeg&&(w+="rotate("+u+_endParenthesis),p!==_zeroDeg&&(w+="rotateY("+p+_endParenthesis),S!==_zeroDeg&&(w+="rotateX("+S+_endParenthesis),(R!==_zeroDeg||y!==_zeroDeg)&&(w+="skew("+R+", "+y+_endParenthesis),(E!==1||g!==1)&&(w+="scale("+E+", "+g+_endParenthesis),T.style[_transformProp]=w||"translate(0, 0)"},_renderSVGTransforms=function l(e,n){var t=n||this,a=t.xPercent,o=t.yPercent,d=t.x,h=t.y,f=t.rotation,u=t.skewX,p=t.skewY,S=t.scaleX,R=t.scaleY,y=t.target,E=t.xOrigin,g=t.yOrigin,v=t.xOffset,b=t.yOffset,T=t.forceCSS,_=parseFloat(d),w=parseFloat(h),C,N,D,P,O;f=parseFloat(f),u=parseFloat(u),p=parseFloat(p),p&&(p=parseFloat(p),u+=p,f+=p),f||u?(f*=_DEG2RAD,u*=_DEG2RAD,C=Math.cos(f)*S,N=Math.sin(f)*S,D=Math.sin(f-u)*-R,P=Math.cos(f-u)*R,u&&(p*=_DEG2RAD,O=Math.tan(u-p),O=Math.sqrt(1+O*O),D*=O,P*=O,p&&(O=Math.tan(p),O=Math.sqrt(1+O*O),C*=O,N*=O)),C=_round(C),N=_round(N),D=_round(D),P=_round(P)):(C=S,P=R,N=D=0),(_&&!~(d+"").indexOf("px")||w&&!~(h+"").indexOf("px"))&&(_=_convertToUnit(y,"x",d,"px"),w=_convertToUnit(y,"y",h,"px")),(E||g||v||b)&&(_=_round(_+E-(E*C+g*D)+v),w=_round(w+g-(E*N+g*P)+b)),(a||o)&&(O=y.getBBox(),_=_round(_+a/100*O.width),w=_round(w+o/100*O.height)),O="matrix("+C+","+N+","+D+","+P+","+_+","+w+")",y.setAttribute("transform",O),T&&(y.style[_transformProp]=O)},_addRotationalPropTween=function l(e,n,t,a,o){var d=360,h=_isString(o),f=parseFloat(o)*(h&&~o.indexOf("rad")?_RAD2DEG:1),u=f-a,p=a+u+"deg",S,R;return h&&(S=o.split("_")[1],S==="short"&&(u%=d,u!==u%(d/2)&&(u+=u<0?d:-d)),S==="cw"&&u<0?u=(u+d*_bigNum)%d-~~(u/d)*d:S==="ccw"&&u>0&&(u=(u-d*_bigNum)%d-~~(u/d)*d)),e._pt=R=new PropTween(e._pt,n,t,a,u,_renderPropWithEnd),R.e=p,R.u="deg",e._props.push(t),R},_assign=function l(e,n){for(var t in n)e[t]=n[t];return e},_addRawTransformPTs=function l(e,n,t){var a=_assign({},t._gsap),o="perspective,force3D,transformOrigin,svgOrigin",d=t.style,h,f,u,p,S,R,y,E;a.svg?(u=t.getAttribute("transform"),t.setAttribute("transform",""),d[_transformProp]=n,h=_parseTransform(t,1),_removeProperty(t,_transformProp),t.setAttribute("transform",u)):(u=getComputedStyle(t)[_transformProp],d[_transformProp]=n,h=_parseTransform(t,1),d[_transformProp]=u);for(f in _transformProps)u=a[f],p=h[f],u!==p&&o.indexOf(f)<0&&(y=getUnit(u),E=getUnit(p),S=y!==E?_convertToUnit(t,f,u,E):parseFloat(u),R=parseFloat(p),e._pt=new PropTween(e._pt,h,f,S,R-S,_renderCSSProp),e._pt.u=E||0,e._props.push(f));_assign(h,a)};_forEachName("padding,margin,Width,Radius",function(l,e){var n="Top",t="Right",a="Bottom",o="Left",d=(e<3?[n,t,a,o]:[n+o,n+t,a+t,a+o]).map(function(h){return e<2?l+h:"border"+h+l});_specialProps[e>1?"border"+l:l]=function(h,f,u,p,S){var R,y;if(arguments.length<4)return R=d.map(function(E){return _get(h,E,u)}),y=R.join(" "),y.split(R[0]).length===5?R[0]:y;R=(p+"").split(" "),y={},d.forEach(function(E,g){return y[E]=R[g]=R[g]||R[(g-1)/2|0]}),h.init(f,y,S)}});var CSSPlugin={name:"css",register:_initCore,targetTest:function l(e){return e.style&&e.nodeType},init:function l(e,n,t,a,o){var d=this._props,h=e.style,f=t.vars.startAt,u,p,S,R,y,E,g,v,b,T,_,w,C,N,D,P;_pluginInitted||_initCore(),this.styles=this.styles||_getStyleSaver(e),P=this.styles.props,this.tween=t;for(g in n)if(g!=="autoRound"&&(p=n[g],!(_plugins[g]&&_checkPlugin(g,n,t,a,e,o)))){if(y=typeof p,E=_specialProps[g],y==="function"&&(p=p.call(t,a,e,o),y=typeof p),y==="string"&&~p.indexOf("random(")&&(p=_replaceRandom(p)),E)E(this,e,g,p,t)&&(D=1);else if(g.substr(0,2)==="--")u=(getComputedStyle(e).getPropertyValue(g)+"").trim(),p+="",_colorExp.lastIndex=0,_colorExp.test(u)||(v=getUnit(u),b=getUnit(p)),b?v!==b&&(u=_convertToUnit(e,g,u,b)+b):v&&(p+=v),this.add(h,"setProperty",u,p,a,o,0,0,g),d.push(g),P.push(g,0,h[g]);else if(y!=="undefined"){if(f&&g in f?(u=typeof f[g]=="function"?f[g].call(t,a,e,o):f[g],_isString(u)&&~u.indexOf("random(")&&(u=_replaceRandom(u)),getUnit(u+"")||u==="auto"||(u+=_config.units[g]||getUnit(_get(e,g))||""),(u+"").charAt(1)==="="&&(u=_get(e,g))):u=_get(e,g),R=parseFloat(u),T=y==="string"&&p.charAt(1)==="="&&p.substr(0,2),T&&(p=p.substr(2)),S=parseFloat(p),g in _propertyAliases&&(g==="autoAlpha"&&(R===1&&_get(e,"visibility")==="hidden"&&S&&(R=0),P.push("visibility",0,h.visibility),_addNonTweeningPT(this,h,"visibility",R?"inherit":"hidden",S?"inherit":"hidden",!S)),g!=="scale"&&g!=="transform"&&(g=_propertyAliases[g],~g.indexOf(",")&&(g=g.split(",")[0]))),_=g in _transformProps,_){if(this.styles.save(g),w||(C=e._gsap,C.renderTransform&&!n.parseTransform||_parseTransform(e,n.parseTransform),N=n.smoothOrigin!==!1&&C.smooth,w=this._pt=new PropTween(this._pt,h,_transformProp,0,1,C.renderTransform,C,0,-1),w.dep=1),g==="scale")this._pt=new PropTween(this._pt,C,"scaleY",C.scaleY,(T?_parseRelative(C.scaleY,T+S):S)-C.scaleY||0,_renderCSSProp),this._pt.u=0,d.push("scaleY",g),g+="X";else if(g==="transformOrigin"){P.push(_transformOriginProp,0,h[_transformOriginProp]),p=_convertKeywordsToPercentages(p),C.svg?_applySVGOrigin(e,p,0,N,0,this):(b=parseFloat(p.split(" ")[2])||0,b!==C.zOrigin&&_addNonTweeningPT(this,C,"zOrigin",C.zOrigin,b),_addNonTweeningPT(this,h,g,_firstTwoOnly(u),_firstTwoOnly(p)));continue}else if(g==="svgOrigin"){_applySVGOrigin(e,p,1,N,0,this);continue}else if(g in _rotationalProperties){_addRotationalPropTween(this,C,g,R,T?_parseRelative(R,T+p):p);continue}else if(g==="smoothOrigin"){_addNonTweeningPT(this,C,"smooth",C.smooth,p);continue}else if(g==="force3D"){C[g]=p;continue}else if(g==="transform"){_addRawTransformPTs(this,p,e);continue}}else g in h||(g=_checkPropPrefix(g)||g);if(_||(S||S===0)&&(R||R===0)&&!_complexExp.test(p)&&g in h)v=(u+"").substr((R+"").length),S||(S=0),b=getUnit(p)||(g in _config.units?_config.units[g]:v),v!==b&&(R=_convertToUnit(e,g,u,b)),this._pt=new PropTween(this._pt,_?C:h,g,R,(T?_parseRelative(R,T+S):S)-R,!_&&(b==="px"||g==="zIndex")&&n.autoRound!==!1?_renderRoundedCSSProp:_renderCSSProp),this._pt.u=b||0,v!==b&&b!=="%"&&(this._pt.b=u,this._pt.r=_renderCSSPropWithBeginning);else if(g in h)_tweenComplexCSSString.call(this,e,g,u,T?T+p:p);else if(g in e)this.add(e,g,u||e[g],T?T+p:p,a,o);else if(g!=="parseTransform"){_missingPlugin(g,p);continue}_||(g in h?P.push(g,0,h[g]):P.push(g,1,u||e[g])),d.push(g)}}D&&_sortPropTweensByPriority(this)},render:function l(e,n){if(n.tween._time||!_reverting())for(var t=n._pt;t;)t.r(e,t.d),t=t._next;else n.styles.revert()},get:_get,aliases:_propertyAliases,getSetter:function l(e,n,t){var a=_propertyAliases[n];return a&&a.indexOf(",")<0&&(n=a),n in _transformProps&&n!==_transformOriginProp&&(e._gsap.x||_get(e,"x"))?t&&_recentSetterPlugin===t?n==="scale"?_setterScale:_setterTransform:(_recentSetterPlugin=t||{})&&(n==="scale"?_setterScaleWithRender:_setterTransformWithRender):e.style&&!_isUndefined(e.style[n])?_setterCSSStyle:~n.indexOf("-")?_setterCSSProp:_getSetter(e,n)},core:{_removeProperty,_getMatrix}};gsap.utils.checkPrefix=_checkPropPrefix;gsap.core.getStyleSaver=_getStyleSaver;(function(l,e,n,t){var a=_forEachName(l+","+e+","+n,function(o){_transformProps[o]=1});_forEachName(e,function(o){_config.units[o]="deg",_rotationalProperties[o]=1}),_propertyAliases[a[13]]=l+","+e,_forEachName(t,function(o){var d=o.split(":");_propertyAliases[d[1]]=a[d[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");_forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(l){_config.units[l]="px"});gsap.registerPlugin(CSSPlugin);var gsapWithCSS=gsap.registerPlugin(CSSPlugin)||gsap;gsapWithCSS.core.Tween;function SpeechBubbleComponent({message:l,translate:e},n){const[t,a]=React$2.useState(!1),o=()=>{const d=l.avatar,h=d.lastIndexOf("/");return d.includes("/object/")?d.slice(0,h).concat("/mini-thumbnail.png"):d.includes("/character/")?d.slice(0,h).concat("/mini-face.png"):d};return React$2.useLayoutEffect(()=>{t||a(!0)},[t]),jsxRuntimeExports.jsxs("div",{dir:"auto",ref:n,className:`
|
|
270
270
|
speech-bubble
|
|
271
271
|
${l.thinkful?"speech-bubble--italic":""}
|
|
272
|
-
`,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader,MIX_TIME=.1;function useStateMachine(l){const e=fiber.useThree(R=>R.scene),n=React$2.useMemo(()=>{var y;const R={};for(const E of l)if(E.slots)for(const g of E.slots){if(!g.uid)continue;const v=(y=g.character)==null?void 0:y.resource.animations;v&&(R[g.uid]||(R[g.uid]=Object.keys(v).reduce((b,T)=>(b[T]=v[T].url,b),{})))}return R},[l]),t=React$2.useMemo(()=>{const R=new Set;for(const y of l)if(y.slots)for(const E of y.slots)E.uid&&R.add(E.uid);return Array.from(R)},[l]),a=async R=>{const y=n[R];if(!cache[y.talking]){const{animations:g}=await loader.loadAsync(y.talking);g[0].name="talking",cache[y.talking]=g[0]}},o=()=>{t.forEach(R=>{S(R,"idle")})},d=()=>{t.forEach(R=>{const y=e.getObjectByProperty("uid",R);y&&(delete y.userData._active,S(R,"idle"))})},h=async(R,y,E=!1)=>{const g=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!g)return new Promise(b=>b(!1));const v=g.userData.animator;if(y){const b=n[R];let T=cache[b.talking],_=y,w=cache[y];if(!w){const{animations:C}=await loader.loadAsync(y);w=cache[y]=C[0]}if(E&&b.talking!==y&&(T?(w=mixWithTalkingClip(T,w),_+="_talking"):a(R).then(()=>{T=cache[b.talking],w=mixWithTalkingClip(T,w),_+="_talking"})),!g.userData._active||g.userData._active!==_){g.userData._active=_;const C=v.register(_,w);return new Promise(N=>{v.mix(_,MIX_TIME).then(D=>N(D?C:!1))})}}return new Promise(b=>b(!1))},f=async(R,y)=>{const E=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!E)return new Promise(D=>D(!1));const g=E.userData.animator,v=n[R],b=v[y];let T=cache[v.talking];if(T||(await a(R),T=cache[v.talking]),!b)return;let _=cache[b];if(!_){const{animations:D}=await loader.loadAsync(b);_=cache[b]=D[0]}const w=b.split("/").pop().replace(".glb",""),C=mixWithTalkingClip(T,_);C.name=`${w}_talking_mixed`;const N=C.name;if(!E.userData._active||E.userData._active!==N){E.userData._active=N;const D=g.register(N,C);return new Promise(P=>{g.mix(N,MIX_TIME).then(O=>P(O?D:!1))})}return new Promise(D=>D(!1))},u=R=>{const y=getCurrentVisible(R,e);if(!y)return;const E=y.userData._active;if(E&&E.includes("_talking")){const g=E.replace("_talking","").replace("_mixed","");y.userData._talkingPaused={wasActive:!0,baseEmotion:g,originalAnimation:E};const b=n[R][g];b&&h(R,b,!1)}},p=async R=>{const y=getCurrentVisible(R,e);if(!y)return;const E=y.userData._talkingPaused;if(E&&E.wasActive){const v=n[R][E.baseEmotion];v&&await h(R,v,!0),delete y.userData._talkingPaused}},S=async(R,y)=>{const E=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!E)return new Promise(v=>v(!1));const g=E.userData.animator;if(y==="idle")return g.mix("idle",MIX_TIME),g.getAction("idle");{const v=n[R],b=y.split("_")[0],T=v[b],_=y.includes("talking");if(T){const w=`${T}_${_?"talking":"silent"}_${R}`;let C=cache[w];if(!C){let N=cache[T];if(!N){const{animations:D}=await loader.loadAsync(T);N=cache[T]=D[0]}if(_&&y!=="talking"){const D=cache[v.talking];D?C=mixWithTalkingClip(D,N):C=N.clone()}else C=N.clone();cache[w]=C}if(!E.userData._active||E.userData._active!==y){E.userData._active=y;const N=g.register(y,C);return new Promise(D=>{g.mix(y,MIX_TIME).then(P=>D(P?N:!1))})}}}return new Promise(v=>v(!1))};return{startAnimation:S,startAnimationUrl:h,preloadTalking:a,resetActives:o,unmountActives:d,startOnlyTalkingAnimation:f,shutUp:u,resumeTalking:p}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:S}){var wt;const R=t.length-1<=(S==null?void 0:S.line)?t.length-1:(S==null?void 0:S.line)||0,[y,E]=React$2.useState(R),[g,v]=React$2.useState(!!f),[b,T]=React$2.useState(!1),[_,w]=React$2.useState(!1),C=fiber.useThree(ge=>ge.scene),N=fiber.useThree(ge=>ge.camera),{start:D,stop:P}=useTimeout(),O=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),I=t[y],$=t[y-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:ae}=I||{},te=React$2.useRef({}),W=(wt=I==null?void 0:I.slots)==null?void 0:wt.find(ge=>ge.talking),ne=React$2.useRef(!1),{startAnimation:ce,startAnimationUrl:me,resetActives:J,preloadTalking:H,unmountActives:K,startOnlyTalkingAnimation:V,shutUp:z}=useStateMachine(t),Y=React$2.useRef(),ie=Object.keys((I==null?void 0:I.audio)||{}).length,le=Object.keys((I==null?void 0:I.voice)||{}).length,fe=re||(I==null?void 0:I.type)==="conversationalNarration",de=ae||(I==null?void 0:I.type)==="conversationalDecision",ve=(I==null?void 0:I.type)==="conversationalCamera",Re=g&&!de&&!ve,[Te,Oe]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Fe=React$2.useRef(null);fiber.useFrame(()=>{var ge;if((ge=At.current)!=null&&ge.node){const Z=At.current.node.weights.sil>.4;Fe.current=Z,Z&&(W!=null&&W.uid)?ft():W!=null&&W.uid&&Ge(W.uid,W.emotion)}});const Ke=React$2.useMemo(()=>t.reduce((ge,Z)=>(Z.slots&&Z.slots.filter(xe=>xe.uid).forEach(xe=>{ge.includes(xe.uid)||ge.push(xe.uid)}),ge),[]),[t]),lt=React$2.useCallback(ge=>n({type:"translate",payload:ge}),[n]),[Qe,_t]=React$2.useState([]),$e=React$2.useMemo(()=>Qe[Qe.length-1],[Qe]),Ae=React$2.useCallback(()=>{const ge=o.find(he=>he.fromId===$e)||o.find(he=>he.toId===$e),Z=t.find(he=>he.id===(ge==null?void 0:ge.fromId));return!$e&&(S==null?void 0:S.line)>=0?{decision:!0}:Z},[o,t,$e]),Pe=React$2.useCallback(()=>{if(X){const Z=Ae();return Z==null?void 0:Z.decision}const ge=t[y-1]?t[y-1]:{};return y>0&&(ge==null?void 0:ge.decision)},[I,X,t,$e,o]),Ue=React$2.useCallback(()=>{if(X){const Z=Ae();return(Z==null?void 0:Z.type)==="conversationalCamera"}const ge=t[y-1]?t[y-1]:{};return y>0&&(ge==null?void 0:ge.type)==="conversationalCamera"},[I,X,t,$e,o]),Ve=React$2.useCallback(ge=>{var he,xe;const Z=a.find(Se=>(Se==null?void 0:Se.uid)===(ge==null?void 0:ge.uid)?Se:"");return((xe=(he=ge==null?void 0:ge.character)==null?void 0:he.resource)==null?void 0:xe.url)||(Z==null?void 0:Z.completeUrl)||""},[a]),Je=(ge=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const Z=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(Z),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const he=M.current.isLeft?-1:1,xe=headSize*he;animationTarget.translateX(-10*he+xe),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(he=>{const{object:xe}=he;xe.material.visible=!0})},onComplete:()=>{ge(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const he=raycast.intersectObjects(C.children,!0);O.current=he.filter(xe=>xe.distance<10),O.current.length&&O.current.forEach(xe=>{const{object:Se}=xe;Se.material.side=0}),ne.current=!1,B.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},xt=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Je()},[h]),nt=(ge,Z,he,xe=!1)=>{const Se=Z.includes("seated");if(he)me(ge,he.url,Z.includes("talking")).then(ue=>{if(ue&&BASIC_ACTIONS_TYPES_WHITELIST.includes(he.animationId))if(B.current)ce(ge,"idle");else{const be=Y.current===ge?"neutral_talking":"neutral";ce(ge,be)}});else{const ue=xe&&!Se?`${Z}-seated`:Z;ce(ge,ue)}},mt=()=>{if(!(W!=null&&W.uid)||B.current)return;const{emotion:ge,uid:Z,animation:he}=W,xe=getCurrentVisible(Z,C);if(xe){delete xe.userData._active;const{isSeated:Se}=xe;Y.current===Z?(nt(Z,"neutral",null,Se),Y.current=null):nt(Z,ge,he,Se)}},Ge=React$2.useCallback((ge,Z)=>{ge&&Z&&V(ge,Z)},[V,W]),ft=()=>{z()},Be=React$2.useCallback(()=>{B.current=!0,Oe({show:!1}),xt(),J(),h||e({type:"success"})},[N,e,xt,h]);React$2.useEffect(()=>()=>{te.current={},K()},[]);const Ye=ge=>{Oe({show:!1}),E(ge),e({type:"notifyProgress",payload:{line:ge}})},Ne=React$2.useCallback((ge=!0)=>{const Z=ge?["fromId","toId"]:["toId","fromId"],he=o.filter(ue=>ue[Z[0]]===I.id),xe=he.length===1?he[0]:he.find(ue=>ue[Z[1]]===$e);if(!(xe!=null&&xe[Z[0]])){Be();return}ge||_t(Qe.slice(0,Qe.length-1));const Se=t.findIndex(ue=>ue.id===xe[Z[1]]);Se>=0?Ye(Se):Be()},[I==null?void 0:I.id,e,o,Be,t]),De=React$2.useCallback((ge,Z)=>{const he=[3,2,1][ge.id],Se=o.filter(be=>be.fromId===(I==null?void 0:I.id)).find(be=>parseInt(be.fromPointIndex)===he),ue=t.findIndex(be=>be.id===(Se==null?void 0:Se.toId));ue>=0?(Se==null?void 0:Se.fromId)===(Se==null?void 0:Se.toId)?Z():Ye(ue):Be()},[I==null?void 0:I.id,o,Be,t]),_e=React$2.useCallback(()=>{if(te.current={...W},w(!1),mt(),X)Ne(!1);else if(!Pe()){const ge=y-1;Oe({show:!1}),E(ge),e({type:"notifyProgress",payload:{line:ge}})}},[Ne,e,X,$,y,W]),ke=React$2.useCallback(ge=>{if(X){if(ge){const Z=[3,2,1][ge.id],xe=o.filter(Se=>Se.fromId===I.id).find(Se=>parseInt(Se.fromPointIndex)===Z);if(xe){const Se=t.findIndex(ue=>ue.id===xe.toId);Se>=0&&e({type:"notifyProgress",payload:{line:Se}})}else e({type:"saveNode"})}}else if(y<t.length-1){const Z=y+1;e({type:"notifyProgress",payload:{line:Z}})}else e({type:"saveNode"})},[o,y,t,e,I==null?void 0:I.id,X]),Xe=React$2.useCallback((ge,Z)=>{if(te.current={...W},_t([...Qe,I.id]),w(!1),mt(),X)ge?De(ge,Z):Ne();else if(y<t.length-1){const he=y+1;Ye(he)}else(u||de||ve)&&Be()},[e,I==null?void 0:I.id,X,de,ve,y,t.length,De,Ne,Be,W]),Ft=()=>{v(!1),_e()},Dt=()=>X?I&&I.type!=="conversationalDecision"&&!o.find(ge=>ge.fromId===I.id):y===t.length-1,Le=()=>{Dt()?Be():(v(!1),Xe())};React$2.useEffect(()=>{if(X&&!b){const ge=S==null?void 0:S.line;if(ge>=0){T(!0),E(ge);return}const Z=t.filter(he=>!o.find(xe=>xe.toId===he.id));if(Z.length){const he=Z[0],xe=t.indexOf(he);xe>=0&&(T(!0),E(xe))}}},[o,X,t,b]);const ht=ge=>{if(te.current.uid===ge.uid||M.current.parent===ge)return;const Z=new three.Object3D,he=ge.getObjectByName("Head_M");he.updateMatrixWorld(!0),Z.applyMatrix4(he.matrixWorld),Z.applyQuaternion(N.quaternion);const xe=h?2.5:2,Se=h?1.2:1.5;Z.translateY(xe),Z.translateX(Se);const ue=new three.Vector3;ue.setFromMatrixPosition(he.matrixWorld);const Ie=ue.project(N).x<0;M.current={pos:Z.position.toArray(),child:he,parent:ge,isLeft:Ie}},Tt=ge=>{e({type:"resetZIndexUIContainer",payload:ge})};React$2.useEffect(()=>{var ge;if(fe)xt(),Oe({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${lt("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Ve(W),show:!0});else if(!B.current&&!de&&!ve){const Z=I==null?void 0:I.slots.filter(Se=>Se.uid&&!Se.talking),he=[...Z.map(Se=>Se.uid)||[],W==null?void 0:W.uid];if(Ke.filter(Se=>!he.includes(Se)).forEach(Se=>{ce(Se,"idle")}),Z.forEach(Se=>{const ue=getCurrentVisible(Se.uid,C);if(ue){const{isSeated:be}=ue;nt(Se.uid,Se.emotion,Se.animation,be)}}),W){const Se=getCurrentVisible(W.uid,C),ue=a.find(be=>be.uid===W.uid);Se&&!B.current?setTimeout(()=>{var be,Ie;if(W.uid===Se.uid){ht(Se);const{isSeated:et,userData:ct}=Se,{emotion:Rt,animation:pt}=W;!((be=ct._active)!=null&&be.includes("talking"))&&!((Ie=ct._active)!=null&&Ie.includes(Rt))&&nt(W.uid,Rt,pt,et);const dt=()=>{var Nt;Oe({text:W.text,name:W.alias||((Nt=W.character)==null?void 0:Nt.name),inScene:!0,thinkful:W.emotion.includes("think"),avatar:Ve(W),show:!0})};h?(ne.current=!1,Je(dt)):dt()}},150):(xt(),Oe({text:W.text,name:W.alias||((ge=W.character)==null?void 0:ge.name)||(ue==null?void 0:ue.name),left:!1,top:W.text.length>maxCharacterToSwitch,inScene:!1,thinkful:W.emotion.includes("think"),avatar:Ve(W),show:!0}))}else xt(),Oe({show:!0})}},[a,I,h,C,lt,Ve,xt,de,fe,Ke]);const it=cleanTextOfHtmlTags(Te==null?void 0:Te.text),[At,Ct]=useEkho({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:Te.show,text:it,audio:I==null?void 0:I.audio,soundActions:d,getEvent:n,pauseTTS:p,onStart:()=>{},onError:()=>{mt(),w(!0)},onFinish:()=>{mt(),Re&&!p&&Xe()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[y,Ct]),React$2.useEffect(()=>{var ge;if(((I==null?void 0:I.audioType)==="none"||_)&&(Te!=null&&Te.show)&&!(W!=null&&W.emotion.includes("think"))){const Z=characterMs*(((ge=Te==null?void 0:Te.text)==null?void 0:ge.length)||0);setTimeout(()=>{mt()},Z<minMs?minMs:Z)}},[_,I==null?void 0:I.audioType,W==null?void 0:W.emotion,Te]),React$2.useEffect(()=>{var ge;if(Re&&Te.show&&((I==null?void 0:I.audioType)==="none"||_)&&!p){const Z=characterMs*(((ge=Te==null?void 0:Te.text)==null?void 0:ge.length)||0);(!Dt()||Dt()&&u)&&D(Xe,Z<minMs?minMs:Z)}return()=>{P()}},[Te,Xe,D,u,P,I==null?void 0:I.audioType,Re,ie,le,_]);const Xt=React$2.useMemo(()=>y===0||Pe()||Ue(),[y,Pe,Ue]),ut=l({disabled:de||!Te.show,repeat:!1,forward:Le,rewind:Xt?null:Ft});React$2.useEffect(()=>ut(),[ut]);const Vt=document.querySelector(".screens--container");if(ve)return jsxRuntimeExports.jsx(ChangeCamera,{...I,emitEvent:e,success:!1,onFinish:Xe},`change-camera-${y}`);if(de){const ge=I.id?t.filter(he=>he.decision).findIndex(he=>he.id===I.id)+1:t.filter(he=>he.decision).findIndex(he=>he===I)+1,Z={...I.payload,decisionNumber:ge,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:ke,onFinish:Xe,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{xt(),Tt(!0)},onUnMount:()=>{ne.current=!1,Tt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...Z})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[Te.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:lt,currentMessage:Te}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Vt?{current:Vt}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:Ft,disabled:Xt||!Te.show,className:`gat--btn__round ${Xt||!Te.show?"disabled":""}`,"aria-label":LangIsRtl()?lt("storylines.misc.forward"):lt("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Le,disabled:!Te.show,className:`gat--btn__round
|
|
272
|
+
`,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader,MIX_TIME=.1;function useStateMachine(l){const e=fiber.useThree(R=>R.scene),n=React$2.useMemo(()=>{var y;const R={};for(const E of l)if(E.slots)for(const g of E.slots){if(!g.uid)continue;const v=(y=g.character)==null?void 0:y.resource.animations;v&&(R[g.uid]||(R[g.uid]=Object.keys(v).reduce((b,T)=>(b[T]=v[T].url,b),{})))}return R},[l]),t=React$2.useMemo(()=>{const R=new Set;for(const y of l)if(y.slots)for(const E of y.slots)E.uid&&R.add(E.uid);return Array.from(R)},[l]),a=async R=>{const y=n[R];if(!cache[y.talking]){const{animations:g}=await loader.loadAsync(y.talking);g[0].name="talking",cache[y.talking]=g[0]}},o=()=>{t.forEach(R=>{S(R,"idle")})},d=()=>{t.forEach(R=>{const y=e.getObjectByProperty("uid",R);y&&(delete y.userData._active,S(R,"idle"))})},h=async(R,y,E=!1)=>{const g=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!g)return new Promise(b=>b(!1));const v=g.userData.animator;if(y){const b=n[R];let T=cache[b.talking],_=y,w=cache[y];if(!w){const{animations:C}=await loader.loadAsync(y);w=cache[y]=C[0]}if(E&&b.talking!==y&&(T?(w=mixWithTalkingClip(T,w),_+="_talking"):a(R).then(()=>{T=cache[b.talking],w=mixWithTalkingClip(T,w),_+="_talking"})),!g.userData._active||g.userData._active!==_){g.userData._active=_;const C=v.register(_,w);return new Promise(N=>{v.mix(_,MIX_TIME).then(D=>N(D?C:!1))})}}return new Promise(b=>b(!1))},f=async(R,y,E)=>{const g=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!g)return new Promise(O=>O(!1));const v=g.userData.animator,b=n[R],{isSeated:T}=g;let _;if(E)_=E.url;else{let O=y;T&&!y.includes("seated")&&(O+="-seated"),_=b[O]}let w=cache[b.talking];if(w||(await a(R),w=cache[b.talking]),!_)return;let C=cache[_];if(!C){const{animations:O}=await loader.loadAsync(_);C=cache[_]=O[0]}const N=_.split("/").pop().replace(".glb",""),D=mixWithTalkingClip(w,C);D.name=`${N}_talking_mixed`;const P=D.name;if(!g.userData._active||g.userData._active!==P){g.userData._active=P;const O=v.register(P,D);return new Promise(F=>{v.mix(P,MIX_TIME).then(M=>F(M?O:!1))})}return new Promise(O=>O(!1))},u=R=>{const y=getCurrentVisible(R,e);if(!y)return;const E=y.userData._active;if(E&&E.includes("_talking")){const g=E.replace("_talking","").replace("_mixed","");y.userData._talkingPaused={wasActive:!0,baseEmotion:g,originalAnimation:E};const b=n[R][g];b&&h(R,b,!1)}},p=async R=>{const y=getCurrentVisible(R,e);if(!y)return;const E=y.userData._talkingPaused;if(E&&E.wasActive){const v=n[R][E.baseEmotion];v&&await h(R,v,!0),delete y.userData._talkingPaused}},S=async(R,y)=>{const E=getCurrentVisible(R,e);if(cache[R]||(cache[R]={}),!E)return new Promise(v=>v(!1));const g=E.userData.animator;if(y==="idle")return g.mix("idle",MIX_TIME),g.getAction("idle");{const v=n[R],b=y.split("_")[0],T=v[b],_=y.includes("talking");if(T){const w=`${T}_${_?"talking":"silent"}_${R}`;let C=cache[w];if(!C){let N=cache[T];if(!N){const{animations:D}=await loader.loadAsync(T);N=cache[T]=D[0]}if(_&&y!=="talking"){const D=cache[v.talking];D?C=mixWithTalkingClip(D,N):C=N.clone()}else C=N.clone();cache[w]=C}if(!E.userData._active||E.userData._active!==y){E.userData._active=y;const N=g.register(y,C);return new Promise(D=>{g.mix(y,MIX_TIME).then(P=>D(P?N:!1))})}}}return new Promise(v=>v(!1))};return{startAnimation:S,startAnimationUrl:h,preloadTalking:a,resetActives:o,unmountActives:d,startOnlyTalkingAnimation:f,shutUp:u,resumeTalking:p}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:S}){var wt;const R=t.length-1<=(S==null?void 0:S.line)?t.length-1:(S==null?void 0:S.line)||0,[y,E]=React$2.useState(R),[g,v]=React$2.useState(!!f),[b,T]=React$2.useState(!1),[_,w]=React$2.useState(!1),C=fiber.useThree(ge=>ge.scene),N=fiber.useThree(ge=>ge.camera),{start:D,stop:P}=useTimeout(),O=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),I=t[y],$=t[y-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:ae}=I||{},te=React$2.useRef({}),W=(wt=I==null?void 0:I.slots)==null?void 0:wt.find(ge=>ge.talking),ne=React$2.useRef(!1),{startAnimation:ce,startAnimationUrl:me,resetActives:J,preloadTalking:H,unmountActives:K,startOnlyTalkingAnimation:V,shutUp:z}=useStateMachine(t),Y=React$2.useRef(),ie=Object.keys((I==null?void 0:I.audio)||{}).length,le=Object.keys((I==null?void 0:I.voice)||{}).length,fe=re||(I==null?void 0:I.type)==="conversationalNarration",de=ae||(I==null?void 0:I.type)==="conversationalDecision",ve=(I==null?void 0:I.type)==="conversationalCamera",Re=g&&!de&&!ve,[Te,Oe]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Fe=React$2.useRef(null);fiber.useFrame(()=>{var ge;if((ge=At.current)!=null&&ge.node){const Z=At.current.node.weights.sil>.4;Fe.current=Z,Z&&(W!=null&&W.uid)?ft():W!=null&&W.uid&&Ge(W)}});const Ke=React$2.useMemo(()=>t.reduce((ge,Z)=>(Z.slots&&Z.slots.filter(xe=>xe.uid).forEach(xe=>{ge.includes(xe.uid)||ge.push(xe.uid)}),ge),[]),[t]),lt=React$2.useCallback(ge=>n({type:"translate",payload:ge}),[n]),[Qe,_t]=React$2.useState([]),$e=React$2.useMemo(()=>Qe[Qe.length-1],[Qe]),Ae=React$2.useCallback(()=>{const ge=o.find(he=>he.fromId===$e)||o.find(he=>he.toId===$e),Z=t.find(he=>he.id===(ge==null?void 0:ge.fromId));return!$e&&(S==null?void 0:S.line)>=0?{decision:!0}:Z},[o,t,$e]),Pe=React$2.useCallback(()=>{if(X){const Z=Ae();return Z==null?void 0:Z.decision}const ge=t[y-1]?t[y-1]:{};return y>0&&(ge==null?void 0:ge.decision)},[I,X,t,$e,o]),Ue=React$2.useCallback(()=>{if(X){const Z=Ae();return(Z==null?void 0:Z.type)==="conversationalCamera"}const ge=t[y-1]?t[y-1]:{};return y>0&&(ge==null?void 0:ge.type)==="conversationalCamera"},[I,X,t,$e,o]),Ve=React$2.useCallback(ge=>{var he,xe;const Z=a.find(Se=>(Se==null?void 0:Se.uid)===(ge==null?void 0:ge.uid)?Se:"");return((xe=(he=ge==null?void 0:ge.character)==null?void 0:he.resource)==null?void 0:xe.url)||(Z==null?void 0:Z.completeUrl)||""},[a]),Je=(ge=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const Z=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(Z),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const he=M.current.isLeft?-1:1,xe=headSize*he;animationTarget.translateX(-10*he+xe),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(he=>{const{object:xe}=he;xe.material.visible=!0})},onComplete:()=>{ge(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const he=raycast.intersectObjects(C.children,!0);O.current=he.filter(xe=>xe.distance<10),O.current.length&&O.current.forEach(xe=>{const{object:Se}=xe;Se.material.side=0}),ne.current=!1,B.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},xt=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Je()},[h]),nt=(ge,Z,he,xe=!1)=>{const Se=Z.includes("seated");if(he)me(ge,he.url,Z.includes("talking")).then(ue=>{if(ue&&BASIC_ACTIONS_TYPES_WHITELIST.includes(he.animationId))if(B.current)ce(ge,"idle");else{const be=Y.current===ge?"neutral_talking":"neutral";ce(ge,be)}});else{const ue=xe&&!Se?`${Z}-seated`:Z;ce(ge,ue)}},mt=()=>{if(!(W!=null&&W.uid)||B.current)return;const{emotion:ge,uid:Z,animation:he}=W,xe=getCurrentVisible(Z,C);if(xe){delete xe.userData._active;const{isSeated:Se}=xe;Y.current===Z?(nt(Z,"neutral",null,Se),Y.current=null):nt(Z,ge,he,Se)}},Ge=React$2.useCallback(()=>{W&&V(W.uid,W.emotion,W.animation)},[V,W]),ft=()=>{z()},Be=React$2.useCallback(()=>{B.current=!0,Oe({show:!1}),xt(),J(),h||e({type:"success"})},[N,e,xt,h]);React$2.useEffect(()=>()=>{te.current={},K()},[]);const Ye=ge=>{Oe({show:!1}),E(ge),e({type:"notifyProgress",payload:{line:ge}})},Ne=React$2.useCallback((ge=!0)=>{const Z=ge?["fromId","toId"]:["toId","fromId"],he=o.filter(ue=>ue[Z[0]]===I.id),xe=he.length===1?he[0]:he.find(ue=>ue[Z[1]]===$e);if(!(xe!=null&&xe[Z[0]])){Be();return}ge||_t(Qe.slice(0,Qe.length-1));const Se=t.findIndex(ue=>ue.id===xe[Z[1]]);Se>=0?Ye(Se):Be()},[I==null?void 0:I.id,e,o,Be,t]),De=React$2.useCallback((ge,Z)=>{const he=[3,2,1][ge.id],Se=o.filter(be=>be.fromId===(I==null?void 0:I.id)).find(be=>parseInt(be.fromPointIndex)===he),ue=t.findIndex(be=>be.id===(Se==null?void 0:Se.toId));ue>=0?(Se==null?void 0:Se.fromId)===(Se==null?void 0:Se.toId)?Z():Ye(ue):Be()},[I==null?void 0:I.id,o,Be,t]),_e=React$2.useCallback(()=>{if(te.current={...W},w(!1),mt(),X)Ne(!1);else if(!Pe()){const ge=y-1;Oe({show:!1}),E(ge),e({type:"notifyProgress",payload:{line:ge}})}},[Ne,e,X,$,y,W]),ke=React$2.useCallback(ge=>{if(X){if(ge){const Z=[3,2,1][ge.id],xe=o.filter(Se=>Se.fromId===I.id).find(Se=>parseInt(Se.fromPointIndex)===Z);if(xe){const Se=t.findIndex(ue=>ue.id===xe.toId);Se>=0&&e({type:"notifyProgress",payload:{line:Se}})}else e({type:"saveNode"})}}else if(y<t.length-1){const Z=y+1;e({type:"notifyProgress",payload:{line:Z}})}else e({type:"saveNode"})},[o,y,t,e,I==null?void 0:I.id,X]),Xe=React$2.useCallback((ge,Z)=>{if(te.current={...W},_t([...Qe,I.id]),w(!1),mt(),X)ge?De(ge,Z):Ne();else if(y<t.length-1){const he=y+1;Ye(he)}else(u||de||ve)&&Be()},[e,I==null?void 0:I.id,X,de,ve,y,t.length,De,Ne,Be,W]),Ft=()=>{v(!1),_e()},Dt=()=>X?I&&I.type!=="conversationalDecision"&&!o.find(ge=>ge.fromId===I.id):y===t.length-1,Le=()=>{Dt()?Be():(v(!1),Xe())};React$2.useEffect(()=>{if(X&&!b){const ge=S==null?void 0:S.line;if(ge>=0){T(!0),E(ge);return}const Z=t.filter(he=>!o.find(xe=>xe.toId===he.id));if(Z.length){const he=Z[0],xe=t.indexOf(he);xe>=0&&(T(!0),E(xe))}}},[o,X,t,b]);const ht=ge=>{if(te.current.uid===ge.uid||M.current.parent===ge)return;const Z=new three.Object3D,he=ge.getObjectByName("Head_M");he.updateMatrixWorld(!0),Z.applyMatrix4(he.matrixWorld),Z.applyQuaternion(N.quaternion);const xe=h?2.5:2,Se=h?1.2:1.5;Z.translateY(xe),Z.translateX(Se);const ue=new three.Vector3;ue.setFromMatrixPosition(he.matrixWorld);const Ie=ue.project(N).x<0;M.current={pos:Z.position.toArray(),child:he,parent:ge,isLeft:Ie}},Tt=ge=>{e({type:"resetZIndexUIContainer",payload:ge})};React$2.useEffect(()=>{var ge;if(fe)xt(),Oe({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${lt("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Ve(W),show:!0});else if(!B.current&&!de&&!ve){const Z=I==null?void 0:I.slots.filter(Se=>Se.uid&&!Se.talking),he=[...Z.map(Se=>Se.uid)||[],W==null?void 0:W.uid];if(Ke.filter(Se=>!he.includes(Se)).forEach(Se=>{ce(Se,"idle")}),Z.forEach(Se=>{const ue=getCurrentVisible(Se.uid,C);if(ue){const{isSeated:be}=ue;nt(Se.uid,Se.emotion,Se.animation,be)}}),W){const Se=getCurrentVisible(W.uid,C),ue=a.find(be=>be.uid===W.uid);Se&&!B.current?setTimeout(()=>{var be,Ie;if(W.uid===Se.uid){ht(Se);const{isSeated:et,userData:ct}=Se,{emotion:Rt,animation:pt}=W;!((be=ct._active)!=null&&be.includes("talking"))&&!((Ie=ct._active)!=null&&Ie.includes(Rt))&&nt(W.uid,Rt,pt,et);const dt=()=>{var Nt;Oe({text:W.text,name:W.alias||((Nt=W.character)==null?void 0:Nt.name),inScene:!0,thinkful:W.emotion.includes("think"),avatar:Ve(W),show:!0})};h?(ne.current=!1,Je(dt)):dt()}},150):(xt(),Oe({text:W.text,name:W.alias||((ge=W.character)==null?void 0:ge.name)||(ue==null?void 0:ue.name),left:!1,top:W.text.length>maxCharacterToSwitch,inScene:!1,thinkful:W.emotion.includes("think"),avatar:Ve(W),show:!0}))}else xt(),Oe({show:!0})}},[a,I,h,C,lt,Ve,xt,de,fe,Ke]);const it=cleanTextOfHtmlTags(Te==null?void 0:Te.text),[At,Ct]=useEkho({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:Te.show,text:it,audio:I==null?void 0:I.audio,soundActions:d,getEvent:n,pauseTTS:p,onStart:()=>{},onError:()=>{mt(),w(!0)},onFinish:()=>{mt(),Re&&!p&&Xe()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[y,Ct]),React$2.useEffect(()=>{var ge;if(((I==null?void 0:I.audioType)==="none"||_)&&(Te!=null&&Te.show)&&!(W!=null&&W.emotion.includes("think"))){const Z=characterMs*(((ge=Te==null?void 0:Te.text)==null?void 0:ge.length)||0);setTimeout(()=>{mt()},Z<minMs?minMs:Z)}},[_,I==null?void 0:I.audioType,W==null?void 0:W.emotion,Te]),React$2.useEffect(()=>{var ge;if(Re&&Te.show&&((I==null?void 0:I.audioType)==="none"||_)&&!p){const Z=characterMs*(((ge=Te==null?void 0:Te.text)==null?void 0:ge.length)||0);(!Dt()||Dt()&&u)&&D(Xe,Z<minMs?minMs:Z)}return()=>{P()}},[Te,Xe,D,u,P,I==null?void 0:I.audioType,Re,ie,le,_]);const Xt=React$2.useMemo(()=>y===0||Pe()||Ue(),[y,Pe,Ue]),ut=l({disabled:de||!Te.show,repeat:!1,forward:Le,rewind:Xt?null:Ft});React$2.useEffect(()=>ut(),[ut]);const Vt=document.querySelector(".screens--container");if(ve)return jsxRuntimeExports.jsx(ChangeCamera,{...I,emitEvent:e,success:!1,onFinish:Xe},`change-camera-${y}`);if(de){const ge=I.id?t.filter(he=>he.decision).findIndex(he=>he.id===I.id)+1:t.filter(he=>he.decision).findIndex(he=>he===I)+1,Z={...I.payload,decisionNumber:ge,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:ke,onFinish:Xe,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{xt(),Tt(!0)},onUnMount:()=>{ne.current=!1,Tt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...Z})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[Te.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:lt,currentMessage:Te}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Vt?{current:Vt}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:Ft,disabled:Xt||!Te.show,className:`gat--btn__round ${Xt||!Te.show?"disabled":""}`,"aria-label":LangIsRtl()?lt("storylines.misc.forward"):lt("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Le,disabled:!Te.show,className:`gat--btn__round
|
|
273
273
|
${Te.show?"":"disabled"}
|
|
274
274
|
${g&&Dt()?"glowing-animation":""}`,"aria-label":LangIsRtl()?lt("storylines.misc.rewind"):lt("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:a,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(1);return React$2.useEffect(()=>{h(!1)},[a.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",a.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:a.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const S=p.userData.animator,R=()=>{S.getAction(l.url).setLoop(three.LoopRepeat,1/0),u.current=1;function E(){u.current>=e&&(S.mix("idle"),n(),S.removeEventListener("loop",E)),u.current+=1}S.mix(l==null?void 0:l.url).then(g=>{g&&S.addEventListener("loop",E)}),h(!0)};S.getAction(l==null?void 0:l.url)?R():assetLoader.load(l==null?void 0:l.url,y=>{S.register(l==null?void 0:l.url,y.animations[0]),R()},void 0,y=>{console.error(`Asset loader failed with: ${l.url}`,y),n()})}else n()}},[f,l==null?void 0:l.url,e,d,a.uid,o,l,a,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,a=React$2.useRef(0),o=()=>{a.current+=1,a.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{a.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[a,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),S=(g,v,b)=>{g.stopPropagation(),o(a.filter(T=>T!==a[b])),v.error&&h(d-1),v.isRepeat&&u(f-1)},R=()=>{p.current&&p.current.focus()},y=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},E=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],T=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(T.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?a.find(w=>w.text===v)?(u(f+1),o([...a,{text:v,error:!0,isRepeat:!0}])):o([...a,{text:v}]):(o([...a,{text:v,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:R,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[a&&a.map((g,v)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>S(b,g,v),emailPillIndex:v},`${a.indexOf(g)}`)),a.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:y,onKeyDown:E,onBlur:E,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[a.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||a.length===0?" disabled":""}`,type:"button",disabled:d>0||a.length===0,onClick:()=>l(a),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[a,o]=React$2.useState(!1),d=()=>{o(!a)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),a?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:a}){const o=y=>e({type:"translate",payload:y}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async y=>{const E=y.map(v=>v.text),g=await l({type:"sendReferrals",payload:E});f.current=g&&g.data?g.data.valid.length:0,u.current=E.length-f.current,h("step2")};if(!a)return l({type:"success"}),null;const S=()=>{l({type:"success"})},R=()=>{if(f.current){const y=t.map(E=>(E.points*=f.current,E));l({type:"addPoints",complex:!0,finish:!0,payload:y})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:S,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:R,valid:f,invalid:u})]})})}function PseudoNoEvaluationEvent({onPass:l}){return React$2.useEffect(()=>{const e=setTimeout(l,0);return()=>clearTimeout(e)},[l]),null}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:a,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u,noEvaluation:p}){const[S]=f,[R,y]=React$2.useState(!1),[E,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),T=D=>h({type:"translate",payload:D}),_=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(a.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(O=>O.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),y({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(O=>O.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],y({...P,success:!1})}},[a,l,t,e,o,d,n]),C=React$2.useCallback(()=>{if(a.find(P=>P===(l==null?void 0:l.uid))){let P;t?P=[...o.resolvers.rights.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.resolvers.rights[0].rewards.filter(F=>F.type==="var")],e&&d({type:"consumeItem",payload:{uid:l==null?void 0:l.uid,targetId:l==null?void 0:l.uid,name:l==null?void 0:l.name}}),b({varsPoints:[...P],success:!0})}else{let P;n?P=[...o.notResolvers.wrongs.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.notResolvers.wrongs[0].rewards.filter(F=>F.type==="var")],b({varsPoints:[...P],success:!1})}},[e,d,o.notResolvers.wrongs,o.resolvers.rights,n,t,l==null?void 0:l.name,l==null?void 0:l.uid,a]),N=React$2.useCallback(()=>{g(!1),d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]})},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v!=null&&v.success&&g(!0)},[v]),E?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:N}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:S,hasTimeout:!R.desc,delay:2e3,translate:T,keyboardControl:u,functionOnClose:_}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver:a}){const[o,d]=React$2.useState(l),[h,f]=React$2.useState(!1),u=React$2.useRef();React$2.useEffect(()=>{t&&(d(l),f(!1))},[t,l]),React$2.useEffect(()=>{e&&f(!1)},[e]),React$2.useEffect(()=>{n&&f(!0)},[n]),React$2.useEffect(()=>(h&&o>0?u.current=setInterval(()=>{d(S=>S-1),o===1&&a()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,a,o]);const p=S=>{const R=Math.floor(S/60),y=S%60,E=String(R).padStart(2,"0"),g=String(y).padStart(2,"0");return`${E}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:a,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:S,timer:R=0,keyboardControl:y}){const E=Ae=>n({type:"translate",payload:Ae}),g=`match-puzzle_${d}`,[v,b]=React$2.useState([]),[T,_]=React$2.useState(null),[w,C]=React$2.useState(!1),[N,D]=React$2.useState(!1),[P,O]=React$2.useState(""),[F,M]=React$2.useState(!1),[I,$]=React$2.useState([]),[B]=e;useEkho({soundActions:e});const X=Ae=>{B("click-ui"),_(Ae.id)},re=Ae=>{const Pe={[T]:Ae};return S.some(Ue=>{const Ve=JSON.stringify(Ue),Je=JSON.stringify(Pe);return Ve===Je})},ae=(Ae,Pe)=>{const Ue=new Map(Ae.map(Ve=>[Ve.id,{...Ve}]));return Pe.forEach(Ve=>{Ue.has(Ve.id)?Ue.get(Ve.id).points+=Ve.points:Ue.set(Ve.id,{...Ve})}),Array.from(Ue.values())},te=Ae=>{var Pe,Ue;if(B("click-ui"),re(Ae.id)){const Ve=[...v,{[T]:Ae.id}];if(b(Ve),a.specificCorrectFeedbacks){const Je=a==null?void 0:a.correctFeedbacks.find(mt=>mt.id===`${T}-${Ae.id}`),xt=ae(I,Je.rewards);$([...xt]),W(Ve)&&(lt(),M(!0)),Je.desc&&(O(Je==null?void 0:Je.desc),D(!0),C(!0),lt());const nt=W(Ve);!Je.desc&&nt&&ne(xt)}else if(W(Ve)&&(lt(),M(!0)),W(Ve)){D(!0),t.solution.right.desc&&(lt(),O(t.solution.right.desc)),C(!0),M(!0);const xt=ae(I,t.solution.right.rewards);$([...xt]),t.solution.right.desc===""&&setTimeout(()=>{ne(xt)},3e3)}_(null)}else{const Ve=ae(I,t.solution.wrong.rewards);$([...Ve]),document.querySelector(`#${Ae.id}`).classList.add("match-button--error"),document.querySelector(`#${T}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${Ae.id}`).classList.remove("match-button--error"),document.querySelector(`#${T}`).classList.remove("match-button--error"),_(null)},1e3),(Ue=(Pe=t.solution)==null?void 0:Pe.wrong)!=null&&Ue.desc&&(O(t.solution.wrong.desc),C(!0),lt())}},W=Ae=>{if(S.length!==Ae.length)return!1;const Pe=new Set(S.map(Ve=>JSON.stringify(Ve))),Ue=new Set(Ae.map(Ve=>JSON.stringify(Ve)));for(const Ve of Ue)if(!Pe.has(Ve))return!1;return!0},ne=Ae=>{B("score");const Pe=Ae?[...Ae]:[...I];l({type:"addPoints",complex:!0,finish:!0,payload:Pe}),l({type:"passPuzzle"})},ce=()=>{C(!1),D(!1),O(""),ie&&(_t(),V(!0)),!ie&&!F&&Qe(),F&&ne()},me=React$2.useMemo(()=>Object.assign({},...v),[v]),J=(Ae,Pe)=>me[Ae]===Pe;React$2.useEffect(()=>{o(()=>{B("score"),lt(),D(!0),O(t.solution.right.desc);const Ae=[...I,...t.resolve.rewards],Pe=[...S];b(Pe),setTimeout(()=>{D(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:g,rewards:Ae,finish:!0}})},5e3)})},[I,S,l,t.resolve.rewards,t.solution.right.desc,B,g,o]);const H=(Ae,Pe)=>v.findIndex(Ue=>{const Ve=Object.keys(Ue)[0],Je=Object.values(Ue)[0];return Ve===Ae&&Je===Pe}),[K,V]=React$2.useState(!0),[z,Y]=React$2.useState("storylines.misc.start"),[ie,le]=React$2.useState(!1),fe=()=>{Y("storylines.misc.retry"),V(!1),le(!1),Qe()},[de,ve]=React$2.useState(!1),[Re,Te]=React$2.useState(!1),[Oe,Fe]=React$2.useState(!1),Ke=()=>{let Ae=ae(I,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const Pe=new Map(Ae.map(Ue=>[Ue.id,{...Ue}]));v.forEach(Ue=>{const Ve=Object.keys(Ue)[0],Je=Ue[Ve],xt=a.correctFeedbacks.find(nt=>nt.id===`${Ve}-${Je}`);xt!=null&&xt.rewards&&xt.rewards.forEach(nt=>{if(Pe.has(nt.id)){const mt=Pe.get(nt.id);mt.points-=nt.points,Pe.set(nt.id,mt)}})}),Ae=Array.from(Pe.values())}$(Ae),b([]),le(!0),O(t.timerFeedback.desc),C(!0)},lt=()=>{ve(!0),Te(!1),Fe(!1)},Qe=()=>{ve(!1),Te(!0),Fe(!1)},_t=()=>{ve(!1),Te(!1),Fe(!0)},$e=React$2.useCallback(()=>{const Ae=document.querySelector('button[id^="source-item"]'),Pe=document.querySelector('button[id^="destination-item"]'),Ue=Ae.getBoundingClientRect().right,Je=Pe.getBoundingClientRect().left+6-Ue;u.items.forEach((xt,nt)=>{if(xt.matchDestinationId!==void 0&&xt.matchDestinationId!==null){const mt=document.querySelector(`#${xt.id}`),Ge=document.querySelector(`#${xt.matchDestinationId}`),ft=mt.getBoundingClientRect().top,Be=Ge.getBoundingClientRect().top,Ye=Be>ft,Ne=Math.abs(Be-ft),De=Math.sqrt(Je*Je+Ne*Ne),_e=mt.querySelector(".match-line__hipotenuse");_e.style.setProperty("width",`${De}px`);const ke=Math.atan(Ne/Je),Xe=Ye?ke*(180/Math.PI):-ke*(180/Math.PI);_e.style.setProperty("transform",`rotate(${Xe}deg)`)}})},[u.items]);return React$2.useEffect(()=>($e(),window.addEventListener("resize",$e),()=>{window.removeEventListener("resize",$e)}),[$e]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"match",children:[(f||R>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:f}),R>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:de,shouldStart:Re,shouldReset:Oe,onTimeOver:Ke})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:u.title}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map((Ae,Pe)=>jsxRuntimeExports.jsxs("button",{id:Ae.id,"data-testid":Ae.id,className:["unset-button match-button",T===Ae.id&&"match-button--marked",J(Ae.id,Ae.matchDestinationId)&&"match-button--success",H(Ae.id,Ae.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${H(Ae.id,Ae.matchDestinationId)+1})`},disabled:J(Ae.id,Ae.matchDestinationId),type:"button",onClick:()=>X(Ae),children:[jsxRuntimeExports.jsx(MatchItem,{item:Ae,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},Ae.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:p.title}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map((Ae,Pe)=>jsxRuntimeExports.jsxs("button",{id:Ae.id,"data-testid":Ae.id,className:["unset-button match-button",T===Ae.id&&"match-button--marked",J(Ae.matchSourceId,Ae.id)&&"match-button--success",H(Ae.matchSourceId,Ae.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${H(Ae.matchSourceId,Ae.id)+1})`},disabled:J(Ae.matchSourceId,Ae.id)||T===null&&!J(Ae.matchSourceId,Ae.id),type:"button",onClick:()=>te(Ae),children:[jsxRuntimeExports.jsx(MatchItem,{item:Ae,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},Ae.id))})]})]})})]}),R>0&&K&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:z,translate:E,onClose:fe}),w&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:N,text:P,hasTimeout:!P,translate:E,timeExpired:ie,functionOnClose:ce,keyboardControl:y})]})}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.MatchPuzzleComponent=MatchPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
|
|
275
275
|
//# sourceMappingURL=arcade-components.cjs.map
|