@gamelearn/arcade-components 3.5.2 → 3.5.3

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 o(){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 o(e,r){return r.set(r.t,r.p,Math.round((r.s+r.c*e)*1e4)/1e4+r.u,r)},_renderPropWithEnd=function o(e,r){return r.set(r.t,r.p,e===1?r.e:Math.round((r.s+r.c*e)*1e4)/1e4+r.u,r)},_renderCSSPropWithBeginning=function o(e,r){return r.set(r.t,r.p,e?Math.round((r.s+r.c*e)*1e4)/1e4+r.u:r.b,r)},_renderRoundedCSSProp=function o(e,r){var t=r.s+r.c*e;r.set(r.t,r.p,~~(t+(t<0?-.5:.5))+r.u,r)},_renderNonTweeningValue=function o(e,r){return r.set(r.t,r.p,e?r.e:r.b,r)},_renderNonTweeningValueOnlyAtEnd=function o(e,r){return r.set(r.t,r.p,e!==1?r.b:r.e,r)},_setterCSSStyle=function o(e,r,t){return e.style[r]=t},_setterCSSProp=function o(e,r,t){return e.style.setProperty(r,t)},_setterTransform=function o(e,r,t){return e._gsap[r]=t},_setterScale=function o(e,r,t){return e._gsap.scaleX=e._gsap.scaleY=t},_setterScaleWithRender=function o(e,r,t,n,a){var u=e._gsap;u.scaleX=u.scaleY=t,u.renderTransform(a,u)},_setterTransformWithRender=function o(e,r,t,n,a){var u=e._gsap;u[r]=t,u.renderTransform(a,u)},_transformProp="transform",_transformOriginProp=_transformProp+"Origin",_saveStyle=function o(e,r){var t=this,n=this.target,a=n.style,u=n._gsap;if(e in _transformProps&&a){if(this.tfm=this.tfm||{},e!=="transform")e=_propertyAliases[e]||e,~e.indexOf(",")?e.split(",").forEach(function(l){return t.tfm[l]=_get(n,l)}):this.tfm[e]=u.x?u[e]:_get(n,e),e===_transformOriginProp&&(this.tfm.zOrigin=u.zOrigin);else return _propertyAliases.transform.split(",").forEach(function(l){return o.call(t,l,r)});if(this.props.indexOf(_transformProp)>=0)return;u.svg&&(this.svgo=n.getAttribute("data-svg-origin"),this.props.push(_transformOriginProp,r,"")),e=_transformProp}(a||r)&&this.props.push(e,r,a[e])},_removeIndependentTransforms=function o(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},_revertStyle=function o(){var e=this.props,r=this.target,t=r.style,n=r._gsap,a,u;for(a=0;a<e.length;a+=3)e[a+1]?r[e[a]]=e[a+2]:e[a+2]?t[e[a]]=e[a+2]:t.removeProperty(e[a].substr(0,2)==="--"?e[a]:e[a].replace(_capsExp,"-$1").toLowerCase());if(this.tfm){for(u in this.tfm)n[u]=this.tfm[u];n.svg&&(n.renderTransform(),r.setAttribute("data-svg-origin",this.svgo||"")),a=_reverting(),(!a||!a.isStart)&&!t[_transformProp]&&(_removeIndependentTransforms(t),n.zOrigin&&t[_transformOriginProp]&&(t[_transformOriginProp]+=" "+n.zOrigin+"px",n.zOrigin=0,n.renderTransform()),n.uncache=1)}},_getStyleSaver=function o(e,r){var t={target:e,props:[],revert:_revertStyle,save:_saveStyle};return e._gsap||gsap.core.getCache(e),r&&r.split(",").forEach(function(n){return t.save(n)}),t},_supports3D,_createElement=function o(e,r){var t=_doc.createElementNS?_doc.createElementNS((r||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),e):_doc.createElement(e);return t&&t.style?t:_doc.createElement(e)},_getComputedProperty=function o(e,r,t){var n=getComputedStyle(e);return n[r]||n.getPropertyValue(r.replace(_capsExp,"-$1").toLowerCase())||n.getPropertyValue(r)||!t&&o(e,_checkPropPrefix(r)||r,1)||""},_prefixes="O,Moz,ms,Ms,Webkit".split(","),_checkPropPrefix=function o(e,r,t){var n=r||_tempDiv,a=n.style,u=5;if(e in a&&!t)return e;for(e=e.charAt(0).toUpperCase()+e.substr(1);u--&&!(_prefixes[u]+e in a););return u<0?null:(u===3?"ms":u>=0?_prefixes[u]:"")+e},_initCore=function o(){_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 o(e){var r=_createElement("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),t=this.parentNode,n=this.nextSibling,a=this.style.cssText,u;if(_docElement.appendChild(r),r.appendChild(this),this.style.display="block",e)try{u=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=o}catch{}else this._gsapBBox&&(u=this._gsapBBox());return t&&(n?t.insertBefore(this,n):t.appendChild(this)),_docElement.removeChild(r),this.style.cssText=a,u},_getAttributeFallbacks=function o(e,r){for(var t=r.length;t--;)if(e.hasAttribute(r[t]))return e.getAttribute(r[t])},_getBBox=function o(e){var r;try{r=e.getBBox()}catch{r=_getBBoxHack.call(e,!0)}return r&&(r.width||r.height)||e.getBBox===_getBBoxHack||(r=_getBBoxHack.call(e,!0)),r&&!r.width&&!r.x&&!r.y?{x:+_getAttributeFallbacks(e,["x","cx","x1"])||0,y:+_getAttributeFallbacks(e,["y","cy","y1"])||0,width:0,height:0}:r},_isSVG=function o(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&_getBBox(e))},_removeProperty=function o(e,r){if(r){var t=e.style,n;r in _transformProps&&r!==_transformOriginProp&&(r=_transformProp),t.removeProperty?(n=r.substr(0,2),(n==="ms"||r.substr(0,6)==="webkit")&&(r="-"+r),t.removeProperty(n==="--"?r:r.replace(_capsExp,"-$1").toLowerCase())):t.removeAttribute(r)}},_addNonTweeningPT=function o(e,r,t,n,a,u){var l=new PropTween(e._pt,r,t,0,1,u?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue);return e._pt=l,l.b=n,l.e=a,e._props.push(t),l},_nonConvertibleUnits={deg:1,rad:1,turn:1},_nonStandardLayouts={grid:1,flex:1},_convertToUnit=function o(e,r,t,n){var a=parseFloat(t)||0,u=(t+"").trim().substr((a+"").length)||"px",l=_tempDiv.style,f=_horizontalExp.test(r),c=e.tagName.toLowerCase()==="svg",h=(c?"client":"offset")+(f?"Width":"Height"),y=100,E=n==="px",g=n==="%",_,p,S,C;if(n===u||!a||_nonConvertibleUnits[n]||_nonConvertibleUnits[u])return a;if(u!=="px"&&!E&&(a=o(e,r,t,"px")),C=e.getCTM&&_isSVG(e),(g||u==="%")&&(_transformProps[r]||~r.indexOf("adius")))return _=C?e.getBBox()[f?"width":"height"]:e[h],_round(g?a/_*y:a/100*_);if(l[f?"width":"height"]=y+(E?u:n),p=~r.indexOf("adius")||n==="em"&&e.appendChild&&!c?e:e.parentNode,C&&(p=(e.ownerSVGElement||{}).parentNode),(!p||p===_doc||!p.appendChild)&&(p=_doc.body),S=p._gsap,S&&g&&S.width&&f&&S.time===_ticker.time&&!S.uncache)return _round(a/S.width*y);if(g&&(r==="height"||r==="width")){var R=e.style[r];e.style[r]=y+n,_=e[h],R?e.style[r]=R:_removeProperty(e,r)}else(g||u==="%")&&!_nonStandardLayouts[_getComputedProperty(p,"display")]&&(l.position=_getComputedProperty(e,"position")),p===e&&(l.position="static"),p.appendChild(_tempDiv),_=_tempDiv[h],p.removeChild(_tempDiv),l.position="absolute";return f&&g&&(S=_getCache(p),S.time=_ticker.time,S.width=p[h]),_round(E?_*a/y:_&&a?y/_*a:0)},_get=function o(e,r,t,n){var a;return _pluginInitted||_initCore(),r in _propertyAliases&&r!=="transform"&&(r=_propertyAliases[r],~r.indexOf(",")&&(r=r.split(",")[0])),_transformProps[r]&&r!=="transform"?(a=_parseTransform(e,n),a=r!=="transformOrigin"?a[r]:a.svg?a.origin:_firstTwoOnly(_getComputedProperty(e,_transformOriginProp))+" "+a.zOrigin+"px"):(a=e.style[r],(!a||a==="auto"||n||~(a+"").indexOf("calc("))&&(a=_specialProps[r]&&_specialProps[r](e,r,t)||_getComputedProperty(e,r)||_getProperty(e,r)||(r==="opacity"?1:0))),t&&!~(a+"").trim().indexOf(" ")?_convertToUnit(e,r,a,t)+t:a},_tweenComplexCSSString=function o(e,r,t,n){if(!t||t==="none"){var a=_checkPropPrefix(r,e,1),u=a&&_getComputedProperty(e,a,1);u&&u!==t?(r=a,t=u):r==="borderColor"&&(t=_getComputedProperty(e,"borderTopColor"))}var l=new PropTween(this._pt,e.style,r,0,1,_renderComplexString),f=0,c=0,h,y,E,g,_,p,S,C,R,x,A,T;if(l.b=t,l.e=n,t+="",n+="",n==="auto"&&(p=e.style[r],e.style[r]=n,n=_getComputedProperty(e,r)||n,p?e.style[r]=p:_removeProperty(e,r)),h=[t,n],_colorStringFilter(h),t=h[0],n=h[1],E=t.match(_numWithUnitExp)||[],T=n.match(_numWithUnitExp)||[],T.length){for(;y=_numWithUnitExp.exec(n);)S=y[0],R=n.substring(f,y.index),_?_=(_+1)%5:(R.substr(-5)==="rgba("||R.substr(-5)==="hsla(")&&(_=1),S!==(p=E[c++]||"")&&(g=parseFloat(p)||0,A=p.substr((g+"").length),S.charAt(1)==="="&&(S=_parseRelative(g,S)+A),C=parseFloat(S),x=S.substr((C+"").length),f=_numWithUnitExp.lastIndex-x.length,x||(x=x||_config.units[r]||A,f===n.length&&(n+=x,l.e+=x)),A!==x&&(g=_convertToUnit(e,r,p,x)||0),l._pt={_next:l._pt,p:R||c===1?R:",",s:g,c:C-g,m:_&&_<4||r==="zIndex"?Math.round:0});l.c=f<n.length?n.substring(f,n.length):""}else l.r=r==="display"&&n==="none"?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue;return _relExp.test(n)&&(l.e=0),this._pt=l,l},_keywordToPercent={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},_convertKeywordsToPercentages=function o(e){var r=e.split(" "),t=r[0],n=r[1]||"50%";return(t==="top"||t==="bottom"||n==="left"||n==="right")&&(e=t,t=n,n=e),r[0]=_keywordToPercent[t]||t,r[1]=_keywordToPercent[n]||n,r.join(" ")},_renderClearProps=function o(e,r){if(r.tween&&r.tween._time===r.tween._dur){var t=r.t,n=t.style,a=r.u,u=t._gsap,l,f,c;if(a==="all"||a===!0)n.cssText="",f=1;else for(a=a.split(","),c=a.length;--c>-1;)l=a[c],_transformProps[l]&&(f=1,l=l==="transformOrigin"?_transformOriginProp:_transformProp),_removeProperty(t,l);f&&(_removeProperty(t,_transformProp),u&&(u.svg&&t.removeAttribute("transform"),_parseTransform(t,1),u.uncache=1,_removeIndependentTransforms(n)))}},_specialProps={clearProps:function o(e,r,t,n,a){if(a.data!=="isFromStart"){var u=e._pt=new PropTween(e._pt,r,t,0,0,_renderClearProps);return u.u=n,u.pr=-10,u.tween=a,e._props.push(t),1}}},_identity2DMatrix=[1,0,0,1,0,0],_rotationalProperties={},_isNullTransform=function o(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},_getComputedTransformMatrixAsArray=function o(e){var r=_getComputedProperty(e,_transformProp);return _isNullTransform(r)?_identity2DMatrix:r.substr(7).match(_numExp).map(_round)},_getMatrix=function o(e,r){var t=e._gsap||_getCache(e),n=e.style,a=_getComputedTransformMatrixAsArray(e),u,l,f,c;return t.svg&&e.getAttribute("transform")?(f=e.transform.baseVal.consolidate().matrix,a=[f.a,f.b,f.c,f.d,f.e,f.f],a.join(",")==="1,0,0,1,0,0"?_identity2DMatrix:a):(a===_identity2DMatrix&&!e.offsetParent&&e!==_docElement&&!t.svg&&(f=n.display,n.display="block",u=e.parentNode,(!u||!e.offsetParent)&&(c=1,l=e.nextElementSibling,_docElement.appendChild(e)),a=_getComputedTransformMatrixAsArray(e),f?n.display=f:_removeProperty(e,"display"),c&&(l?u.insertBefore(e,l):u?u.appendChild(e):_docElement.removeChild(e))),r&&a.length>6?[a[0],a[1],a[4],a[5],a[12],a[13]]:a)},_applySVGOrigin=function o(e,r,t,n,a,u){var l=e._gsap,f=a||_getMatrix(e,!0),c=l.xOrigin||0,h=l.yOrigin||0,y=l.xOffset||0,E=l.yOffset||0,g=f[0],_=f[1],p=f[2],S=f[3],C=f[4],R=f[5],x=r.split(" "),A=parseFloat(x[0])||0,T=parseFloat(x[1])||0,P,w,O,k;t?f!==_identity2DMatrix&&(w=g*S-_*p)&&(O=A*(S/w)+T*(-p/w)+(p*R-S*C)/w,k=A*(-_/w)+T*(g/w)-(g*R-_*C)/w,A=O,T=k):(P=_getBBox(e),A=P.x+(~x[0].indexOf("%")?A/100*P.width:A),T=P.y+(~(x[1]||x[0]).indexOf("%")?T/100*P.height:T)),n||n!==!1&&l.smooth?(C=A-c,R=T-h,l.xOffset=y+(C*g+R*p)-C,l.yOffset=E+(C*_+R*S)-R):l.xOffset=l.yOffset=0,l.xOrigin=A,l.yOrigin=T,l.smooth=!!n,l.origin=r,l.originIsAbsolute=!!t,e.style[_transformOriginProp]="0px 0px",u&&(_addNonTweeningPT(u,l,"xOrigin",c,A),_addNonTweeningPT(u,l,"yOrigin",h,T),_addNonTweeningPT(u,l,"xOffset",y,l.xOffset),_addNonTweeningPT(u,l,"yOffset",E,l.yOffset)),e.setAttribute("data-svg-origin",A+" "+T)},_parseTransform=function o(e,r){var t=e._gsap||new GSCache(e);if("x"in t&&!r&&!t.uncache)return t;var n=e.style,a=t.scaleX<0,u="px",l="deg",f=getComputedStyle(e),c=_getComputedProperty(e,_transformOriginProp)||"0",h,y,E,g,_,p,S,C,R,x,A,T,P,w,O,k,D,F,U,z,W,ee,Q,B,G,I,$,V,X,q,J,ne;return h=y=E=p=S=C=R=x=A=0,g=_=1,t.svg=!!(e.getCTM&&_isSVG(e)),f.translate&&((f.translate!=="none"||f.scale!=="none"||f.rotate!=="none")&&(n[_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]:"")),n.scale=n.rotate=n.translate="none"),w=_getMatrix(e,t.svg),t.svg&&(t.uncache?(G=e.getBBox(),c=t.xOrigin-G.x+"px "+(t.yOrigin-G.y)+"px",B=""):B=!r&&e.getAttribute("data-svg-origin"),_applySVGOrigin(e,B||c,!!B||t.originIsAbsolute,t.smooth!==!1,w)),T=t.xOrigin||0,P=t.yOrigin||0,w!==_identity2DMatrix&&(F=w[0],U=w[1],z=w[2],W=w[3],h=ee=w[4],y=Q=w[5],w.length===6?(g=Math.sqrt(F*F+U*U),_=Math.sqrt(W*W+z*z),p=F||U?_atan2(U,F)*_RAD2DEG:0,R=z||W?_atan2(z,W)*_RAD2DEG+p:0,R&&(_*=Math.abs(Math.cos(R*_DEG2RAD))),t.svg&&(h-=T-(T*F+P*z),y-=P-(T*U+P*W))):(ne=w[6],q=w[7],$=w[8],V=w[9],X=w[10],J=w[11],h=w[12],y=w[13],E=w[14],O=_atan2(ne,X),S=O*_RAD2DEG,O&&(k=Math.cos(-O),D=Math.sin(-O),B=ee*k+$*D,G=Q*k+V*D,I=ne*k+X*D,$=ee*-D+$*k,V=Q*-D+V*k,X=ne*-D+X*k,J=q*-D+J*k,ee=B,Q=G,ne=I),O=_atan2(-z,X),C=O*_RAD2DEG,O&&(k=Math.cos(-O),D=Math.sin(-O),B=F*k-$*D,G=U*k-V*D,I=z*k-X*D,J=W*D+J*k,F=B,U=G,z=I),O=_atan2(U,F),p=O*_RAD2DEG,O&&(k=Math.cos(O),D=Math.sin(O),B=F*k+U*D,G=ee*k+Q*D,U=U*k-F*D,Q=Q*k-ee*D,F=B,ee=G),S&&Math.abs(S)+Math.abs(p)>359.9&&(S=p=0,C=180-C),g=_round(Math.sqrt(F*F+U*U+z*z)),_=_round(Math.sqrt(Q*Q+ne*ne)),O=_atan2(ee,Q),R=Math.abs(O)>2e-4?O*_RAD2DEG:0,A=J?1/(J<0?-J:J):0),t.svg&&(B=e.getAttribute("transform"),t.forceCSS=e.setAttribute("transform","")||!_isNullTransform(_getComputedProperty(e,_transformProp)),B&&e.setAttribute("transform",B))),Math.abs(R)>90&&Math.abs(R)<270&&(a?(g*=-1,R+=p<=0?180:-180,p+=p<=0?180:-180):(_*=-1,R+=R<=0?180:-180)),r=r||t.uncache,t.x=h-((t.xPercent=h&&(!r&&t.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-h)?-50:0)))?e.offsetWidth*t.xPercent/100:0)+u,t.y=y-((t.yPercent=y&&(!r&&t.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-y)?-50:0)))?e.offsetHeight*t.yPercent/100:0)+u,t.z=E+u,t.scaleX=_round(g),t.scaleY=_round(_),t.rotation=_round(p)+l,t.rotationX=_round(S)+l,t.rotationY=_round(C)+l,t.skewX=R+l,t.skewY=x+l,t.transformPerspective=A+u,(t.zOrigin=parseFloat(c.split(" ")[2])||!r&&t.zOrigin||0)&&(n[_transformOriginProp]=_firstTwoOnly(c)),t.xOffset=t.yOffset=0,t.force3D=_config.force3D,t.renderTransform=t.svg?_renderSVGTransforms:_supports3D?_renderCSSTransforms:_renderNon3DTransforms,t.uncache=0,t},_firstTwoOnly=function o(e){return(e=e.split(" "))[0]+" "+e[1]},_addPxTranslate=function o(e,r,t){var n=getUnit(r);return _round(parseFloat(r)+parseFloat(_convertToUnit(e,"x",t+"px",n)))+n},_renderNon3DTransforms=function o(e,r){r.z="0px",r.rotationY=r.rotationX="0deg",r.force3D=0,_renderCSSTransforms(e,r)},_zeroDeg="0deg",_zeroPx="0px",_endParenthesis=") ",_renderCSSTransforms=function o(e,r){var t=r||this,n=t.xPercent,a=t.yPercent,u=t.x,l=t.y,f=t.z,c=t.rotation,h=t.rotationY,y=t.rotationX,E=t.skewX,g=t.skewY,_=t.scaleX,p=t.scaleY,S=t.transformPerspective,C=t.force3D,R=t.target,x=t.zOrigin,A="",T=C==="auto"&&e&&e!==1||C===!0;if(x&&(y!==_zeroDeg||h!==_zeroDeg)){var P=parseFloat(h)*_DEG2RAD,w=Math.sin(P),O=Math.cos(P),k;P=parseFloat(y)*_DEG2RAD,k=Math.cos(P),u=_addPxTranslate(R,u,w*k*-x),l=_addPxTranslate(R,l,-Math.sin(P)*-x),f=_addPxTranslate(R,f,O*k*-x+x)}S!==_zeroPx&&(A+="perspective("+S+_endParenthesis),(n||a)&&(A+="translate("+n+"%, "+a+"%) "),(T||u!==_zeroPx||l!==_zeroPx||f!==_zeroPx)&&(A+=f!==_zeroPx||T?"translate3d("+u+", "+l+", "+f+") ":"translate("+u+", "+l+_endParenthesis),c!==_zeroDeg&&(A+="rotate("+c+_endParenthesis),h!==_zeroDeg&&(A+="rotateY("+h+_endParenthesis),y!==_zeroDeg&&(A+="rotateX("+y+_endParenthesis),(E!==_zeroDeg||g!==_zeroDeg)&&(A+="skew("+E+", "+g+_endParenthesis),(_!==1||p!==1)&&(A+="scale("+_+", "+p+_endParenthesis),R.style[_transformProp]=A||"translate(0, 0)"},_renderSVGTransforms=function o(e,r){var t=r||this,n=t.xPercent,a=t.yPercent,u=t.x,l=t.y,f=t.rotation,c=t.skewX,h=t.skewY,y=t.scaleX,E=t.scaleY,g=t.target,_=t.xOrigin,p=t.yOrigin,S=t.xOffset,C=t.yOffset,R=t.forceCSS,x=parseFloat(u),A=parseFloat(l),T,P,w,O,k;f=parseFloat(f),c=parseFloat(c),h=parseFloat(h),h&&(h=parseFloat(h),c+=h,f+=h),f||c?(f*=_DEG2RAD,c*=_DEG2RAD,T=Math.cos(f)*y,P=Math.sin(f)*y,w=Math.sin(f-c)*-E,O=Math.cos(f-c)*E,c&&(h*=_DEG2RAD,k=Math.tan(c-h),k=Math.sqrt(1+k*k),w*=k,O*=k,h&&(k=Math.tan(h),k=Math.sqrt(1+k*k),T*=k,P*=k)),T=_round(T),P=_round(P),w=_round(w),O=_round(O)):(T=y,O=E,P=w=0),(x&&!~(u+"").indexOf("px")||A&&!~(l+"").indexOf("px"))&&(x=_convertToUnit(g,"x",u,"px"),A=_convertToUnit(g,"y",l,"px")),(_||p||S||C)&&(x=_round(x+_-(_*T+p*w)+S),A=_round(A+p-(_*P+p*O)+C)),(n||a)&&(k=g.getBBox(),x=_round(x+n/100*k.width),A=_round(A+a/100*k.height)),k="matrix("+T+","+P+","+w+","+O+","+x+","+A+")",g.setAttribute("transform",k),R&&(g.style[_transformProp]=k)},_addRotationalPropTween=function o(e,r,t,n,a){var u=360,l=_isString(a),f=parseFloat(a)*(l&&~a.indexOf("rad")?_RAD2DEG:1),c=f-n,h=n+c+"deg",y,E;return l&&(y=a.split("_")[1],y==="short"&&(c%=u,c!==c%(u/2)&&(c+=c<0?u:-u)),y==="cw"&&c<0?c=(c+u*_bigNum)%u-~~(c/u)*u:y==="ccw"&&c>0&&(c=(c-u*_bigNum)%u-~~(c/u)*u)),e._pt=E=new PropTween(e._pt,r,t,n,c,_renderPropWithEnd),E.e=h,E.u="deg",e._props.push(t),E},_assign=function o(e,r){for(var t in r)e[t]=r[t];return e},_addRawTransformPTs=function o(e,r,t){var n=_assign({},t._gsap),a="perspective,force3D,transformOrigin,svgOrigin",u=t.style,l,f,c,h,y,E,g,_;n.svg?(c=t.getAttribute("transform"),t.setAttribute("transform",""),u[_transformProp]=r,l=_parseTransform(t,1),_removeProperty(t,_transformProp),t.setAttribute("transform",c)):(c=getComputedStyle(t)[_transformProp],u[_transformProp]=r,l=_parseTransform(t,1),u[_transformProp]=c);for(f in _transformProps)c=n[f],h=l[f],c!==h&&a.indexOf(f)<0&&(g=getUnit(c),_=getUnit(h),y=g!==_?_convertToUnit(t,f,c,_):parseFloat(c),E=parseFloat(h),e._pt=new PropTween(e._pt,l,f,y,E-y,_renderCSSProp),e._pt.u=_||0,e._props.push(f));_assign(l,n)};_forEachName("padding,margin,Width,Radius",function(o,e){var r="Top",t="Right",n="Bottom",a="Left",u=(e<3?[r,t,n,a]:[r+a,r+t,n+t,n+a]).map(function(l){return e<2?o+l:"border"+l+o});_specialProps[e>1?"border"+o:o]=function(l,f,c,h,y){var E,g;if(arguments.length<4)return E=u.map(function(_){return _get(l,_,c)}),g=E.join(" "),g.split(E[0]).length===5?E[0]:g;E=(h+"").split(" "),g={},u.forEach(function(_,p){return g[_]=E[p]=E[p]||E[(p-1)/2|0]}),l.init(f,g,y)}});var CSSPlugin={name:"css",register:_initCore,targetTest:function o(e){return e.style&&e.nodeType},init:function o(e,r,t,n,a){var u=this._props,l=e.style,f=t.vars.startAt,c,h,y,E,g,_,p,S,C,R,x,A,T,P,w,O;_pluginInitted||_initCore(),this.styles=this.styles||_getStyleSaver(e),O=this.styles.props,this.tween=t;for(p in r)if(p!=="autoRound"&&(h=r[p],!(_plugins[p]&&_checkPlugin(p,r,t,n,e,a)))){if(g=typeof h,_=_specialProps[p],g==="function"&&(h=h.call(t,n,e,a),g=typeof h),g==="string"&&~h.indexOf("random(")&&(h=_replaceRandom(h)),_)_(this,e,p,h,t)&&(w=1);else if(p.substr(0,2)==="--")c=(getComputedStyle(e).getPropertyValue(p)+"").trim(),h+="",_colorExp.lastIndex=0,_colorExp.test(c)||(S=getUnit(c),C=getUnit(h)),C?S!==C&&(c=_convertToUnit(e,p,c,C)+C):S&&(h+=S),this.add(l,"setProperty",c,h,n,a,0,0,p),u.push(p),O.push(p,0,l[p]);else if(g!=="undefined"){if(f&&p in f?(c=typeof f[p]=="function"?f[p].call(t,n,e,a):f[p],_isString(c)&&~c.indexOf("random(")&&(c=_replaceRandom(c)),getUnit(c+"")||c==="auto"||(c+=_config.units[p]||getUnit(_get(e,p))||""),(c+"").charAt(1)==="="&&(c=_get(e,p))):c=_get(e,p),E=parseFloat(c),R=g==="string"&&h.charAt(1)==="="&&h.substr(0,2),R&&(h=h.substr(2)),y=parseFloat(h),p in _propertyAliases&&(p==="autoAlpha"&&(E===1&&_get(e,"visibility")==="hidden"&&y&&(E=0),O.push("visibility",0,l.visibility),_addNonTweeningPT(this,l,"visibility",E?"inherit":"hidden",y?"inherit":"hidden",!y)),p!=="scale"&&p!=="transform"&&(p=_propertyAliases[p],~p.indexOf(",")&&(p=p.split(",")[0]))),x=p in _transformProps,x){if(this.styles.save(p),A||(T=e._gsap,T.renderTransform&&!r.parseTransform||_parseTransform(e,r.parseTransform),P=r.smoothOrigin!==!1&&T.smooth,A=this._pt=new PropTween(this._pt,l,_transformProp,0,1,T.renderTransform,T,0,-1),A.dep=1),p==="scale")this._pt=new PropTween(this._pt,T,"scaleY",T.scaleY,(R?_parseRelative(T.scaleY,R+y):y)-T.scaleY||0,_renderCSSProp),this._pt.u=0,u.push("scaleY",p),p+="X";else if(p==="transformOrigin"){O.push(_transformOriginProp,0,l[_transformOriginProp]),h=_convertKeywordsToPercentages(h),T.svg?_applySVGOrigin(e,h,0,P,0,this):(C=parseFloat(h.split(" ")[2])||0,C!==T.zOrigin&&_addNonTweeningPT(this,T,"zOrigin",T.zOrigin,C),_addNonTweeningPT(this,l,p,_firstTwoOnly(c),_firstTwoOnly(h)));continue}else if(p==="svgOrigin"){_applySVGOrigin(e,h,1,P,0,this);continue}else if(p in _rotationalProperties){_addRotationalPropTween(this,T,p,E,R?_parseRelative(E,R+h):h);continue}else if(p==="smoothOrigin"){_addNonTweeningPT(this,T,"smooth",T.smooth,h);continue}else if(p==="force3D"){T[p]=h;continue}else if(p==="transform"){_addRawTransformPTs(this,h,e);continue}}else p in l||(p=_checkPropPrefix(p)||p);if(x||(y||y===0)&&(E||E===0)&&!_complexExp.test(h)&&p in l)S=(c+"").substr((E+"").length),y||(y=0),C=getUnit(h)||(p in _config.units?_config.units[p]:S),S!==C&&(E=_convertToUnit(e,p,c,C)),this._pt=new PropTween(this._pt,x?T:l,p,E,(R?_parseRelative(E,R+y):y)-E,!x&&(C==="px"||p==="zIndex")&&r.autoRound!==!1?_renderRoundedCSSProp:_renderCSSProp),this._pt.u=C||0,S!==C&&C!=="%"&&(this._pt.b=c,this._pt.r=_renderCSSPropWithBeginning);else if(p in l)_tweenComplexCSSString.call(this,e,p,c,R?R+h:h);else if(p in e)this.add(e,p,c||e[p],R?R+h:h,n,a);else if(p!=="parseTransform"){_missingPlugin(p,h);continue}x||(p in l?O.push(p,0,l[p]):O.push(p,1,c||e[p])),u.push(p)}}w&&_sortPropTweensByPriority(this)},render:function o(e,r){if(r.tween._time||!_reverting())for(var t=r._pt;t;)t.r(e,t.d),t=t._next;else r.styles.revert()},get:_get,aliases:_propertyAliases,getSetter:function o(e,r,t){var n=_propertyAliases[r];return n&&n.indexOf(",")<0&&(r=n),r in _transformProps&&r!==_transformOriginProp&&(e._gsap.x||_get(e,"x"))?t&&_recentSetterPlugin===t?r==="scale"?_setterScale:_setterTransform:(_recentSetterPlugin=t||{})&&(r==="scale"?_setterScaleWithRender:_setterTransformWithRender):e.style&&!_isUndefined(e.style[r])?_setterCSSStyle:~r.indexOf("-")?_setterCSSProp:_getSetter(e,r)},core:{_removeProperty,_getMatrix}};gsap.utils.checkPrefix=_checkPropPrefix;gsap.core.getStyleSaver=_getStyleSaver;(function(o,e,r,t){var n=_forEachName(o+","+e+","+r,function(a){_transformProps[a]=1});_forEachName(e,function(a){_config.units[a]="deg",_rotationalProperties[a]=1}),_propertyAliases[n[13]]=o+","+e,_forEachName(t,function(a){var u=a.split(":");_propertyAliases[u[1]]=n[u[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(o){_config.units[o]="px"});gsap.registerPlugin(CSSPlugin);var gsapWithCSS=gsap.registerPlugin(CSSPlugin)||gsap;gsapWithCSS.core.Tween;function SpeechBubbleComponent({message:o,translate:e},r){const[t,n]=React$2.useState(!1),a=()=>{const u=o.avatar,l=u.lastIndexOf("/");return u.includes("/object/")?u.slice(0,l).concat("/mini-thumbnail.png"):u.includes("/character/")?u.slice(0,l).concat("/mini-face.png"):u};return React$2.useLayoutEffect(()=>{t||n(!0)},[t]),jsxRuntimeExports.jsxs("div",{dir:"auto",ref:r,className:`
270
270
  speech-bubble
271
271
  ${o.thinkful?"speech-bubble--italic":""}
272
- `,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${o.thinkful?"speech-bubble__header--thinking":""}`,children:[o.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,o.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:a(),alt:o.name})}):null,o.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:o.name}),o.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),o.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:o.text}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:o,translate:e}){const r=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:r?{current:r}:void 0,style:{width:"100vw",height:"100%",position:"static",outline:"1px solid yellow"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:o})})})}const cleanStyle={width:"100vw",height:"100vh",position:"static"};function DialogDecision(o){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(o.onMount&&o.onMount(),()=>{o.onUnMount&&o.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...o})})}const cache={},loader=new GLTFLoader;function useStateMachine(o){const e=fiber.useThree(l=>l.scene),r=React$2.useMemo(()=>{var f,c,h;const l={};for(const y of o)if(y.slots)for(const E of y.slots){if(!E.uid)continue;const g=(f=E.character)==null?void 0:f.resource.animations;if(!g)continue;const _=((c=E.animation)==null?void 0:c.url)||g[E.emotion].url;l[E.uid]?l[E.uid]={...l[E.uid],[E.emotion]:_}:l[E.uid]={[E.emotion]:_},E.emotion.includes("seated")||(l[E.uid]={...l[E.uid],[`${E.emotion}-seated`]:((h=g[`${E.emotion}-seated`])==null?void 0:h.url)||g["idle-seated"].url}),l[E.uid].talking=g.talking.url}return l},[o]),t=React$2.useMemo(()=>{const l=new Set;for(const f of o)if(f.slots)for(const c of f.slots)c.uid&&l.add(c.uid);return Array.from(l)},[o]),n=()=>{t.forEach(l=>{u(l,"idle")})},a=()=>{t.forEach(l=>{const f=e.getObjectByProperty("uid",l);f&&delete f.userData._active})},u=async(l,f)=>{var E;const c=e.getObjectByProperty("uid",l);if(cache[l]||(cache[l]={}),!c)return;const{clipAction:h,defaultAnim:y}=c.userData.animation;if(f==="idle")h(y,c);else{const g=r[l],_=(E=cache[l])==null?void 0:E[f],p=cache[l].talking,S=C=>{(!c.userData._active||c.userData._active!==f)&&(c.userData._active=f,c.userData.animation.clipAction(C,c))};if(!p){const{animations:C}=await loader.loadAsync(g.talking);C[0].name="talking",cache[l].talking=C[0]}if(_)_&&S(_);else{if(f.includes("talking")){const C=f.split("_")[0];let R=cache[l][C];if(!R){const{animations:x}=await loader.loadAsync(g[C]);x[0].name=C,R=cache[l][C]=x[0]}cache[l][f]=mixWithTalkingClip(cache[l].talking,R)}else{const{animations:C}=await loader.loadAsync(g[f]);cache[l][f]=C[0]}S(cache[l][f])}}};return{startAnimation:u,resetActives:n,unmountActives:a}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:o,emitEvent:e,lines:r,actors:t,edges:n,soundActions:a,zoomInActor:u,autoPlay:l,autoEnd:f,pause:c,progress:h}){var Dt;const y=(h==null?void 0:h.line)||0,[E,g]=React$2.useState(y),[_,p]=React$2.useState(!!l),[S,C]=React$2.useState(!1),[R,x]=React$2.useState(!1),A=fiber.useThree(Ce=>Ce.scene),T=fiber.useThree(Ce=>Ce.camera),{start:P,stop:w}=useTimeout(),O=React$2.useRef([]),k=React$2.useMemo(()=>T.clone(),[]),D=React$2.useRef({pos:[0,0,0],child:null}),F=r[E],U=r[E-1],z=React$2.useRef(!1),W=!!n,{voiceOver:ee,decision:Q}=F||{},B=React$2.useRef({}),G=(Dt=F==null?void 0:F.slots)==null?void 0:Dt.find(Ce=>Ce.talking),I=React$2.useRef(!1),{startAnimation:$,resetActives:V,unmountActives:X}=useStateMachine(r),q=Object.keys((F==null?void 0:F.audio)||{}).length,J=Object.keys((F==null?void 0:F.voice)||{}).length,ne=ee||(F==null?void 0:F.type)==="conversationalNarration",ie=Q||(F==null?void 0:F.type)==="conversationalDecision",Z=F.type==="conversationalCamera",oe=_&&!ie&&!Z,[se,ce]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),fe=React$2.useMemo(()=>r.reduce((Ce,Xe)=>(Xe.slots&&Xe.slots.filter(St=>St.uid).forEach(St=>{Ce.includes(St.uid)||Ce.push(St.uid)}),Ce),[]),[r]),de=React$2.useCallback(Ce=>e({type:"translate",payload:Ce}),[e]),[xe,Ae]=React$2.useState([]),Pe=React$2.useMemo(()=>xe[xe.length-1],[xe]),Ke=React$2.useCallback(()=>{const Ce=n.find(pt=>pt.fromId===Pe)||n.find(pt=>pt.toId===Pe),Xe=r.find(pt=>pt.id===(Ce==null?void 0:Ce.fromId));return!Pe&&(h==null?void 0:h.line)>=0?{decision:!0}:Xe},[n,r,Pe]),He=React$2.useCallback(()=>{if(W){const Xe=Ke();return Xe==null?void 0:Xe.decision}const Ce=r[E-1]?r[E-1]:{};return E>0&&(Ce==null?void 0:Ce.decision)},[F,W,r,Pe,n]),Qe=React$2.useCallback(()=>{if(W){const Xe=Ke();return(Xe==null?void 0:Xe.type)==="conversationalCamera"}const Ce=r[E-1]?r[E-1]:{};return E>0&&(Ce==null?void 0:Ce.type)==="conversationalCamera"},[F,W,r,Pe,n]),ft=React$2.useCallback(Ce=>{if(!Ce)return null;let Xe;return A.traverseVisible(pt=>{pt.uid===Ce&&!Xe&&(Xe=pt)}),Xe},[A]),vt=React$2.useCallback(Ce=>{var pt,St;const Xe=t.find(et=>(et==null?void 0:et.uid)===(Ce==null?void 0:Ce.uid)?et:"");return((St=(pt=Ce==null?void 0:Ce.character)==null?void 0:pt.resource)==null?void 0:St.url)||(Xe==null?void 0:Xe.completeUrl)||""},[t]),ot=(Ce=()=>{})=>{if(I.current)I.current&&(I.current=!1);else{T.updateProjectionMatrix(),T.updateMatrixWorld(!0);const Xe=D.current.child?D.current.pos:k.position.toArray();if(animationTarget.position.fromArray(Xe),D.current.parent){animationTarget.quaternion.equals(T.quaternion)||animationTarget.applyQuaternion(T.quaternion);const pt=D.current.isLeft?-1:1,St=headSize*pt;animationTarget.translateX(-10*pt+St),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(T.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{I.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(pt=>{const{object:St}=pt;St.material.visible=!0})},onComplete:()=>{Ce(),raycast.set(T.getWorldPosition(new three.Vector3(0,0,0)),T.getWorldDirection(new three.Vector3));const pt=raycast.intersectObjects(A.children,!0);O.current=pt.filter(St=>St.distance<10),O.current.length&&O.current.forEach(St=>{const{object:et}=St;et.material.side=0}),I.current=!1,z.current&&e({type:"success"}),D.current.child||T.copy(k)},...animationTarget.position})}},dt=React$2.useCallback(()=>{D.current.child=null,D.current.parent=null,u&&ot()},[u]),Qt=()=>{if(!(G!=null&&G.emotion)||z.current)return;const{emotion:Ce,uid:Xe,animation:pt}=G,St=ft(Xe);if(St){const{isSeated:et}=St,Ht=Ce.includes("seated");$==null||$(Xe,et&&!Ht&&!pt?`${Ce}-seated_talking`:`${Ce}_talking`)}},Ot=()=>{if(!(G!=null&&G.uid)||z.current)return;const{emotion:Ce,uid:Xe,animation:pt}=G,St=ft(Xe);if(St){const{isSeated:et}=St,Ht=Ce.includes("seated");$==null||$(Xe,et&&!Ht&&!pt?`${Ce}-seated`:Ce)}},Me=React$2.useCallback(()=>{z.current=!0,g(0),ce({show:!1}),dt(),V(),u||e({type:"success"})},[T,e,dt,u]);React$2.useEffect(()=>()=>{B.current={},X()},[]);const qe=Ce=>{ce({show:!1}),g(Ce),e({type:"notifyProgress",payload:{line:Ce}})},nt=React$2.useCallback((Ce=!0)=>{const Xe=Ce?["fromId","toId"]:["toId","fromId"],pt=n.filter(Ht=>Ht[Xe[0]]===F.id),St=pt.length===1?pt[0]:pt.find(Ht=>Ht[Xe[1]]===Pe);if(!(St!=null&&St[Xe[0]])){Me();return}Ce||Ae(xe.slice(0,xe.length-1));const et=r.findIndex(Ht=>Ht.id===St[Xe[1]]);et>=0?qe(et):Me()},[F==null?void 0:F.id,e,n,Me,r]),Jt=React$2.useCallback((Ce,Xe)=>{const pt=[3,2,1][Ce.id],et=n.filter(Lt=>Lt.fromId===(F==null?void 0:F.id)).find(Lt=>parseInt(Lt.fromPointIndex)===pt),Ht=r.findIndex(Lt=>Lt.id===(et==null?void 0:et.toId));Ht>=0?(et==null?void 0:et.fromId)===(et==null?void 0:et.toId)?Xe():qe(Ht):Me()},[F==null?void 0:F.id,n,Me,r]),cr=React$2.useCallback(()=>{if(B.current={...G},x(!1),Ot(),W)nt(!1);else if(!He()){const Ce=E-1;ce({show:!1}),g(Ce),e({type:"notifyProgress",payload:{line:Ce}})}},[nt,e,W,U,E,G]),ar=React$2.useCallback(Ce=>{if(W){if(Ce){const Xe=[3,2,1][Ce.id],St=n.filter(et=>et.fromId===F.id).find(et=>parseInt(et.fromPointIndex)===Xe);if(St){const et=r.findIndex(Ht=>Ht.id===St.toId);et>=0&&e({type:"notifyProgress",payload:{line:et}})}else e({type:"saveNode"})}}else if(E<r.length-1){const Xe=E+1;e({type:"notifyProgress",payload:{line:Xe}})}else e({type:"saveNode"})},[n,E,r,e,F.id,W]),he=React$2.useCallback((Ce,Xe)=>{if(B.current={...G},Ae([...xe,F.id]),x(!1),Ot(),W)Ce?Jt(Ce,Xe):nt();else if(E<r.length-1){const pt=E+1;qe(pt)}else(f||ie||Z)&&Me()},[e,F==null?void 0:F.id,W,ie,Z,E,r.length,Jt,nt,Me,G]),pe=()=>{p(!1),cr()},ye=()=>W?F&&F.type!=="conversationalDecision"&&!n.find(Ce=>Ce.fromId===F.id):E===r.length-1,we=()=>{ye()?Me():(p(!1),he())};React$2.useEffect(()=>{if(W&&!S){const Ce=h==null?void 0:h.line;if(Ce>=0){C(!0),g(Ce);return}const Xe=r.filter(pt=>!n.find(St=>St.toId===pt.id));if(Xe.length){const pt=Xe[0],St=r.indexOf(pt);St>=0&&(C(!0),g(St))}}},[n,W,r,S]);const je=Ce=>{if(B.current.uid===Ce.uid||D.current.parent===Ce)return;const Xe=new three.Object3D,pt=Ce.getObjectByName("Head_M");pt.updateMatrixWorld(!0),Xe.applyMatrix4(pt.matrixWorld),Xe.applyQuaternion(T.quaternion);const St=u?2.5:2,et=u?1.2:1.5;Xe.translateY(St),Xe.translateX(et);const Ht=new three.Vector3;Ht.setFromMatrixPosition(pt.matrixWorld);const jr=Ht.project(T).x<0;D.current={pos:Xe.position.toArray(),child:pt,parent:Ce,isLeft:jr}},Ve=Ce=>{e({type:"resetZIndexUIContainer",payload:Ce})};React$2.useEffect(()=>{var Ce;if(ne)dt(),ce({text:F==null?void 0:F.text,name:(F==null?void 0:F.alias)||(F==null?void 0:F.name)||`[ ${de("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:vt(G),show:!0});else if(!z.current&&!ie)if(G){const Xe=F==null?void 0:F.slots.filter(Lt=>Lt.uid&&!Lt.talking),pt=[...Xe.map(Lt=>Lt.uid)||[],G==null?void 0:G.uid];fe.filter(Lt=>!pt.includes(Lt)).forEach(Lt=>{$(Lt,"idle")}),Xe.forEach(Lt=>{const jr=ft(Lt.uid);if(jr){const{isSeated:Mr}=jr,hn=Lt.emotion.includes("seated");$(Lt.uid,Mr&&!hn&&!Lt.animation?`${Lt.emotion}-seated`:Lt.emotion)}});const et=ft(G.uid),Ht=t.find(Lt=>Lt.uid===G.uid);et&&!z.current?setTimeout(()=>{var Lt,jr;if(G.uid===et.uid){je(et);const{isSeated:Mr,userData:hn}=et,{emotion:wn,animation:Ui}=G,us=wn.includes("seated");!((Lt=hn._active)!=null&&Lt.includes("talking"))&&!((jr=hn._active)!=null&&jr.includes(wn))&&$(G.uid,Mr&&!us&&!Ui?`${wn}-seated`:wn);const la=()=>{var Ci;ce({text:G.text,name:G.alias||((Ci=G.character)==null?void 0:Ci.name),inScene:!0,thinkful:G.emotion.includes("think"),avatar:vt(G),show:!0})};u?(I.current=!1,ot(la)):la()}},150):(dt(),ce({text:G.text,name:G.alias||((Ce=G.character)==null?void 0:Ce.name)||(Ht==null?void 0:Ht.name),left:!1,top:G.text.length>maxCharacterToSwitch,inScene:!1,thinkful:G.emotion.includes("think"),avatar:vt(G),show:!0}))}else dt(),ce({show:!0})},[t,F,u,ft,de,vt,dt,ie,ne,fe]);const Ie=useEkho({audioType:F==null?void 0:F.audioType,volume:F==null?void 0:F.audioVolume,voice:F==null?void 0:F.voice,started:se.show,text:se==null?void 0:se.text,audio:F==null?void 0:F.audio,slide:E,soundActions:a,emitEvent:e,pauseTTS:c,onStart:()=>{var Ce;(Ce=G==null?void 0:G.emotion)!=null&&Ce.includes("think")||Qt()},onError:()=>{x(!0)},onFinish:()=>{Ot(),oe&&!c&&he()}});React$2.useEffect(()=>(Ie(),()=>{Ie()}),[E,Ie]),React$2.useEffect(()=>{var Ce;if(((F==null?void 0:F.audioType)==="none"||R)&&(se!=null&&se.show)&&!(G!=null&&G.emotion.includes("think"))){Qt();const Xe=characterMs*(((Ce=se==null?void 0:se.text)==null?void 0:Ce.length)||0);setTimeout(()=>{Ot()},Xe<minMs?minMs:Xe)}},[R,F==null?void 0:F.audioType,G==null?void 0:G.emotion,se]),React$2.useEffect(()=>{var Ce;if(oe&&se.show&&((F==null?void 0:F.audioType)==="none"||R)&&!c){const Xe=characterMs*(((Ce=se==null?void 0:se.text)==null?void 0:Ce.length)||0);(!ye()||ye()&&f)&&P(he,Xe<minMs?minMs:Xe)}return()=>{w()}},[se,he,P,f,w,F==null?void 0:F.audioType,oe,q,J,R]);const Be=React$2.useMemo(()=>E===0||He()||Qe(),[E,He,Qe]);o(ie||Be||!se.show?null:pe,ie||!se.show?null:we);const kt=document.querySelector(".screens--container");if(Z)return jsxRuntimeExports.jsx(ChangeCamera,{...F,emitEvent:e,success:!1,onFinish:he});if(ie){const Ce={...F.payload,decisionNumber:r.filter(Xe=>Xe.decision).findIndex(Xe=>Xe.id===F.id)+1,inheritProps:{slots:[],disableBackground:!0},required:!W,branched:W,onAddPoints:ar,onFinish:he,emitEvent:e,pause:c,soundActions:a,keyboardControl:o,onMount:()=>{dt(),Ve(!0)},onUnMount:()=>{I.current=!1,Ve(!1)}};return jsxRuntimeExports.jsx(DialogDecision,{...Ce})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[se.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:de,currentMessage:se}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100vw",height:"100%",position:"static"},portal:kt?{current:kt}: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:pe,disabled:Be||!se.show,className:`gat--btn__round ${Be||!se.show?"disabled":""}`,"aria-label":LangIsRtl()?de("storylines.misc.forward"):de("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:we,disabled:!se.show,className:`gat--btn__round
272
+ `,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${o.thinkful?"speech-bubble__header--thinking":""}`,children:[o.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,o.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:a(),alt:o.name})}):null,o.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:o.name}),o.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),o.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:o.text}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:o,translate:e}){const r=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:r?{current:r}:void 0,style:{width:"100vw",height:"100%",position:"static",outline:"1px solid yellow"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:o})})})}const cleanStyle={width:"100vw",height:"100vh",position:"static"};function DialogDecision(o){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(o.onMount&&o.onMount(),()=>{o.onUnMount&&o.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...o})})}const cache={},loader=new GLTFLoader;function useStateMachine(o){const e=fiber.useThree(l=>l.scene),r=React$2.useMemo(()=>{var f,c,h,y;const l={};for(const E of o)if(E.slots)for(const g of E.slots){if(!g.uid)continue;const _=(f=g.character)==null?void 0:f.resource.animations;if(!_)continue;const p=((c=g.animation)==null?void 0:c.url)||_[g.emotion].url;l[g.uid]?(h=l[g.uid])!=null&&h[g.emotion]||(l[g.uid]={...l[g.uid],[g.emotion]:p}):l[g.uid]={[g.emotion]:p},g.emotion.includes("seated")||(l[g.uid]={...l[g.uid],[`${g.emotion}-seated`]:((y=_[`${g.emotion}-seated`])==null?void 0:y.url)||_["idle-seated"].url}),l[g.uid].talking=_.talking.url}return l},[o]),t=React$2.useMemo(()=>{const l=new Set;for(const f of o)if(f.slots)for(const c of f.slots)c.uid&&l.add(c.uid);return Array.from(l)},[o]),n=()=>{t.forEach(l=>{u(l,"idle")})},a=()=>{t.forEach(l=>{const f=e.getObjectByProperty("uid",l);f&&delete f.userData._active})},u=async(l,f)=>{var E;const c=e.getObjectByProperty("uid",l);if(cache[l]||(cache[l]={}),!c)return;const{clipAction:h,defaultAnim:y}=c.userData.animation;if(f==="idle")h(y,c);else{const g=r[l],_=(E=cache[l])==null?void 0:E[f],p=cache[l].talking,S=C=>{(!c.userData._active||c.userData._active!==f)&&(c.userData._active=f,c.userData.animation.clipAction(C,c))};if(!p){const{animations:C}=await loader.loadAsync(g.talking);C[0].name="talking",cache[l].talking=C[0]}if(_)_&&S(_);else{if(f.includes("talking")){const C=f.split("_")[0];let R=cache[l][C];if(!R){const{animations:x}=await loader.loadAsync(g[C]);x[0].name=C,R=cache[l][C]=x[0]}cache[l][f]=mixWithTalkingClip(cache[l].talking,R)}else{const{animations:C}=await loader.loadAsync(g[f]);cache[l][f]=C[0]}S(cache[l][f])}}};return{startAnimation:u,resetActives:n,unmountActives:a}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:o,emitEvent:e,lines:r,actors:t,edges:n,soundActions:a,zoomInActor:u,autoPlay:l,autoEnd:f,pause:c,progress:h}){var Dt;const y=(h==null?void 0:h.line)||0,[E,g]=React$2.useState(y),[_,p]=React$2.useState(!!l),[S,C]=React$2.useState(!1),[R,x]=React$2.useState(!1),A=fiber.useThree(Ce=>Ce.scene),T=fiber.useThree(Ce=>Ce.camera),{start:P,stop:w}=useTimeout(),O=React$2.useRef([]),k=React$2.useMemo(()=>T.clone(),[]),D=React$2.useRef({pos:[0,0,0],child:null}),F=r[E],U=r[E-1],z=React$2.useRef(!1),W=!!n,{voiceOver:ee,decision:Q}=F||{},B=React$2.useRef({}),G=(Dt=F==null?void 0:F.slots)==null?void 0:Dt.find(Ce=>Ce.talking),I=React$2.useRef(!1),{startAnimation:$,resetActives:V,unmountActives:X}=useStateMachine(r),q=Object.keys((F==null?void 0:F.audio)||{}).length,J=Object.keys((F==null?void 0:F.voice)||{}).length,ne=ee||(F==null?void 0:F.type)==="conversationalNarration",ie=Q||(F==null?void 0:F.type)==="conversationalDecision",Z=F.type==="conversationalCamera",oe=_&&!ie&&!Z,[se,ce]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),fe=React$2.useMemo(()=>r.reduce((Ce,Xe)=>(Xe.slots&&Xe.slots.filter(St=>St.uid).forEach(St=>{Ce.includes(St.uid)||Ce.push(St.uid)}),Ce),[]),[r]),de=React$2.useCallback(Ce=>e({type:"translate",payload:Ce}),[e]),[xe,Ae]=React$2.useState([]),Pe=React$2.useMemo(()=>xe[xe.length-1],[xe]),Ke=React$2.useCallback(()=>{const Ce=n.find(pt=>pt.fromId===Pe)||n.find(pt=>pt.toId===Pe),Xe=r.find(pt=>pt.id===(Ce==null?void 0:Ce.fromId));return!Pe&&(h==null?void 0:h.line)>=0?{decision:!0}:Xe},[n,r,Pe]),He=React$2.useCallback(()=>{if(W){const Xe=Ke();return Xe==null?void 0:Xe.decision}const Ce=r[E-1]?r[E-1]:{};return E>0&&(Ce==null?void 0:Ce.decision)},[F,W,r,Pe,n]),Qe=React$2.useCallback(()=>{if(W){const Xe=Ke();return(Xe==null?void 0:Xe.type)==="conversationalCamera"}const Ce=r[E-1]?r[E-1]:{};return E>0&&(Ce==null?void 0:Ce.type)==="conversationalCamera"},[F,W,r,Pe,n]),ft=React$2.useCallback(Ce=>{if(!Ce)return null;let Xe;return A.traverseVisible(pt=>{pt.uid===Ce&&!Xe&&(Xe=pt)}),Xe},[A]),vt=React$2.useCallback(Ce=>{var pt,St;const Xe=t.find(et=>(et==null?void 0:et.uid)===(Ce==null?void 0:Ce.uid)?et:"");return((St=(pt=Ce==null?void 0:Ce.character)==null?void 0:pt.resource)==null?void 0:St.url)||(Xe==null?void 0:Xe.completeUrl)||""},[t]),ot=(Ce=()=>{})=>{if(I.current)I.current&&(I.current=!1);else{T.updateProjectionMatrix(),T.updateMatrixWorld(!0);const Xe=D.current.child?D.current.pos:k.position.toArray();if(animationTarget.position.fromArray(Xe),D.current.parent){animationTarget.quaternion.equals(T.quaternion)||animationTarget.applyQuaternion(T.quaternion);const pt=D.current.isLeft?-1:1,St=headSize*pt;animationTarget.translateX(-10*pt+St),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(T.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{I.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(pt=>{const{object:St}=pt;St.material.visible=!0})},onComplete:()=>{Ce(),raycast.set(T.getWorldPosition(new three.Vector3(0,0,0)),T.getWorldDirection(new three.Vector3));const pt=raycast.intersectObjects(A.children,!0);O.current=pt.filter(St=>St.distance<10),O.current.length&&O.current.forEach(St=>{const{object:et}=St;et.material.side=0}),I.current=!1,z.current&&e({type:"success"}),D.current.child||T.copy(k)},...animationTarget.position})}},dt=React$2.useCallback(()=>{D.current.child=null,D.current.parent=null,u&&ot()},[u]),Qt=()=>{if(!(G!=null&&G.emotion)||z.current)return;const{emotion:Ce,uid:Xe,animation:pt}=G,St=ft(Xe);if(St){const{isSeated:et}=St,Ht=Ce.includes("seated");$==null||$(Xe,et&&!Ht&&!pt?`${Ce}-seated_talking`:`${Ce}_talking`)}},Ot=()=>{if(!(G!=null&&G.uid)||z.current)return;const{emotion:Ce,uid:Xe,animation:pt}=G,St=ft(Xe);if(St){const{isSeated:et}=St,Ht=Ce.includes("seated");$==null||$(Xe,et&&!Ht&&!pt?`${Ce}-seated`:Ce)}},Me=React$2.useCallback(()=>{z.current=!0,g(0),ce({show:!1}),dt(),V(),u||e({type:"success"})},[T,e,dt,u]);React$2.useEffect(()=>()=>{B.current={},X()},[]);const qe=Ce=>{ce({show:!1}),g(Ce),e({type:"notifyProgress",payload:{line:Ce}})},nt=React$2.useCallback((Ce=!0)=>{const Xe=Ce?["fromId","toId"]:["toId","fromId"],pt=n.filter(Ht=>Ht[Xe[0]]===F.id),St=pt.length===1?pt[0]:pt.find(Ht=>Ht[Xe[1]]===Pe);if(!(St!=null&&St[Xe[0]])){Me();return}Ce||Ae(xe.slice(0,xe.length-1));const et=r.findIndex(Ht=>Ht.id===St[Xe[1]]);et>=0?qe(et):Me()},[F==null?void 0:F.id,e,n,Me,r]),Jt=React$2.useCallback((Ce,Xe)=>{const pt=[3,2,1][Ce.id],et=n.filter(Lt=>Lt.fromId===(F==null?void 0:F.id)).find(Lt=>parseInt(Lt.fromPointIndex)===pt),Ht=r.findIndex(Lt=>Lt.id===(et==null?void 0:et.toId));Ht>=0?(et==null?void 0:et.fromId)===(et==null?void 0:et.toId)?Xe():qe(Ht):Me()},[F==null?void 0:F.id,n,Me,r]),cr=React$2.useCallback(()=>{if(B.current={...G},x(!1),Ot(),W)nt(!1);else if(!He()){const Ce=E-1;ce({show:!1}),g(Ce),e({type:"notifyProgress",payload:{line:Ce}})}},[nt,e,W,U,E,G]),ar=React$2.useCallback(Ce=>{if(W){if(Ce){const Xe=[3,2,1][Ce.id],St=n.filter(et=>et.fromId===F.id).find(et=>parseInt(et.fromPointIndex)===Xe);if(St){const et=r.findIndex(Ht=>Ht.id===St.toId);et>=0&&e({type:"notifyProgress",payload:{line:et}})}else e({type:"saveNode"})}}else if(E<r.length-1){const Xe=E+1;e({type:"notifyProgress",payload:{line:Xe}})}else e({type:"saveNode"})},[n,E,r,e,F.id,W]),he=React$2.useCallback((Ce,Xe)=>{if(B.current={...G},Ae([...xe,F.id]),x(!1),Ot(),W)Ce?Jt(Ce,Xe):nt();else if(E<r.length-1){const pt=E+1;qe(pt)}else(f||ie||Z)&&Me()},[e,F==null?void 0:F.id,W,ie,Z,E,r.length,Jt,nt,Me,G]),pe=()=>{p(!1),cr()},ye=()=>W?F&&F.type!=="conversationalDecision"&&!n.find(Ce=>Ce.fromId===F.id):E===r.length-1,we=()=>{ye()?Me():(p(!1),he())};React$2.useEffect(()=>{if(W&&!S){const Ce=h==null?void 0:h.line;if(Ce>=0){C(!0),g(Ce);return}const Xe=r.filter(pt=>!n.find(St=>St.toId===pt.id));if(Xe.length){const pt=Xe[0],St=r.indexOf(pt);St>=0&&(C(!0),g(St))}}},[n,W,r,S]);const je=Ce=>{if(B.current.uid===Ce.uid||D.current.parent===Ce)return;const Xe=new three.Object3D,pt=Ce.getObjectByName("Head_M");pt.updateMatrixWorld(!0),Xe.applyMatrix4(pt.matrixWorld),Xe.applyQuaternion(T.quaternion);const St=u?2.5:2,et=u?1.2:1.5;Xe.translateY(St),Xe.translateX(et);const Ht=new three.Vector3;Ht.setFromMatrixPosition(pt.matrixWorld);const jr=Ht.project(T).x<0;D.current={pos:Xe.position.toArray(),child:pt,parent:Ce,isLeft:jr}},Ve=Ce=>{e({type:"resetZIndexUIContainer",payload:Ce})};React$2.useEffect(()=>{var Ce;if(ne)dt(),ce({text:F==null?void 0:F.text,name:(F==null?void 0:F.alias)||(F==null?void 0:F.name)||`[ ${de("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:vt(G),show:!0});else if(!z.current&&!ie)if(G){const Xe=F==null?void 0:F.slots.filter(Lt=>Lt.uid&&!Lt.talking),pt=[...Xe.map(Lt=>Lt.uid)||[],G==null?void 0:G.uid];fe.filter(Lt=>!pt.includes(Lt)).forEach(Lt=>{$(Lt,"idle")}),Xe.forEach(Lt=>{const jr=ft(Lt.uid);if(jr){const{isSeated:Mr}=jr,hn=Lt.emotion.includes("seated");$(Lt.uid,Mr&&!hn&&!Lt.animation?`${Lt.emotion}-seated`:Lt.emotion)}});const et=ft(G.uid),Ht=t.find(Lt=>Lt.uid===G.uid);et&&!z.current?setTimeout(()=>{var Lt,jr;if(G.uid===et.uid){je(et);const{isSeated:Mr,userData:hn}=et,{emotion:wn,animation:Ui}=G,us=wn.includes("seated");!((Lt=hn._active)!=null&&Lt.includes("talking"))&&!((jr=hn._active)!=null&&jr.includes(wn))&&$(G.uid,Mr&&!us&&!Ui?`${wn}-seated`:wn);const la=()=>{var Ci;ce({text:G.text,name:G.alias||((Ci=G.character)==null?void 0:Ci.name),inScene:!0,thinkful:G.emotion.includes("think"),avatar:vt(G),show:!0})};u?(I.current=!1,ot(la)):la()}},150):(dt(),ce({text:G.text,name:G.alias||((Ce=G.character)==null?void 0:Ce.name)||(Ht==null?void 0:Ht.name),left:!1,top:G.text.length>maxCharacterToSwitch,inScene:!1,thinkful:G.emotion.includes("think"),avatar:vt(G),show:!0}))}else dt(),ce({show:!0})},[t,F,u,ft,de,vt,dt,ie,ne,fe]);const Ie=useEkho({audioType:F==null?void 0:F.audioType,volume:F==null?void 0:F.audioVolume,voice:F==null?void 0:F.voice,started:se.show,text:se==null?void 0:se.text,audio:F==null?void 0:F.audio,slide:E,soundActions:a,emitEvent:e,pauseTTS:c,onStart:()=>{var Ce;(Ce=G==null?void 0:G.emotion)!=null&&Ce.includes("think")||Qt()},onError:()=>{x(!0)},onFinish:()=>{Ot(),oe&&!c&&he()}});React$2.useEffect(()=>(Ie(),()=>{Ie()}),[E,Ie]),React$2.useEffect(()=>{var Ce;if(((F==null?void 0:F.audioType)==="none"||R)&&(se!=null&&se.show)&&!(G!=null&&G.emotion.includes("think"))){Qt();const Xe=characterMs*(((Ce=se==null?void 0:se.text)==null?void 0:Ce.length)||0);setTimeout(()=>{Ot()},Xe<minMs?minMs:Xe)}},[R,F==null?void 0:F.audioType,G==null?void 0:G.emotion,se]),React$2.useEffect(()=>{var Ce;if(oe&&se.show&&((F==null?void 0:F.audioType)==="none"||R)&&!c){const Xe=characterMs*(((Ce=se==null?void 0:se.text)==null?void 0:Ce.length)||0);(!ye()||ye()&&f)&&P(he,Xe<minMs?minMs:Xe)}return()=>{w()}},[se,he,P,f,w,F==null?void 0:F.audioType,oe,q,J,R]);const Be=React$2.useMemo(()=>E===0||He()||Qe(),[E,He,Qe]);o(ie||Be||!se.show?null:pe,ie||!se.show?null:we);const kt=document.querySelector(".screens--container");if(Z)return jsxRuntimeExports.jsx(ChangeCamera,{...F,emitEvent:e,success:!1,onFinish:he});if(ie){const Ce={...F.payload,decisionNumber:r.filter(Xe=>Xe.decision).findIndex(Xe=>Xe.id===F.id)+1,inheritProps:{slots:[],disableBackground:!0},required:!W,branched:W,onAddPoints:ar,onFinish:he,emitEvent:e,pause:c,soundActions:a,keyboardControl:o,onMount:()=>{dt(),Ve(!0)},onUnMount:()=>{I.current=!1,Ve(!1)}};return jsxRuntimeExports.jsx(DialogDecision,{...Ce})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[se.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:de,currentMessage:se}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100vw",height:"100%",position:"static"},portal:kt?{current:kt}: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:pe,disabled:Be||!se.show,className:`gat--btn__round ${Be||!se.show?"disabled":""}`,"aria-label":LangIsRtl()?de("storylines.misc.forward"):de("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:we,disabled:!se.show,className:`gat--btn__round
273
273
  ${se.show?"":"disabled"}
274
274
  ${_&&ye()?"glowing-animation":""}`,"aria-label":LangIsRtl()?de("storylines.misc.rewind"):de("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}function AnimationComponent({animation:o,loopTimes:e,resource:r,enableInteraction:t,makeDefault:n,emitEvent:a}){const[u,l]=React$2.useState(!1),f=fiber.useThree(h=>h.scene),c=React$2.useMemo(()=>new GLTFLoader,[]);return React$2.useEffect(()=>{l(!1)},[r.uid,o==null?void 0:o.url]),React$2.useEffect(()=>{if(!u){let h;if(f.traverseVisible(y=>{r.uid&&y.uid===r.uid&&!h&&(h=y)}),h&&o&&h.skeletonId===o.skeletonId)if(n)a({type:"saveAnimation",payload:{uid:r.uid,animation:o.id,index:h.index}}),a({type:"success"});else{const y=t;y||a({type:"success"}),c.load(o.url,E=>{const{mixer:g,clipAction:_,defaultAnim:p}=h.userData.animation;_(E.animations[0],h).setLoop(three.LoopRepeat,e);const C=()=>{g.removeEventListener("finished",C),_(p,h),y&&a({type:"success"})};g.addEventListener("finished",C),l(!0)})}else a({type:"success"})}},[f,o==null?void 0:o.url,e,a,u,c,r.uid,n,o,r,t]),null}function EmailPill({text:o,error:e,handleClick:r}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:o}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:r,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:o,handleCancel:e,translate:r,text:t}){const[n,a]=React$2.useState([]),[u,l]=React$2.useState(0),[f,c]=React$2.useState(0),h=React$2.useRef(null),y=(p,S,C)=>{p.stopPropagation(),a(n.filter(R=>R!==n[C])),S.error&&l(u-1),S.isRepeat&&c(f-1)},E=()=>{h.current&&h.current.focus()},g=()=>{[" ",",",";","."].includes(h.current.value)&&(h.current.value="")},_=p=>{const S=h.current.value,C=["Space","Comma","Period","Enter"],R=["Space","Comma","Enter","Tab"];S===""&&(C.includes(p.code)||p.keyCode==="186"||p.key==="Enter"||p.key===" ")?p.preventDefault():h.current.value.length>1&&(R.includes(p.code)||p.type==="blur")&&(p.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(S)?n.find(A=>A.text===S)?(c(f+1),a([...n,{text:S,error:!0,isRepeat:!0}])):a([...n,{text:S}]):(a([...n,{text:S,error:!0}]),l(u+1)),h.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:r("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:r("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:r("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:E,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[n&&n.map((p,S)=>jsxRuntimeExports.jsx(EmailPill,{text:p.text,error:p.error,handleClick:C=>y(C,p,S),emailPillIndex:S},`${n.indexOf(p)}`)),n.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:h,className:"referrals-piece__inputemail",onChange:g,onKeyDown:_,onBlur:_,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:r("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?r("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:u>0?r("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[n.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:r("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||u>0||n.length===0?" disabled":""}`,type:"button",disabled:u>0||n.length===0,onClick:()=>o(n),children:r("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:o,translate:e,valid:r,invalid:t}){const[n,a]=React$2.useState(!1),u=()=>{a(!n)},l=r===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:[!!r.current&&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:r.current})," ",e(`puzzles.referrals.inviter.${l}`)]})]}),!!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:u,children:e("puzzles.referrals.inviter.whyFail")})]})]}),n?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:o,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:o,text:e,rewards:r,referrals:t}){const n=E=>o({type:"translate",payload:E}),[a,u]=React$2.useState("step1"),l=React$2.useRef(0),f=React$2.useRef(0),c=async E=>{const g=E.map(p=>p.text),_=await o({type:"sendReferrals",payload:g});l.current=_&&_.data?_.data.valid.length:0,f.current=g.length-l.current,u("step2")};if(!t)return o({type:"success"}),null;const h=()=>{o({type:"success"})},y=()=>{if(l.current){const E=r.map(g=>(g.points*=l.current,g));o({type:"addPoints",complex:!0,finish:!0,payload:E})}else o({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[a==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:n,handleContinue:c,handleCancel:h,text:e}),a==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:n,handleFinish:y,valid:l,invalid:f})]})})}exports.AnimationComponent=AnimationComponent;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.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.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