@gamelearn/arcade-components 3.31.4 → 3.31.5
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"),_=100,R=a==="px",x=a==="%",S,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),(x||d==="%")&&(_transformProps[n]||~n.indexOf("adius")))return S=b?e.getBBox()[f?"width":"height"]:e[p],_round(x?o/S*_:o/100*S);if(h[f?"width":"height"]=_+(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&&x&&v.width&&f&&v.time===_ticker.time&&!v.uncache)return _round(o/v.width*_);if(x&&(n==="height"||n==="width")){var T=e.style[n];e.style[n]=_+a,S=e[p],T?e.style[n]=T:_removeProperty(e,n)}else(x||d==="%")&&!_nonStandardLayouts[_getComputedProperty(g,"display")]&&(h.position=_getComputedProperty(e,"position")),g===e&&(h.position="static"),g.appendChild(_tempDiv),S=_tempDiv[p],g.removeChild(_tempDiv),h.position="absolute";return f&&x&&(v=_getCache(g),v.time=_ticker.time,v.width=g[p]),_round(R?S*o/_:S&&o?_/S*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,_,R,x,S,g,v,b,T,y,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(;_=_numWithUnitExp.exec(a);)v=_[0],T=a.substring(f,_.index),S?S=(S+1)%5:(T.substr(-5)==="rgba("||T.substr(-5)==="hsla(")&&(S=1),v!==(g=R[u++]||"")&&(x=parseFloat(g)||0,w=g.substr((x+"").length),v.charAt(1)==="="&&(v=_parseRelative(x,v)+w),b=parseFloat(v),y=v.substr((b+"").length),f=_numWithUnitExp.lastIndex-y.length,y||(y=y||_config.units[n]||w,f===a.length&&(a+=y,h.e+=y)),w!==y&&(x=_convertToUnit(e,n,g,y)||0),h._pt={_next:h._pt,p:T||u===1?T:",",s:x,c:b-x,m:S&&S<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,_=h.xOffset||0,R=h.yOffset||0,x=f[0],S=f[1],g=f[2],v=f[3],b=f[4],T=f[5],y=n.split(" "),w=parseFloat(y[0])||0,C=parseFloat(y[1])||0,N,D,P,k;t?f!==_identity2DMatrix&&(D=x*v-S*g)&&(P=w*(v/D)+C*(-g/D)+(g*T-v*b)/D,k=w*(-S/D)+C*(x/D)-(x*T-S*b)/D,w=P,C=k):(N=_getBBox(e),w=N.x+(~y[0].indexOf("%")?w/100*N.width:w),C=N.y+(~(y[1]||y[0]).indexOf("%")?C/100*N.height:C)),a||a!==!1&&h.smooth?(b=w-u,T=C-p,h.xOffset=_+(b*x+T*g)-b,h.yOffset=R+(b*S+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",_,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,_,R,x,S,g,v,b,T,y,w,C,N,D,P,k,F,M,j,$,B,X,re,ae,ee,K,ne,ue,pe,J,H,W;return p=_=R=g=v=b=T=y=w=0,x=S=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?(ee=e.getBBox(),u=t.xOrigin-ee.x+"px "+(t.yOrigin-ee.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],j=D[1],$=D[2],B=D[3],p=X=D[4],_=re=D[5],D.length===6?(x=Math.sqrt(M*M+j*j),S=Math.sqrt(B*B+$*$),g=M||j?_atan2(j,M)*_RAD2DEG:0,T=$||B?_atan2($,B)*_RAD2DEG+g:0,T&&(S*=Math.abs(Math.cos(T*_DEG2RAD))),t.svg&&(p-=C-(C*M+N*$),_-=N-(C*j+N*B))):(W=D[6],J=D[7],ne=D[8],ue=D[9],pe=D[10],H=D[11],p=D[12],_=D[13],R=D[14],P=_atan2(W,pe),v=P*_RAD2DEG,P&&(k=Math.cos(-P),F=Math.sin(-P),ae=X*k+ne*F,ee=re*k+ue*F,K=W*k+pe*F,ne=X*-F+ne*k,ue=re*-F+ue*k,pe=W*-F+pe*k,H=J*-F+H*k,X=ae,re=ee,W=K),P=_atan2(-$,pe),b=P*_RAD2DEG,P&&(k=Math.cos(-P),F=Math.sin(-P),ae=M*k-ne*F,ee=j*k-ue*F,K=$*k-pe*F,H=B*F+H*k,M=ae,j=ee,$=K),P=_atan2(j,M),g=P*_RAD2DEG,P&&(k=Math.cos(P),F=Math.sin(P),ae=M*k+j*F,ee=X*k+re*F,j=j*k-M*F,re=re*k-X*F,M=ae,X=ee),v&&Math.abs(v)+Math.abs(g)>359.9&&(v=g=0,b=180-b),x=_round(Math.sqrt(M*M+j*j+$*$)),S=_round(Math.sqrt(re*re+W*W)),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?(x*=-1,T+=g<=0?180:-180,g+=g<=0?180:-180):(S*=-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=_-((t.yPercent=_&&(!n&&t.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-_)?-50:0)))?e.offsetHeight*t.yPercent/100:0)+d,t.z=R+d,t.scaleX=_round(x),t.scaleY=_round(S),t.rotation=_round(g)+h,t.rotationX=_round(v)+h,t.rotationY=_round(b)+h,t.skewX=T+h,t.skewY=y+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,_=t.rotationX,R=t.skewX,x=t.skewY,S=t.scaleX,g=t.scaleY,v=t.transformPerspective,b=t.force3D,T=t.target,y=t.zOrigin,w="",C=b==="auto"&&e&&e!==1||b===!0;if(y&&(_!==_zeroDeg||p!==_zeroDeg)){var N=parseFloat(p)*_DEG2RAD,D=Math.sin(N),P=Math.cos(N),k;N=parseFloat(_)*_DEG2RAD,k=Math.cos(N),d=_addPxTranslate(T,d,D*k*-y),h=_addPxTranslate(T,h,-Math.sin(N)*-y),f=_addPxTranslate(T,f,P*k*-y+y)}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),_!==_zeroDeg&&(w+="rotateX("+_+_endParenthesis),(R!==_zeroDeg||x!==_zeroDeg)&&(w+="skew("+R+", "+x+_endParenthesis),(S!==1||g!==1)&&(w+="scale("+S+", "+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,_=t.scaleX,R=t.scaleY,x=t.target,S=t.xOrigin,g=t.yOrigin,v=t.xOffset,b=t.yOffset,T=t.forceCSS,y=parseFloat(d),w=parseFloat(h),C,N,D,P,k;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)*_,N=Math.sin(f)*_,D=Math.sin(f-u)*-R,P=Math.cos(f-u)*R,u&&(p*=_DEG2RAD,k=Math.tan(u-p),k=Math.sqrt(1+k*k),D*=k,P*=k,p&&(k=Math.tan(p),k=Math.sqrt(1+k*k),C*=k,N*=k)),C=_round(C),N=_round(N),D=_round(D),P=_round(P)):(C=_,P=R,N=D=0),(y&&!~(d+"").indexOf("px")||w&&!~(h+"").indexOf("px"))&&(y=_convertToUnit(x,"x",d,"px"),w=_convertToUnit(x,"y",h,"px")),(S||g||v||b)&&(y=_round(y+S-(S*C+g*D)+v),w=_round(w+g-(S*N+g*P)+b)),(a||o)&&(k=x.getBBox(),y=_round(y+a/100*k.width),w=_round(w+o/100*k.height)),k="matrix("+C+","+N+","+D+","+P+","+y+","+w+")",x.setAttribute("transform",k),T&&(x.style[_transformProp]=k)},_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",_,R;return h&&(_=o.split("_")[1],_==="short"&&(u%=d,u!==u%(d/2)&&(u+=u<0?d:-d)),_==="cw"&&u<0?u=(u+d*_bigNum)%d-~~(u/d)*d:_==="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,_,R,x,S;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&&(x=getUnit(u),S=getUnit(p),_=x!==S?_convertToUnit(t,f,u,S):parseFloat(u),R=parseFloat(p),e._pt=new PropTween(e._pt,h,f,_,R-_,_renderCSSProp),e._pt.u=S||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,_){var R,x;if(arguments.length<4)return R=d.map(function(S){return _get(h,S,u)}),x=R.join(" "),x.split(R[0]).length===5?R[0]:x;R=(p+"").split(" "),x={},d.forEach(function(S,g){return x[S]=R[g]=R[g]||R[(g-1)/2|0]}),h.init(f,x,_)}});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,_,R,x,S,g,v,b,T,y,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(x=typeof p,S=_specialProps[g],x==="function"&&(p=p.call(t,a,e,o),x=typeof p),x==="string"&&~p.indexOf("random(")&&(p=_replaceRandom(p)),S)S(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(x!=="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=x==="string"&&p.charAt(1)==="="&&p.substr(0,2),T&&(p=p.substr(2)),_=parseFloat(p),g in _propertyAliases&&(g==="autoAlpha"&&(R===1&&_get(e,"visibility")==="hidden"&&_&&(R=0),P.push("visibility",0,h.visibility),_addNonTweeningPT(this,h,"visibility",R?"inherit":"hidden",_?"inherit":"hidden",!_)),g!=="scale"&&g!=="transform"&&(g=_propertyAliases[g],~g.indexOf(",")&&(g=g.split(",")[0]))),y=g in _transformProps,y){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+_):_)-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(y||(_||_===0)&&(R||R===0)&&!_complexExp.test(p)&&g in h)v=(u+"").substr((R+"").length),_||(_=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,y?C:h,g,R,(T?_parseRelative(R,T+_):_)-R,!y&&(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}y||(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(p=>p.scene),n=React$2.useMemo(()=>{var _;const p={};for(const R of l)if(R.slots)for(const x of R.slots){if(!x.uid)continue;const S=(_=x.character)==null?void 0:_.resource.animations;S&&(p[x.uid]||(p[x.uid]=Object.keys(S).reduce((g,v)=>(g[v]=S[v].url,g),{})))}return p},[l]),t=React$2.useMemo(()=>{const p=new Set;for(const _ of l)if(_.slots)for(const R of _.slots)R.uid&&p.add(R.uid);return Array.from(p)},[l]),a=async(p,_)=>{if(p&&!cache[p]){const{animations:R}=await loader.loadAsync(p);R[0].name=_,cache[p]=R[0]}},o=async p=>{const _=n[p],R=_.talking,x=_["talking-short"];await Promise.all([a(x,"talking-short"),a(R,"talking")])},d=()=>{t.forEach(p=>{u(p,"idle")})},h=()=>{t.forEach(p=>{const _=e.getObjectByProperty("uid",p);_&&(delete _.userData._active,u(p,"idle"))})},f=async(p,_,R=!1)=>{const x=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!x)return new Promise(g=>g(!1));const S=x.userData.animator;if(_){const g=n[p],v=g["talking-short"]||g.talking;let b=cache[v],T=_,y=cache[_];if(!y){const{animations:w}=await loader.loadAsync(_);y=cache[_]=w[0]}if(R&&v!==_&&(b?(y=mixWithTalkingClip(b,y),T+="_talking"):o(p).then(()=>{b=cache[v],y=mixWithTalkingClip(b,y),T+="_talking"})),!x.userData._active||x.userData._active!==T){x.userData._active=T;const w=S.register(T,y);return new Promise(C=>{S.mix(T,MIX_TIME).then(N=>C(N?w:!1))})}}return new Promise(g=>g(!1))},u=async(p,_)=>{const R=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!R)return new Promise(S=>S(!1));const x=R.userData.animator;if(_==="idle")return x.mix("idle",MIX_TIME),x.getAction("idle");{const S=n[p],g=_.split("_")[0],v=S[g],b=_.includes("talking");if(v){const T=`${v}_${b?"talking":"silent"}_${p}`;let y=cache[T];if(!y){let w=cache[v];if(!w){const{animations:C}=await loader.loadAsync(v);w=cache[v]=C[0]}if(b&&_!=="talking"){const C=S["talking-short"]||S.talking,N=cache[C];N?y=mixWithTalkingClip(N,w):y=w.clone()}else y=w.clone();cache[T]=y}if(!R.userData._active||R.userData._active!==_){R.userData._active=_;const w=x.register(_,y);return new Promise(C=>{x.mix(_,MIX_TIME).then(N=>C(N?w:!1))})}}}return new Promise(S=>S(!1))};return{startAnimation:u,startAnimationUrl:f,preloadTalking:o,resetActives:d,unmountActives:h}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:_}){var qt;const R=t.length-1<=(_==null?void 0:_.line)?t.length-1:(_==null?void 0:_.line)||0,[x,S]=React$2.useState(R),[g,v]=React$2.useState(!!f),[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!1),C=fiber.useThree(ke=>ke.scene),N=fiber.useThree(ke=>ke.camera),{start:D,stop:P}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),j=t[x],$=t[x-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:ae}=j||{},ee=React$2.useRef({}),K=(qt=j==null?void 0:j.slots)==null?void 0:qt.find(ke=>ke.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:pe,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),z=Object.keys((j==null?void 0:j.audio)||{}).length,Y=Object.keys((j==null?void 0:j.voice)||{}).length,ie=re||(j==null?void 0:j.type)==="conversationalNarration",le=ae||(j==null?void 0:j.type)==="conversationalDecision",fe=(j==null?void 0:j.type)==="conversationalCamera",ce=g&&!le&&!fe,[ge,Se]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1});fiber.useFrame(()=>{var ke;(ke=mt.current)!=null&&ke.node&&(mt.current.node.weights.sil>.8?Xe():St())});const Te=React$2.useMemo(()=>t.reduce((ke,pt)=>(pt.slots&&pt.slots.filter(_e=>_e.uid).forEach(_e=>{ke.includes(_e.uid)||ke.push(_e.uid)}),ke),[]),[t]),Fe=React$2.useCallback(ke=>n({type:"translate",payload:ke}),[n]),[Ne,Qe]=React$2.useState([]),st=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),Ze=React$2.useCallback(()=>{const ke=o.find(ot=>ot.fromId===st)||o.find(ot=>ot.toId===st),pt=t.find(ot=>ot.id===(ke==null?void 0:ke.fromId));return!st&&(_==null?void 0:_.line)>=0?{decision:!0}:pt},[o,t,st]),yt=React$2.useCallback(()=>{if(X){const ke=t.filter(pt=>!o.find(ot=>ot.toId===pt.id));if(ke.length){const pt=ke[0],ot=t.indexOf(pt);if(ot>=0)return ot}}return-1},[X,t,o]),Ve=React$2.useCallback(()=>{if(X){const pt=Ze();return pt==null?void 0:pt.decision}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.decision)},[j,X,t,st,o]),Me=React$2.useCallback(()=>{if(X){const pt=Ze();return(pt==null?void 0:pt.type)==="conversationalCamera"}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.type)==="conversationalCamera"},[j,X,t,st,o]),Le=React$2.useCallback(ke=>{var ot,_e;const pt=a.find(te=>(te==null?void 0:te.uid)===(ke==null?void 0:ke.uid)?te:"");return((_e=(ot=ke==null?void 0:ke.character)==null?void 0:ot.resource)==null?void 0:_e.url)||(pt==null?void 0:pt.completeUrl)||""},[a]),Ke=(ke=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const pt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(pt),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const ot=M.current.isLeft?-1:1,_e=headSize*ot;animationTarget.translateX(-10*ot+_e),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(ot=>{const{object:_e}=ot;_e.material.visible=!0})},onComplete:()=>{ke(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const ot=raycast.intersectObjects(C.children,!0);k.current=ot.filter(_e=>_e.distance<10),k.current.length&&k.current.forEach(_e=>{const{object:te}=_e;te.material.side=0}),ne.current=!1,B.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},Oe=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Ke()},[h]),qe=(ke,pt,ot,_e=!1)=>{const te=pt.includes("seated");if(ot)pe(ke,ot.url,pt.includes("talking")).then(me=>{if(me&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId))if(B.current)ue(ke,"idle");else{const Ee=V.current===ke?"neutral_talking":"neutral";ue(ke,Ee)}});else{const me=_e&&!te?`${pt}-seated`:pt;ue(ke,me)}},St=()=>{if(!K.uid||!(K!=null&&K.emotion)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){const{isSeated:te}=_e;H(pt).then(()=>{qe(pt,te&&!ke.includes("seated")?`${ke}-seated_talking`:`${ke}_talking`,ot,te),ot&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId)&&(V.current=pt)}).catch(me=>{console.error(me)})}},Xe=()=>{if(!(K!=null&&K.uid)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){delete _e.userData._active;const{isSeated:te}=_e;V.current===pt?(qe(pt,"neutral",null,te),V.current=null):qe(pt,ke,ot,te)}},lt=React$2.useCallback(()=>{B.current=!0,Se({show:!1}),Oe(),J(),h||e({type:"success"})},[N,e,Oe,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const $e=ke=>{Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})},rt=React$2.useCallback((ke=!0)=>{const pt=ke?["fromId","toId"]:["toId","fromId"],ot=o.filter(me=>me[pt[0]]===j.id),_e=ot.length===1?ot[0]:ot.find(me=>me[pt[1]]===st);if(!(_e!=null&&_e[pt[0]])){lt();return}ke||Qe(Ne.slice(0,Ne.length-1));const te=t.findIndex(me=>me.id===_e[pt[1]]);te>=0?$e(te):lt()},[j==null?void 0:j.id,e,o,lt,t]),ft=React$2.useCallback((ke,pt)=>{const ot=[3,2,1][ke.id],te=o.filter(Ee=>Ee.fromId===(j==null?void 0:j.id)).find(Ee=>parseInt(Ee.fromPointIndex)===ot),me=t.findIndex(Ee=>Ee.id===(te==null?void 0:te.toId));me>=0?(te==null?void 0:te.fromId)===(te==null?void 0:te.toId)?pt():$e(me):lt()},[j==null?void 0:j.id,o,lt,t]),Ge=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Xe(),X)rt(!1);else if(!Ve()){const ke=x-1;Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})}},[rt,e,X,$,x,K]),De=React$2.useCallback(ke=>{if(X){if(ke){const pt=[3,2,1][ke.id],_e=o.filter(te=>te.fromId===j.id).find(te=>parseInt(te.fromPointIndex)===pt);if(_e){const te=t.findIndex(me=>me.id===_e.toId);te>=0&&e({type:"notifyProgress",payload:{line:te}})}else e({type:"saveNode"})}}else if(x<t.length-1){const pt=x+1;e({type:"notifyProgress",payload:{line:pt}})}else e({type:"saveNode"})},[o,x,t,e,j==null?void 0:j.id,X]),Re=React$2.useCallback((ke,pt)=>{if(ee.current={...K},w(!1),Xe(),X)Qe([...Ne,j.id]),ke?ft(ke,pt):rt();else if(x<t.length-1){const ot=x+1;$e(ot)}else(u||le||fe)&<()},[e,j==null?void 0:j.id,X,le,fe,x,t.length,ft,rt,lt,K]),ye=()=>{v(!1),Ge()},Pe=()=>X?j&&j.type!=="conversationalDecision"&&!o.find(ke=>ke.fromId===j.id):x===t.length-1,Ye=()=>{Pe()?lt():(v(!1),Re())};React$2.useEffect(()=>{if(X&&!b){const ke=_==null?void 0:_.line;if(ke>=0){T(!0),S(ke);return}const pt=yt();pt>=0&&(T(!0),S(pt))}},[o,X,t,b,yt]);const Ft=ke=>{if(ee.current.uid===ke.uid||M.current.parent===ke)return;const pt=new three.Object3D,ot=ke.getObjectByName("Head_M");ot.updateMatrixWorld(!0),pt.applyMatrix4(ot.matrixWorld),pt.applyQuaternion(N.quaternion);const _e=h?2.5:2,te=h?1.2:1.5;pt.translateY(_e),pt.translateX(te);const me=new three.Vector3;me.setFromMatrixPosition(ot.matrixWorld);const we=me.project(N).x<0;M.current={pos:pt.position.toArray(),child:ot,parent:ke,isLeft:we}},Pt=ke=>{e({type:"resetZIndexUIContainer",payload:ke})};React$2.useEffect(()=>{var ke;if(ie)Oe(),Se({text:j==null?void 0:j.text,name:(j==null?void 0:j.alias)||(j==null?void 0:j.name)||`[ ${Fe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Le(K),show:!0});else if(!B.current&&!le&&!fe){const pt=j==null?void 0:j.slots.filter(te=>te.uid&&!te.talking),ot=[...pt.map(te=>te.uid)||[],K==null?void 0:K.uid];if(Te.filter(te=>!ot.includes(te)).forEach(te=>{ue(te,"idle")}),pt.forEach(te=>{const me=getCurrentVisible(te.uid,C);if(me){const{isSeated:Ee}=me;qe(te.uid,te.emotion,te.animation,Ee)}}),K){const te=getCurrentVisible(K.uid,C),me=a.find(Ee=>Ee.uid===K.uid);te&&!B.current?setTimeout(()=>{var Ee,we;if(K.uid===te.uid){Ft(te);const{isSeated:de,userData:be}=te,{emotion:Be,animation:tt}=K;!((Ee=be._active)!=null&&Ee.includes("talking"))&&!((we=be._active)!=null&&we.includes(Be))&&qe(K.uid,Be,tt,de);const ht=()=>{var At;Se({text:K.text,name:K.alias||((At=K.character)==null?void 0:At.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0})};h?(ne.current=!1,Ke(ht)):ht()}},150):(Oe(),Se({text:K.text,name:K.alias||((ke=K.character)==null?void 0:ke.name)||(me==null?void 0:me.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0}))}else Oe(),Se({show:!0})}},[a,j,h,C,Fe,Le,Oe,le,ie,Te]);const Ie=cleanTextOfHtmlTags(ge==null?void 0:ge.text),[mt,Ct]=useEkho({audioType:j==null?void 0:j.audioType,volume:j==null?void 0:j.audioVolume,voice:j==null?void 0:j.voice,started:ge.show,text:Ie,audio:j==null?void 0:j.audio,soundActions:d,getEvent:n,pauseTTS:p,onError:()=>{w(!0)},onFinish:()=>{Xe(),ce&&!p&&Re()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[x,Ct]),React$2.useEffect(()=>{var ke;if(((j==null?void 0:j.audioType)==="none"||y)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){St();const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);setTimeout(()=>{Xe()},pt<minMs?minMs:pt)}},[y,j==null?void 0:j.audioType,Xe,St,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var ke;if(ce&&ge.show&&((j==null?void 0:j.audioType)==="none"||y)&&!p){const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);(!Pe()||Pe()&&u)&&D(Re,pt<minMs?minMs:pt)}return()=>{P()}},[ge,Re,D,u,P,j==null?void 0:j.audioType,ce,z,Y,y]);const at=React$2.useMemo(()=>yt()>=0&&Ne.length===0&&X||!X&&x===0||Ve()||Me(),[x,Ve,Me,yt,Ne]),wt=l({disabled:le||!ge.show,repeat:!1,forward:Ye,rewind:at?null:ye});React$2.useEffect(()=>wt(),[wt]);const Nt=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...j,emitEvent:e,success:!1,onFinish:Re},`change-camera-${x}`);if(le){const ke=j.id?t.filter(ot=>ot.decision).findIndex(ot=>ot.id===j.id)+1:t.filter(ot=>ot.decision).findIndex(ot=>ot===j)+1,pt={...j.payload,decisionNumber:ke,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:De,onFinish:Re,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{Oe(),Pt(!0)},onUnMount:()=>{ne.current=!1,Pt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...pt})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Fe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Nt?{current:Nt}: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:ye,disabled:at||!ge.show,className:`gat--btn__round ${at||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.forward"):Fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Ye,disabled:!ge.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(p=>p.scene),n=React$2.useMemo(()=>{var _;const p={};for(const R of l)if(R.slots)for(const x of R.slots){if(!x.uid)continue;const S=(_=x.character)==null?void 0:_.resource.animations;S&&(p[x.uid]||(p[x.uid]=Object.keys(S).reduce((g,v)=>(g[v]=S[v].url,g),{})))}return p},[l]),t=React$2.useMemo(()=>{const p=new Set;for(const _ of l)if(_.slots)for(const R of _.slots)R.uid&&p.add(R.uid);return Array.from(p)},[l]),a=async(p,_)=>{if(p&&!cache[p]){const{animations:R}=await loader.loadAsync(p);R[0].name=_,cache[p]=R[0]}},o=async p=>{const _=n[p],R=_.talking,x=_["talking-short"];await Promise.all([a(x,"talking-short"),a(R,"talking")])},d=()=>{t.forEach(p=>{u(p,"idle")})},h=()=>{t.forEach(p=>{const _=e.getObjectByProperty("uid",p);_&&(delete _.userData._active,u(p,"idle"))})},f=async(p,_,R=!1)=>{const x=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!x)return new Promise(g=>g(!1));const S=x.userData.animator;if(_){const g=n[p],v=g["talking-short"]||g.talking;let b=cache[v],T=_,y=cache[_];if(!y){const{animations:w}=await loader.loadAsync(_);y=cache[_]=w[0]}if(R&&v!==_&&(b?(y=mixWithTalkingClip(b,y),T+="_talking"):o(p).then(()=>{b=cache[v],y=mixWithTalkingClip(b,y),T+="_talking"})),!x.userData._active||x.userData._active!==T){x.userData._active=T;const w=S.register(T,y);return new Promise(C=>{S.mix(T,MIX_TIME).then(N=>C(N?w:!1))})}}return new Promise(g=>g(!1))},u=async(p,_)=>{const R=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!R)return new Promise(S=>S(!1));const x=R.userData.animator;if(_==="idle")return x.mix("idle",MIX_TIME),x.getAction("idle");{const S=n[p],g=_.split("_")[0],v=S[g],b=_.includes("talking");if(v){const T=`${v}_${b?"talking":"silent"}_${p}`;let y=cache[T];if(!y){let w=cache[v];if(!w){const{animations:C}=await loader.loadAsync(v);w=cache[v]=C[0]}if(b&&_!=="talking"){const C=S["talking-short"]||S.talking,N=cache[C];N?y=mixWithTalkingClip(N,w):y=w.clone()}else y=w.clone();cache[T]=y}if(!R.userData._active||R.userData._active!==_){R.userData._active=_;const w=x.register(_,y);return new Promise(C=>{x.mix(_,MIX_TIME).then(N=>C(N?w:!1))})}}}return new Promise(S=>S(!1))};return{startAnimation:u,startAnimationUrl:f,preloadTalking:o,resetActives:d,unmountActives:h}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:_}){var qt;const R=t.length-1<=(_==null?void 0:_.line)?t.length-1:(_==null?void 0:_.line)||0,[x,S]=React$2.useState(R),[g,v]=React$2.useState(!!f),[b,T]=React$2.useState(!1),[y,w]=React$2.useState(!1),C=fiber.useThree(ke=>ke.scene),N=fiber.useThree(ke=>ke.camera),{start:D,stop:P}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),j=t[x],$=t[x-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:ae}=j||{},ee=React$2.useRef({}),K=(qt=j==null?void 0:j.slots)==null?void 0:qt.find(ke=>ke.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:pe,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),z=Object.keys((j==null?void 0:j.audio)||{}).length,Y=Object.keys((j==null?void 0:j.voice)||{}).length,ie=re||(j==null?void 0:j.type)==="conversationalNarration",le=ae||(j==null?void 0:j.type)==="conversationalDecision",fe=(j==null?void 0:j.type)==="conversationalCamera",ce=g&&!le&&!fe,[ge,Se]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1});fiber.useFrame(()=>{var ke;(ke=mt.current)!=null&&ke.node&&(mt.current.node.weights.sil>.8?Xe():St())});const Te=React$2.useMemo(()=>t.reduce((ke,pt)=>(pt.slots&&pt.slots.filter(_e=>_e.uid).forEach(_e=>{ke.includes(_e.uid)||ke.push(_e.uid)}),ke),[]),[t]),Fe=React$2.useCallback(ke=>n({type:"translate",payload:ke}),[n]),[Ne,Qe]=React$2.useState([]),st=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),Ze=React$2.useCallback(()=>{const ke=o.find(ot=>ot.fromId===st)||o.find(ot=>ot.toId===st),pt=t.find(ot=>ot.id===(ke==null?void 0:ke.fromId));return!st&&(_==null?void 0:_.line)>=0?{decision:!0}:pt},[o,t,st]),yt=React$2.useCallback(()=>{if(X){const ke=t.filter(pt=>!o.find(ot=>ot.toId===pt.id));if(ke.length){const pt=ke[0],ot=t.indexOf(pt);if(ot>=0)return ot}}return-1},[X,t,o]),Ve=React$2.useCallback(()=>{if(X){const pt=Ze();return pt==null?void 0:pt.decision}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.decision)},[j,X,t,st,o]),Me=React$2.useCallback(()=>{if(X){const pt=Ze();return(pt==null?void 0:pt.type)==="conversationalCamera"}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.type)==="conversationalCamera"},[j,X,t,st,o]),Le=React$2.useCallback(ke=>{var ot,_e;const pt=a.find(te=>(te==null?void 0:te.uid)===(ke==null?void 0:ke.uid)?te:"");return((_e=(ot=ke==null?void 0:ke.character)==null?void 0:ot.resource)==null?void 0:_e.url)||(pt==null?void 0:pt.completeUrl)||""},[a]),Ke=(ke=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const pt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(pt),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const ot=M.current.isLeft?-1:1,_e=headSize*ot;animationTarget.translateX(-10*ot+_e),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(ot=>{const{object:_e}=ot;_e.material.visible=!0})},onComplete:()=>{ke(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const ot=raycast.intersectObjects(C.children,!0);k.current=ot.filter(_e=>_e.distance<10),k.current.length&&k.current.forEach(_e=>{const{object:te}=_e;te.material.side=0}),ne.current=!1,B.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},Oe=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Ke()},[h]),qe=(ke,pt,ot,_e=!1)=>{const te=pt.includes("seated");if(ot)pe(ke,ot.url,pt.includes("talking")).then(me=>{if(me&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId))if(B.current)ue(ke,"idle");else{const Ee=V.current===ke?"neutral_talking":"neutral";ue(ke,Ee)}});else{const me=_e&&!te?`${pt}-seated`:pt;ue(ke,me)}},St=()=>{if(!(K!=null&&K.uid)||!(K!=null&&K.emotion)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){const{isSeated:te}=_e;H(pt).then(()=>{qe(pt,te&&!ke.includes("seated")?`${ke}-seated_talking`:`${ke}_talking`,ot,te),ot&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId)&&(V.current=pt)}).catch(me=>{console.error(me)})}},Xe=()=>{if(!(K!=null&&K.uid)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){delete _e.userData._active;const{isSeated:te}=_e;V.current===pt?(qe(pt,"neutral",null,te),V.current=null):qe(pt,ke,ot,te)}},lt=React$2.useCallback(()=>{B.current=!0,Se({show:!1}),Oe(),J(),h||e({type:"success"})},[N,e,Oe,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const $e=ke=>{Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})},rt=React$2.useCallback((ke=!0)=>{const pt=ke?["fromId","toId"]:["toId","fromId"],ot=o.filter(me=>me[pt[0]]===j.id),_e=ot.length===1?ot[0]:ot.find(me=>me[pt[1]]===st);if(!(_e!=null&&_e[pt[0]])){lt();return}ke||Qe(Ne.slice(0,Ne.length-1));const te=t.findIndex(me=>me.id===_e[pt[1]]);te>=0?$e(te):lt()},[j==null?void 0:j.id,e,o,lt,t]),ft=React$2.useCallback((ke,pt)=>{const ot=[3,2,1][ke.id],te=o.filter(Ee=>Ee.fromId===(j==null?void 0:j.id)).find(Ee=>parseInt(Ee.fromPointIndex)===ot),me=t.findIndex(Ee=>Ee.id===(te==null?void 0:te.toId));me>=0?(te==null?void 0:te.fromId)===(te==null?void 0:te.toId)?pt():$e(me):lt()},[j==null?void 0:j.id,o,lt,t]),Ge=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Xe(),X)rt(!1);else if(!Ve()){const ke=x-1;Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})}},[rt,e,X,$,x,K]),De=React$2.useCallback(ke=>{if(X){if(ke){const pt=[3,2,1][ke.id],_e=o.filter(te=>te.fromId===j.id).find(te=>parseInt(te.fromPointIndex)===pt);if(_e){const te=t.findIndex(me=>me.id===_e.toId);te>=0&&e({type:"notifyProgress",payload:{line:te}})}else e({type:"saveNode"})}}else if(x<t.length-1){const pt=x+1;e({type:"notifyProgress",payload:{line:pt}})}else e({type:"saveNode"})},[o,x,t,e,j==null?void 0:j.id,X]),Re=React$2.useCallback((ke,pt)=>{if(ee.current={...K},w(!1),Xe(),X)Qe([...Ne,j.id]),ke?ft(ke,pt):rt();else if(x<t.length-1){const ot=x+1;$e(ot)}else(u||le||fe)&<()},[e,j==null?void 0:j.id,X,le,fe,x,t.length,ft,rt,lt,K]),ye=()=>{v(!1),Ge()},Pe=()=>X?j&&j.type!=="conversationalDecision"&&!o.find(ke=>ke.fromId===j.id):x===t.length-1,Ye=()=>{Pe()?lt():(v(!1),Re())};React$2.useEffect(()=>{if(X&&!b){const ke=_==null?void 0:_.line;if(ke>=0){T(!0),S(ke);return}const pt=yt();pt>=0&&(T(!0),S(pt))}},[o,X,t,b,yt]);const Ft=ke=>{if(ee.current.uid===ke.uid||M.current.parent===ke)return;const pt=new three.Object3D,ot=ke.getObjectByName("Head_M");ot.updateMatrixWorld(!0),pt.applyMatrix4(ot.matrixWorld),pt.applyQuaternion(N.quaternion);const _e=h?2.5:2,te=h?1.2:1.5;pt.translateY(_e),pt.translateX(te);const me=new three.Vector3;me.setFromMatrixPosition(ot.matrixWorld);const we=me.project(N).x<0;M.current={pos:pt.position.toArray(),child:ot,parent:ke,isLeft:we}},Pt=ke=>{e({type:"resetZIndexUIContainer",payload:ke})};React$2.useEffect(()=>{var ke;if(ie)Oe(),Se({text:j==null?void 0:j.text,name:(j==null?void 0:j.alias)||(j==null?void 0:j.name)||`[ ${Fe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Le(K),show:!0});else if(!B.current&&!le&&!fe){const pt=j==null?void 0:j.slots.filter(te=>te.uid&&!te.talking),ot=[...pt.map(te=>te.uid)||[],K==null?void 0:K.uid];if(Te.filter(te=>!ot.includes(te)).forEach(te=>{ue(te,"idle")}),pt.forEach(te=>{const me=getCurrentVisible(te.uid,C);if(me){const{isSeated:Ee}=me;qe(te.uid,te.emotion,te.animation,Ee)}}),K){const te=getCurrentVisible(K.uid,C),me=a.find(Ee=>Ee.uid===K.uid);te&&!B.current?setTimeout(()=>{var Ee,we;if(K.uid===te.uid){Ft(te);const{isSeated:de,userData:be}=te,{emotion:Be,animation:tt}=K;!((Ee=be._active)!=null&&Ee.includes("talking"))&&!((we=be._active)!=null&&we.includes(Be))&&qe(K.uid,Be,tt,de);const ht=()=>{var At;Se({text:K.text,name:K.alias||((At=K.character)==null?void 0:At.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0})};h?(ne.current=!1,Ke(ht)):ht()}},150):(Oe(),Se({text:K.text,name:K.alias||((ke=K.character)==null?void 0:ke.name)||(me==null?void 0:me.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0}))}else Oe(),Se({show:!0})}},[a,j,h,C,Fe,Le,Oe,le,ie,Te]);const Ie=cleanTextOfHtmlTags(ge==null?void 0:ge.text),[mt,Ct]=useEkho({audioType:j==null?void 0:j.audioType,volume:j==null?void 0:j.audioVolume,voice:j==null?void 0:j.voice,started:ge.show,text:Ie,audio:j==null?void 0:j.audio,soundActions:d,getEvent:n,pauseTTS:p,onError:()=>{w(!0)},onFinish:()=>{Xe(),ce&&!p&&Re()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[x,Ct]),React$2.useEffect(()=>{var ke;if(((j==null?void 0:j.audioType)==="none"||y)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){St();const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);setTimeout(()=>{Xe()},pt<minMs?minMs:pt)}},[y,j==null?void 0:j.audioType,Xe,St,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var ke;if(ce&&ge.show&&((j==null?void 0:j.audioType)==="none"||y)&&!p){const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);(!Pe()||Pe()&&u)&&D(Re,pt<minMs?minMs:pt)}return()=>{P()}},[ge,Re,D,u,P,j==null?void 0:j.audioType,ce,z,Y,y]);const at=React$2.useMemo(()=>yt()>=0&&Ne.length===0&&X||!X&&x===0||Ve()||Me(),[x,Ve,Me,yt,Ne]),wt=l({disabled:le||!ge.show,repeat:!1,forward:Ye,rewind:at?null:ye});React$2.useEffect(()=>wt(),[wt]);const Nt=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...j,emitEvent:e,success:!1,onFinish:Re},`change-camera-${x}`);if(le){const ke=j.id?t.filter(ot=>ot.decision).findIndex(ot=>ot.id===j.id)+1:t.filter(ot=>ot.decision).findIndex(ot=>ot===j)+1,pt={...j.payload,decisionNumber:ke,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:De,onFinish:Re,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{Oe(),Pt(!0)},onUnMount:()=>{ne.current=!1,Pt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...pt})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Fe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Nt?{current:Nt}: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:ye,disabled:at||!ge.show,className:`gat--btn__round ${at||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.forward"):Fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Ye,disabled:!ge.show,className:`gat--btn__round
|
|
273
273
|
${ge.show?"":"disabled"}
|
|
274
274
|
${g&&Pe()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.rewind"):Fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource: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 _=p.userData.animator,R=()=>{_.getAction(l.url).setLoop(three.LoopRepeat,1/0),u.current=1;function S(){u.current>=e&&(_.mix("idle"),n(),_.removeEventListener("loop",S)),u.current+=1}_.mix(l==null?void 0:l.url).then(g=>{g&&_.addEventListener("loop",S)}),h(!0)};_.getAction(l==null?void 0:l.url)?R():assetLoader.load(l==null?void 0:l.url,x=>{_.register(l==null?void 0:l.url,x.animations[0]),R()},void 0,x=>{console.error(`Asset loader failed with: ${l.url}`,x),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),_=(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()},x=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],T=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(T.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?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=>_(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:x,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[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=x=>e({type:"translate",payload:x}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async x=>{const S=x.map(v=>v.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!a)return l({type:"success"}),null;const _=()=>{l({type:"success"})},R=()=>{if(f.current){const x=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:x})}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:_,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[_]=f,[R,x]=React$2.useState(!1),[S,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),T=D=>h({type:"translate",payload:D}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(a.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(k=>k.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),x({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(k=>k.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],x({...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(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:N}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:_,hasTimeout:!R.desc,delay:2e3,translate:T,keyboardControl:u,functionOnClose:y}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver: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(_=>_-1),o===1&&a()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,a,o]);const p=_=>{const R=Math.floor(_/60),x=_%60,S=String(R).padStart(2,"0"),g=String(x).padStart(2,"0");return`${S}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:a,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:_,timer:R=0,keyboardControl:x,backgroundImage:S}){const g=Oe=>n({type:"translate",payload:Oe}),v=`match-puzzle_${d}`,[b,T]=React$2.useState([]),[y,w]=React$2.useState(null),[C,N]=React$2.useState(!1),[D,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[$,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=Oe=>{X("click-ui");const qe=ft=>ft==null?void 0:ft.startsWith("source-item"),St=ft=>ft==null?void 0:ft.startsWith("destination-item");if(Oe.id===y){w(null);return}const Xe=qe(Oe.id),lt=qe(y),$e=St(Oe.id),rt=St(y);if(Xe&&rt||$e&<){K(Oe);return}w(Oe.id)},ae=Oe=>{let qe;return Oe.startsWith("destination-item")?qe={[y]:Oe}:qe={[Oe]:y},_.some(St=>{const Xe=JSON.stringify(St),lt=JSON.stringify(qe);return Xe===lt})},ee=(Oe,qe)=>{const St=new Map(Oe.map(Xe=>[Xe.id,{...Xe}]));return qe.forEach(Xe=>{St.has(Xe.id)?St.get(Xe.id).points+=Xe.points:St.set(Xe.id,{...Xe})}),Array.from(St.values())},K=Oe=>{var qe,St;if(X("click-ui"),ae(Oe.id)){const Xe=Oe.id.startsWith("source-item")?Oe.id:y,lt=Oe.id.startsWith("destination-item")?Oe.id:y,$e=[...b,{[Xe]:lt}];if(T($e),a.specificCorrectFeedbacks){const rt=a==null?void 0:a.correctFeedbacks.find(De=>De.id===`${Xe}-${lt}`),ft=ee($,rt.rewards);B([...ft]),ne($e)&&(Ze(),j(!0)),rt.desc&&(F(rt==null?void 0:rt.desc),P(!0),N(!0),Ze());const Ge=ne($e);!rt.desc&&Ge&&ue(ft)}else if(ne($e)&&(Ze(),j(!0)),ne($e)){P(!0),t.solution.right.desc&&(Ze(),F(t.solution.right.desc)),N(!0),j(!0);const ft=ee($,t.solution.right.rewards);B([...ft]),t.solution.right.desc===""&&setTimeout(()=>{ue(ft)},3e3)}w(null)}else if(document.querySelector(`#${Oe.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${Oe.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),a.specificWrongFeedbacks){const Xe=Oe.id.startsWith("destination-item")?Oe.id:y,lt=a==null?void 0:a.wrongFeedbacks.find(rt=>rt.id===Xe),$e=ee($,lt.rewards);B([...$e]),lt!=null&<.desc&&(F(lt.desc),P(!1),N(!0),Ze())}else{const Xe=ee($,t.solution.wrong.rewards);B([...Xe]),(St=(qe=t.solution)==null?void 0:qe.wrong)!=null&&St.desc&&(F(t.solution.wrong.desc),N(!0),Ze())}},ne=Oe=>{if(_.length!==Oe.length)return!1;const qe=new Set(_.map(Xe=>JSON.stringify(Xe))),St=new Set(Oe.map(Xe=>JSON.stringify(Xe)));for(const Xe of St)if(!qe.has(Xe))return!1;return!0},ue=Oe=>{X("score");const qe=Oe?[...Oe]:[...$];l({type:"addPoints",complex:!0,finish:!0,payload:qe}),l({type:"passPuzzle"})},pe=()=>{N(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&yt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(Oe,qe)=>J[Oe]===qe;React$2.useEffect(()=>{o(()=>{X("score"),Ze(),P(!0),F(t.solution.right.desc);const Oe=[...$,...t.resolve.rewards],qe=[..._];T(qe),setTimeout(()=>{P(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:Oe,finish:!0}})},5e3)})},[$,_,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(Oe,qe)=>b.findIndex(St=>{const Xe=Object.keys(St)[0],lt=Object.values(St)[0];return Xe===Oe&<===qe}),[V,z]=React$2.useState(!0),[Y,ie]=React$2.useState("storylines.misc.start"),[le,fe]=React$2.useState(!1),ce=()=>{ie("storylines.misc.retry"),z(!1),fe(!1),yt()},[ge,Se]=React$2.useState(!1),[Te,Fe]=React$2.useState(!1),[Ne,Qe]=React$2.useState(!1),st=()=>{let Oe=ee($,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const qe=new Map(Oe.map(St=>[St.id,{...St}]));b.forEach(St=>{const Xe=Object.keys(St)[0],lt=St[Xe],$e=a.correctFeedbacks.find(rt=>rt.id===`${Xe}-${lt}`);$e!=null&&$e.rewards&&$e.rewards.forEach(rt=>{if(qe.has(rt.id)){const ft=qe.get(rt.id);ft.points-=rt.points,qe.set(rt.id,ft)}})}),Oe=Array.from(qe.values())}B(Oe),T([]),fe(!0),F(t.timerFeedback.desc),N(!0)},Ze=()=>{Se(!0),Fe(!1),Qe(!1)},yt=()=>{Se(!1),Fe(!0),Qe(!1)},Ve=()=>{Se(!1),Fe(!1),Qe(!0)},Me=React$2.useCallback(()=>{const Oe=document.querySelector('button[id^="source-item"]'),qe=document.querySelector('button[id^="destination-item"]'),St=Oe.getBoundingClientRect().right,lt=qe.getBoundingClientRect().left+6-St;u.items.forEach(($e,rt)=>{if($e.matchDestinationId!==void 0&&$e.matchDestinationId!==null){const ft=document.querySelector(`#${$e.id}`),Ge=document.querySelector(`#${$e.matchDestinationId}`),De=ft.getBoundingClientRect().top,Re=Ge.getBoundingClientRect().top,ye=Re>De,Pe=Math.abs(Re-De),Ye=Math.sqrt(lt*lt+Pe*Pe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Ye}px`);const Pt=Math.atan(Pe/lt),Ie=ye?Pt*(180/Math.PI):-Pt*(180/Math.PI);Ft.style.setProperty("transform",`rotate(${Ie}deg)`)}})},[u.items]);React$2.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>{window.removeEventListener("resize",Me)}),[Me]);const Le=React$2.useMemo(()=>{let Oe="";return Oe="match ",S!=null&&S.url&&(Oe+="match--with-custom-bg"),Oe},[S==null?void 0:S.url]),Ke={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Le,style:Ke,children:[(f||R>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[jsxRuntimeExports.jsx("div",{}),f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:HTMLReactParser$1(f)}),R>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:R,isPaused:ge,shouldStart:Te,shouldReset:Ne,onTimeOver:st})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(u.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.id,Oe.matchDestinationId)&&"match-button--success",W(Oe.id,Oe.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.id,Oe.matchDestinationId)+1})`},disabled:H(Oe.id,Oe.matchDestinationId),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,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"})]},Oe.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.matchSourceId,Oe.id)&&"match-button--success",W(Oe.matchSourceId,Oe.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.matchSourceId,Oe.id)+1})`},disabled:H(Oe.matchSourceId,Oe.id),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},Oe.id))})]})]})})]}),R>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:D,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:pe,keyboardControl:x})]})}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
|