@gamelearn/arcade-components 3.12.0 → 3.12.2
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.
|
@@ -249,7 +249,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/256
|
|
|
249
249
|
`,Z_INDEX_WARNING=`ReactKonva: You are using "zIndex" attribute for a Konva node.
|
|
250
250
|
react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
|
|
251
251
|
For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
252
|
-
`,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",u=r[a]!==e[a];if(l&&u){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,v={},E=!1;const g={};for(var a in e)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",_=r[a]!==e[a];if(l&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(g[f]=e[a])}!l&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,v[a]=e[a])}E&&(o.setAttrs(v),updatePicture(o));for(var f in g)o.on(f+EVENTS_NAMESPACE,g[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var l in e){var u=l.slice(0,2)==="on";u?a[l]=e[l]:n[l]=e[l]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let l=a.memoizedState;for(;l;){if(l.memoizedState===e)return!0;l=l.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),l=u=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(u):f.current=u)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),l(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(l(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{l(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[l]=React$2.useState(()=>document.createElement("div")),u=React$2.useMemo(()=>client.createRoot(l),[l]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),l.style.position="absolute",l.style.zIndex="10",l.style.top="0px",l.style.left="0px",l.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,l.style.transformOrigin="top left"}else l.style.position="",l.style.zIndex="",l.style.top="",l.style.left="",l.style.transform="",l.style.transformOrigin="";const h=r||{},{style:v}=h,E=__rest(h,["style"]);Object.assign(l.style,v),Object.assign(l,E)});return React$2.useLayoutEffect(()=>{var h;const v=a.current;if(!v)return;const E=(h=v.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(l),f&&needForceStyle(E)&&(E.style.position="relative"),v.on("absoluteTransformChange",c),c(),()=>{var g;v.off("absoluteTransformChange",c),(g=l.parentNode)===null||g===void 0||g.removeChild(l)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{u.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{u.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:l,onClickOutside:u}){const f=React$2.useRef(),[c,h]=React$2.useState(),v=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",g=DeviceDetection(),_=()=>{var S,A,C;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},p=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,C;a&&!e&&(t?(C=f.current)==null||C.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?u(o):l(o),(S=f.current)==null||S.setAttr("fill",v),(A=f.current)==null||A.setAttr("stroke",E))},T=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:p,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:T,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":v,stroke:e||r?E:"",strokeWidth:g?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:l,clickedZones:u}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),[p,x]=React$2.useState(new window.Image),[T,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const C=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{p.src=r,p.addEventListener("load",()=>{if(f.current){const w={x:T/2,y:R/2,width:p.width,height:p.height,offsetX:p.width/2,offsetY:p.height/2,scale:{x:Math.min(T/p.width,R/p.height),y:Math.min(T/p.width,R/p.height)}};v.current&&v.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),g.current&&g.current.setAttrs(w),f.current.batchDraw(),x(p),f.current.fire("stage-loaded")}})},[p,R,r,T]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:T,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:g,image:p})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:T,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:v,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:u.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ge,Ee;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:l,image:u,areas:f,badAreas:c,hasClickOrder:h,timer:v,hasClickOnce:E,hasHighlights:g,hasImageReview:_,defaultCompleted:p,className:x,emitFinish:T,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:C,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[U,H]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[V,X]=React$2.useState(!0),[Q,re]=React$2.useState(!1),ne=React$2.useRef(null),ie=React$2.useRef(null),J=React$2.useRef(null),se=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),he=React$2.useRef(null),ue=React$2.useRef(null),_e=React$2.useRef(null),[Oe,Te]=React$2.useState(v),He=Le=>S?S(Le):r({type:"translate",payload:Le}),[Ge]=e,{solution:Xe}=l,pt=u.img.url||defaultImg,yt=f.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),at=c.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),ht=React$2.useCallback(()=>{if(!V){const Le=setInterval(()=>{Te(Ve=>Ve>1?Ve-1:0)},1e3);_e.current=Le}},[V]),er=React$2.useCallback((Le,Ve)=>{T?T(Le,Ve):r({type:"addPoints",payload:Le})},[r,T]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(p)},[p]);const Ot=React$2.useCallback(()=>{clearInterval(J.current)},[]),_t=React$2.useCallback(()=>{clearInterval(_e.current)},[]),kt=React$2.useCallback(Le=>{oe.current=Date.now(),se.current?(he.current=se.current-oe.current,Ot()):(he.current=oe.current-(oe.current-Le*1e3),Ot())},[Ot]),Ft=React$2.useCallback(()=>{I(()=>{var Le,Ve;return{show:!0,success:!1,text:(Le=l==null?void 0:l.timerFeedback)!=null&&Le.desc?l.timerFeedback.desc:"",rewards:(Ve=l==null?void 0:l.timerFeedback)==null?void 0:Ve.rewards}}),re(!0),_t(),Ot()},[_t,Ot,(ge=l.timerFeedback)==null?void 0:ge.desc,(Ee=l.timerFeedback)==null?void 0:Ee.rewards]),Ke=React$2.useCallback(()=>{clearInterval(J.current),J.current=setInterval(()=>{ie.current=Date.now(),ie.current>se.current&&Ft()},250)},[Ft]);React$2.useEffect(()=>{var Le;if((f.length===U.length||E&&U.length>0)&&!W){Z(!0);const Ve=U[U.length-1],De=A==null?void 0:A.correctFeedbacks.find(ze=>ze.id===Ve.id);(!((Le=A==null?void 0:A.correctFeedbacks)!=null&&Le.length)||A!=null&&A.correctFeedbacks.some(ze=>!ze.desc)||E)&&(I(ze=>({...ze,show:!0,success:!0,text:De?De.desc:l.solution.right.desc,rewards:De?De.rewards:l.solution.right.rewards})),v&&(_t(),kt()))}},[U,f.length,A,E,W,l.solution.right,kt,v,_t]),React$2.useEffect(()=>{a(Le=>{v&&(_t(),X(!1),G.show?I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]})):Ot()),Z(!0),B(!0),setTimeout(()=>{R?R(Le):Le()},4e3)})},[a,R,Ge,v,G.show,Ot,_t]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const mt=(Le,Ve=!1)=>{var De,ze;if(!W){const{rewards:jt,desc:Mt}=Xe.wrong;let dt=Mt,vr=jt;const Wr=(De=A==null?void 0:A.wrongFeedbacks)==null?void 0:De.find(pn=>pn.id===Le.id);Wr&&(dt=Wr.desc,vr=Wr.rewards),h&&(H([]),Ve&&(ze=l==null?void 0:l.orderFeedback)!=null&&ze.desc&&(dt=l.orderFeedback.desc,vr=l.orderFeedback.rewards)),v&&(_t(),kt()),I(pn=>({...pn,show:!0,success:!1,text:dt,rewards:vr})),Ge("fail")}},ct=React$2.useCallback(()=>{fe.current=Date.now();const Le=fe.current+he.current;ie.current=null,se.current=Le,(v||Q)&&(G.success?f.length===U.length||E&&U.length>0?_t():(Te(he.current*.001),ht(),Ke()):(H([]),X(!0),w())),er(G.rewards,G.success),Ge("click-ui"),I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]}))},[v,Q,er,G.rewards,G.success,Ge,f.length,U.length,E,w,_t,ht,Ke]),ye=Le=>{var Ve,De;if(!U.some(ze=>ze.index===Le.index)&&!G.show&&!W){Ge("click-ui");let ze=Xe.right.desc,{rewards:jt}=Xe.right;const Mt=[...U,Le];if(h&&Le.index===U.length||!h){if(v&&kt(Oe),t(),(Ve=A==null?void 0:A.correctFeedbacks)!=null&&Ve.length){const dt=(De=A.correctFeedbacks)==null?void 0:De.find(vr=>vr.id===Le.id);dt&&(ze=dt.desc,jt=dt.rewards),!ze&&f.length>Mt.length&&!E?er(jt,!0):ze&&!E&&(I(vr=>({...vr,show:!0,success:!0,text:ze,rewards:jt})),v&&_t())}H(Mt)}else mt(Le,!0)}},de=React$2.useCallback(()=>{_t(),Te(v),ht(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),se.current=ne.current+v*1e3,Ke()},[_t,v,ht,P,Ke,k]);return React$2.useEffect(()=>{v&&C>0&&!ue.current&&(P&&Object.keys(O).length&&O[C-1]?(X(!0),ue.current=!0):X(!1))},[p,P,O,C,v]),React$2.useEffect(()=>{v&&Oe===0&&Ft()},[Oe,Ft,v]),React$2.useEffect(()=>{v&&(D?(_t(),kt()):ht())},[_t,Ke,D,kt,ht,v]),jsxRuntimeExports.jsxs("div",{className:x,children:[G.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ge,text:G.text,success:G.success,translate:He,hasTimeout:!G.text,delay:v?1e3:2e3,functionOnClose:ct,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&U.length?[U[0]]:yt,badAreas:at,clickedZones:U,onClick:ye,onClickOutside:mt,hasHighlights:g,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,v&&V?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[C-1],translate:He,onInit:de}):null,v?jsxRuntimeExports.jsx(CountDown,{time:Oe}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const l of e.toLowerCase()){const u=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[u][f].value=l,n.push({char:l,position:[u,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let l=0;l<r;l+=1)switch(t.reduce((f,c)=>{const h=[a,l],v=getDistance(c.position,h);return v<f?v:f},9999)){case 0:n[a][l].hiddenColor=GREEN;break;case 1:n[a][l].hiddenColor=ORANGE;break;case 2:n[a][l].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,l]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,l)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let l=0;l<e;l+=1){const u={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(u)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[l,u]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(l,e,o,u)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:l,setResolveAction:u}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),v=React$2.useRef(),{solution:E}=r,[g,_]=React$2.useState(n.toLowerCase()),[p,x]=React$2.useState(),[T,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:U,visibleColumns:H}=DIFFICULTY_MAP[l];let W=U==="auto"?Math.ceil(window.innerHeight*.025):U;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{u(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[u,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,re)=>({char:Q,index:re,used:!1})),B=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),G=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(v.current!==void 0){const Q=X-v.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(G),I=0)}v.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:H,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const V=()=>{if(D.length<=1)return;const[X,Q]=C,re=D[X][Q];if(re.hiddenColor===GREEN){const ne=p.filter(ie=>ie.char===re.value.toLowerCase()&&ie.used===!1)[0];if(ne){const{index:ie}=ne;f("score");const J=p;J[ie].used=!0,x(J);const se=[...T];se[ie]=re.value;const oe=B(J);_(oe);const fe=repaintGridPassword(D,oe,W,H);F(fe),R(se)}}g<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||V()},[C]),jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__container",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__header",children:[jsxRuntimeExports.jsx("span",{className:"title",children:"Dcoder.exe"}),jsxRuntimeExports.jsx("div",{className:"puzzle--pieces",children:T.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:C,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(l=>{n[a]||(n[a]=[]),n[a]=[...n[a],l],l.char===" "&&(a+=1),t||(l.positionInitial=l.index)}),n.map((l,u)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${u}`,children:r?l.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):l.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${l[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${l+u}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:l,hintUsed:u,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[v]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[g,_]=React$2.useState(0),[p,x]=React$2.useState(!1),[T,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,U]=React$2.useState([]),[H,W]=React$2.useState(!1),Z=l.toUpperCase().split(""),q=Z.filter(he=>restrictCharacters(he,"and")),B=he=>e({type:"translate",payload:he}),G=React$2.useCallback(()=>{const he=q.map(Oe=>({char:Oe}));let ue=[];const _e=analyzeChars(q);for(;ue.length<MAX_EXTRA_LETTERS;){const Oe=makeChar(_e);ue=[...ue,{char:Oe}]}return[...he,...ue]},[q]),I=l.toUpperCase().split("").map((he,ue)=>restrictCharacters(he,"or")?{index:ue,letter:he,char:he,fixed:!0}:{index:ue,letter:he,char:""}),$=React$2.useCallback(()=>{let he=G();for(;he.length>MAX_POOL_LETTERS;){const ue=Math.trunc(Math.random()*(he.length-1))+1,_e=he[ue],Oe=I.find((Te,He)=>_e.char===Te.letter&&!I[He].fixed);Oe&&(he.splice(ue,1),I[Oe.index]={...Oe,char:Oe.letter,fixed:!0})}u&&(he=[],I.forEach(({letter:ue})=>{ue!==" "&&he.push({char:ue})})),w(I),R(he)},[I,u,G]),V=(he,ue)=>T.map((Oe,Te)=>Te===ue?{...Oe,deleted:!0}:{...Oe}),X=(he,ue,_e)=>{const Oe=ue.map((He,Ge)=>_e.find(pt=>pt.poolIndex===Ge)?{char:He.char}:He);R(Oe),w(he);const Te=he.find(He=>He.char==="");_(Te.index)},Q=(he,ue)=>{v("click-ui");let _e=!1;const Oe=C.map(Ge=>!Ge.char&&!_e?(_e=!0,{...Ge,char:he,poolIndex:ue}):Ge),Te=V(he,ue),He=Oe.filter(Ge=>Ge.char).length;R(Te),w(Oe),re(),He===C.length&&se(Oe,Te)},re=()=>{var he;if(p){const ue=C.find(_e=>_e.index!==g&&_e.letter!==" "&&_e.char===""&&_e.poolIndex===!1);ue&&_(ue.index)}else{const ue=C.find(_e=>_e.char==="");_(ue.index+1),((he=C[ue.index+1])==null?void 0:he.letter)===" "&&_(ue.index+2)}},ne=()=>{v("click-ui");const he=C.map((ue,_e)=>C[C.length-1-_e]).find(ue=>ue.char&&!ue.fixed);if(he){const ue=C.map(Te=>Te.index===he.index?{...he,char:""}:Te);let _e=!1;const Oe=T.map((Te,He)=>He===he.poolIndex&&(Te.deleted||!_e)?(_e=!0,{char:Te.char}):Te);R(Oe),w(ue),_(he.index)}},ie=()=>{r(!0),O("");const he=[...F,...a.solution.right.rewards];v("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:he}),e({type:"passPuzzle"})},J=()=>{v("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},se=(he,ue)=>{let _e=[];D(!0);const Oe=he.map((He,Ge)=>Z[Ge]===He.char?{...He,fixed:!0}:(_e=[..._e,He],{...He,poolIndex:!1,char:""})),Te=Oe.filter(He=>He.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Te===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{ie()},2e3)):(O("failed"),X(Oe,ue,_e),a.solution.wrong.desc===""&&setTimeout(()=>{J()},2e3))},oe=()=>{if(P==="success")ie();else{J();const he=C.find(ue=>ue.char==="");_(he.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(he=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),he()},2e3)}),c(he=>{const ue=[];I.forEach(({letter:_e})=>{_e!==" "&&ue.push({char:_e})}),R(ue),he()})},[$,S,l,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:B,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:H?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,answer:l.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,flickerPosition:g,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((he,ue)=>sortChar(he,ue)).map((he,ue)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${he.char}`,type:"button",onClick:()=>{!he.deleted&&!P&&!k&&(Q(he.char,ue),v("click-ui"))},className:`puzzle--hanged__keyboard--item ${he.deleted||k?"disabled":""}`,children:he.char},`${he+ue}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":B("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:l,soundActions:u,setSelected:f,selected:c,pause:h,loadPuzzleStatus:v,index:E,setIndex:g,slidesCompleted:_,setSlidesCompleted:p,keyboardControl:x,totalCorrects:T}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),C=`chained-image-click-puzzle_${E}_${r}`,[w]=u,P=B=>{R.current=[...R.current,...B]},O=React$2.useCallback(B=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...B]}),n({type:"passPuzzle"})},[w,n]),[k,D]=React$2.useState(!1),F=o[E],{info:U,specificFeedbacks:H}=F;U.description=e,React$2.useEffect(()=>{S.current=0,A.current=0,D(!1)},[E]);const W=React$2.useCallback((B,G=!1)=>{var $;let I={..._};if(G){if(($=H==null?void 0:H.correctFeedbacks)!=null&&$.length&&!F.hasClickOnce){const V=H.correctFeedbacks.length;k&&V?(S.current>0?f(c+(V-S.current)):f(c+V),S.current=V):S.current+=1}else{let V=c;A.current&&(V-=A.current),S.current=F.areas.length,f(V+S.current)}S.current===F.areas.length&&(E+1>=o.length?O(B):g(E+1),I={...I,[E]:!0},p(I)),P(B)}else n({type:"addPoints",payload:B,finish:!1}),n({type:"failPuzzle"}),F.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&F.hasClickOrder&&!c&&f(0)},[_,H,F.hasClickOnce,F.areas.length,F.hasClickOrder,c,f,E,o.length,p,O,g,n]),Z=()=>{D(!0),E>=o.length-1&&f(T),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{v&&E!==o.length-1&&W([],!0)},[E,o.length,v,W]);const q=()=>{const B=F.hasClickOnce?F.areas.length:1;A.current+=B,f(c+B)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...F,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:H,emitFinish:W,emitError:P,emitResolve:Z,isLast:E+1===o.length,defaultCompleted:_[E]||!!v,hideContinue:E+1!==o.length,handleClick:q,emitEvent:n,disableExit:a,soundActions:u,setResolveAction:l,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:l,showFrames:u,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[v,E]=React$2.useState(0),[g,_]=React$2.useState(0),[p,x]=React$2.useState({}),T=`chained-image-click-puzzle_${g}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:T}),[r,T]),S=n.reduce((C,w)=>C+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:l,setInfo:e,setSelected:E,selected:v,index:g,setIndex:_,slidesCompleted:p,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[u?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:l,setFramesCompleted:u,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:v,description:E,translateFromParent:g,setInfo:_,emitEvent:p,nodeId:x,setSelected:T,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:C,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:U}){var ie;const[H]=c,[W,Z]=React$2.useState(!1),q=o[e],{info:B,specificFeedbacks:G}=q;B.description=E;const I=React$2.useRef(0),$=React$2.useRef(0),V=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...B,hintId:V})},[_,B,V]),React$2.useEffect(()=>{O&&($.current=0,I.current=0,T(0),k(!1))},[O,k,T]),React$2.useEffect(()=>{$.current=0,I.current=0,Z(!1)},[e]);const X=React$2.useCallback((J,se=!1)=>{var fe;let oe={...t};if(se){if((fe=G==null?void 0:G.correctFeedbacks)!=null&&fe.length&&!q.hasClickOnce){const he=G.correctFeedbacks.length;W&&he?($.current>0?T(R+(he-$.current)):T(R+he),$.current=he):$.current+=1}else{let he=R;I.current&&(he-=I.current),$.current=q.areas.length,w[0]&&Object.entries(t).length===0?T($.current):T(he+$.current)}$.current===q.areas.length&&(e+1>=o.length&&n(J),oe={...oe,[e]:!0},u(oe),l(e+1>o.length-1?0:e+1)),a(J)}else p({type:"addPoints",payload:J,finish:!1}),p({type:"failPuzzle"}),q.hasClickOrder&&(T(R-$.current),$.current=0)},[t,(ie=G==null?void 0:G.correctFeedbacks)==null?void 0:ie.length,q.hasClickOnce,q.areas.length,q.hasClickOrder,a,R,w,T,e,o.length,u,l,n,p]),Q=React$2.useCallback(()=>{Z(!0),e>=o.length-1&&T(U),H("score"),p({type:"hidePuzzleButtons",payload:!1}),C(J=>({...J,[e]:!0})),p({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:B.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,H,p,C,V,B.resolve.rewards,T,U]),re=React$2.useCallback(()=>{u({}),$.current=0,I.current=0,S()},[S,u]);React$2.useEffect(()=>{f&&e!==o.length-1&&X([],!0)},[t,e,o.length,f,X]);const ne=()=>{const J=q.hasClickOnce?q.areas.length:1;I.current+=J,T(R+J)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...q,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:G,emitFinish:X,emitResolve:Q,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:v,translateFromParent:g,emitEvent:p,slideNumber:e,handleClick:ne,emitResetPuzzle:re,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:l,setResolveAction:u,setInfo:f,pause:c,keyboardControl:h}){const[v,E]=React$2.useState({}),g=React$2.useRef([]),[_,p]=React$2.useState(0),[x,T]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[C,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((V,X)=>V+X.areas.length,0),U=V=>{g.current=[...g.current,...V]},H=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:H}),[o,H]),Z=React$2.useCallback(V=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...g.current,...V]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),g.current=[],S(0),p(0),T({}),w(!0),D(!0)},[]),B=V=>o({type:"translate",payload:V}),G=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:U,accRewards:g,setSelected:S,selected:R,setIndex:p,setFramesCompleted:T,loadPuzzleStatus:W,soundActions:a,setResolveAction:u,disableExit:l,translateFromParent:B,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:v,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:G,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!C,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:l=>t({logo:l})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:l=>t({color:l})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const l=o?e.header.userImage:r.userImage,u=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+l})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(u||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const l=o?e.body.work:r.work,u=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const l=o?e.body.bgImage:r.bgImage,u=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+l})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${u}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(),f=l===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${l===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>u(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(l)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(),f=!l;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>u(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(l.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(""),f=l==="",[c,h]=React$2.useState(!1),v=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:v,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:l,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(g=>g instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:[jsxRuntimeExports.jsx("span",{children:t(g.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(g.desc)})]},g.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:t(g)},g))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(l)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n.props,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:l}){const[u,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(!1),[g,_]=React$2.useState(!1),[p,x]=React$2.useState(!1),[T,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[C,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,U=re=>r({type:"translate",payload:re}),H=()=>{w({type:"",props:{}})},W=(re,ne={})=>{w({type:re,props:ne})},Z=()=>{if(e.solution){const{rewards:re}=e.solution.right,{rewards:ne}=e.solution.wrong;F(v?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:v?ne:re}),r({type:"passPuzzle"})}},q=l({disabled:T!=="success",forward:Z,escape:Z});React$2.useEffect(()=>q(),[q]);const B=(re,ne)=>{const ie=Object.keys(re),J={existing:0,equal:0};return ie.forEach(se=>{ne[se]!==null&&ne[se]!==""&&(J.existing+=1),re[se]===ne[se]&&(J.equal+=1)}),J},G=(re,ne)=>{const ie=Object.keys(A.header).length,J=Object.keys(A.body).length,se=B(A.header,re),oe=B(A.body,ne),fe=oe.existing+se.existing===ie+J,he=oe.equal+se.equal===ie+J;return{exist:fe,equal:he}},I=()=>{F("click-ui");const{exist:re,equal:ne}=G(P,k);r({type:"hidePuzzleButtons",payload:!0}),re&&!ne?(p&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):re&&ne&&(p&&(a(!1),x(!1)),_(!0),R("success"))},$=re=>{if(Object.keys(re).length>0){const ne={...P,...re};O(ne),H();const{exist:ie}=G(ne,k);x(!!ie)}},V=re=>{if(Object.keys(re).length>0){const ne={...k,...re};D(ne),H();const{exist:ie}=G(P,ne);x(!!ie)}};React$2.useEffect(()=>{t(re=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),re()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const X={showingReference:u||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:U},Q=()=>{T==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):T==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:H,soundActions:n,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:u,displayButton:!c&&!g,translate:U,clickAction:()=>{F("click-ui"),f(!u)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...X,header:P,onSave:$}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...X,header:P,onSave:$}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...X,body:k,onSave:V})]}),!p&&!u?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:Q,resolved:c,translate:U}):null,p&&!u?jsxRuntimeExports.jsx(PublishButton,{onPublish:I,translate:U}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),l=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},u=()=>o.text?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${o.img?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o.text||"_"})})}):null,f=()=>!!(r&&!o.correct||!r),c=()=>jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})}),h=()=>o.order?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o.order})}):null,v=()=>jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[h(),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]}),E=()=>!a()&&r&&o.correct&&!n?v():!a()&&r?c():null;return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&f()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[l(),u(),E()]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:l,onFinish:u,handleSuccess:f,resolveWithAnyCard:c}){const[h,v]=React$2.useState(Array(o.length).fill(!1)),[E,g]=React$2.useState(Array(o.length).fill(!1)),[_,p]=React$2.useState(0),[x,T]=React$2.useState(!1),[R]=l,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,C=React$2.useCallback(()=>{v(Array(o.length).fill(!1)),g(Array(o.length).fill(!1)),p(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{C()},1e3)};function P(F){const U=Array.from(h);U[F]=F,v(U)}const O=React$2.useCallback(()=>{const F=[];o.forEach((U,H)=>{U.correct===!0&&F.push(H)}),v(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(u(),T(!0),p(0))},[_,u,S,c]);const k=F=>{P(F),f(o[F].id||null),p(_+1)},D=F=>{var U,H;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A)if(o[F].order===e)r(e+1),k(F);else{if(o[F].order!==e){const W=Array.from(E);W[F]=F,g(W),t(((U=o[F])==null?void 0:U.id)||null,o[F].correct),w()}P(F)}else t(((H=o[F])==null?void 0:H.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(U),flipped:h.includes(U),wrongOrder:E.includes(U),cardIndex:U},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:l,soundActions:u,backgroundImage:f,nodeId:c,keyboardControl:h,hideBackgroundImageTheme:v=!1}){var Q,re;const[E,g]=React$2.useState(!1),[_,p]=React$2.useState(1),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(!1),[w,P]=React$2.useState([]),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(""),[U]=u,H=ne=>o({type:"translate",payload:ne}),W=`cards-selector-puzzle_${c}`,Z=React$2.useCallback(ne=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{var se,oe;o({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:ne}=((se=e==null?void 0:e.solution)==null?void 0:se.right)||{},ie=((oe=n==null?void 0:n.correctFeedbacks)==null?void 0:oe.map(fe=>fe.rewards).flat())||[],J=[...w,...ne,...ie];U("score"),Z(J)},[w,Z,o,(Q=e==null?void 0:e.solution)==null?void 0:Q.right,U,n==null?void 0:n.correctFeedbacks]),B=()=>{g(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&F(e.solution.right.desc),C(!0)},G=()=>{x||E?q():(T(!1),a(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1})),F("")},I=ne=>{if(S(!0),n!=null&&n.specificCorrectFeedbacks){const ie=n.correctFeedbacks.find(J=>J.id===ne);ie!=null&&ie.desc&&(F(ie.desc),C(!0))}U("score"),o({type:"hidePuzzleButtons",payload:!0})},$=(ne,ie=!1)=>{var J,se;if(S(!1),ie)F((J=e.orderFeedback)==null?void 0:J.desc),C(!0),P([...w,...((se=e.orderFeedback)==null?void 0:se.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const oe=n.wrongFeedbacks.find(fe=>fe.id===ne);oe!=null&&oe.desc?(F(oe.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),P([...w,...(oe==null?void 0:oe.rewards)||[]])}else e.solution.wrong.desc?(F(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!ie&&P([...w,...e.solution.wrong.rewards]),U("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};React$2.useEffect(()=>{E&&a(!0)},[a,E]),React$2.useEffect(()=>{l(()=>{var ie;o({type:"hidePuzzleButtons",payload:!0}),k(!0);const ne=[...w,...((ie=e==null?void 0:e.resolve)==null?void 0:ie.rewards)||{}];setTimeout(()=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:W,rewards:ne,finish:!0}})},2e3)})},[l,a,w,(re=e==null?void 0:e.resolve)==null?void 0:re.rewards,o,W]);const V=React$2.useMemo(()=>{let ne="";return ne="cards-selector",f!=null&&f.url&&(ne+=" cards-selector--with-custom-bg"),v&&(ne+=" disable-background-image"),ne},[f==null?void 0:f.url,v]),X={backgroundImage:f!=null&&f.url?`url('${f.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:V,style:X,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:p,currentOrder:_,cards:r,onFinish:B,resolveWithAnyCard:t,handleError:$,feedbackIsShown:A,resolvePuzzle:O,soundActions:u,handleSuccess:I})}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:x||R,text:D,hasTimeout:!D,translate:H,functionOnClose:G,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:l}){const[u,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[v,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const g=T=>{if(!T||!T.length)return"";const R=T.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const T=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const C=[...S];if(g(S[A]).length!==0){const w=S[A];return C[A]=`<span class="lastWord" >${w}</span>`,C}return R(S,A-1)};a==="election"?h(T()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},p=t.split("<p>");p.shift();const x=p.length>1;return u&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:l,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&v&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[l]=a,u=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{l("click-ui"),r(t)},h=E=>{E.keyCode===13&&v(E)},v=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:u(o)})}),jsxRuntimeExports.jsx("div",{onClick:v,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(l=>!!l.fullText).length}`,children:o&&o.map((l,u)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:l,soundActions:t,index:u,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},u))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:l,skip:u,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:v}){const[E]=v,g=p=>o({type:"translate",payload:p}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:g("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(p=>n[p.currenTextParagraph].electionTexts[p.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[p.currenTextParagraph].electionTexts[p.index]},p.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:g("puzzles.skip")}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:g(f()?"puzzles.continue":"puzzles.retry")}),!l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:g("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:l,setResolveAction:u,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:v,backgroundImage:E,hideBackgroundImageTheme:g=!1}){const _=Ke=>o({type:"translate",payload:Ke}),p=React$2.useRef(),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(0),[w,P]=React$2.useState({[`text_${A}`]:{...h[A],id:`text_${A}`,correct:""}}),[O,k]=React$2.useState(!1),[D,F]=React$2.useState([]),[U,H]=React$2.useState(!1),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState(!0),[$,V]=React$2.useState([]),[X,Q]=React$2.useState(!0),[re]=v,ne=React$2.useRef({}),ie=Ke=>{let mt;return Ke.electionTexts.forEach((ct,ye)=>{ct.correct&&(mt=ye)}),mt},J=React$2.useCallback(Ke=>D.filter(ct=>ct.currenTextParagraph===Ke)[0].fullText_labelId,[D]),se=React$2.useCallback(()=>h.map((Ke,mt)=>{if(Ke.type==="fixed")return Ke.fullText_labelId??Ke.fullText;if(Ke.type==="election"){const ct=ie(Ke);return ct>=0?Ke.electionTexts[ct].fullText_labelId:J(mt)}return""}),[J,h]),oe=12,fe=()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="none"&&(mt+=1);return mt===Ke}return!0},he=React$2.useCallback(()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="green"&&(mt+=1);return mt===Ke}return!0},[D]),ue=()=>!!(D&&D.length),_e=()=>D.find(Ke=>{const{feedback:mt}=h[Ke.currenTextParagraph].electionTexts[Ke.index];return mt.body!==""}),Oe=React$2.useCallback(()=>{const Ke=se();o({type:"finishMedia",payload:{name:c,text:Ke,documentType:a,type:"text"}})},[se,c,o,a]),Te=React$2.useCallback(Ke=>{const mt=he();re(R?"fail":mt?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ke||$,onFinish:a!=="view"?Oe:null}),o({type:"passPuzzle"})},[he,o,R,Oe,re,$,a]);React$2.useEffect(()=>{x&&Q(!1),u(()=>{Te(l.resolve.rewards)})},[o,Te,x,Oe,l.resolve.rewards,u,a]);const He=()=>{T(!1),C(0),F([]),V([]),S(!1),B(!1),k(!1),Z(!1),H(!1),P({text_0:{...h[0],id:"text_0",correct:""}}),I(!0),o({type:"addPoints",complex:!0,finish:!1,payload:$}),o({type:"failPuzzle"})},Ge=()=>{ue()?fe()&&(H(!0),Te()):(H(!0),B(!0),Te()),U?(I(!1),q&&!W?Z(!0):(W||!q&&!W)&&(!q&&!W&&t?he()?Te():He():Te())):(H(!0),_e()&&B(!0))},Xe=()=>{const Ke=h[A].electionTexts.filter(ct=>ct.correct).length,mt=h[A].electionTexts;return Ke===0||Ke===mt},pt=Ke=>{const mt=h[A].electionTexts[Ke],ct=mt.feedback.rewards;ct&&ct[0]&&ct[0].points&&(ne.current[`t${A}_e${Ke}`]||(mt.correct&&(ne.current[`t${A}_e${Ke}`]=!0),V([...$,...ct])));const ye=()=>Xe()?"none":mt.correct?"green":"red",de={currenTextParagraph:A,fullText:mt.fullText,index:Ke,isCorrect:ye()};P({...w,[`text_${A}`]:{type:"fixed",fullText:mt.fullText,correct:de.isCorrect}}),F([...D,de])},yt=()=>{p.current.scrollTop=p.current.scrollHeight+100},at=()=>{if(p.current.querySelector(".wrapfixed").offsetHeight>p.current.offsetHeight){const Ke=p.current.querySelector(".wrapfixed").offsetHeight;p.current.scrollTo({top:Ke,behavior:"smooth"})}},ht=(Ke,mt,ct)=>{const ye=Ke.fullText,de=h[ct+1]?h[ct+1].type:"",ge=w[`text_${ct+1}`]&&w[`text_${ct+1}`].type?w[`text_${ct+1}`].type:de;return jsxRuntimeExports.jsx(FixedComponent,{length:mt,doneTyping:O,index:ct,delay:oe,setDoneTyping:k,nextParagraphType:ge,isWriting:at,textToPrint:ye},ct.toString())},er=(Ke,mt)=>{const ct=Ke.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:ct,correct:Ke.correct},mt)},Ot=Ke=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:v,textWithOpts:Ke.electionTexts,setCurrentDecisionSelected:pt,printed:yt,disableExit:X},Ke.electionTexts),_t=(Ke,mt,ct)=>Ke.type==="fixed"?ht(Ke,mt,ct):Ot(Ke);React$2.useEffect(()=>{O===!0&&(()=>{h[A+1]?(P({...w,[`text_${A+1}`]:{...h[A+1],id:`text_${A+1}`,correct:""}}),C(A+1),k(!1)):T(!0)})()},[O,A,w,h]);const kt=React$2.useMemo(()=>{let Ke=`writer-puzzle writer-puzzle--${e}`;return g&&(Ke+=" disable-background-image"),Ke},[g,e]),Ft={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:kt,style:Ft,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[W&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>S(!0),decisionsList:D,closingAction:Ge,retry:t,skip:n,checkCorrect:he,retryAction:He,rewardsStack:$,nodeId:r,soundActions:v}),!W&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:p,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:G&&!U&&Object.values(w).map((Ke,mt)=>_t(Ke,Object.values(w).length-1,mt))}),U&&Object.values(w).map((Ke,mt)=>er(Ke,mt))]})}),x&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Ge,children:_("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:l,soundActions:u,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[v]=u,E={image:{component:Image$1,props:{...o,url:h,soundActions:u}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:u,translate:l}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:u}},pdf:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const g=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),T=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,shortText:!0,success:c===T,text:c===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===T?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:l,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(g,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===T&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:l("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${l}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:l,setResolveAction:u,nodeId:f,keyboardControl:c}){const[h,v]=React$2.useState({}),[E]=React$2.useState(!1),[g,_]=React$2.useState([]),p=React$2.useRef([]),[x]=l,T=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),v(k),_([...g,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[g,a,o,x]);React$2.useEffect(()=>{v(S),_([S])},[S]),React$2.useEffect(()=>{u(()=>{p.current=[...p.current,...n.resolve.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[u,n.resolve.rewards,o,R]);const C=()=>{p.current=[...p.current,...n.solution.wrong.rewards];const k=g.length-1,D=g.filter((F,U)=>k>U);v(g[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=g[0];v(k),_([k])},P=()=>{p.current=[...p.current,...n.solution.right.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:C,initFile:S,selectItem:A,breadcrumb:g,closeFolder:w,file:h,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:l,backFile:C,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:T,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:l,emitEvent:u,soundActions:f,keyboardControl:c}){const{solution:h}=t,v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),p=React$2.useRef({}),[x,T]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(),[w]=React$2.useState(new window.Image),P=React$2.useRef([]),[O]=f,k=X=>u({type:"translate",payload:X});React$2.useEffect(()=>{l(x!=="")},[x,l]);const D=(X,Q)=>(X.x+X.width>Q.x&&X.x+X.width<=Q.x+Q.width||Q.x+Q.width>X.x&&Q.x+Q.width<=X.x+X.width)&&(X.y+X.height>Q.y&&X.y+X.height<=Q.y+Q.height||Q.y+Q.height>X.y&&Q.y+Q.height<=X.y+X.height),F=()=>{v&&n&&(v.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},U=()=>{v&&n&&(v.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},H=React$2.useCallback(X=>{let Q=!1;if(X){const re=g.current;re.setPointersPositions(X);const ne=re.getPointerPosition(),ie=v.current.getClientRect({relativeTo:re});Q=D({...ne,width:1,height:1},ie)}return Q},[]),W=React$2.useCallback(X=>X&&r.uid===JSON.parse(X).uid,[r.uid]),Z=React$2.useCallback(()=>{T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"addPoints",complex:!0,finish:!0,payload:P.current}),u({type:"passPuzzle"}),a&&u({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),u({type:"closeUI",ui:"inventory"})},[a,u,r.name,r.uid]),q=React$2.useCallback(()=>{T("success"),u({type:"hidePuzzleButtons",payload:!0}),P.current=[...P.current,...h.right.rewards],setTimeout(()=>{Z()},2e3)},[u,Z,h.right.rewards]),B=React$2.useCallback(()=>{u({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"failPuzzle"}),P.current=[...P.current,...h.wrong.rewards]},[u,h.wrong.rewards]),G=React$2.useCallback(X=>{const Q=X.dataTransfer.getData("item");g.current.setPointersPositions(X);const re=H(X);u({type:"hidePuzzleButtons",payload:!0}),re&&W(Q)?(T("success"),u({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&q()):(u({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{B()},2e3))},[H,W,u,q,B,t.solution.right.desc,t.solution.wrong.desc]),I=()=>{x==="success"?q():B()};React$2.useEffect(()=>{const X=e.img.url||"";w.src=X,w.onload=()=>{_.current&&(p.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:w.width,height:w.height,offsetX:w.width/2,offsetY:w.height/2,scale:{x:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height),y:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height)}},S(!0))}},[w,e.img.url]);const $=X=>{X!==null&&(v.current=X)},V=X=>{if(X!==null&&(E.current=X,v.current)){const{x:Q,y:re,width:ne,height:ie}=v.current.getClientRect();X.setAttr("x",Q),X.setAttr("y",re),X.setAttr("height",ie),X.setAttr("width",ne)}};return React$2.useLayoutEffect(()=>{if(v.current&&R){const X=v.current.getClientRect({relativeTo:v.current.getParent()});C({x:X.x+X.width/2,y:X.y+X.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:G,onDragOver:X=>{X.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:g,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:w,...p.current}),jsxRuntimeExports.jsxs(Group,{...p.current,children:[A?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...A},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:F,onMouseLeave:U,ref:$,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:F,onMouseLeave:U,ref:V,text:k("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:k,playSound:O,functionOnClose:I,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:l}){const[u,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let T=!1;return n[r.id].find(R=>R.id===x)&&(T=!0),T},v=x=>{let T="";return u?(e&&h(x.id)&&(T="selected"),o&&h(x.id)&&a.includes(x.id)&&(T="success"),o&&h(x.id)&&!a.includes(x.id)&&(T="failed")):(e&&x.id===n[r.id][0].id&&(T="selected"),o&&x.id===n[r.id][0].id&&(T=n[r.id][0].isCorrect?"success":"failed")),T},E=x=>{const T=v(x);return T==="selected"?"icon-check-circle-black color--selected":T==="success"?"icon-check-circle-black color--success":T==="failed"?"icon-error-circle-black color--error":""},g=x=>o&&x.feedback&&(u&&h(x.id)||x.id===n[r.id][0].id),_=(x,T)=>T===0?"tooltip--right__top":T===x.length-1?"tooltip--right__bottom":"tooltip--center__right",p=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{p.length===1?f(!1):f(!0)},[p.length,u,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),u&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:l("tests.chooseMoreOneAnswer")}):null,c.map((x,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[u?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!v(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${v(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[T]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${g(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${v(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${_(c,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:l("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=u=>e.includes(u),a=(u,f)=>u.index<f.index?-1:u.index>f.index?1:0,l=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),l.map(u=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(u.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[u.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:u.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(u.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[u.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:u.feedback})]})]},u.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:l,showResults:u,answered:f,answerPage:c,updateForm:h,disabled:v,translate:E,soundActions:g,paused:_,view:p,correctQuestions:x,feedbacksOnlyWhenReview:T}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[C,w]=React$2.useState(),P=o[S].id,[O]=g;React$2.useEffect(()=>{if(l>=0&&!v&&!_){const q=setInterval(()=>{C||e(B=>B-1)},1e3);return r(q),()=>{clearInterval(q)}}},[v,C,_,r,e,l]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!v&&!T?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):u()},U=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!v&&!T?w(!0):u()},H=Math.floor(l/60),W=l%60;React$2.useEffect(()=>{if(p==="review"){const q=t[`q${S}`][0].id,B=document.querySelector(`#${q}`);R.scrollTo(0,B.offsetTop)}},[S,R,t,p]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,B=t[P],G=B.find($=>$.isCorrect===!1);let I=0;return B.forEach($=>{q.includes($.id)&&(I+=1)}),!G&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[p==="review"||C?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),p!=="review"&&l>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[H<10?`0${H}`:H," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:v,answered:f,updateForm:h,question:o[S],correctQuestions:v?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${p==="review"?"reviewmode":"next"}`,children:[p==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,C?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!C&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&U()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:l,restartTest:u,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:v}){const[E,g]=React$2.useState(0),[_,p]=React$2.useState(),[x,T]=React$2.useState([]),[R,S]=React$2.useState([]),[A,C]=React$2.useState([]),w=React$2.useCallback(()=>{const B=[];return t.forEach(G=>B.push(G.answers)),B},[t]),P=React$2.useCallback(()=>{const B=[];return Object.values(o).forEach(G=>{if(G.length>1){const I=G.find(V=>V.isCorrect===!1),$=[];I?B.push([]):(G.forEach(V=>{V.isCorrect&&$.push(V.id)}),B.push($))}else G[0].isCorrect?B.push([G[0].id]):G[0].isCorrect===!1&&B.push("")}),B},[o]),O=React$2.useCallback(()=>{let B=0;return R.length>0&&x.forEach((G,I)=>{G.length>1?G.every($=>R[I].includes($))&&(B+=1):G.length===1&&R[I]&&G[0]===R[I][0]&&(B+=1)}),B},[x,R]);React$2.useEffect(()=>{T(w),S(P),C(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<v,U=A>=v,H=!r||U,W=Math.trunc(E/k*100),Z=(B,G)=>h({type:"translate",payload:B,values:G}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const B=setInterval(()=>{g(G=>G+1)},100);return p(B),()=>{clearInterval(B)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&U||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:v})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),H?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),H?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:l,minimumPercentage:u=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,v]=React$2.useState({}),[E,g]=React$2.useState(),[_,p]=React$2.useState(0),[x,T]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,C]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[U,H]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,B=React$2.useRef({}),[G,I]=React$2.useState(),[$,V]=t,X=(se,oe,fe,he,ue)=>{const _e={...se,index:fe};if(_>0&&(_e.rewards=_e.rewards.filter(Te=>!U[se.id]||Te.points<0)),h[oe]){const Te=h[oe].find(He=>He.id===ue);if(Te){if(Te.id===se.id){const He=h[oe].find(Xe=>Xe.id===ue),Ge=h[oe].indexOf(He);if(h[oe].splice(Ge,1),h[oe].length===0){C(!1);return}}}else h[oe].push(_e)}else h[oe]=[_e];let Oe;he==="isRadio"?Oe={...h,[oe]:[_e]}:Oe={...h},v(Oe),F(Oe),H({...U,[se.id]:{...se}}),C(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(se=>{const oe=se.answers.filter(he=>he.isCorrect),fe=[];return oe.forEach(he=>{fe.push(he.id)}),{question:se.id,answers:fe}});React$2.useEffect(()=>{T(Q)},[Q]),React$2.useEffect(()=>{if(u){const se=Math.ceil(c.length*u/100);I(se)}},[c.length,u]),React$2.useEffect(()=>{R===0&&(clearInterval(E),C(!1),Z(!0),P("results"),V("tts"))},[E,V,R]);const re=()=>{clearInterval(E),C(!1),P("results");const se={...D};F(se),V("tts")},ne=()=>{const se={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(he=>{B.current[he.id]&&(he.rewards=[])})}),r({type:"saveTest",payload:se})},ie=()=>{const se=()=>{F({}),H({}),P("test"),v({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(he=>{he.forEach(ue=>{ue.isCorrect&&(B.current[ue.id]?ue.rewards=[]:B.current[ue.id]=!0)})});let fe=oe.reduce((he,ue)=>{const _e=[];return ue.forEach(Oe=>{_e.push(Oe.rewards)}),[...he,..._e.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:se}),r({type:"failTest"})},J=(se,oe)=>r({type:"translate",payload:se,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:p,tries:_,answerPage:C,setTime:S,paused:l,saveInterval:g,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:re,translate:J,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:ie,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:G})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((l,u)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--response__item ${e[r]===l?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[u]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${l}`)})]},l))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(l=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--points__item survey--points__item--colorized ${e[r]===l?"selected":""}`,children:l},l))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[l,u]=React$2.useState(!1),[f]=e,c=(E,g)=>o({type:"translate",payload:E,values:g}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)u(!0);else{E&&u(!1);const g=E?n-1:n+1;a(g)}},v=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(v,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),l&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!l&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,C,w;const[a,l]=React$2.useState(null),[u,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(0),[g,_]=React$2.useState({current:{questions:[],type:r}}),[p]=n,x=P=>t({type:"translate",payload:P}),T=P=>{P.keyCode===13&&P.target.blur()},R=()=>{p("click-ui"),t({type:"saveSurveyPrePos",payload:g.current})};React$2.useEffect(()=>{!e.length&&u==="questions"&&f("end")},[e,u]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=g.current.questions.find(F=>F.id===e[v].id))==null?void 0:D.answer;if(p("click-ui"),O)E(v-1),h(!1);else{const F=g.current.questions.findIndex(H=>H.id===e[v].id),U=[...g.current.questions];F>-1?U.splice(F,1,{id:e[v].id,answer:k}):U.push({id:e[v].id,answer:k}),_({...g,current:{...g.current,questions:U}}),v===e.length-1?h(!0):(E(v+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[u==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),p("click-ui")},translate:x}),u==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",v+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[v])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{l(O)},onTouchEnd:()=>{l(null)},onKeyUp:D=>{T(D)},onClick:()=>{S(O,!1)},className:`survey--points__item survey--points__item--simple ${((k=g.current.questions[v])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[v]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:v===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${v===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),p("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
252
|
+
`,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",u=r[a]!==e[a];if(l&&u){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,v={},E=!1;const g={};for(var a in e)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",_=r[a]!==e[a];if(l&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(g[f]=e[a])}!l&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,v[a]=e[a])}E&&(o.setAttrs(v),updatePicture(o));for(var f in g)o.on(f+EVENTS_NAMESPACE,g[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var l in e){var u=l.slice(0,2)==="on";u?a[l]=e[l]:n[l]=e[l]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let l=a.memoizedState;for(;l;){if(l.memoizedState===e)return!0;l=l.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),l=u=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(u):f.current=u)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),l(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(l(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{l(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[l]=React$2.useState(()=>document.createElement("div")),u=React$2.useMemo(()=>client.createRoot(l),[l]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),l.style.position="absolute",l.style.zIndex="10",l.style.top="0px",l.style.left="0px",l.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,l.style.transformOrigin="top left"}else l.style.position="",l.style.zIndex="",l.style.top="",l.style.left="",l.style.transform="",l.style.transformOrigin="";const h=r||{},{style:v}=h,E=__rest(h,["style"]);Object.assign(l.style,v),Object.assign(l,E)});return React$2.useLayoutEffect(()=>{var h;const v=a.current;if(!v)return;const E=(h=v.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(l),f&&needForceStyle(E)&&(E.style.position="relative"),v.on("absoluteTransformChange",c),c(),()=>{var g;v.off("absoluteTransformChange",c),(g=l.parentNode)===null||g===void 0||g.removeChild(l)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{u.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{u.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:l,onClickOutside:u}){const f=React$2.useRef(),[c,h]=React$2.useState(),v=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",g=DeviceDetection(),_=()=>{var S,A,C;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},p=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,C;a&&!e&&(t?(C=f.current)==null||C.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?u(o):l(o),(S=f.current)==null||S.setAttr("fill",v),(A=f.current)==null||A.setAttr("stroke",E))},T=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:p,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:T,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":v,stroke:e||r?E:"",strokeWidth:g?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:l,clickedZones:u}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),[p,x]=React$2.useState(new window.Image),[T,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const C=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{p.src=r,p.addEventListener("load",()=>{if(f.current){const w={x:T/2,y:R/2,width:p.width,height:p.height,offsetX:p.width/2,offsetY:p.height/2,scale:{x:Math.min(T/p.width,R/p.height),y:Math.min(T/p.width,R/p.height)}};v.current&&v.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),g.current&&g.current.setAttrs(w),f.current.batchDraw(),x(p),f.current.fire("stage-loaded")}})},[p,R,r,T]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:T,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:g,image:p})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:T,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:v,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:u.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ge,Ee;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:l,image:u,areas:f,badAreas:c,hasClickOrder:h,timer:v,hasClickOnce:E,hasHighlights:g,hasImageReview:_,defaultCompleted:p,className:x,emitFinish:T,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:C,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[U,H]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[V,X]=React$2.useState(!0),[Q,re]=React$2.useState(!1),ne=React$2.useRef(null),ie=React$2.useRef(null),J=React$2.useRef(null),se=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),he=React$2.useRef(null),ue=React$2.useRef(null),_e=React$2.useRef(null),[Oe,Te]=React$2.useState(v),He=Le=>S?S(Le):r({type:"translate",payload:Le}),[Ge]=e,{solution:Xe}=l,pt=u.img.url||defaultImg,yt=f.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),at=c.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),ht=React$2.useCallback(()=>{if(!V){const Le=setInterval(()=>{Te(Ve=>Ve>1?Ve-1:0)},1e3);_e.current=Le}},[V]),er=React$2.useCallback((Le,Ve)=>{T?T(Le,Ve):r({type:"addPoints",payload:Le})},[r,T]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(p)},[p]);const Ot=React$2.useCallback(()=>{clearInterval(J.current)},[]),_t=React$2.useCallback(()=>{clearInterval(_e.current)},[]),kt=React$2.useCallback(Le=>{oe.current=Date.now(),se.current?(he.current=se.current-oe.current,Ot()):(he.current=oe.current-(oe.current-Le*1e3),Ot())},[Ot]),Ft=React$2.useCallback(()=>{I(()=>{var Le,Ve;return{show:!0,success:!1,text:(Le=l==null?void 0:l.timerFeedback)!=null&&Le.desc?l.timerFeedback.desc:"",rewards:(Ve=l==null?void 0:l.timerFeedback)==null?void 0:Ve.rewards}}),re(!0),_t(),Ot()},[_t,Ot,(ge=l.timerFeedback)==null?void 0:ge.desc,(Ee=l.timerFeedback)==null?void 0:Ee.rewards]),Ke=React$2.useCallback(()=>{clearInterval(J.current),J.current=setInterval(()=>{ie.current=Date.now(),ie.current>se.current&&Ft()},250)},[Ft]);React$2.useEffect(()=>{var Le;if((f.length===U.length||E&&U.length>0)&&!W){Z(!0);const Ve=U[U.length-1],De=A==null?void 0:A.correctFeedbacks.find(ze=>ze.id===Ve.id);(!((Le=A==null?void 0:A.correctFeedbacks)!=null&&Le.length)||A!=null&&A.correctFeedbacks.some(ze=>!ze.desc)||E)&&(I(ze=>({...ze,show:!0,success:!0,text:De?De.desc:l.solution.right.desc,rewards:De?De.rewards:l.solution.right.rewards})),v&&(_t(),kt()))}},[U,f.length,A,E,W,l.solution.right,kt,v,_t]),React$2.useEffect(()=>{a(Le=>{v&&(_t(),X(!1),G.show?I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]})):Ot()),Z(!0),B(!0),setTimeout(()=>{R?R(Le):Le()},4e3)})},[a,R,Ge,v,G.show,Ot,_t]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const mt=(Le,Ve=!1)=>{var De,ze;if(!W){const{rewards:jt,desc:Mt}=Xe.wrong;let dt=Mt,vr=jt;const Wr=(De=A==null?void 0:A.wrongFeedbacks)==null?void 0:De.find(pn=>pn.id===Le.id);Wr&&(dt=Wr.desc,vr=Wr.rewards),h&&(H([]),Ve&&(ze=l==null?void 0:l.orderFeedback)!=null&&ze.desc&&(dt=l.orderFeedback.desc,vr=l.orderFeedback.rewards)),v&&(_t(),kt()),I(pn=>({...pn,show:!0,success:!1,text:dt,rewards:vr})),Ge("fail")}},ct=React$2.useCallback(()=>{fe.current=Date.now();const Le=fe.current+he.current;ie.current=null,se.current=Le,(v||Q)&&(G.success?f.length===U.length||E&&U.length>0?_t():(Te(he.current*.001),ht(),Ke()):(H([]),X(!0),w())),er(G.rewards,G.success),Ge("click-ui"),I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]}))},[v,Q,er,G.rewards,G.success,Ge,f.length,U.length,E,w,_t,ht,Ke]),ye=Le=>{var Ve,De;if(!U.some(ze=>ze.index===Le.index)&&!G.show&&!W){Ge("click-ui");let ze=Xe.right.desc,{rewards:jt}=Xe.right;const Mt=[...U,Le];if(h&&Le.index===U.length||!h){if(v&&kt(Oe),t(),(Ve=A==null?void 0:A.correctFeedbacks)!=null&&Ve.length){const dt=(De=A.correctFeedbacks)==null?void 0:De.find(vr=>vr.id===Le.id);dt&&(ze=dt.desc,jt=dt.rewards),!ze&&f.length>Mt.length&&!E?er(jt,!0):ze&&!E&&(I(vr=>({...vr,show:!0,success:!0,text:ze,rewards:jt})),v&&_t())}H(Mt)}else mt(Le,!0)}},de=React$2.useCallback(()=>{_t(),Te(v),ht(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),se.current=ne.current+v*1e3,Ke()},[_t,v,ht,P,Ke,k]);return React$2.useEffect(()=>{v&&C>0&&!ue.current&&(P&&Object.keys(O).length&&O[C-1]?(X(!0),ue.current=!0):X(!1))},[p,P,O,C,v]),React$2.useEffect(()=>{v&&Oe===0&&Ft()},[Oe,Ft,v]),React$2.useEffect(()=>{v&&(D?(_t(),kt()):ht())},[_t,Ke,D,kt,ht,v]),jsxRuntimeExports.jsxs("div",{className:x,children:[G.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ge,text:G.text,success:G.success,translate:He,hasTimeout:!G.text,delay:v?1e3:2e3,functionOnClose:ct,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&U.length?[U[0]]:yt,badAreas:at,clickedZones:U,onClick:ye,onClickOutside:mt,hasHighlights:g,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,v&&V?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[C-1],translate:He,onInit:de}):null,v?jsxRuntimeExports.jsx(CountDown,{time:Oe}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const l of e.toLowerCase()){const u=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[u][f].value=l,n.push({char:l,position:[u,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let l=0;l<r;l+=1)switch(t.reduce((f,c)=>{const h=[a,l],v=getDistance(c.position,h);return v<f?v:f},9999)){case 0:n[a][l].hiddenColor=GREEN;break;case 1:n[a][l].hiddenColor=ORANGE;break;case 2:n[a][l].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,l]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,l)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let l=0;l<e;l+=1){const u={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(u)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[l,u]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(l,e,o,u)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:l,setResolveAction:u}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),v=React$2.useRef(),{solution:E}=r,[g,_]=React$2.useState(n.toLowerCase()),[p,x]=React$2.useState(),[T,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:U,visibleColumns:H}=DIFFICULTY_MAP[l];let W=U==="auto"?Math.ceil(window.innerHeight*.025):U;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{u(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[u,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,re)=>({char:Q,index:re,used:!1})),B=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),G=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(v.current!==void 0){const Q=X-v.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(G),I=0)}v.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:H,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const V=()=>{if(D.length<=1)return;const[X,Q]=C,re=D[X][Q];if(re.hiddenColor===GREEN){const ne=p.filter(ie=>ie.char===re.value.toLowerCase()&&ie.used===!1)[0];if(ne){const{index:ie}=ne;f("score");const J=p;J[ie].used=!0,x(J);const se=[...T];se[ie]=re.value;const oe=B(J);_(oe);const fe=repaintGridPassword(D,oe,W,H);F(fe),R(se)}}g<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||V()},[C]),jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__container",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__header",children:[jsxRuntimeExports.jsx("span",{className:"title",children:"Dcoder.exe"}),jsxRuntimeExports.jsx("div",{className:"puzzle--pieces",children:T.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:C,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(l=>{n[a]||(n[a]=[]),n[a]=[...n[a],l],l.char===" "&&(a+=1),t||(l.positionInitial=l.index)}),n.map((l,u)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${u}`,children:r?l.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):l.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${l[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${l+u}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:l,hintUsed:u,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[v]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[g,_]=React$2.useState(0),[p,x]=React$2.useState(!1),[T,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,U]=React$2.useState([]),[H,W]=React$2.useState(!1),Z=l.toUpperCase().split(""),q=Z.filter(he=>restrictCharacters(he,"and")),B=he=>e({type:"translate",payload:he}),G=React$2.useCallback(()=>{const he=q.map(Oe=>({char:Oe}));let ue=[];const _e=analyzeChars(q);for(;ue.length<MAX_EXTRA_LETTERS;){const Oe=makeChar(_e);ue=[...ue,{char:Oe}]}return[...he,...ue]},[q]),I=l.toUpperCase().split("").map((he,ue)=>restrictCharacters(he,"or")?{index:ue,letter:he,char:he,fixed:!0}:{index:ue,letter:he,char:""}),$=React$2.useCallback(()=>{let he=G();for(;he.length>MAX_POOL_LETTERS;){const ue=Math.trunc(Math.random()*(he.length-1))+1,_e=he[ue],Oe=I.find((Te,He)=>_e.char===Te.letter&&!I[He].fixed);Oe&&(he.splice(ue,1),I[Oe.index]={...Oe,char:Oe.letter,fixed:!0})}u&&(he=[],I.forEach(({letter:ue})=>{ue!==" "&&he.push({char:ue})})),w(I),R(he)},[I,u,G]),V=(he,ue)=>T.map((Oe,Te)=>Te===ue?{...Oe,deleted:!0}:{...Oe}),X=(he,ue,_e)=>{const Oe=ue.map((He,Ge)=>_e.find(pt=>pt.poolIndex===Ge)?{char:He.char}:He);R(Oe),w(he);const Te=he.find(He=>He.char==="");_(Te.index)},Q=(he,ue)=>{v("click-ui");let _e=!1;const Oe=C.map(Ge=>!Ge.char&&!_e?(_e=!0,{...Ge,char:he,poolIndex:ue}):Ge),Te=V(he,ue),He=Oe.filter(Ge=>Ge.char).length;R(Te),w(Oe),re(),He===C.length&&se(Oe,Te)},re=()=>{var he;if(p){const ue=C.find(_e=>_e.index!==g&&_e.letter!==" "&&_e.char===""&&_e.poolIndex===!1);ue&&_(ue.index)}else{const ue=C.find(_e=>_e.char==="");_(ue.index+1),((he=C[ue.index+1])==null?void 0:he.letter)===" "&&_(ue.index+2)}},ne=()=>{v("click-ui");const he=C.map((ue,_e)=>C[C.length-1-_e]).find(ue=>ue.char&&!ue.fixed);if(he){const ue=C.map(Te=>Te.index===he.index?{...he,char:""}:Te);let _e=!1;const Oe=T.map((Te,He)=>He===he.poolIndex&&(Te.deleted||!_e)?(_e=!0,{char:Te.char}):Te);R(Oe),w(ue),_(he.index)}},ie=()=>{r(!0),O("");const he=[...F,...a.solution.right.rewards];v("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:he}),e({type:"passPuzzle"})},J=()=>{v("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},se=(he,ue)=>{let _e=[];D(!0);const Oe=he.map((He,Ge)=>Z[Ge]===He.char?{...He,fixed:!0}:(_e=[..._e,He],{...He,poolIndex:!1,char:""})),Te=Oe.filter(He=>He.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Te===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{ie()},2e3)):(O("failed"),X(Oe,ue,_e),a.solution.wrong.desc===""&&setTimeout(()=>{J()},2e3))},oe=()=>{if(P==="success")ie();else{J();const he=C.find(ue=>ue.char==="");_(he.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(he=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),he()},2e3)}),c(he=>{const ue=[];I.forEach(({letter:_e})=>{_e!==" "&&ue.push({char:_e})}),R(ue),he()})},[$,S,l,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:B,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:H?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,answer:l.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,flickerPosition:g,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((he,ue)=>sortChar(he,ue)).map((he,ue)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${he.char}`,type:"button",onClick:()=>{!he.deleted&&!P&&!k&&(Q(he.char,ue),v("click-ui"))},className:`puzzle--hanged__keyboard--item ${he.deleted||k?"disabled":""}`,children:he.char},`${he+ue}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":B("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:l,soundActions:u,setSelected:f,selected:c,pause:h,loadPuzzleStatus:v,index:E,setIndex:g,slidesCompleted:_,setSlidesCompleted:p,keyboardControl:x,totalCorrects:T}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),C=`chained-image-click-puzzle_${E}_${r}`,[w]=u,P=B=>{R.current=[...R.current,...B]},O=React$2.useCallback(B=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...B]}),n({type:"passPuzzle"})},[w,n]),[k,D]=React$2.useState(!1),F=o[E],{info:U,specificFeedbacks:H}=F;U.description=e,React$2.useEffect(()=>{S.current=0,A.current=0,D(!1)},[E]);const W=React$2.useCallback((B,G=!1)=>{var $;let I={..._};if(G){if(($=H==null?void 0:H.correctFeedbacks)!=null&&$.length&&!F.hasClickOnce){const V=H.correctFeedbacks.length;k&&V?(S.current>0?f(c+(V-S.current)):f(c+V),S.current=V):S.current+=1}else{let V=c;A.current&&(V-=A.current),S.current=F.areas.length,f(V+S.current)}S.current===F.areas.length&&(E+1>=o.length?O(B):g(E+1),I={...I,[E]:!0},p(I)),P(B)}else n({type:"addPoints",payload:B,finish:!1}),n({type:"failPuzzle"}),F.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&F.hasClickOrder&&!c&&f(0)},[_,H,F.hasClickOnce,F.areas.length,F.hasClickOrder,c,f,E,o.length,p,O,g,n]),Z=()=>{D(!0),E>=o.length-1&&f(T),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{v&&E!==o.length-1&&W([],!0)},[E,o.length,v,W]);const q=()=>{const B=F.hasClickOnce?F.areas.length:1;A.current+=B,f(c+B)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...F,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:H,emitFinish:W,emitError:P,emitResolve:Z,isLast:E+1===o.length,defaultCompleted:_[E]||!!v,hideContinue:E+1!==o.length,handleClick:q,emitEvent:n,disableExit:a,soundActions:u,setResolveAction:l,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:l,showFrames:u,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[v,E]=React$2.useState(0),[g,_]=React$2.useState(0),[p,x]=React$2.useState({}),T=`chained-image-click-puzzle_${g}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:T}),[r,T]),S=n.reduce((C,w)=>C+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:l,setInfo:e,setSelected:E,selected:v,index:g,setIndex:_,slidesCompleted:p,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[u?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:l,setFramesCompleted:u,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:v,description:E,translateFromParent:g,setInfo:_,emitEvent:p,nodeId:x,setSelected:T,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:C,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:U}){var ie;const[H]=c,[W,Z]=React$2.useState(!1),q=o[e],{info:B,specificFeedbacks:G}=q;B.description=E;const I=React$2.useRef(0),$=React$2.useRef(0),V=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...B,hintId:V})},[_,B,V]),React$2.useEffect(()=>{O&&($.current=0,I.current=0,T(0),k(!1))},[O,k,T]),React$2.useEffect(()=>{$.current=0,I.current=0,Z(!1)},[e]);const X=React$2.useCallback((J,se=!1)=>{var fe;let oe={...t};if(se){if((fe=G==null?void 0:G.correctFeedbacks)!=null&&fe.length&&!q.hasClickOnce){const he=G.correctFeedbacks.length;W&&he?($.current>0?T(R+(he-$.current)):T(R+he),$.current=he):$.current+=1}else{let he=R;I.current&&(he-=I.current),$.current=q.areas.length,w[0]&&Object.entries(t).length===0?T($.current):T(he+$.current)}$.current===q.areas.length&&(e+1>=o.length&&n(J),oe={...oe,[e]:!0},u(oe),l(e+1>o.length-1?0:e+1)),a(J)}else p({type:"addPoints",payload:J,finish:!1}),p({type:"failPuzzle"}),q.hasClickOrder&&(T(R-$.current),$.current=0)},[t,(ie=G==null?void 0:G.correctFeedbacks)==null?void 0:ie.length,q.hasClickOnce,q.areas.length,q.hasClickOrder,a,R,w,T,e,o.length,u,l,n,p]),Q=React$2.useCallback(()=>{Z(!0),e>=o.length-1&&T(U),H("score"),p({type:"hidePuzzleButtons",payload:!1}),C(J=>({...J,[e]:!0})),p({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:B.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,H,p,C,V,B.resolve.rewards,T,U]),re=React$2.useCallback(()=>{u({}),$.current=0,I.current=0,S()},[S,u]);React$2.useEffect(()=>{f&&e!==o.length-1&&X([],!0)},[t,e,o.length,f,X]);const ne=()=>{const J=q.hasClickOnce?q.areas.length:1;I.current+=J,T(R+J)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...q,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:G,emitFinish:X,emitResolve:Q,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:v,translateFromParent:g,emitEvent:p,slideNumber:e,handleClick:ne,emitResetPuzzle:re,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:l,setResolveAction:u,setInfo:f,pause:c,keyboardControl:h}){const[v,E]=React$2.useState({}),g=React$2.useRef([]),[_,p]=React$2.useState(0),[x,T]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[C,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((V,X)=>V+X.areas.length,0),U=V=>{g.current=[...g.current,...V]},H=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:H}),[o,H]),Z=React$2.useCallback(V=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...g.current,...V]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),g.current=[],S(0),p(0),T({}),w(!0),D(!0)},[]),B=V=>o({type:"translate",payload:V}),G=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:U,accRewards:g,setSelected:S,selected:R,setIndex:p,setFramesCompleted:T,loadPuzzleStatus:W,soundActions:a,setResolveAction:u,disableExit:l,translateFromParent:B,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:v,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:G,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!C,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:l=>t({logo:l})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:l=>t({color:l})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const l=o?e.header.userImage:r.userImage,u=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+l})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(u||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const l=o?e.body.work:r.work,u=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const l=o?e.body.bgImage:r.bgImage,u=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+l})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${u}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(),f=l===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${l===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>u(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(l)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(),f=!l;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>u(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(l.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[l,u]=React$2.useState(""),f=l==="",[c,h]=React$2.useState(!1),v=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:v,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:l,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(g=>g instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:[jsxRuntimeExports.jsx("span",{children:t(g.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(g.desc)})]},g.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:t(g)},g))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(l)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n.props,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:l}){const[u,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(!1),[g,_]=React$2.useState(!1),[p,x]=React$2.useState(!1),[T,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[C,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,U=re=>r({type:"translate",payload:re}),H=()=>{w({type:"",props:{}})},W=(re,ne={})=>{w({type:re,props:ne})},Z=()=>{if(e.solution){const{rewards:re}=e.solution.right,{rewards:ne}=e.solution.wrong;F(v?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:v?ne:re}),r({type:"passPuzzle"})}},q=l({disabled:T!=="success",forward:Z,escape:Z});React$2.useEffect(()=>q(),[q]);const B=(re,ne)=>{const ie=Object.keys(re),J={existing:0,equal:0};return ie.forEach(se=>{ne[se]!==null&&ne[se]!==""&&(J.existing+=1),re[se]===ne[se]&&(J.equal+=1)}),J},G=(re,ne)=>{const ie=Object.keys(A.header).length,J=Object.keys(A.body).length,se=B(A.header,re),oe=B(A.body,ne),fe=oe.existing+se.existing===ie+J,he=oe.equal+se.equal===ie+J;return{exist:fe,equal:he}},I=()=>{F("click-ui");const{exist:re,equal:ne}=G(P,k);r({type:"hidePuzzleButtons",payload:!0}),re&&!ne?(p&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):re&&ne&&(p&&(a(!1),x(!1)),_(!0),R("success"))},$=re=>{if(Object.keys(re).length>0){const ne={...P,...re};O(ne),H();const{exist:ie}=G(ne,k);x(!!ie)}},V=re=>{if(Object.keys(re).length>0){const ne={...k,...re};D(ne),H();const{exist:ie}=G(P,ne);x(!!ie)}};React$2.useEffect(()=>{t(re=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),re()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const X={showingReference:u||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:U},Q=()=>{T==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):T==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:H,soundActions:n,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:u,displayButton:!c&&!g,translate:U,clickAction:()=>{F("click-ui"),f(!u)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...X,header:P,onSave:$}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...X,header:P,onSave:$}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...X,body:k,onSave:V})]}),!p&&!u?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:Q,resolved:c,translate:U}):null,p&&!u?jsxRuntimeExports.jsx(PublishButton,{onPublish:I,translate:U}):null]})}function CardImage({img:o}){const r=(o||{}).url;return jsxRuntimeExports.jsx("img",{src:r,alt:""})}function CardText({text:o,hasImage:e}){return o?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${e?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o||"_"})})}):null}function CardNumber({order:o}){return o?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o})}):null}function CardSuccess({order:o}){return jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[jsxRuntimeExports.jsx(CardNumber,{order:o}),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]})}function CardFail(){return jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})})}function CardContainer({flipped:o,correct:e,order:r,wrongOrder:t,isEmpty:n}){return!n&&o&&e&&!t?jsxRuntimeExports.jsx(CardSuccess,{order:r}):!n&&o?jsxRuntimeExports.jsx(CardFail,{}):null}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),l=()=>!!(r&&!o.correct||!r);return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&l()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[jsxRuntimeExports.jsx(CardImage,{img:o.img}),jsxRuntimeExports.jsx(CardText,{text:o.text,hasImage:!!o.img}),jsxRuntimeExports.jsx(CardContainer,{isEmpty:a(),flipped:r,wrongOrder:n,order:o.order,correct:o.correct})]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:l,onFinish:u,handleSuccess:f,resolveWithAnyCard:c}){const[h,v]=React$2.useState(Array(o.length).fill(!1)),[E,g]=React$2.useState(Array(o.length).fill(!1)),[_,p]=React$2.useState(0),[x,T]=React$2.useState(!1),[R]=l,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,C=React$2.useCallback(()=>{v(Array(o.length).fill(!1)),g(Array(o.length).fill(!1)),p(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{C()},1e3)};function P(F,U=F){const H=Array.from(h);H[F]=U,v(H)}const O=React$2.useCallback(()=>{const F=[];o.forEach((U,H)=>{U.correct===!0&&F.push(H)}),v(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(u(),T(!0),p(0))},[_,u,S,c]);const k=F=>{P(F),f(o[F].id||null),p(_+1)},D=F=>{var U,H;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A){if(o[F].order===e)r(e+1),k(F);else if(P(F),o[F].order!==e){const W=Array.from(E);W[F]=F,g(W),t(((U=o[F])==null?void 0:U.id)||null,o[F].correct),w()}}else t(((H=o[F])==null?void 0:H.id)||null),P(F),setTimeout(()=>{P(F,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(U),flipped:h.includes(U),wrongOrder:E.includes(U),cardIndex:U},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:l,soundActions:u,backgroundImage:f,nodeId:c,keyboardControl:h,hideBackgroundImageTheme:v=!1}){var Q,re;const[E,g]=React$2.useState(!1),[_,p]=React$2.useState(1),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(!1),[w,P]=React$2.useState([]),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(""),[U]=u,H=ne=>o({type:"translate",payload:ne}),W=`cards-selector-puzzle_${c}`,Z=React$2.useCallback(ne=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{var se,oe;o({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:ne}=((se=e==null?void 0:e.solution)==null?void 0:se.right)||{},ie=((oe=n==null?void 0:n.correctFeedbacks)==null?void 0:oe.map(fe=>fe.rewards).flat())||[],J=[...w,...ne,...ie];U("score"),Z(J)},[w,Z,o,(Q=e==null?void 0:e.solution)==null?void 0:Q.right,U,n==null?void 0:n.correctFeedbacks]),B=()=>{g(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&F(e.solution.right.desc),C(!0)},G=()=>{x||E?q():(T(!1),a(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1})),F("")},I=ne=>{if(S(!0),n!=null&&n.specificCorrectFeedbacks){const ie=n.correctFeedbacks.find(J=>J.id===ne);ie!=null&&ie.desc&&(F(ie.desc),C(!0))}U("score"),o({type:"hidePuzzleButtons",payload:!0})},$=(ne,ie=!1)=>{var J,se;if(S(!1),ie)F((J=e.orderFeedback)==null?void 0:J.desc),C(!0),P([...w,...((se=e.orderFeedback)==null?void 0:se.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const oe=n.wrongFeedbacks.find(fe=>fe.id===ne);oe!=null&&oe.desc?(F(oe.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),P([...w,...(oe==null?void 0:oe.rewards)||[]])}else e.solution.wrong.desc?(F(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!ie&&P([...w,...e.solution.wrong.rewards]),U("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};React$2.useEffect(()=>{E&&a(!0)},[a,E]),React$2.useEffect(()=>{l(()=>{var ie;o({type:"hidePuzzleButtons",payload:!0}),k(!0);const ne=[...w,...((ie=e==null?void 0:e.resolve)==null?void 0:ie.rewards)||{}];setTimeout(()=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:W,rewards:ne,finish:!0}})},2e3)})},[l,a,w,(re=e==null?void 0:e.resolve)==null?void 0:re.rewards,o,W]);const V=React$2.useMemo(()=>{let ne="";return ne="cards-selector",f!=null&&f.url&&(ne+=" cards-selector--with-custom-bg"),v&&(ne+=" disable-background-image"),ne},[f==null?void 0:f.url,v]),X={backgroundImage:f!=null&&f.url?`url('${f.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:V,style:X,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:p,currentOrder:_,cards:r,onFinish:B,resolveWithAnyCard:t,handleError:$,feedbackIsShown:A,resolvePuzzle:O,soundActions:u,handleSuccess:I})}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:x||R,text:D,hasTimeout:!D,translate:H,functionOnClose:G,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:l}){const[u,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[v,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const g=T=>{if(!T||!T.length)return"";const R=T.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const T=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const C=[...S];if(g(S[A]).length!==0){const w=S[A];return C[A]=`<span class="lastWord" >${w}</span>`,C}return R(S,A-1)};a==="election"?h(T()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},p=t.split("<p>");p.shift();const x=p.length>1;return u&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:l,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&v&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[l]=a,u=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{l("click-ui"),r(t)},h=E=>{E.keyCode===13&&v(E)},v=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:u(o)})}),jsxRuntimeExports.jsx("div",{onClick:v,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(l=>!!l.fullText).length}`,children:o&&o.map((l,u)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:l,soundActions:t,index:u,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},u))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:l,skip:u,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:v}){const[E]=v,g=p=>o({type:"translate",payload:p}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:g("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(p=>n[p.currenTextParagraph].electionTexts[p.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[p.currenTextParagraph].electionTexts[p.index]},p.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:g("puzzles.skip")}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:g(f()?"puzzles.continue":"puzzles.retry")}),!l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:g("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:l,setResolveAction:u,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:v,backgroundImage:E,hideBackgroundImageTheme:g=!1}){const _=Ke=>o({type:"translate",payload:Ke}),p=React$2.useRef(),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(0),[w,P]=React$2.useState({[`text_${A}`]:{...h[A],id:`text_${A}`,correct:""}}),[O,k]=React$2.useState(!1),[D,F]=React$2.useState([]),[U,H]=React$2.useState(!1),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState(!0),[$,V]=React$2.useState([]),[X,Q]=React$2.useState(!0),[re]=v,ne=React$2.useRef({}),ie=Ke=>{let mt;return Ke.electionTexts.forEach((ct,ye)=>{ct.correct&&(mt=ye)}),mt},J=React$2.useCallback(Ke=>D.filter(ct=>ct.currenTextParagraph===Ke)[0].fullText_labelId,[D]),se=React$2.useCallback(()=>h.map((Ke,mt)=>{if(Ke.type==="fixed")return Ke.fullText_labelId??Ke.fullText;if(Ke.type==="election"){const ct=ie(Ke);return ct>=0?Ke.electionTexts[ct].fullText_labelId:J(mt)}return""}),[J,h]),oe=12,fe=()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="none"&&(mt+=1);return mt===Ke}return!0},he=React$2.useCallback(()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="green"&&(mt+=1);return mt===Ke}return!0},[D]),ue=()=>!!(D&&D.length),_e=()=>D.find(Ke=>{const{feedback:mt}=h[Ke.currenTextParagraph].electionTexts[Ke.index];return mt.body!==""}),Oe=React$2.useCallback(()=>{const Ke=se();o({type:"finishMedia",payload:{name:c,text:Ke,documentType:a,type:"text"}})},[se,c,o,a]),Te=React$2.useCallback(Ke=>{const mt=he();re(R?"fail":mt?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ke||$,onFinish:a!=="view"?Oe:null}),o({type:"passPuzzle"})},[he,o,R,Oe,re,$,a]);React$2.useEffect(()=>{x&&Q(!1),u(()=>{Te(l.resolve.rewards)})},[o,Te,x,Oe,l.resolve.rewards,u,a]);const He=()=>{T(!1),C(0),F([]),V([]),S(!1),B(!1),k(!1),Z(!1),H(!1),P({text_0:{...h[0],id:"text_0",correct:""}}),I(!0),o({type:"addPoints",complex:!0,finish:!1,payload:$}),o({type:"failPuzzle"})},Ge=()=>{ue()?fe()&&(H(!0),Te()):(H(!0),B(!0),Te()),U?(I(!1),q&&!W?Z(!0):(W||!q&&!W)&&(!q&&!W&&t?he()?Te():He():Te())):(H(!0),_e()&&B(!0))},Xe=()=>{const Ke=h[A].electionTexts.filter(ct=>ct.correct).length,mt=h[A].electionTexts;return Ke===0||Ke===mt},pt=Ke=>{const mt=h[A].electionTexts[Ke],ct=mt.feedback.rewards;ct&&ct[0]&&ct[0].points&&(ne.current[`t${A}_e${Ke}`]||(mt.correct&&(ne.current[`t${A}_e${Ke}`]=!0),V([...$,...ct])));const ye=()=>Xe()?"none":mt.correct?"green":"red",de={currenTextParagraph:A,fullText:mt.fullText,index:Ke,isCorrect:ye()};P({...w,[`text_${A}`]:{type:"fixed",fullText:mt.fullText,correct:de.isCorrect}}),F([...D,de])},yt=()=>{p.current.scrollTop=p.current.scrollHeight+100},at=()=>{if(p.current.querySelector(".wrapfixed").offsetHeight>p.current.offsetHeight){const Ke=p.current.querySelector(".wrapfixed").offsetHeight;p.current.scrollTo({top:Ke,behavior:"smooth"})}},ht=(Ke,mt,ct)=>{const ye=Ke.fullText,de=h[ct+1]?h[ct+1].type:"",ge=w[`text_${ct+1}`]&&w[`text_${ct+1}`].type?w[`text_${ct+1}`].type:de;return jsxRuntimeExports.jsx(FixedComponent,{length:mt,doneTyping:O,index:ct,delay:oe,setDoneTyping:k,nextParagraphType:ge,isWriting:at,textToPrint:ye},ct.toString())},er=(Ke,mt)=>{const ct=Ke.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:ct,correct:Ke.correct},mt)},Ot=Ke=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:v,textWithOpts:Ke.electionTexts,setCurrentDecisionSelected:pt,printed:yt,disableExit:X},Ke.electionTexts),_t=(Ke,mt,ct)=>Ke.type==="fixed"?ht(Ke,mt,ct):Ot(Ke);React$2.useEffect(()=>{O===!0&&(()=>{h[A+1]?(P({...w,[`text_${A+1}`]:{...h[A+1],id:`text_${A+1}`,correct:""}}),C(A+1),k(!1)):T(!0)})()},[O,A,w,h]);const kt=React$2.useMemo(()=>{let Ke=`writer-puzzle writer-puzzle--${e}`;return g&&(Ke+=" disable-background-image"),Ke},[g,e]),Ft={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:kt,style:Ft,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[W&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>S(!0),decisionsList:D,closingAction:Ge,retry:t,skip:n,checkCorrect:he,retryAction:He,rewardsStack:$,nodeId:r,soundActions:v}),!W&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:p,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:G&&!U&&Object.values(w).map((Ke,mt)=>_t(Ke,Object.values(w).length-1,mt))}),U&&Object.values(w).map((Ke,mt)=>er(Ke,mt))]})}),x&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Ge,children:_("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:l,soundActions:u,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[v]=u,E={image:{component:Image$1,props:{...o,url:h,soundActions:u}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:u,translate:l}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:u}},pdf:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const g=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),T=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,shortText:!0,success:c===T,text:c===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===T?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:l,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(g,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===T&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:l("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${l}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:l,setResolveAction:u,nodeId:f,keyboardControl:c}){const[h,v]=React$2.useState({}),[E]=React$2.useState(!1),[g,_]=React$2.useState([]),p=React$2.useRef([]),[x]=l,T=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),v(k),_([...g,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[g,a,o,x]);React$2.useEffect(()=>{v(S),_([S])},[S]),React$2.useEffect(()=>{u(()=>{p.current=[...p.current,...n.resolve.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[u,n.resolve.rewards,o,R]);const C=()=>{p.current=[...p.current,...n.solution.wrong.rewards];const k=g.length-1,D=g.filter((F,U)=>k>U);v(g[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=g[0];v(k),_([k])},P=()=>{p.current=[...p.current,...n.solution.right.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:C,initFile:S,selectItem:A,breadcrumb:g,closeFolder:w,file:h,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:l,backFile:C,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:T,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:l,emitEvent:u,soundActions:f,keyboardControl:c}){const{solution:h}=t,v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),p=React$2.useRef({}),[x,T]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(),[w]=React$2.useState(new window.Image),P=React$2.useRef([]),[O]=f,k=X=>u({type:"translate",payload:X});React$2.useEffect(()=>{l(x!=="")},[x,l]);const D=(X,Q)=>(X.x+X.width>Q.x&&X.x+X.width<=Q.x+Q.width||Q.x+Q.width>X.x&&Q.x+Q.width<=X.x+X.width)&&(X.y+X.height>Q.y&&X.y+X.height<=Q.y+Q.height||Q.y+Q.height>X.y&&Q.y+Q.height<=X.y+X.height),F=()=>{v&&n&&(v.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},U=()=>{v&&n&&(v.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},H=React$2.useCallback(X=>{let Q=!1;if(X){const re=g.current;re.setPointersPositions(X);const ne=re.getPointerPosition(),ie=v.current.getClientRect({relativeTo:re});Q=D({...ne,width:1,height:1},ie)}return Q},[]),W=React$2.useCallback(X=>X&&r.uid===JSON.parse(X).uid,[r.uid]),Z=React$2.useCallback(()=>{T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"addPoints",complex:!0,finish:!0,payload:P.current}),u({type:"passPuzzle"}),a&&u({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),u({type:"closeUI",ui:"inventory"})},[a,u,r.name,r.uid]),q=React$2.useCallback(()=>{T("success"),u({type:"hidePuzzleButtons",payload:!0}),P.current=[...P.current,...h.right.rewards],setTimeout(()=>{Z()},2e3)},[u,Z,h.right.rewards]),B=React$2.useCallback(()=>{u({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"failPuzzle"}),P.current=[...P.current,...h.wrong.rewards]},[u,h.wrong.rewards]),G=React$2.useCallback(X=>{const Q=X.dataTransfer.getData("item");g.current.setPointersPositions(X);const re=H(X);u({type:"hidePuzzleButtons",payload:!0}),re&&W(Q)?(T("success"),u({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&q()):(u({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{B()},2e3))},[H,W,u,q,B,t.solution.right.desc,t.solution.wrong.desc]),I=()=>{x==="success"?q():B()};React$2.useEffect(()=>{const X=e.img.url||"";w.src=X,w.onload=()=>{_.current&&(p.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:w.width,height:w.height,offsetX:w.width/2,offsetY:w.height/2,scale:{x:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height),y:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height)}},S(!0))}},[w,e.img.url]);const $=X=>{X!==null&&(v.current=X)},V=X=>{if(X!==null&&(E.current=X,v.current)){const{x:Q,y:re,width:ne,height:ie}=v.current.getClientRect();X.setAttr("x",Q),X.setAttr("y",re),X.setAttr("height",ie),X.setAttr("width",ne)}};return React$2.useLayoutEffect(()=>{if(v.current&&R){const X=v.current.getClientRect({relativeTo:v.current.getParent()});C({x:X.x+X.width/2,y:X.y+X.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:G,onDragOver:X=>{X.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:g,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:w,...p.current}),jsxRuntimeExports.jsxs(Group,{...p.current,children:[A?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...A},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:F,onMouseLeave:U,ref:$,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:F,onMouseLeave:U,ref:V,text:k("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:k,playSound:O,functionOnClose:I,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:l}){const[u,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let T=!1;return n[r.id].find(R=>R.id===x)&&(T=!0),T},v=x=>{let T="";return u?(e&&h(x.id)&&(T="selected"),o&&h(x.id)&&a.includes(x.id)&&(T="success"),o&&h(x.id)&&!a.includes(x.id)&&(T="failed")):(e&&x.id===n[r.id][0].id&&(T="selected"),o&&x.id===n[r.id][0].id&&(T=n[r.id][0].isCorrect?"success":"failed")),T},E=x=>{const T=v(x);return T==="selected"?"icon-check-circle-black color--selected":T==="success"?"icon-check-circle-black color--success":T==="failed"?"icon-error-circle-black color--error":""},g=x=>o&&x.feedback&&(u&&h(x.id)||x.id===n[r.id][0].id),_=(x,T)=>T===0?"tooltip--right__top":T===x.length-1?"tooltip--right__bottom":"tooltip--center__right",p=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{p.length===1?f(!1):f(!0)},[p.length,u,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),u&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:l("tests.chooseMoreOneAnswer")}):null,c.map((x,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[u?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!v(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${v(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[T]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${g(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${v(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${_(c,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:l("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=u=>e.includes(u),a=(u,f)=>u.index<f.index?-1:u.index>f.index?1:0,l=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),l.map(u=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(u.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[u.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:u.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(u.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[u.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:u.feedback})]})]},u.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:l,showResults:u,answered:f,answerPage:c,updateForm:h,disabled:v,translate:E,soundActions:g,paused:_,view:p,correctQuestions:x,feedbacksOnlyWhenReview:T}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[C,w]=React$2.useState(),P=o[S].id,[O]=g;React$2.useEffect(()=>{if(l>=0&&!v&&!_){const q=setInterval(()=>{C||e(B=>B-1)},1e3);return r(q),()=>{clearInterval(q)}}},[v,C,_,r,e,l]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!v&&!T?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):u()},U=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!v&&!T?w(!0):u()},H=Math.floor(l/60),W=l%60;React$2.useEffect(()=>{if(p==="review"){const q=t[`q${S}`][0].id,B=document.querySelector(`#${q}`);R.scrollTo(0,B.offsetTop)}},[S,R,t,p]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,B=t[P],G=B.find($=>$.isCorrect===!1);let I=0;return B.forEach($=>{q.includes($.id)&&(I+=1)}),!G&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[p==="review"||C?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),p!=="review"&&l>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[H<10?`0${H}`:H," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:v,answered:f,updateForm:h,question:o[S],correctQuestions:v?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${p==="review"?"reviewmode":"next"}`,children:[p==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,C?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!C&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&U()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:l,restartTest:u,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:v}){const[E,g]=React$2.useState(0),[_,p]=React$2.useState(),[x,T]=React$2.useState([]),[R,S]=React$2.useState([]),[A,C]=React$2.useState([]),w=React$2.useCallback(()=>{const B=[];return t.forEach(G=>B.push(G.answers)),B},[t]),P=React$2.useCallback(()=>{const B=[];return Object.values(o).forEach(G=>{if(G.length>1){const I=G.find(V=>V.isCorrect===!1),$=[];I?B.push([]):(G.forEach(V=>{V.isCorrect&&$.push(V.id)}),B.push($))}else G[0].isCorrect?B.push([G[0].id]):G[0].isCorrect===!1&&B.push("")}),B},[o]),O=React$2.useCallback(()=>{let B=0;return R.length>0&&x.forEach((G,I)=>{G.length>1?G.every($=>R[I].includes($))&&(B+=1):G.length===1&&R[I]&&G[0]===R[I][0]&&(B+=1)}),B},[x,R]);React$2.useEffect(()=>{T(w),S(P),C(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<v,U=A>=v,H=!r||U,W=Math.trunc(E/k*100),Z=(B,G)=>h({type:"translate",payload:B,values:G}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const B=setInterval(()=>{g(G=>G+1)},100);return p(B),()=>{clearInterval(B)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&U||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:v})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),H?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),H?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:l,minimumPercentage:u=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,v]=React$2.useState({}),[E,g]=React$2.useState(),[_,p]=React$2.useState(0),[x,T]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,C]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[U,H]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,B=React$2.useRef({}),[G,I]=React$2.useState(),[$,V]=t,X=(se,oe,fe,he,ue)=>{const _e={...se,index:fe};if(_>0&&(_e.rewards=_e.rewards.filter(Te=>!U[se.id]||Te.points<0)),h[oe]){const Te=h[oe].find(He=>He.id===ue);if(Te){if(Te.id===se.id){const He=h[oe].find(Xe=>Xe.id===ue),Ge=h[oe].indexOf(He);if(h[oe].splice(Ge,1),h[oe].length===0){C(!1);return}}}else h[oe].push(_e)}else h[oe]=[_e];let Oe;he==="isRadio"?Oe={...h,[oe]:[_e]}:Oe={...h},v(Oe),F(Oe),H({...U,[se.id]:{...se}}),C(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(se=>{const oe=se.answers.filter(he=>he.isCorrect),fe=[];return oe.forEach(he=>{fe.push(he.id)}),{question:se.id,answers:fe}});React$2.useEffect(()=>{T(Q)},[Q]),React$2.useEffect(()=>{if(u){const se=Math.ceil(c.length*u/100);I(se)}},[c.length,u]),React$2.useEffect(()=>{R===0&&(clearInterval(E),C(!1),Z(!0),P("results"),V("tts"))},[E,V,R]);const re=()=>{clearInterval(E),C(!1),P("results");const se={...D};F(se),V("tts")},ne=()=>{const se={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(he=>{B.current[he.id]&&(he.rewards=[])})}),r({type:"saveTest",payload:se})},ie=()=>{const se=()=>{F({}),H({}),P("test"),v({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(he=>{he.forEach(ue=>{ue.isCorrect&&(B.current[ue.id]?ue.rewards=[]:B.current[ue.id]=!0)})});let fe=oe.reduce((he,ue)=>{const _e=[];return ue.forEach(Oe=>{_e.push(Oe.rewards)}),[...he,..._e.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:se}),r({type:"failTest"})},J=(se,oe)=>r({type:"translate",payload:se,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:p,tries:_,answerPage:C,setTime:S,paused:l,saveInterval:g,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:re,translate:J,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:ie,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:G})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((l,u)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--response__item ${e[r]===l?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[u]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${l}`)})]},l))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(l=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--points__item survey--points__item--colorized ${e[r]===l?"selected":""}`,children:l},l))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[l,u]=React$2.useState(!1),[f]=e,c=(E,g)=>o({type:"translate",payload:E,values:g}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)u(!0);else{E&&u(!1);const g=E?n-1:n+1;a(g)}},v=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(v,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),l&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!l&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,C,w;const[a,l]=React$2.useState(null),[u,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(0),[g,_]=React$2.useState({current:{questions:[],type:r}}),[p]=n,x=P=>t({type:"translate",payload:P}),T=P=>{P.keyCode===13&&P.target.blur()},R=()=>{p("click-ui"),t({type:"saveSurveyPrePos",payload:g.current})};React$2.useEffect(()=>{!e.length&&u==="questions"&&f("end")},[e,u]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=g.current.questions.find(F=>F.id===e[v].id))==null?void 0:D.answer;if(p("click-ui"),O)E(v-1),h(!1);else{const F=g.current.questions.findIndex(H=>H.id===e[v].id),U=[...g.current.questions];F>-1?U.splice(F,1,{id:e[v].id,answer:k}):U.push({id:e[v].id,answer:k}),_({...g,current:{...g.current,questions:U}}),v===e.length-1?h(!0):(E(v+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[u==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),p("click-ui")},translate:x}),u==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",v+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[v])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{l(O)},onTouchEnd:()=>{l(null)},onKeyUp:D=>{T(D)},onClick:()=>{S(O,!1)},className:`survey--points__item survey--points__item--simple ${((k=g.current.questions[v])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[v]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:v===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${v===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),p("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
253
253
|
`,children:jsxRuntimeExports.jsx("span",{children:x("auto-evaluation.end")})}):jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>S(null,!1),disabled:((C=g.current.questions[v])==null?void 0:C.answer)===void 0,"aria-label":LangIsRtl()?x("survey.previous"):x("survey.next"),className:`gat--btn__navigation ${((w=g.current.questions[v])==null?void 0:w.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),u==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:R,translate:x})]})]})}function PatternComponent({img:o,name:e,viewed:r,emitEvent:t,soundActions:n,keyboardControl:a}){const[l]=n,u=v=>t({type:"translate",payload:v}),f=()=>{l("click-ui"),t({type:"emitSavePattern",payload:{imgId:o.resourceId,name:e,viewed:!0,url:h,type:"pattern"}})},c=a({disabled:r,forward:f,escape:f});if(React$2.useEffect(()=>c(),[c]),!o)return null;const h=o.url;return jsxRuntimeExports.jsx("div",{className:r?"notes--results":"readings--container pattern-wrap--overlay",children:jsxRuntimeExports.jsx("div",{className:r?"notes--results__text":"pattern-wrap",children:r?jsxRuntimeExports.jsx("div",{children:h&&jsxRuntimeExports.jsx("img",{src:h,alt:"pattern"})}):jsxRuntimeExports.jsxs("div",{className:"pattern",children:[jsxRuntimeExports.jsxs("div",{className:"pattern__header",children:[jsxRuntimeExports.jsx("div",{className:"pattern__title",children:u("phone.pattern")}),jsxRuntimeExports.jsx("button",{type:"button","aria-label":u("storylines.misc.closePiece"),className:"pattern__close gat--btn__round gat--btn__close",onClick:()=>f(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:h&&jsxRuntimeExports.jsx("img",{src:h,alt:"pattern"})})]})})})}const getRecursiveJSX=(o,e=0,r,t,n)=>{var a,l;if((a=o.props)!=null&&a.children){const u=o.type,{children:f,...c}=o.props;if(o.props["data-text-id"]){if(c.dir="auto",c.onClick=h=>t(h,c["data-text-id"]||-1),r!=null&&r.hasHighlights){const h=[...r.correctTexts,...r.wrongTexts];for(let v=0;v<h.length;v+=1)c["data-text-id"]===h[v].id&&(c.className="text-click__hover-correct")}}else r!=null&&r.allWrong&&!o.props["data-text-id"]&&(c.onClick=h=>t(h,"allWrong"));return Array.isArray(f)?jsxRuntimeExports.jsx(u,{...c,children:f.map((h,v)=>getRecursiveJSX(h,v,r,t))},`${o.type}_${e}`):jsxRuntimeExports.jsx(u,{...c,children:getRecursiveJSX(f,e,r,t)},`${o.type}_${e}`)}return((l=o.props)==null?void 0:l.children)!==null?o.split(" ").filter(u=>u!=="").map(u=>jsxRuntimeExports.jsx("span",{dir:"auto",children:u},u)):null};function TextClickPuzzleComponent({emitEvent:o,showFrames:e,styles:r,list:t,soundActions:n,description:a,setInfo:l,setResolveAction:u,keyboardControl:f,backgroundImage:c,hideBackgroundImageTheme:h=!1,nodeId:v}){const E=`textclick-puzzle_${v}`,[g,_]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[p]=n,[x,T]=React$2.useState(0),[R,S]=React$2.useState(0),[A,C]=React$2.useState(0),w=React$2.useRef(0),P=React$2.useRef([]),[O,k]=React$2.useState(0),[D,F]=React$2.useState(),U=React$2.useCallback(ne=>o({type:"translate",payload:ne}),[o]),H=React$2.useRef(null),W=React$2.useCallback(()=>w.current===t[x].correctTexts.length||t[x].hasClickOnce&&w.current>=1,[x,t]),Z=React$2.useCallback((ne,ie)=>{ne&&o({type:"hidePuzzleButtons",payload:!0}),_(J=>({...J,show:ne,...ie}))},[o]),q=React$2.useCallback(()=>{if(W())if(_(ne=>({...ne,result:!1})),w.current=0,A===R){const ne=P.current.reduce((ie,J)=>{const se=ie.findIndex(oe=>oe.id===J.id);return se>=0?ie[se].points+=J.points:ie.push({...J}),ie},[]);o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})}else H.current=null,T(x+1),k(0),F(!0),setTimeout(()=>{F(!1)},1200)},[W,A,R,o,x]),B=React$2.useCallback(()=>{o({type:"hidePuzzleButtons",payload:!1}),q(),_(ie=>({...ie,show:!1,text:""}));const ne=document.querySelectorAll(".text-click__failed");ne.length>0&&ne.forEach(ie=>ie.classList.remove("text-click__failed"))},[o,q]),G=React$2.useCallback((ne,ie)=>{var J,se;ne.forEach(oe=>oe.classList.add("text-click__success")),C(A+1),w.current+=1,p("score"),(J=t[x].info.solution.right)!=null&&J.desc?W()&&(P.current=[...P.current,...t[x].info.solution.right.rewards],Z(!0,{result:!0,text:t[x].info.solution.right.desc,timeout:!1})):t[x].info.solution.right.desc===""&&(ie!=null&&ie.desc)?(P.current=((se=ie==null?void 0:ie.rewards)==null?void 0:se.length)>0?[...P.current,...(ie==null?void 0:ie.rewards)||{}]:[...P.current],Z(!0,{result:!0,text:ie.desc,timeout:!1})):t[x].specificFeedbacks.specificCorrectFeedbacks?(P.current=[...P.current,...(ie==null?void 0:ie.rewards)||{}],W()&&Z(!0,{result:!0,timeout:!0})):W()&&(P.current=[...P.current,...t[x].info.solution.right.rewards],Z(!0,{result:!0,timeout:!0}))},[A,p,t,x,W,Z]),I=React$2.useCallback((ne,ie)=>{var J;ne.forEach(se=>se.classList.add("text-click__failed")),p("fail"),o({type:"failPuzzle"}),t[x].info.solution.wrong.desc!==""?(P.current=[...P.current,...t[x].info.solution.wrong.rewards],Z(!0,{result:!1,text:t[x].info.solution.wrong.desc,timeout:!1})):t[x].info.solution.wrong.desc===""&&(ie!=null&&ie.desc)?(P.current=(J=ie==null?void 0:ie.rewards)!=null&&J.length?[...P.current,...(ie==null?void 0:ie.rewards)||{}]:[...P.current],Z(!0,{result:!1,text:ie.desc,timeout:!1})):t[x].specificFeedbacks.specificWrongFeedbacks?(P.current=[...P.current,...(ie==null?void 0:ie.rewards)||{}],Z(!0,{result:!1,timeout:!0})):(P.current=[...P.current,...t[x].info.solution.wrong.rewards],Z(!0,{result:!1,timeout:!0}))},[p,o,t,x,Z]),$=React$2.useCallback((ne,ie)=>{var _e,Oe,Te,He;ne.stopPropagation();const J=document.querySelectorAll(`[data-text-id="${ie}"]`),se=document.querySelectorAll("[data-text-id]"),oe=t[x].correctTexts.find(Ge=>Ge.id===ie),fe=t[x].wrongTexts.find(Ge=>Ge.id===ie),he=(Oe=(_e=t[x])==null?void 0:_e.specificFeedbacks)==null?void 0:Oe.correctFeedbacks.find(Ge=>Ge.id===ie),ue=(He=(Te=t[x])==null?void 0:Te.specificFeedbacks)==null?void 0:He.wrongFeedbacks.find(Ge=>Ge.id===ie);p("click-ui"),t[x].hasClickOrder?t[x].correctTexts[O].id===ie?(k(O+1),G(J,he)):t[x].correctTexts.find(Ge=>Ge.id===ie)&&t[x].correctTexts[O].id!==ie?(se.forEach(Ge=>Ge.classList.remove("text-click__success")),k(0),C(0),w.current=0,Z(!0,{result:!1,text:t[x].info.orderFeedback.desc||U("puzzles.incorrectOrder"),timeout:!1}),T(0)):I(J,ue):(oe==null?void 0:oe.id)===ie?G(J,he):((fe==null?void 0:fe.id)===ie||ie==="allWrong")&&I(J,ue)},[t,x,p,O,G,Z,U,I]),V=React$2.useCallback(ne=>getRecursiveJSX(ne,0,t[x],$),[x,t,$]),X=React$2.useCallback(()=>{let ne=0;for(let ie=0;ie<t.length;ie+=1)if(t[ie].hasClickOnce)ne+=1,S(ne);else for(let J=0;J<t[ie].correctTexts.length;J+=1)ne+=1,S(ne)},[t]);React$2.useEffect(()=>{var ne;if(t!=null&&t[x]&&l({...t[x].info,description:a}),(ne=t[x])!=null&&ne.text){const ie=HTMLReactParser$1(t[x].text);H.current=V(ie),X()}else H.current=""},[x,a,X,t,V,l]),React$2.useEffect(()=>{u(()=>{o({type:"hidePuzzleButtons",payload:!0});const ne=document.querySelectorAll(".text-click [data-text-id]"),ie=t[x].correctTexts.map(se=>se.id);ne.forEach(se=>{ie.includes(se.getAttribute("data-text-id"))&&se.classList.add("text-click__success")});const J=t[x].info.resolve.rewards;x+1<t.length?(setTimeout(()=>{o({type:"puzzleAction",action:"addPoints",payload:{element:E,rewards:J,finish:!1,payload:J}});let se=0;t.forEach((oe,fe)=>{fe<=x&&(se+=oe.correctTexts.length)}),C(se),H.current=null,w.current=0,F(!0),T(x+1)},2e3),setTimeout(()=>{F(!1),o({type:"hidePuzzleButtons",payload:!1})},3200)):setTimeout(()=>{o({type:"puzzleAction",action:"resolve",payload:{element:E,rewards:J,finish:x+1>=t.length}})},2e3)})},[u,o,t,x,E]);const Q=React$2.useMemo(()=>{let ne=`text-click text-click--${r}`;return h&&(ne+=" disable-background-image"),ne},[h,r]),re={pointerEvents:g.show?"none":null,backgroundImage:c!=null&&c.url?`url('${c.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Q,style:re,children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${D?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:H.current})})})}),e&&jsxRuntimeExports.jsxs("div",{className:"text-click__paginator",children:[jsxRuntimeExports.jsx("div",{className:"text-click__icon-check-circle-black",children:jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black"})}),jsxRuntimeExports.jsxs("span",{className:"text-click__slide",children:[A," / ",R]})]})]}),g.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:p,success:g.result,text:g.text,translate:U,functionOnClose:B,hasTimeout:g.timeout,keyboardControl:f})]})}function _assertThisInitialized(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function _inheritsLoose(o,e){o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.__proto__=e}/*!
|
|
254
254
|
* GSAP 3.12.4
|
|
255
255
|
* https://gsap.com
|
|
@@ -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 l=e._gsap;l.scaleX=l.scaleY=t,l.renderTransform(a,l)},_setterTransformWithRender=function o(e,r,t,n,a){var l=e._gsap;l[r]=t,l.renderTransform(a,l)},_transformProp="transform",_transformOriginProp=_transformProp+"Origin",_saveStyle=function o(e,r){var t=this,n=this.target,a=n.style,l=n._gsap;if(e in _transformProps&&a){if(this.tfm=this.tfm||{},e!=="transform")e=_propertyAliases[e]||e,~e.indexOf(",")?e.split(",").forEach(function(u){return t.tfm[u]=_get(n,u)}):this.tfm[e]=l.x?l[e]:_get(n,e),e===_transformOriginProp&&(this.tfm.zOrigin=l.zOrigin);else return _propertyAliases.transform.split(",").forEach(function(u){return o.call(t,u,r)});if(this.props.indexOf(_transformProp)>=0)return;l.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,l;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(l in this.tfm)n[l]=this.tfm[l];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,l=5;if(e in a&&!t)return e;for(e=e.charAt(0).toUpperCase()+e.substr(1);l--&&!(_prefixes[l]+e in a););return l<0?null:(l===3?"ms":l>=0?_prefixes[l]:"")+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,l;if(_docElement.appendChild(r),r.appendChild(this),this.style.display="block",e)try{l=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=o}catch{}else this._gsapBBox&&(l=this._gsapBBox());return t&&(n?t.insertBefore(this,n):t.appendChild(this)),_docElement.removeChild(r),this.style.cssText=a,l},_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,l){var u=new PropTween(e._pt,r,t,0,1,l?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue);return e._pt=u,u.b=n,u.e=a,e._props.push(t),u},_nonConvertibleUnits={deg:1,rad:1,turn:1},_nonStandardLayouts={grid:1,flex:1},_convertToUnit=function o(e,r,t,n){var a=parseFloat(t)||0,l=(t+"").trim().substr((a+"").length)||"px",u=_tempDiv.style,f=_horizontalExp.test(r),c=e.tagName.toLowerCase()==="svg",h=(c?"client":"offset")+(f?"Width":"Height"),v=100,E=n==="px",g=n==="%",_,p,x,T;if(n===l||!a||_nonConvertibleUnits[n]||_nonConvertibleUnits[l])return a;if(l!=="px"&&!E&&(a=o(e,r,t,"px")),T=e.getCTM&&_isSVG(e),(g||l==="%")&&(_transformProps[r]||~r.indexOf("adius")))return _=T?e.getBBox()[f?"width":"height"]:e[h],_round(g?a/_*v:a/100*_);if(u[f?"width":"height"]=v+(E?l:n),p=~r.indexOf("adius")||n==="em"&&e.appendChild&&!c?e:e.parentNode,T&&(p=(e.ownerSVGElement||{}).parentNode),(!p||p===_doc||!p.appendChild)&&(p=_doc.body),x=p._gsap,x&&g&&x.width&&f&&x.time===_ticker.time&&!x.uncache)return _round(a/x.width*v);if(g&&(r==="height"||r==="width")){var R=e.style[r];e.style[r]=v+n,_=e[h],R?e.style[r]=R:_removeProperty(e,r)}else(g||l==="%")&&!_nonStandardLayouts[_getComputedProperty(p,"display")]&&(u.position=_getComputedProperty(e,"position")),p===e&&(u.position="static"),p.appendChild(_tempDiv),_=_tempDiv[h],p.removeChild(_tempDiv),u.position="absolute";return f&&g&&(x=_getCache(p),x.time=_ticker.time,x.width=p[h]),_round(E?_*a/v:_&&a?v/_*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),l=a&&_getComputedProperty(e,a,1);l&&l!==t?(r=a,t=l):r==="borderColor"&&(t=_getComputedProperty(e,"borderTopColor"))}var u=new PropTween(this._pt,e.style,r,0,1,_renderComplexString),f=0,c=0,h,v,E,g,_,p,x,T,R,S,A,C;if(u.b=t,u.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)||[],C=n.match(_numWithUnitExp)||[],C.length){for(;v=_numWithUnitExp.exec(n);)x=v[0],R=n.substring(f,v.index),_?_=(_+1)%5:(R.substr(-5)==="rgba("||R.substr(-5)==="hsla(")&&(_=1),x!==(p=E[c++]||"")&&(g=parseFloat(p)||0,A=p.substr((g+"").length),x.charAt(1)==="="&&(x=_parseRelative(g,x)+A),T=parseFloat(x),S=x.substr((T+"").length),f=_numWithUnitExp.lastIndex-S.length,S||(S=S||_config.units[r]||A,f===n.length&&(n+=S,u.e+=S)),A!==S&&(g=_convertToUnit(e,r,p,S)||0),u._pt={_next:u._pt,p:R||c===1?R:",",s:g,c:T-g,m:_&&_<4||r==="zIndex"?Math.round:0});u.c=f<n.length?n.substring(f,n.length):""}else u.r=r==="display"&&n==="none"?_renderNonTweeningValueOnlyAtEnd:_renderNonTweeningValue;return _relExp.test(n)&&(u.e=0),this._pt=u,u},_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,l=t._gsap,u,f,c;if(a==="all"||a===!0)n.cssText="",f=1;else for(a=a.split(","),c=a.length;--c>-1;)u=a[c],_transformProps[u]&&(f=1,u=u==="transformOrigin"?_transformOriginProp:_transformProp),_removeProperty(t,u);f&&(_removeProperty(t,_transformProp),l&&(l.svg&&t.removeAttribute("transform"),_parseTransform(t,1),l.uncache=1,_removeIndependentTransforms(n)))}},_specialProps={clearProps:function o(e,r,t,n,a){if(a.data!=="isFromStart"){var l=e._pt=new PropTween(e._pt,r,t,0,0,_renderClearProps);return l.u=n,l.pr=-10,l.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),l,u,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",l=e.parentNode,(!l||!e.offsetParent)&&(c=1,u=e.nextElementSibling,_docElement.appendChild(e)),a=_getComputedTransformMatrixAsArray(e),f?n.display=f:_removeProperty(e,"display"),c&&(u?l.insertBefore(e,u):l?l.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,l){var u=e._gsap,f=a||_getMatrix(e,!0),c=u.xOrigin||0,h=u.yOrigin||0,v=u.xOffset||0,E=u.yOffset||0,g=f[0],_=f[1],p=f[2],x=f[3],T=f[4],R=f[5],S=r.split(" "),A=parseFloat(S[0])||0,C=parseFloat(S[1])||0,w,P,O,k;t?f!==_identity2DMatrix&&(P=g*x-_*p)&&(O=A*(x/P)+C*(-p/P)+(p*R-x*T)/P,k=A*(-_/P)+C*(g/P)-(g*R-_*T)/P,A=O,C=k):(w=_getBBox(e),A=w.x+(~S[0].indexOf("%")?A/100*w.width:A),C=w.y+(~(S[1]||S[0]).indexOf("%")?C/100*w.height:C)),n||n!==!1&&u.smooth?(T=A-c,R=C-h,u.xOffset=v+(T*g+R*p)-T,u.yOffset=E+(T*_+R*x)-R):u.xOffset=u.yOffset=0,u.xOrigin=A,u.yOrigin=C,u.smooth=!!n,u.origin=r,u.originIsAbsolute=!!t,e.style[_transformOriginProp]="0px 0px",l&&(_addNonTweeningPT(l,u,"xOrigin",c,A),_addNonTweeningPT(l,u,"yOrigin",h,C),_addNonTweeningPT(l,u,"xOffset",v,u.xOffset),_addNonTweeningPT(l,u,"yOffset",E,u.yOffset)),e.setAttribute("data-svg-origin",A+" "+C)},_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,l="px",u="deg",f=getComputedStyle(e),c=_getComputedProperty(e,_transformOriginProp)||"0",h,v,E,g,_,p,x,T,R,S,A,C,w,P,O,k,D,F,U,H,W,Z,q,B,G,I,$,V,X,Q,re,ne;return h=v=E=p=x=T=R=S=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"),P=_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,P)),C=t.xOrigin||0,w=t.yOrigin||0,P!==_identity2DMatrix&&(F=P[0],U=P[1],H=P[2],W=P[3],h=Z=P[4],v=q=P[5],P.length===6?(g=Math.sqrt(F*F+U*U),_=Math.sqrt(W*W+H*H),p=F||U?_atan2(U,F)*_RAD2DEG:0,R=H||W?_atan2(H,W)*_RAD2DEG+p:0,R&&(_*=Math.abs(Math.cos(R*_DEG2RAD))),t.svg&&(h-=C-(C*F+w*H),v-=w-(C*U+w*W))):(ne=P[6],Q=P[7],$=P[8],V=P[9],X=P[10],re=P[11],h=P[12],v=P[13],E=P[14],O=_atan2(ne,X),x=O*_RAD2DEG,O&&(k=Math.cos(-O),D=Math.sin(-O),B=Z*k+$*D,G=q*k+V*D,I=ne*k+X*D,$=Z*-D+$*k,V=q*-D+V*k,X=ne*-D+X*k,re=Q*-D+re*k,Z=B,q=G,ne=I),O=_atan2(-H,X),T=O*_RAD2DEG,O&&(k=Math.cos(-O),D=Math.sin(-O),B=F*k-$*D,G=U*k-V*D,I=H*k-X*D,re=W*D+re*k,F=B,U=G,H=I),O=_atan2(U,F),p=O*_RAD2DEG,O&&(k=Math.cos(O),D=Math.sin(O),B=F*k+U*D,G=Z*k+q*D,U=U*k-F*D,q=q*k-Z*D,F=B,Z=G),x&&Math.abs(x)+Math.abs(p)>359.9&&(x=p=0,T=180-T),g=_round(Math.sqrt(F*F+U*U+H*H)),_=_round(Math.sqrt(q*q+ne*ne)),O=_atan2(Z,q),R=Math.abs(O)>2e-4?O*_RAD2DEG:0,A=re?1/(re<0?-re:re):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)+l,t.y=v-((t.yPercent=v&&(!r&&t.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-v)?-50:0)))?e.offsetHeight*t.yPercent/100:0)+l,t.z=E+l,t.scaleX=_round(g),t.scaleY=_round(_),t.rotation=_round(p)+u,t.rotationX=_round(x)+u,t.rotationY=_round(T)+u,t.skewX=R+u,t.skewY=S+u,t.transformPerspective=A+l,(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,l=t.x,u=t.y,f=t.z,c=t.rotation,h=t.rotationY,v=t.rotationX,E=t.skewX,g=t.skewY,_=t.scaleX,p=t.scaleY,x=t.transformPerspective,T=t.force3D,R=t.target,S=t.zOrigin,A="",C=T==="auto"&&e&&e!==1||T===!0;if(S&&(v!==_zeroDeg||h!==_zeroDeg)){var w=parseFloat(h)*_DEG2RAD,P=Math.sin(w),O=Math.cos(w),k;w=parseFloat(v)*_DEG2RAD,k=Math.cos(w),l=_addPxTranslate(R,l,P*k*-S),u=_addPxTranslate(R,u,-Math.sin(w)*-S),f=_addPxTranslate(R,f,O*k*-S+S)}x!==_zeroPx&&(A+="perspective("+x+_endParenthesis),(n||a)&&(A+="translate("+n+"%, "+a+"%) "),(C||l!==_zeroPx||u!==_zeroPx||f!==_zeroPx)&&(A+=f!==_zeroPx||C?"translate3d("+l+", "+u+", "+f+") ":"translate("+l+", "+u+_endParenthesis),c!==_zeroDeg&&(A+="rotate("+c+_endParenthesis),h!==_zeroDeg&&(A+="rotateY("+h+_endParenthesis),v!==_zeroDeg&&(A+="rotateX("+v+_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,l=t.x,u=t.y,f=t.rotation,c=t.skewX,h=t.skewY,v=t.scaleX,E=t.scaleY,g=t.target,_=t.xOrigin,p=t.yOrigin,x=t.xOffset,T=t.yOffset,R=t.forceCSS,S=parseFloat(l),A=parseFloat(u),C,w,P,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,C=Math.cos(f)*v,w=Math.sin(f)*v,P=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),P*=k,O*=k,h&&(k=Math.tan(h),k=Math.sqrt(1+k*k),C*=k,w*=k)),C=_round(C),w=_round(w),P=_round(P),O=_round(O)):(C=v,O=E,w=P=0),(S&&!~(l+"").indexOf("px")||A&&!~(u+"").indexOf("px"))&&(S=_convertToUnit(g,"x",l,"px"),A=_convertToUnit(g,"y",u,"px")),(_||p||x||T)&&(S=_round(S+_-(_*C+p*P)+x),A=_round(A+p-(_*w+p*O)+T)),(n||a)&&(k=g.getBBox(),S=_round(S+n/100*k.width),A=_round(A+a/100*k.height)),k="matrix("+C+","+w+","+P+","+O+","+S+","+A+")",g.setAttribute("transform",k),R&&(g.style[_transformProp]=k)},_addRotationalPropTween=function o(e,r,t,n,a){var l=360,u=_isString(a),f=parseFloat(a)*(u&&~a.indexOf("rad")?_RAD2DEG:1),c=f-n,h=n+c+"deg",v,E;return u&&(v=a.split("_")[1],v==="short"&&(c%=l,c!==c%(l/2)&&(c+=c<0?l:-l)),v==="cw"&&c<0?c=(c+l*_bigNum)%l-~~(c/l)*l:v==="ccw"&&c>0&&(c=(c-l*_bigNum)%l-~~(c/l)*l)),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",l=t.style,u,f,c,h,v,E,g,_;n.svg?(c=t.getAttribute("transform"),t.setAttribute("transform",""),l[_transformProp]=r,u=_parseTransform(t,1),_removeProperty(t,_transformProp),t.setAttribute("transform",c)):(c=getComputedStyle(t)[_transformProp],l[_transformProp]=r,u=_parseTransform(t,1),l[_transformProp]=c);for(f in _transformProps)c=n[f],h=u[f],c!==h&&a.indexOf(f)<0&&(g=getUnit(c),_=getUnit(h),v=g!==_?_convertToUnit(t,f,c,_):parseFloat(c),E=parseFloat(h),e._pt=new PropTween(e._pt,u,f,v,E-v,_renderCSSProp),e._pt.u=_||0,e._props.push(f));_assign(u,n)};_forEachName("padding,margin,Width,Radius",function(o,e){var r="Top",t="Right",n="Bottom",a="Left",l=(e<3?[r,t,n,a]:[r+a,r+t,n+t,n+a]).map(function(u){return e<2?o+u:"border"+u+o});_specialProps[e>1?"border"+o:o]=function(u,f,c,h,v){var E,g;if(arguments.length<4)return E=l.map(function(_){return _get(u,_,c)}),g=E.join(" "),g.split(E[0]).length===5?E[0]:g;E=(h+"").split(" "),g={},l.forEach(function(_,p){return g[_]=E[p]=E[p]||E[(p-1)/2|0]}),u.init(f,g,v)}});var CSSPlugin={name:"css",register:_initCore,targetTest:function o(e){return e.style&&e.nodeType},init:function o(e,r,t,n,a){var l=this._props,u=e.style,f=t.vars.startAt,c,h,v,E,g,_,p,x,T,R,S,A,C,w,P,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)&&(P=1);else if(p.substr(0,2)==="--")c=(getComputedStyle(e).getPropertyValue(p)+"").trim(),h+="",_colorExp.lastIndex=0,_colorExp.test(c)||(x=getUnit(c),T=getUnit(h)),T?x!==T&&(c=_convertToUnit(e,p,c,T)+T):x&&(h+=x),this.add(u,"setProperty",c,h,n,a,0,0,p),l.push(p),O.push(p,0,u[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)),v=parseFloat(h),p in _propertyAliases&&(p==="autoAlpha"&&(E===1&&_get(e,"visibility")==="hidden"&&v&&(E=0),O.push("visibility",0,u.visibility),_addNonTweeningPT(this,u,"visibility",E?"inherit":"hidden",v?"inherit":"hidden",!v)),p!=="scale"&&p!=="transform"&&(p=_propertyAliases[p],~p.indexOf(",")&&(p=p.split(",")[0]))),S=p in _transformProps,S){if(this.styles.save(p),A||(C=e._gsap,C.renderTransform&&!r.parseTransform||_parseTransform(e,r.parseTransform),w=r.smoothOrigin!==!1&&C.smooth,A=this._pt=new PropTween(this._pt,u,_transformProp,0,1,C.renderTransform,C,0,-1),A.dep=1),p==="scale")this._pt=new PropTween(this._pt,C,"scaleY",C.scaleY,(R?_parseRelative(C.scaleY,R+v):v)-C.scaleY||0,_renderCSSProp),this._pt.u=0,l.push("scaleY",p),p+="X";else if(p==="transformOrigin"){O.push(_transformOriginProp,0,u[_transformOriginProp]),h=_convertKeywordsToPercentages(h),C.svg?_applySVGOrigin(e,h,0,w,0,this):(T=parseFloat(h.split(" ")[2])||0,T!==C.zOrigin&&_addNonTweeningPT(this,C,"zOrigin",C.zOrigin,T),_addNonTweeningPT(this,u,p,_firstTwoOnly(c),_firstTwoOnly(h)));continue}else if(p==="svgOrigin"){_applySVGOrigin(e,h,1,w,0,this);continue}else if(p in _rotationalProperties){_addRotationalPropTween(this,C,p,E,R?_parseRelative(E,R+h):h);continue}else if(p==="smoothOrigin"){_addNonTweeningPT(this,C,"smooth",C.smooth,h);continue}else if(p==="force3D"){C[p]=h;continue}else if(p==="transform"){_addRawTransformPTs(this,h,e);continue}}else p in u||(p=_checkPropPrefix(p)||p);if(S||(v||v===0)&&(E||E===0)&&!_complexExp.test(h)&&p in u)x=(c+"").substr((E+"").length),v||(v=0),T=getUnit(h)||(p in _config.units?_config.units[p]:x),x!==T&&(E=_convertToUnit(e,p,c,T)),this._pt=new PropTween(this._pt,S?C:u,p,E,(R?_parseRelative(E,R+v):v)-E,!S&&(T==="px"||p==="zIndex")&&r.autoRound!==!1?_renderRoundedCSSProp:_renderCSSProp),this._pt.u=T||0,x!==T&&T!=="%"&&(this._pt.b=c,this._pt.r=_renderCSSPropWithBeginning);else if(p in u)_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}S||(p in u?O.push(p,0,u[p]):O.push(p,1,c||e[p])),l.push(p)}}P&&_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 l=a.split(":");_propertyAliases[l[1]]=n[l[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 l=o.avatar,u=l.lastIndexOf("/");return l.includes("/object/")?l.slice(0,u).concat("/mini-thumbnail.png"):l.includes("/character/")?l.slice(0,u).concat("/mini-face.png"):l};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(c=>c.scene),r=React$2.useMemo(()=>{var h;const c={};for(const v of o)if(v.slots)for(const E of v.slots){if(!E.uid)continue;const g=(h=E.character)==null?void 0:h.resource.animations;g&&(c[E.uid]||(c[E.uid]=Object.keys(g).reduce((_,p)=>(_[p]=g[p].url,_),{})))}return c},[o]),t=React$2.useMemo(()=>{const c=new Set;for(const h of o)if(h.slots)for(const v of h.slots)v.uid&&c.add(v.uid);return Array.from(c)},[o]),n=async c=>{const h=r[c];if(!cache[h.talking]){const{animations:E}=await loader.loadAsync(h.talking);E[0].name="talking",cache[h.talking]=E[0]}},a=()=>{t.forEach(c=>{f(c,"idle")})},l=()=>{t.forEach(c=>{const h=e.getObjectByProperty("uid",c);h&&(delete h.userData._active,f(c,"idle"))})},u=async(c,h,v)=>{const E=getCurrentVisible(c,e);if(cache[c]||(cache[c]={}),!E)return;const{clipAction:g}=E.userData.animation;if(h){const _=r[c],p=cache[_.talking];let x=h,T=cache[h];if(!T){const{animations:R}=await loader.loadAsync(h);T=cache[h]=R[0]}if(v&&_.talking!==h&&(T=mixWithTalkingClip(p,T),x+="_talking"),!E.userData._active||E.userData._active!==x)return E.userData._active=x,g(T,E)}return null},f=async(c,h)=>{const v=getCurrentVisible(c,e);if(cache[c]||(cache[c]={}),!v)return;const{clipAction:E,defaultAnim:g}=v.userData.animation;if(h==="idle")return E(g,v);{const _=r[c],p=h.split("_")[0],x=_[p],T=cache[_.talking];let R=cache[x];if(!R){const{animations:S}=await loader.loadAsync(_[p]);R=cache[_[p]]=S[0]}if(h.includes("talking")&&h!=="talking"&&(R=mixWithTalkingClip(T,R)),!v.userData._active||v.userData._active!==h)return v.userData._active=h,E(R,v)}return null};return{startAnimation:f,startAnimationUrl:u,preloadTalking:n,resetActives:a,unmountActives:l}}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:l,autoPlay:u,autoEnd:f,pause:c,progress:h}){var pn;const v=r.length-1<=(h==null?void 0:h.line)?r.length-1:(h==null?void 0:h.line)||0,[E,g]=React$2.useState(v),[_,p]=React$2.useState(!!u),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),A=fiber.useThree(ke=>ke.scene),C=fiber.useThree(ke=>ke.camera),{start:w,stop:P}=useTimeout(),O=React$2.useRef([]),k=React$2.useMemo(()=>C.clone(),[]),D=React$2.useRef({pos:[0,0,0],child:null}),F=r[E],U=r[E-1],H=React$2.useRef(!1),W=!!n,{voiceOver:Z,decision:q}=F||{},B=React$2.useRef({}),G=(pn=F==null?void 0:F.slots)==null?void 0:pn.find(ke=>ke.talking),I=React$2.useRef(!1),{startAnimation:$,startAnimationUrl:V,resetActives:X,preloadTalking:Q,unmountActives:re}=useStateMachine(r),ne=React$2.useRef(),ie=Object.keys((F==null?void 0:F.audio)||{}).length,J=Object.keys((F==null?void 0:F.voice)||{}).length,se=Z||(F==null?void 0:F.type)==="conversationalNarration",oe=q||(F==null?void 0:F.type)==="conversationalDecision",fe=(F==null?void 0:F.type)==="conversationalCamera",he=_&&!oe&&!fe,[ue,_e]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Oe=React$2.useMemo(()=>r.reduce((ke,qe)=>(qe.slots&&qe.slots.filter(bt=>bt.uid).forEach(bt=>{ke.includes(bt.uid)||ke.push(bt.uid)}),ke),[]),[r]),Te=React$2.useCallback(ke=>e({type:"translate",payload:ke}),[e]),[He,Ge]=React$2.useState([]),Xe=React$2.useMemo(()=>He[He.length-1],[He]),pt=React$2.useCallback(()=>{const ke=n.find(st=>st.fromId===Xe)||n.find(st=>st.toId===Xe),qe=r.find(st=>st.id===(ke==null?void 0:ke.fromId));return!Xe&&(h==null?void 0:h.line)>=0?{decision:!0}:qe},[n,r,Xe]),yt=React$2.useCallback(()=>{if(W){const qe=pt();return qe==null?void 0:qe.decision}const ke=r[E-1]?r[E-1]:{};return E>0&&(ke==null?void 0:ke.decision)},[F,W,r,Xe,n]),at=React$2.useCallback(()=>{if(W){const qe=pt();return(qe==null?void 0:qe.type)==="conversationalCamera"}const ke=r[E-1]?r[E-1]:{};return E>0&&(ke==null?void 0:ke.type)==="conversationalCamera"},[F,W,r,Xe,n]),ht=React$2.useCallback(ke=>{var st,bt;const qe=t.find(tt=>(tt==null?void 0:tt.uid)===(ke==null?void 0:ke.uid)?tt:"");return((bt=(st=ke==null?void 0:ke.character)==null?void 0:st.resource)==null?void 0:bt.url)||(qe==null?void 0:qe.completeUrl)||""},[t]),er=(ke=()=>{})=>{if(I.current)I.current&&(I.current=!1);else{C.updateProjectionMatrix(),C.updateMatrixWorld(!0);const qe=D.current.child?D.current.pos:k.position.toArray();if(animationTarget.position.fromArray(qe),D.current.parent){animationTarget.quaternion.equals(C.quaternion)||animationTarget.applyQuaternion(C.quaternion);const st=D.current.isLeft?-1:1,bt=headSize*st;animationTarget.translateX(-10*st+bt),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(C.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{I.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(st=>{const{object:bt}=st;bt.material.visible=!0})},onComplete:()=>{ke(),raycast.set(C.getWorldPosition(new three.Vector3(0,0,0)),C.getWorldDirection(new three.Vector3));const st=raycast.intersectObjects(A.children,!0);O.current=st.filter(bt=>bt.distance<10),O.current.length&&O.current.forEach(bt=>{const{object:tt}=bt;tt.material.side=0}),I.current=!1,H.current&&e({type:"success"}),D.current.child||C.copy(k)},...animationTarget.position})}},Ot=React$2.useCallback(()=>{D.current.child=null,D.current.parent=null,l&&er()},[l]),_t=(ke,qe,st,bt=!1)=>{const tt=qe.includes("seated");st?V(ke,st.url,qe.includes("talking")).then(Kt=>{if(Kt){const sr=Kt.setLoop(three.LoopRepeat,1/0).getMixer(),mn=()=>{H.current?$(ke,"idle").then(()=>{sr.removeEventListener("loop",mn)}):$(ke,ne.current===ke?"neutral_talking":"neutral").then(()=>{sr.removeEventListener("loop",mn)})};Kt&&BASIC_ACTIONS_TYPES_WHITELIST.includes(st.animationId)?sr.addEventListener("loop",mn):sr._listeners&&(sr._listeners.loop=[])}}):$(ke,bt&&!tt?`${qe}-seated`:qe)},kt=()=>{if(!(G!=null&&G.emotion)||H.current)return;const{emotion:ke,uid:qe,animation:st}=G,bt=getCurrentVisible(qe,A);if(bt){const{isSeated:tt}=bt;Q(qe).then(()=>{_t(qe,tt&&!ke.includes("seated")?`${ke}-seated_talking`:`${ke}_talking`,st,tt),st&&BASIC_ACTIONS_TYPES_WHITELIST.includes(st.animationId)&&(ne.current=qe)})}},Ft=()=>{if(!(G!=null&&G.uid)||H.current)return;const{emotion:ke,uid:qe,animation:st}=G,bt=getCurrentVisible(qe,A);if(bt){const{isSeated:tt}=bt;ne.current===qe?(_t(qe,"neutral",null,tt),ne.current=null):_t(qe,ke,st,tt)}},Ke=React$2.useCallback(()=>{H.current=!0,_e({show:!1}),Ot(),X(),l||e({type:"success"})},[C,e,Ot,l]);React$2.useEffect(()=>()=>{B.current={},re()},[]);const mt=ke=>{_e({show:!1}),g(ke),e({type:"notifyProgress",payload:{line:ke}})},ct=React$2.useCallback((ke=!0)=>{const qe=ke?["fromId","toId"]:["toId","fromId"],st=n.filter(Kt=>Kt[qe[0]]===F.id),bt=st.length===1?st[0]:st.find(Kt=>Kt[qe[1]]===Xe);if(!(bt!=null&&bt[qe[0]])){Ke();return}ke||Ge(He.slice(0,He.length-1));const tt=r.findIndex(Kt=>Kt.id===bt[qe[1]]);tt>=0?mt(tt):Ke()},[F==null?void 0:F.id,e,n,Ke,r]),ye=React$2.useCallback((ke,qe)=>{const st=[3,2,1][ke.id],tt=n.filter(sr=>sr.fromId===(F==null?void 0:F.id)).find(sr=>parseInt(sr.fromPointIndex)===st),Kt=r.findIndex(sr=>sr.id===(tt==null?void 0:tt.toId));Kt>=0?(tt==null?void 0:tt.fromId)===(tt==null?void 0:tt.toId)?qe():mt(Kt):Ke()},[F==null?void 0:F.id,n,Ke,r]),de=React$2.useCallback(()=>{if(B.current={...G},S(!1),Ft(),W)ct(!1);else if(!yt()){const ke=E-1;_e({show:!1}),g(ke),e({type:"notifyProgress",payload:{line:ke}})}},[ct,e,W,U,E,G]),ge=React$2.useCallback(ke=>{if(W){if(ke){const qe=[3,2,1][ke.id],bt=n.filter(tt=>tt.fromId===F.id).find(tt=>parseInt(tt.fromPointIndex)===qe);if(bt){const tt=r.findIndex(Kt=>Kt.id===bt.toId);tt>=0&&e({type:"notifyProgress",payload:{line:tt}})}else e({type:"saveNode"})}}else if(E<r.length-1){const qe=E+1;e({type:"notifyProgress",payload:{line:qe}})}else e({type:"saveNode"})},[n,E,r,e,F==null?void 0:F.id,W]),Ee=React$2.useCallback((ke,qe)=>{if(B.current={...G},Ge([...He,F.id]),S(!1),Ft(),W)ke?ye(ke,qe):ct();else if(E<r.length-1){const st=E+1;mt(st)}else(f||oe||fe)&&Ke()},[e,F==null?void 0:F.id,W,oe,fe,E,r.length,ye,ct,Ke,G]),Le=()=>{p(!1),de()},Ve=()=>W?F&&F.type!=="conversationalDecision"&&!n.find(ke=>ke.fromId===F.id):E===r.length-1,De=()=>{Ve()?Ke():(p(!1),Ee())};React$2.useEffect(()=>{if(W&&!x){const ke=h==null?void 0:h.line;if(ke>=0){T(!0),g(ke);return}const qe=r.filter(st=>!n.find(bt=>bt.toId===st.id));if(qe.length){const st=qe[0],bt=r.indexOf(st);bt>=0&&(T(!0),g(bt))}}},[n,W,r,x]);const ze=ke=>{if(B.current.uid===ke.uid||D.current.parent===ke)return;const qe=new three.Object3D,st=ke.getObjectByName("Head_M");st.updateMatrixWorld(!0),qe.applyMatrix4(st.matrixWorld),qe.applyQuaternion(C.quaternion);const bt=l?2.5:2,tt=l?1.2:1.5;qe.translateY(bt),qe.translateX(tt);const Kt=new three.Vector3;Kt.setFromMatrixPosition(st.matrixWorld);const mn=Kt.project(C).x<0;D.current={pos:qe.position.toArray(),child:st,parent:ke,isLeft:mn}},jt=ke=>{e({type:"resetZIndexUIContainer",payload:ke})};React$2.useEffect(()=>{var ke;if(se)Ot(),_e({text:F==null?void 0:F.text,name:(F==null?void 0:F.alias)||(F==null?void 0:F.name)||`[ ${Te("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:ht(G),show:!0});else if(!H.current&&!oe&&!fe){const qe=F==null?void 0:F.slots.filter(tt=>tt.uid&&!tt.talking),st=[...qe.map(tt=>tt.uid)||[],G==null?void 0:G.uid];if(Oe.filter(tt=>!st.includes(tt)).forEach(tt=>{$(tt,"idle")}),qe.forEach(tt=>{const Kt=getCurrentVisible(tt.uid,A);if(Kt){const{isSeated:sr}=Kt;_t(tt.uid,tt.emotion,tt.animation,sr)}}),G){const tt=getCurrentVisible(G.uid,A),Kt=t.find(sr=>sr.uid===G.uid);tt&&!H.current?setTimeout(()=>{var sr,mn;if(G.uid===tt.uid){ze(tt);const{isSeated:us,userData:la}=tt,{emotion:Ai,animation:Ir}=G;!((sr=la._active)!=null&&sr.includes("talking"))&&!((mn=la._active)!=null&&mn.includes(Ai))&&_t(G.uid,Ai,Ir,us);const me=()=>{var Be;_e({text:G.text,name:G.alias||((Be=G.character)==null?void 0:Be.name),inScene:!0,thinkful:G.emotion.includes("think"),avatar:ht(G),show:!0})};l?(I.current=!1,er(me)):me()}},150):(Ot(),_e({text:G.text,name:G.alias||((ke=G.character)==null?void 0:ke.name)||(Kt==null?void 0:Kt.name),left:!1,top:G.text.length>maxCharacterToSwitch,inScene:!1,thinkful:G.emotion.includes("think"),avatar:ht(G),show:!0}))}else Ot(),_e({show:!0})}},[t,F,l,A,Te,ht,Ot,oe,se,Oe]);const Mt=useEkho({audioType:F==null?void 0:F.audioType,volume:F==null?void 0:F.audioVolume,voice:F==null?void 0:F.voice,started:ue.show,text:ue==null?void 0:ue.text,audio:F==null?void 0:F.audio,slide:E,soundActions:a,emitEvent:e,pauseTTS:c,onStart:()=>{var ke;(ke=G==null?void 0:G.emotion)!=null&&ke.includes("think")||kt()},onError:()=>{Ft(),S(!0)},onFinish:()=>{Ft(),he&&!c&&Ee()}});React$2.useEffect(()=>(Mt(),()=>{Mt()}),[E,Mt]),React$2.useEffect(()=>{var ke;if(((F==null?void 0:F.audioType)==="none"||R)&&(ue!=null&&ue.show)&&!(G!=null&&G.emotion.includes("think"))){kt();const qe=characterMs*(((ke=ue==null?void 0:ue.text)==null?void 0:ke.length)||0);setTimeout(()=>{Ft()},qe<minMs?minMs:qe)}},[R,F==null?void 0:F.audioType,G==null?void 0:G.emotion,ue]),React$2.useEffect(()=>{var ke;if(he&&ue.show&&((F==null?void 0:F.audioType)==="none"||R)&&!c){const qe=characterMs*(((ke=ue==null?void 0:ue.text)==null?void 0:ke.length)||0);(!Ve()||Ve()&&f)&&w(Ee,qe<minMs?minMs:qe)}return()=>{P()}},[ue,Ee,w,f,P,F==null?void 0:F.audioType,he,ie,J,R]);const dt=React$2.useMemo(()=>E===0||yt()||at(),[E,yt,at]),vr=o({disabled:oe||!ue.show,repeat:!1,forward:De,rewind:dt?null:Le});React$2.useEffect(()=>vr(),[vr]);const Wr=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...F,emitEvent:e,success:!1,onFinish:Ee},`change-camera-${E}`);if(oe){const ke=F.id?r.filter(st=>st.decision).findIndex(st=>st.id===F.id)+1:r.filter(st=>st.decision).findIndex(st=>st===F)+1,qe={...F.payload,decisionNumber:ke,inheritProps:{slots:[],disableBackground:!0},required:!W,branched:W,onAddPoints:ge,onFinish:Ee,emitEvent:e,pause:c,soundActions:a,keyboardControl:o,onMount:()=>{Ot(),jt(!0)},onUnMount:()=>{I.current=!1,jt(!1)}};return jsxRuntimeExports.jsx(DialogDecision,{...qe})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ue.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Te,currentMessage:ue}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100vw",height:"100%",position:"static"},portal:Wr?{current:Wr}: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:Le,disabled:dt||!ue.show,className:`gat--btn__round ${dt||!ue.show?"disabled":""}`,"aria-label":LangIsRtl()?Te("storylines.misc.forward"):Te("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:De,disabled:!ue.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"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:o})})})}const cleanStyle={width:"100vw",height:"100%",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,{wrapperClass:"htmlpro-wrap-100-h",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(c=>c.scene),r=React$2.useMemo(()=>{var h;const c={};for(const v of o)if(v.slots)for(const E of v.slots){if(!E.uid)continue;const g=(h=E.character)==null?void 0:h.resource.animations;g&&(c[E.uid]||(c[E.uid]=Object.keys(g).reduce((_,p)=>(_[p]=g[p].url,_),{})))}return c},[o]),t=React$2.useMemo(()=>{const c=new Set;for(const h of o)if(h.slots)for(const v of h.slots)v.uid&&c.add(v.uid);return Array.from(c)},[o]),n=async c=>{const h=r[c];if(!cache[h.talking]){const{animations:E}=await loader.loadAsync(h.talking);E[0].name="talking",cache[h.talking]=E[0]}},a=()=>{t.forEach(c=>{f(c,"idle")})},l=()=>{t.forEach(c=>{const h=e.getObjectByProperty("uid",c);h&&(delete h.userData._active,f(c,"idle"))})},u=async(c,h,v)=>{const E=getCurrentVisible(c,e);if(cache[c]||(cache[c]={}),!E)return;const{clipAction:g}=E.userData.animation;if(h){const _=r[c],p=cache[_.talking];let x=h,T=cache[h];if(!T){const{animations:R}=await loader.loadAsync(h);T=cache[h]=R[0]}if(v&&_.talking!==h&&(T=mixWithTalkingClip(p,T),x+="_talking"),!E.userData._active||E.userData._active!==x)return E.userData._active=x,g(T,E)}return null},f=async(c,h)=>{const v=getCurrentVisible(c,e);if(cache[c]||(cache[c]={}),!v)return;const{clipAction:E,defaultAnim:g}=v.userData.animation;if(h==="idle")return E(g,v);{const _=r[c],p=h.split("_")[0],x=_[p],T=cache[_.talking];let R=cache[x];if(!R){const{animations:S}=await loader.loadAsync(_[p]);R=cache[_[p]]=S[0]}if(h.includes("talking")&&h!=="talking"&&(R=mixWithTalkingClip(T,R)),!v.userData._active||v.userData._active!==h)return v.userData._active=h,E(R,v)}return null};return{startAnimation:f,startAnimationUrl:u,preloadTalking:n,resetActives:a,unmountActives:l}}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:l,autoPlay:u,autoEnd:f,pause:c,progress:h}){var pn;const v=r.length-1<=(h==null?void 0:h.line)?r.length-1:(h==null?void 0:h.line)||0,[E,g]=React$2.useState(v),[_,p]=React$2.useState(!!u),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),A=fiber.useThree(ke=>ke.scene),C=fiber.useThree(ke=>ke.camera),{start:w,stop:P}=useTimeout(),O=React$2.useRef([]),k=React$2.useMemo(()=>C.clone(),[]),D=React$2.useRef({pos:[0,0,0],child:null}),F=r[E],U=r[E-1],H=React$2.useRef(!1),W=!!n,{voiceOver:Z,decision:q}=F||{},B=React$2.useRef({}),G=(pn=F==null?void 0:F.slots)==null?void 0:pn.find(ke=>ke.talking),I=React$2.useRef(!1),{startAnimation:$,startAnimationUrl:V,resetActives:X,preloadTalking:Q,unmountActives:re}=useStateMachine(r),ne=React$2.useRef(),ie=Object.keys((F==null?void 0:F.audio)||{}).length,J=Object.keys((F==null?void 0:F.voice)||{}).length,se=Z||(F==null?void 0:F.type)==="conversationalNarration",oe=q||(F==null?void 0:F.type)==="conversationalDecision",fe=(F==null?void 0:F.type)==="conversationalCamera",he=_&&!oe&&!fe,[ue,_e]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Oe=React$2.useMemo(()=>r.reduce((ke,qe)=>(qe.slots&&qe.slots.filter(bt=>bt.uid).forEach(bt=>{ke.includes(bt.uid)||ke.push(bt.uid)}),ke),[]),[r]),Te=React$2.useCallback(ke=>e({type:"translate",payload:ke}),[e]),[He,Ge]=React$2.useState([]),Xe=React$2.useMemo(()=>He[He.length-1],[He]),pt=React$2.useCallback(()=>{const ke=n.find(st=>st.fromId===Xe)||n.find(st=>st.toId===Xe),qe=r.find(st=>st.id===(ke==null?void 0:ke.fromId));return!Xe&&(h==null?void 0:h.line)>=0?{decision:!0}:qe},[n,r,Xe]),yt=React$2.useCallback(()=>{if(W){const qe=pt();return qe==null?void 0:qe.decision}const ke=r[E-1]?r[E-1]:{};return E>0&&(ke==null?void 0:ke.decision)},[F,W,r,Xe,n]),at=React$2.useCallback(()=>{if(W){const qe=pt();return(qe==null?void 0:qe.type)==="conversationalCamera"}const ke=r[E-1]?r[E-1]:{};return E>0&&(ke==null?void 0:ke.type)==="conversationalCamera"},[F,W,r,Xe,n]),ht=React$2.useCallback(ke=>{var st,bt;const qe=t.find(tt=>(tt==null?void 0:tt.uid)===(ke==null?void 0:ke.uid)?tt:"");return((bt=(st=ke==null?void 0:ke.character)==null?void 0:st.resource)==null?void 0:bt.url)||(qe==null?void 0:qe.completeUrl)||""},[t]),er=(ke=()=>{})=>{if(I.current)I.current&&(I.current=!1);else{C.updateProjectionMatrix(),C.updateMatrixWorld(!0);const qe=D.current.child?D.current.pos:k.position.toArray();if(animationTarget.position.fromArray(qe),D.current.parent){animationTarget.quaternion.equals(C.quaternion)||animationTarget.applyQuaternion(C.quaternion);const st=D.current.isLeft?-1:1,bt=headSize*st;animationTarget.translateX(-10*st+bt),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(C.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{I.current=!0},onUpdate:()=>{O.current.length&&O.current.forEach(st=>{const{object:bt}=st;bt.material.visible=!0})},onComplete:()=>{ke(),raycast.set(C.getWorldPosition(new three.Vector3(0,0,0)),C.getWorldDirection(new three.Vector3));const st=raycast.intersectObjects(A.children,!0);O.current=st.filter(bt=>bt.distance<10),O.current.length&&O.current.forEach(bt=>{const{object:tt}=bt;tt.material.side=0}),I.current=!1,H.current&&e({type:"success"}),D.current.child||C.copy(k)},...animationTarget.position})}},Ot=React$2.useCallback(()=>{D.current.child=null,D.current.parent=null,l&&er()},[l]),_t=(ke,qe,st,bt=!1)=>{const tt=qe.includes("seated");st?V(ke,st.url,qe.includes("talking")).then(Kt=>{if(Kt){const sr=Kt.setLoop(three.LoopRepeat,1/0).getMixer(),mn=()=>{H.current?$(ke,"idle").then(()=>{sr.removeEventListener("loop",mn)}):$(ke,ne.current===ke?"neutral_talking":"neutral").then(()=>{sr.removeEventListener("loop",mn)})};Kt&&BASIC_ACTIONS_TYPES_WHITELIST.includes(st.animationId)?sr.addEventListener("loop",mn):sr._listeners&&(sr._listeners.loop=[])}}):$(ke,bt&&!tt?`${qe}-seated`:qe)},kt=()=>{if(!(G!=null&&G.emotion)||H.current)return;const{emotion:ke,uid:qe,animation:st}=G,bt=getCurrentVisible(qe,A);if(bt){const{isSeated:tt}=bt;Q(qe).then(()=>{_t(qe,tt&&!ke.includes("seated")?`${ke}-seated_talking`:`${ke}_talking`,st,tt),st&&BASIC_ACTIONS_TYPES_WHITELIST.includes(st.animationId)&&(ne.current=qe)})}},Ft=()=>{if(!(G!=null&&G.uid)||H.current)return;const{emotion:ke,uid:qe,animation:st}=G,bt=getCurrentVisible(qe,A);if(bt){const{isSeated:tt}=bt;ne.current===qe?(_t(qe,"neutral",null,tt),ne.current=null):_t(qe,ke,st,tt)}},Ke=React$2.useCallback(()=>{H.current=!0,_e({show:!1}),Ot(),X(),l||e({type:"success"})},[C,e,Ot,l]);React$2.useEffect(()=>()=>{B.current={},re()},[]);const mt=ke=>{_e({show:!1}),g(ke),e({type:"notifyProgress",payload:{line:ke}})},ct=React$2.useCallback((ke=!0)=>{const qe=ke?["fromId","toId"]:["toId","fromId"],st=n.filter(Kt=>Kt[qe[0]]===F.id),bt=st.length===1?st[0]:st.find(Kt=>Kt[qe[1]]===Xe);if(!(bt!=null&&bt[qe[0]])){Ke();return}ke||Ge(He.slice(0,He.length-1));const tt=r.findIndex(Kt=>Kt.id===bt[qe[1]]);tt>=0?mt(tt):Ke()},[F==null?void 0:F.id,e,n,Ke,r]),ye=React$2.useCallback((ke,qe)=>{const st=[3,2,1][ke.id],tt=n.filter(sr=>sr.fromId===(F==null?void 0:F.id)).find(sr=>parseInt(sr.fromPointIndex)===st),Kt=r.findIndex(sr=>sr.id===(tt==null?void 0:tt.toId));Kt>=0?(tt==null?void 0:tt.fromId)===(tt==null?void 0:tt.toId)?qe():mt(Kt):Ke()},[F==null?void 0:F.id,n,Ke,r]),de=React$2.useCallback(()=>{if(B.current={...G},S(!1),Ft(),W)ct(!1);else if(!yt()){const ke=E-1;_e({show:!1}),g(ke),e({type:"notifyProgress",payload:{line:ke}})}},[ct,e,W,U,E,G]),ge=React$2.useCallback(ke=>{if(W){if(ke){const qe=[3,2,1][ke.id],bt=n.filter(tt=>tt.fromId===F.id).find(tt=>parseInt(tt.fromPointIndex)===qe);if(bt){const tt=r.findIndex(Kt=>Kt.id===bt.toId);tt>=0&&e({type:"notifyProgress",payload:{line:tt}})}else e({type:"saveNode"})}}else if(E<r.length-1){const qe=E+1;e({type:"notifyProgress",payload:{line:qe}})}else e({type:"saveNode"})},[n,E,r,e,F==null?void 0:F.id,W]),Ee=React$2.useCallback((ke,qe)=>{if(B.current={...G},Ge([...He,F.id]),S(!1),Ft(),W)ke?ye(ke,qe):ct();else if(E<r.length-1){const st=E+1;mt(st)}else(f||oe||fe)&&Ke()},[e,F==null?void 0:F.id,W,oe,fe,E,r.length,ye,ct,Ke,G]),Le=()=>{p(!1),de()},Ve=()=>W?F&&F.type!=="conversationalDecision"&&!n.find(ke=>ke.fromId===F.id):E===r.length-1,De=()=>{Ve()?Ke():(p(!1),Ee())};React$2.useEffect(()=>{if(W&&!x){const ke=h==null?void 0:h.line;if(ke>=0){T(!0),g(ke);return}const qe=r.filter(st=>!n.find(bt=>bt.toId===st.id));if(qe.length){const st=qe[0],bt=r.indexOf(st);bt>=0&&(T(!0),g(bt))}}},[n,W,r,x]);const ze=ke=>{if(B.current.uid===ke.uid||D.current.parent===ke)return;const qe=new three.Object3D,st=ke.getObjectByName("Head_M");st.updateMatrixWorld(!0),qe.applyMatrix4(st.matrixWorld),qe.applyQuaternion(C.quaternion);const bt=l?2.5:2,tt=l?1.2:1.5;qe.translateY(bt),qe.translateX(tt);const Kt=new three.Vector3;Kt.setFromMatrixPosition(st.matrixWorld);const mn=Kt.project(C).x<0;D.current={pos:qe.position.toArray(),child:st,parent:ke,isLeft:mn}},jt=ke=>{e({type:"resetZIndexUIContainer",payload:ke})};React$2.useEffect(()=>{var ke;if(se)Ot(),_e({text:F==null?void 0:F.text,name:(F==null?void 0:F.alias)||(F==null?void 0:F.name)||`[ ${Te("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:ht(G),show:!0});else if(!H.current&&!oe&&!fe){const qe=F==null?void 0:F.slots.filter(tt=>tt.uid&&!tt.talking),st=[...qe.map(tt=>tt.uid)||[],G==null?void 0:G.uid];if(Oe.filter(tt=>!st.includes(tt)).forEach(tt=>{$(tt,"idle")}),qe.forEach(tt=>{const Kt=getCurrentVisible(tt.uid,A);if(Kt){const{isSeated:sr}=Kt;_t(tt.uid,tt.emotion,tt.animation,sr)}}),G){const tt=getCurrentVisible(G.uid,A),Kt=t.find(sr=>sr.uid===G.uid);tt&&!H.current?setTimeout(()=>{var sr,mn;if(G.uid===tt.uid){ze(tt);const{isSeated:us,userData:la}=tt,{emotion:Ai,animation:Ir}=G;!((sr=la._active)!=null&&sr.includes("talking"))&&!((mn=la._active)!=null&&mn.includes(Ai))&&_t(G.uid,Ai,Ir,us);const me=()=>{var Be;_e({text:G.text,name:G.alias||((Be=G.character)==null?void 0:Be.name),inScene:!0,thinkful:G.emotion.includes("think"),avatar:ht(G),show:!0})};l?(I.current=!1,er(me)):me()}},150):(Ot(),_e({text:G.text,name:G.alias||((ke=G.character)==null?void 0:ke.name)||(Kt==null?void 0:Kt.name),left:!1,top:G.text.length>maxCharacterToSwitch,inScene:!1,thinkful:G.emotion.includes("think"),avatar:ht(G),show:!0}))}else Ot(),_e({show:!0})}},[t,F,l,A,Te,ht,Ot,oe,se,Oe]);const Mt=useEkho({audioType:F==null?void 0:F.audioType,volume:F==null?void 0:F.audioVolume,voice:F==null?void 0:F.voice,started:ue.show,text:ue==null?void 0:ue.text,audio:F==null?void 0:F.audio,slide:E,soundActions:a,emitEvent:e,pauseTTS:c,onStart:()=>{var ke;(ke=G==null?void 0:G.emotion)!=null&&ke.includes("think")||kt()},onError:()=>{Ft(),S(!0)},onFinish:()=>{Ft(),he&&!c&&Ee()}});React$2.useEffect(()=>(Mt(),()=>{Mt()}),[E,Mt]),React$2.useEffect(()=>{var ke;if(((F==null?void 0:F.audioType)==="none"||R)&&(ue!=null&&ue.show)&&!(G!=null&&G.emotion.includes("think"))){kt();const qe=characterMs*(((ke=ue==null?void 0:ue.text)==null?void 0:ke.length)||0);setTimeout(()=>{Ft()},qe<minMs?minMs:qe)}},[R,F==null?void 0:F.audioType,G==null?void 0:G.emotion,ue]),React$2.useEffect(()=>{var ke;if(he&&ue.show&&((F==null?void 0:F.audioType)==="none"||R)&&!c){const qe=characterMs*(((ke=ue==null?void 0:ue.text)==null?void 0:ke.length)||0);(!Ve()||Ve()&&f)&&w(Ee,qe<minMs?minMs:qe)}return()=>{P()}},[ue,Ee,w,f,P,F==null?void 0:F.audioType,he,ie,J,R]);const dt=React$2.useMemo(()=>E===0||yt()||at(),[E,yt,at]),vr=o({disabled:oe||!ue.show,repeat:!1,forward:De,rewind:dt?null:Le});React$2.useEffect(()=>vr(),[vr]);const Wr=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...F,emitEvent:e,success:!1,onFinish:Ee},`change-camera-${E}`);if(oe){const ke=F.id?r.filter(st=>st.decision).findIndex(st=>st.id===F.id)+1:r.filter(st=>st.decision).findIndex(st=>st===F)+1,qe={...F.payload,decisionNumber:ke,inheritProps:{slots:[],disableBackground:!0},required:!W,branched:W,onAddPoints:ge,onFinish:Ee,emitEvent:e,pause:c,soundActions:a,keyboardControl:o,onMount:()=>{Ot(),jt(!0)},onUnMount:()=>{I.current=!1,jt(!1)}};return jsxRuntimeExports.jsx(DialogDecision,{...qe})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ue.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Te,currentMessage:ue}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100vw",height:"100%",position:"static"},portal:Wr?{current:Wr}: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:Le,disabled:dt||!ue.show,className:`gat--btn__round ${dt||!ue.show?"disabled":""}`,"aria-label":LangIsRtl()?Te("storylines.misc.forward"):Te("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:De,disabled:!ue.show,className:`gat--btn__round
|
|
273
273
|
${ue.show?"":"disabled"}
|
|
274
274
|
${_&&Ve()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Te("storylines.misc.rewind"):Te("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[l,u]=React$2.useState(!1),f=fiber.useThree(v=>v.scene),c=React$2.useMemo(()=>new GLTFLoader,[]),h=React$2.useRef(0);return React$2.useEffect(()=>{u(!1)},[r.uid,o==null?void 0:o.url]),React$2.useEffect(()=>{if(!l){const v=f.getObjectByProperty("uid",r.uid);if(v&&o&&v.skeletonId===o.skeletonId)if(n)a({type:"saveAnimation",payload:{uid:r.uid,animation:o.id,index:v.index}}),a({type:"success"});else{const E=t;E||a({type:"success"}),c.load(o.url,g=>{const{mixer:_,clipAction:p,defaultAnim:x}=v.userData.animation;p(g.animations[0],v).setLoop(three.LoopRepeat,1/0),h.current=0;function R(){h.current+=1,h.current>=e&&(p(x,v),E&&a({type:"success"}),_.removeEventListener("loop",R))}_._listeners&&(_._listeners.loop=[]),_.addEventListener("loop",R),u(!0)})}else a({type:"success"})}},[f,o==null?void 0:o.url,e,a,l,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([]),[l,u]=React$2.useState(0),[f,c]=React$2.useState(0),h=React$2.useRef(null),v=(p,x,T)=>{p.stopPropagation(),a(n.filter(R=>R!==n[T])),x.error&&u(l-1),x.isRepeat&&c(f-1)},E=()=>{h.current&&h.current.focus()},g=()=>{[" ",",",";","."].includes(h.current.value)&&(h.current.value="")},_=p=>{const x=h.current.value,T=["Space","Comma","Period","Enter"],R=["Space","Comma","Enter","Tab"];x===""&&(T.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(x)?n.find(A=>A.text===x)?(c(f+1),a([...n,{text:x,error:!0,isRepeat:!0}])):a([...n,{text:x}]):(a([...n,{text:x,error:!0}]),u(l+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,x)=>jsxRuntimeExports.jsx(EmailPill,{text:p.text,error:p.error,handleClick:T=>v(T,p,x),emailPillIndex:x},`${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:l>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||l>0||n.length===0?" disabled":""}`,type:"button",disabled:l>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),l=()=>{a(!n)},u=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.${u}`)]})]}),!!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:l,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,l]=React$2.useState("step1"),u=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});u.current=_&&_.data?_.data.valid.length:0,f.current=g.length-u.current,l("step2")};if(!t)return o({type:"success"}),null;const h=()=>{o({type:"success"})},v=()=>{if(u.current){const E=r.map(g=>(g.points*=u.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:v,valid:u,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
|