@gamelearn/arcade-components 3.32.5 → 3.32.6
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.
|
@@ -271,5 +271,5 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
271
271
|
${l.thinkful?"speech-bubble--italic":""}
|
|
272
272
|
`,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader,MIX_TIME=.25;function useStateMachine(l){const e=fiber.useThree(p=>p.scene),n=React$2.useMemo(()=>{var _;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,x=!1)=>{const S=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!S)return new Promise(v=>v(!1));const g=S.userData.animator;if(_){const v=n[p],b=v["talking-short"]||v.talking;let T=cache[b],y=_,w=cache[_];if(!w){const{animations:C}=await loader.loadAsync(_);w=cache[_]=C[0]}if(R&&b!==_&&(T?(w=mixWithTalkingClip(T,w),y+="_talking"):o(p).then(()=>{T=cache[b],w=mixWithTalkingClip(T,w),y+="_talking"})),!S.userData._active||S.userData._active!==y){S.userData._active=y;const C=g.register(y,w,S);return new Promise(D=>{x&&g.setTime(0),g.mix(y,MIX_TIME).then(N=>D(N?C:!1))})}}return new Promise(v=>v(!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":""}`;let y=cache[T];if(!y){let w=cache[v];if(!w){const{animations:C}=await loader.loadAsync(v);w=cache[v]=C[0],w.name=g}if(y=w.clone(),b&&_!=="talking"){const C=S["talking-short"]||S.talking,D=cache[C];D&&(y=mixWithTalkingClip(D,w))}cache[T]=y}if(!R.userData._active||R.userData._active!==_){R.userData._active=_;const w=x.register(_,y,R);return new Promise(C=>{x.mix(_,MIX_TIME).then(D=>C(D?w:!1))})}}}return new Promise(S=>S(!1))};return{startAnimation:u,startAnimationUrl:f,preloadTalking:o,resetActives:d,unmountActives:h}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors: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(Oe=>Oe.scene),D=fiber.useThree(Oe=>Oe.camera),{start:N,stop:P}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>D.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),j=t[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(Oe=>Oe.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:me,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),z=Object.keys((j==null?void 0:j.audio)||{}).length,Y=Object.keys((j==null?void 0:j.voice)||{}).length,ie=re||(j==null?void 0:j.type)==="conversationalNarration",le=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}),Te=React$2.useMemo(()=>t.reduce((Oe,pt)=>(pt.slots&&pt.slots.filter(_e=>_e.uid).forEach(_e=>{Oe.includes(_e.uid)||Oe.push(_e.uid)}),Oe),[]),[t]),Fe=React$2.useCallback(Oe=>n({type:"translate",payload:Oe}),[n]),[Ne,Qe]=React$2.useState([]),st=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),Ze=React$2.useCallback(()=>{const Oe=o.find(ut=>ut.fromId===st)||o.find(ut=>ut.toId===st),pt=t.find(ut=>ut.id===(Oe==null?void 0:Oe.fromId));return!st&&(_==null?void 0:_.line)>=0?{decision:!0}:pt},[o,t,st]),yt=React$2.useCallback(()=>{if(X){const Oe=t.filter(pt=>!o.find(ut=>ut.toId===pt.id));if(Oe.length){const pt=Oe[0],ut=t.indexOf(pt);if(ut>=0)return ut}}return-1},[X,t,o]),Ve=React$2.useCallback(()=>{if(X){const pt=Ze();return pt==null?void 0:pt.decision}const Oe=t[x-1]?t[x-1]:{};return x>0&&(Oe==null?void 0:Oe.decision)},[j,X,t,st,o]),Me=React$2.useCallback(()=>{if(X){const pt=Ze();return(pt==null?void 0:pt.type)==="conversationalCamera"}const Oe=t[x-1]?t[x-1]:{};return x>0&&(Oe==null?void 0:Oe.type)==="conversationalCamera"},[j,X,t,st,o]),Le=React$2.useCallback(Oe=>{var ut,_e;const pt=a.find(te=>(te==null?void 0:te.uid)===(Oe==null?void 0:Oe.uid)?te:"");return((_e=(ut=Oe==null?void 0:Oe.character)==null?void 0:ut.resource)==null?void 0:_e.url)||(pt==null?void 0:pt.completeUrl)||""},[a]),Ke=(Oe=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{D.updateProjectionMatrix(),D.updateMatrixWorld(!0);const pt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(pt),M.current.parent){animationTarget.quaternion.equals(D.quaternion)||animationTarget.applyQuaternion(D.quaternion);const ut=M.current.isLeft?-1:1,_e=headSize*ut;animationTarget.translateX(-10*ut+_e),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(D.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(ut=>{const{object:_e}=ut;_e.material.visible=!0})},onComplete:()=>{Oe(),raycast.set(D.getWorldPosition(new three.Vector3(0,0,0)),D.getWorldDirection(new three.Vector3));const ut=raycast.intersectObjects(C.children,!0);k.current=ut.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||D.copy(F)},...animationTarget.position})}},ke=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Ke()},[h]),qe=(Oe,pt,ut,_e=!1)=>{const te=pt.includes("seated");if(ut){const pe=BASIC_ACTIONS_TYPES_WHITELIST.includes(ut.animationId);pe&&pt.includes("talking")&&(V.current=Oe),me(Oe,ut.url,pt.includes("talking"),pe).then(Ee=>{if(Ee&&pe)if(B.current)ue(Oe,"idle");else{const we=V.current===Oe?"neutral_talking":"neutral";ue(Oe,we)}})}else{const pe=_e&&!te?`${pt}-seated`:pt;ue(Oe,pe)}},St=()=>{if(!(K!=null&&K.uid)||!(K!=null&&K.emotion)||B.current)return;const{emotion:Oe,uid:pt,animation:ut}=K,_e=getCurrentVisible(pt,C);if(_e){const{isSeated:te}=_e;H(pt).then(()=>{qe(pt,te&&!Oe.includes("seated")?`${Oe}-seated_talking`:`${Oe}_talking`,ut,te)}).catch(pe=>{console.error(pe)})}},Ye=()=>{if(!(K!=null&&K.uid)||B.current)return;const{emotion:Oe,uid:pt,animation:ut}=K,_e=getCurrentVisible(pt,C);if(_e){delete _e.userData._active;const{isSeated:te}=_e;if(V.current===pt)qe(pt,"neutral",null,te),V.current=null;else{const pe=Oe.includes("talking");qe(pt,pe?"neutral":Oe,pe?null:ut,te)}}},ot=React$2.useCallback(()=>{B.current=!0,Se({show:!1}),ke(),J(),h||e({type:"success"})},[D,e,ke,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const $e=Oe=>{Se({show:!1}),S(Oe),e({type:"notifyProgress",payload:{line:Oe}})},rt=React$2.useCallback((Oe=!0)=>{const pt=Oe?["fromId","toId"]:["toId","fromId"],ut=o.filter(pe=>pe[pt[0]]===j.id),_e=ut.length===1?ut[0]:ut.find(pe=>pe[pt[1]]===st);if(!(_e!=null&&_e[pt[0]])){ot();return}Oe||Qe(Ne.slice(0,Ne.length-1));const te=t.findIndex(pe=>pe.id===_e[pt[1]]);te>=0?$e(te):ot()},[j==null?void 0:j.id,e,o,ot,t]),ft=React$2.useCallback((Oe,pt)=>{const ut=[3,2,1][Oe.id],te=o.filter(Ee=>Ee.fromId===(j==null?void 0:j.id)).find(Ee=>parseInt(Ee.fromPointIndex)===ut),pe=t.findIndex(Ee=>Ee.id===(te==null?void 0:te.toId));pe>=0?(te==null?void 0:te.fromId)===(te==null?void 0:te.toId)?pt():$e(pe):ot()},[j==null?void 0:j.id,o,ot,t]),Ge=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Ye(),X)rt(!1);else if(!Ve()){const Oe=x-1;Se({show:!1}),S(Oe),e({type:"notifyProgress",payload:{line:Oe}})}},[rt,e,X,$,x,K]),De=React$2.useCallback(Oe=>{if(X){if(Oe){const pt=[3,2,1][Oe.id],_e=o.filter(te=>te.fromId===j.id).find(te=>parseInt(te.fromPointIndex)===pt);if(_e){const te=t.findIndex(pe=>pe.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((Oe,pt)=>{if(ee.current={...K},w(!1),Ye(),X)Qe([...Ne,j.id]),Oe?ft(Oe,pt):rt();else if(x<t.length-1){const ut=x+1;$e(ut)}else(u||le||fe)&&ot()},[e,j==null?void 0:j.id,X,le,fe,x,t.length,ft,rt,ot,K]),ye=()=>{v(!1),Ge()},Pe=()=>X?j&&j.type!=="conversationalDecision"&&!o.find(Oe=>Oe.fromId===j.id):x===t.length-1,Xe=()=>{Pe()?ot():(v(!1),Re())};React$2.useEffect(()=>{if(X&&!b){const Oe=_==null?void 0:_.line;if(Oe>=0){T(!0),S(Oe);return}const pt=yt();pt>=0&&(T(!0),S(pt))}},[o,X,t,b,yt]);const Ft=Oe=>{if(ee.current.uid===Oe.uid||M.current.parent===Oe)return;const pt=new three.Object3D,ut=Oe.getObjectByName("Head_M");ut.updateMatrixWorld(!0),pt.applyMatrix4(ut.matrixWorld),pt.applyQuaternion(D.quaternion);const _e=h?2.5:2,te=h?1.2:1.5;pt.translateY(_e),pt.translateX(te);const pe=new three.Vector3;pe.setFromMatrixPosition(ut.matrixWorld);const we=pe.project(D).x<0;M.current={pos:pt.position.toArray(),child:ut,parent:Oe,isLeft:we}},Pt=Oe=>{e({type:"resetZIndexUIContainer",payload:Oe})};React$2.useEffect(()=>{var Oe;if(ie)ke(),Se({text:j==null?void 0:j.text,name:(j==null?void 0:j.alias)||(j==null?void 0:j.name)||`[ ${Fe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Le(K),show:!0});else if(!B.current&&!le&&!fe){const pt=j==null?void 0:j.slots.filter(te=>te.uid&&!te.talking),ut=[...pt.map(te=>te.uid)||[],K==null?void 0:K.uid];if(Te.filter(te=>!ut.includes(te)).forEach(te=>{ue(te,"idle")}),pt.forEach(te=>{const pe=getCurrentVisible(te.uid,C);if(pe){const{isSeated:Ee}=pe;qe(te.uid,te.emotion,te.animation,Ee)}}),K){const te=getCurrentVisible(K.uid,C),pe=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):(ke(),Se({text:K.text,name:K.alias||((Oe=K.character)==null?void 0:Oe.name)||(pe==null?void 0:pe.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0}))}else ke(),Se({show:!0})}},[a,j,h,C,Fe,Le,ke,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,onStart:()=>{var Oe;(Oe=K==null?void 0:K.emotion)!=null&&Oe.includes("think")||St()},onError:()=>{w(!0)},onFinish:()=>{Ye(),ce&&!p&&Re()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[x,Ct]),React$2.useEffect(()=>{var Oe;if(((j==null?void 0:j.audioType)==="none"||y)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){St();const pt=characterMs*(((Oe=ge==null?void 0:ge.text)==null?void 0:Oe.length)||0);setTimeout(()=>{Ye()},pt<minMs?minMs:pt)}},[y,j==null?void 0:j.audioType,Ye,St,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var Oe;if(ce&&ge.show&&((j==null?void 0:j.audioType)==="none"||y)&&!p){const pt=characterMs*(((Oe=ge==null?void 0:ge.text)==null?void 0:Oe.length)||0);(!Pe()||Pe()&&u)&&N(Re,pt<minMs?minMs:pt)}return()=>{P()}},[ge,Re,N,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:Xe,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 Oe=j.id?t.filter(ut=>ut.decision).findIndex(ut=>ut.id===j.id)+1:t.filter(ut=>ut.decision).findIndex(ut=>ut===j)+1,pt={...j.payload,decisionNumber:Oe,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:()=>{ke(),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:Xe,disabled:!ge.show,className:`gat--btn__round
|
|
273
273
|
${ge.show?"":"disabled"}
|
|
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=()=>{const x=_.getAction(l.url);x.setLoop(three.LoopRepeat,1/0),x.reset();function S(){u.current+=1,u.current>=e&&(_.mix("idle"),n(),_.removeEventListener("loop",S))}_.mix(l==null?void 0:l.url).then(g=>{g&&(u.current=1,_.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=N=>h({type:"translate",payload:N}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(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]),D=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:D}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:_,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=ke=>n({type:"translate",payload:ke}),v=`match-puzzle_${d}`,[b,T]=React$2.useState([]),[y,w]=React$2.useState(null),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[$,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=ke=>{X("click-ui");const qe=ft=>ft==null?void 0:ft.startsWith("source-item"),St=ft=>ft==null?void 0:ft.startsWith("destination-item");if(ke.id===y){w(null);return}const Ye=qe(ke.id),ot=qe(y),$e=St(ke.id),rt=St(y);if(Ye&&rt||$e&&ot){K(ke);return}w(ke.id)},ae=ke=>{let qe;return ke.startsWith("destination-item")?qe={[y]:ke}:qe={[ke]:y},_.some(St=>{const Ye=JSON.stringify(St),ot=JSON.stringify(qe);return Ye===ot})},ee=(ke,qe)=>{const St=new Map(ke.map(Ye=>[Ye.id,{...Ye}]));return qe.forEach(Ye=>{St.has(Ye.id)?St.get(Ye.id).points+=Ye.points:St.set(Ye.id,{...Ye})}),Array.from(St.values())},K=ke=>{var qe,St;if(X("click-ui"),ae(ke.id)){const Ye=ke.id.startsWith("source-item")?ke.id:y,ot=ke.id.startsWith("destination-item")?ke.id:y,$e=[...b,{[Ye]:ot}];if(T($e),a.specificCorrectFeedbacks){const rt=a==null?void 0:a.correctFeedbacks.find(De=>De.id===`${Ye}-${ot}`),ft=ee($,rt.rewards);B([...ft]),ne($e)&&(Ze(),j(!0)),rt.desc&&(F(rt==null?void 0:rt.desc),P(!0),D(!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)),D(!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(`#${ke.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${ke.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),a.specificWrongFeedbacks){const Ye=ke.id.startsWith("destination-item")?ke.id:y,ot=a==null?void 0:a.wrongFeedbacks.find(rt=>rt.id===Ye),$e=ee($,ot.rewards);B([...$e]),ot!=null&&ot.desc&&(F(ot.desc),P(!1),D(!0),Ze())}else{const Ye=ee($,t.solution.wrong.rewards);B([...Ye]),(St=(qe=t.solution)==null?void 0:qe.wrong)!=null&&St.desc&&(F(t.solution.wrong.desc),D(!0),Ze())}},ne=ke=>{if(_.length!==ke.length)return!1;const qe=new Set(_.map(Ye=>JSON.stringify(Ye))),St=new Set(ke.map(Ye=>JSON.stringify(Ye)));for(const Ye of St)if(!qe.has(Ye))return!1;return!0},ue=ke=>{X("score");const qe=ke?[...ke]:[...$];l({type:"addPoints",complex:!0,finish:!0,payload:qe}),l({type:"passPuzzle"})},me=()=>{D(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&yt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(ke,qe)=>J[ke]===qe;React$2.useEffect(()=>{o(()=>{X("score"),Ze(),P(!0),F(t.solution.right.desc);const ke=[...$,...t.resolve.rewards],qe=[..._];T(qe),setTimeout(()=>{P(!1),D(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ke,finish:!0}})},5e3)})},[$,_,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(ke,qe)=>b.findIndex(St=>{const Ye=Object.keys(St)[0],ot=Object.values(St)[0];return Ye===ke&&ot===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 ke=ee($,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const qe=new Map(ke.map(St=>[St.id,{...St}]));b.forEach(St=>{const Ye=Object.keys(St)[0],ot=St[Ye],$e=a.correctFeedbacks.find(rt=>rt.id===`${Ye}-${ot}`);$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)}})}),ke=Array.from(qe.values())}B(ke),T([]),fe(!0),F(t.timerFeedback.desc),D(!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 ke=document.querySelector('button[id^="source-item"]'),qe=document.querySelector('button[id^="destination-item"]'),St=ke.getBoundingClientRect().right,ot=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),Xe=Math.sqrt(ot*ot+Pe*Pe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Xe}px`);const Pt=Math.atan(Pe/ot),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 ke="";return ke="match ",S!=null&&S.url&&(ke+="match--with-custom-bg"),ke},[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(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.id,ke.matchDestinationId)&&"match-button--success",W(ke.id,ke.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.id,ke.matchDestinationId)+1})`},disabled:H(ke.id,ke.matchDestinationId),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},ke.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.matchSourceId,ke.id)&&"match-button--success",W(ke.matchSourceId,ke.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.matchSourceId,ke.id)+1})`},disabled:H(ke.matchSourceId,ke.id),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},ke.id))})]})]})})]}),R>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:N,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:me,keyboardControl: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;
|
|
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(0);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=()=>{const x=_.getAction(l.url);x.setLoop(three.LoopRepeat,1/0),x.reset();function S(){u.current+=1,u.current>=e&&g()}function g(){_.mix("idle"),n(),_.removeEventListener("loop",S)}_.mix(l==null?void 0:l.url).then(v=>{v&&(u.current=1,u.current>=e?g():_.addEventListener("loop",S))}),h(!0)};_.getAction(l==null?void 0:l.url)?(_.setTime(0),R()):assetLoader.load(l==null?void 0:l.url,x=>{_.register(l==null?void 0:l.url,x.animations[0]),_.setTime(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=N=>h({type:"translate",payload:N}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:R.success,onFinish:()=>{R.success?d({type:"success"}):d({type:"closeScreen"})},payload:R.rewards})},[d,R]),w=React$2.useCallback(()=>{if(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]),D=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:D}):R?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:R.desc,success:R.success,playSound:_,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=ke=>n({type:"translate",payload:ke}),v=`match-puzzle_${d}`,[b,T]=React$2.useState([]),[y,w]=React$2.useState(null),[C,D]=React$2.useState(!1),[N,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[$,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=ke=>{X("click-ui");const qe=ft=>ft==null?void 0:ft.startsWith("source-item"),St=ft=>ft==null?void 0:ft.startsWith("destination-item");if(ke.id===y){w(null);return}const Ye=qe(ke.id),ot=qe(y),$e=St(ke.id),rt=St(y);if(Ye&&rt||$e&&ot){K(ke);return}w(ke.id)},ae=ke=>{let qe;return ke.startsWith("destination-item")?qe={[y]:ke}:qe={[ke]:y},_.some(St=>{const Ye=JSON.stringify(St),ot=JSON.stringify(qe);return Ye===ot})},ee=(ke,qe)=>{const St=new Map(ke.map(Ye=>[Ye.id,{...Ye}]));return qe.forEach(Ye=>{St.has(Ye.id)?St.get(Ye.id).points+=Ye.points:St.set(Ye.id,{...Ye})}),Array.from(St.values())},K=ke=>{var qe,St;if(X("click-ui"),ae(ke.id)){const Ye=ke.id.startsWith("source-item")?ke.id:y,ot=ke.id.startsWith("destination-item")?ke.id:y,$e=[...b,{[Ye]:ot}];if(T($e),a.specificCorrectFeedbacks){const rt=a==null?void 0:a.correctFeedbacks.find(De=>De.id===`${Ye}-${ot}`),ft=ee($,rt.rewards);B([...ft]),ne($e)&&(Ze(),j(!0)),rt.desc&&(F(rt==null?void 0:rt.desc),P(!0),D(!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)),D(!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(`#${ke.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${ke.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),a.specificWrongFeedbacks){const Ye=ke.id.startsWith("destination-item")?ke.id:y,ot=a==null?void 0:a.wrongFeedbacks.find(rt=>rt.id===Ye),$e=ee($,ot.rewards);B([...$e]),ot!=null&&ot.desc&&(F(ot.desc),P(!1),D(!0),Ze())}else{const Ye=ee($,t.solution.wrong.rewards);B([...Ye]),(St=(qe=t.solution)==null?void 0:qe.wrong)!=null&&St.desc&&(F(t.solution.wrong.desc),D(!0),Ze())}},ne=ke=>{if(_.length!==ke.length)return!1;const qe=new Set(_.map(Ye=>JSON.stringify(Ye))),St=new Set(ke.map(Ye=>JSON.stringify(Ye)));for(const Ye of St)if(!qe.has(Ye))return!1;return!0},ue=ke=>{X("score");const qe=ke?[...ke]:[...$];l({type:"addPoints",complex:!0,finish:!0,payload:qe}),l({type:"passPuzzle"})},me=()=>{D(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&yt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(ke,qe)=>J[ke]===qe;React$2.useEffect(()=>{o(()=>{X("score"),Ze(),P(!0),F(t.solution.right.desc);const ke=[...$,...t.resolve.rewards],qe=[..._];T(qe),setTimeout(()=>{P(!1),D(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:ke,finish:!0}})},5e3)})},[$,_,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(ke,qe)=>b.findIndex(St=>{const Ye=Object.keys(St)[0],ot=Object.values(St)[0];return Ye===ke&&ot===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 ke=ee($,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const qe=new Map(ke.map(St=>[St.id,{...St}]));b.forEach(St=>{const Ye=Object.keys(St)[0],ot=St[Ye],$e=a.correctFeedbacks.find(rt=>rt.id===`${Ye}-${ot}`);$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)}})}),ke=Array.from(qe.values())}B(ke),T([]),fe(!0),F(t.timerFeedback.desc),D(!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 ke=document.querySelector('button[id^="source-item"]'),qe=document.querySelector('button[id^="destination-item"]'),St=ke.getBoundingClientRect().right,ot=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),Xe=Math.sqrt(ot*ot+Pe*Pe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Xe}px`);const Pt=Math.atan(Pe/ot),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 ke="";return ke="match ",S!=null&&S.url&&(ke+="match--with-custom-bg"),ke},[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(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.id,ke.matchDestinationId)&&"match-button--success",W(ke.id,ke.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.id,ke.matchDestinationId)+1})`},disabled:H(ke.id,ke.matchDestinationId),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},ke.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(ke=>jsxRuntimeExports.jsxs("button",{id:ke.id,"data-testid":ke.id,className:["unset-button match-button",y===ke.id&&"match-button--marked",H(ke.matchSourceId,ke.id)&&"match-button--success",W(ke.matchSourceId,ke.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(ke.matchSourceId,ke.id)+1})`},disabled:H(ke.matchSourceId,ke.id),type:"button",onClick:()=>re(ke),children:[jsxRuntimeExports.jsx(MatchItem,{item:ke,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},ke.id))})]})]})})]}),R>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:N,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:me,keyboardControl: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
|